87 lines
2.4 KiB
YAML
87 lines
2.4 KiB
YAML
---
|
|
- name: Pulling latest branch "{{ branch }}"
|
|
ansible.builtin.git:
|
|
repo: "{{ source_url }}"
|
|
dest: "{{ dir.source }}"
|
|
accept_hostkey: true
|
|
version: "{{ branch }}"
|
|
tags:
|
|
- git
|
|
|
|
- name: Copying error pages
|
|
ansible.builtin.template:
|
|
src: templates/nginx/errors/503-service-unavailable.html
|
|
dest: "{{ dir.errors }}/503-service-unavailable.html"
|
|
mode: 0644
|
|
|
|
- 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 }}"
|
|
extra_args: --disable-pip-version-check
|
|
environment:
|
|
XDG_CACHE_HOME: "{{ dir.source }}/.cache"
|
|
tags:
|
|
- pip
|
|
- pip-install
|
|
|
|
- name: Preparing to run database migrations
|
|
become: true
|
|
become_user: "{{ user }}"
|
|
tags:
|
|
- migrate
|
|
block:
|
|
- name: Displaying database migrations
|
|
import_tasks: managepy.yaml
|
|
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
|