Anna Sirota
4052fe9548
Upgrading to Python 3.10 lead to the following changes: * Python's builtin `venv` is used instead of `virtualenv`: `python3-virtualenv` is packaged incorrectly making it impossible to use with Python binaries from ppa:deadsnakes, see https://github.com/pre-commit/pre-commit/issues/2211#issuecomment-1013954780 * uWSGI installed in the venv is used instead of OS-wide installed
94 lines
2.7 KiB
YAML
94 lines
2.7 KiB
YAML
---
|
|
- name: Pulling latest branch "{{ branch }}"
|
|
ansible.builtin.git:
|
|
repo: "{{ source_url }}"
|
|
dest: "{{ dir.source }}"
|
|
accept_hostkey: true
|
|
version: "{{ branch }}"
|
|
tags:
|
|
- git
|
|
|
|
- import_tasks: copy_error_pages.yaml
|
|
|
|
- name: Deleting {{ dir.source }}/.venv if it exists
|
|
ansible.builtin.file:
|
|
path: "{{ dir.source }}/.venv"
|
|
state: absent
|
|
when: delete_venv
|
|
|
|
- name: Installing uWSGI {{ uwsgi_version }} in {{ dir.source }}/.venv
|
|
ansible.builtin.pip:
|
|
name: uwsgi
|
|
version: "{{ uwsgi_version }}"
|
|
virtualenv: "{{ dir.source }}/.venv"
|
|
virtualenv_command: python{{ python_version }} -m venv
|
|
chdir: "{{ dir.source }}"
|
|
|
|
- name: Installing Poetry in {{ dir.source }}/.venv
|
|
ansible.builtin.pip:
|
|
name: poetry
|
|
version: "{{ poetry_version }}"
|
|
virtualenv: "{{ dir.source }}/.venv"
|
|
virtualenv_command: python{{ python_version }} -m venv
|
|
chdir: "{{ dir.source }}"
|
|
tags:
|
|
- pip
|
|
|
|
- name: Installing remaining Python dependencies in {{ dir.source }}/.venv
|
|
environment:
|
|
CRYPTOGRAPHY_DONT_BUILD_RUST: "1"
|
|
loop:
|
|
- "{{ dir.source }}/.venv/bin/poetry install --no-dev"
|
|
- "{{ dir.source }}/.venv/bin/poetry config virtualenvs.create false"
|
|
- "{{ dir.source }}/.venv/bin/poetry config virtualenvs.in-project true"
|
|
ansible.builtin.command: "{{ item }}"
|
|
args:
|
|
chdir: "{{ dir.source }}"
|
|
changed_when: false
|
|
tags:
|
|
- pip
|
|
|
|
- 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)
|
|
|
|
- name: Collecting static files
|
|
ansible.builtin.command: "{{ dir.source }}/.venv/bin/python {{ dir.source }}/manage.py collectstatic --noinput"
|
|
args:
|
|
chdir: "{{ dir.source }}"
|
|
changed_when: true
|
|
tags:
|
|
- collectstatic
|
|
notify:
|
|
- restart service
|
|
- test nginx
|
|
- reload nginx
|