cappuccino.yml

  • raw
  • text/plain
  • 1.0K
  • 2021-06-07
---
- name: Update cappuccino
  hosts: firefly
  tasks:
    - name: Set OS-specific variables.
      include_vars: "../os_vars/{{ ansible_os_family|lower }}.yml"

    - name: Update git repo
      become: yes
      become_user: cappuccino
      register: gitclone
      git:
        repo: 'https://github.com/FoxDev/cappuccino'
        dest: /srv/cappuccino

    - name: Stop cappuccino
      become: yes
      when: gitclone.changed
      service:
        name: "cappuccino"
        state: stopped
        enabled: yes

    - name: Update python dependencies
      become: yes
      become_user: cappuccino
      when: gitclone.changed
      command:
        chdir: /srv/cappuccino
        cmd: 'poetry install'

    - name: Run database migrations
      become: yes
      become_user: cappuccino
      when: gitclone.changed
      command:
        chdir: /srv/cappuccino
        cmd: 'poetry run alembic upgrade head'

    - name: Start cappuccino
      become: yes
      service:
        name: "cappuccino"
        state: started
        enabled: yes