conference-website/playbooks/tasks/deploy.yaml

73 lines
2.0 KiB
YAML

---
- import_tasks: copy_error_pages.yaml
become: true
become_user: "{{ user }}"
- name: Deleting {{ dir.source }}/.venv if it exists
become: true
become_user: "{{ user }}"
ansible.builtin.file:
path: "{{ dir.source }}/.venv"
state: absent
when: delete_venv
tags:
- pip
- name: Install Python requirements in {{ dir.source }}/.venv
become: true
become_user: "{{ user }}"
ansible.builtin.pip:
requirements: "{{ dir.source }}/requirements_prod.txt"
virtualenv: "{{ dir.source }}/.venv"
virtualenv_command: python{{ python_version }} -m venv
chdir: "{{ dir.source }}"
tags:
- pip
- name: Preparing to run database migrations
become: true
become_user: "{{ user }}"
tags:
- migrate
block:
- name: Displaying database migrations
import_tasks: managepy.yaml
changed_when: false
vars:
command: migrate --plan
- name: Displaying database migrations
ansible.builtin.debug:
var: management_command_output.stdout
- name: Confirming database migrations
when:
- management_command_output.stdout | length > 0
- ('No planned migration operations' not in management_command_output.stdout)
ansible.builtin.pause:
prompt: Press return to continue. Press Ctrl+c and then "a" to abort.
- name: Running database migrations
when:
- management_command_output.stdout | length > 0
- ('No planned migration operations' not in management_command_output.stdout)
import_tasks: managepy.yaml
vars:
command: migrate
changed_when:
- management_command_output.stdout | length > 0
- ('No planned migration operations' not in management_command_output.stdout)
- import_tasks: managepy.yaml
become: true
become_user: "{{ user }}"
vars:
command: collectstatic --noinput
changed_when: true
tags:
- collectstatic
notify:
- reload service
- restart background
- test nginx
- reload nginx