vps/roles/postgres/tasks/update.yml

55 lines
1.6 KiB
YAML
Raw Normal View History

2024-03-29 20:56:28 +01:00
- name: "Create {{ project_dir }} directory"
file:
path: "{{ project_dir }}"
state: directory
- name: "Create (if not exists) directory {{ volumes['postgres_datadir'] }} & set permissions"
file:
path: "{{ volumes['postgres_datadir'] }}"
state: directory
owner: "{{ users['postgres'] + uid_shift }}"
group: "{{ users['postgres'] + uid_shift }}"
mode: '700'
become: true
- name: "Check if directory {{ volumes['postgres_datadir'] }} is empty"
find:
paths: "{{ volumes['postgres_datadir'] }}"
register: postgres_find_datadir_result
become: true
2024-03-29 20:56:28 +01:00
- name: Template docker-compose.yaml & .env to project directory
template:
src: "{{ item }}"
dest: "{{ project_dir }}/{{ item }}"
owner: "{{ host_uid }}"
group: "{{ host_uid }}"
mode: '600'
loop:
- docker-compose.yaml
- .env
- name: Pull project services
community.docker.docker_compose:
project_src: "{{ project_dir }}"
recreate: never
pull: true
debug: true
when: docker_pull_images | bool
register: postgres_docker_compose_pull_result
- name: Display pulled image(s) name
set_fact:
postgres_pulled_images: "{{ postgres_pulled_images | default([]) + [item.pulled_image.name] }}"
loop: "{{ postgres_docker_compose_pull_result['actions'] | default([]) | selectattr('pulled_image', 'defined') }}"
- name: Include backup tasks
include_tasks:
file: backup.yml
# Make a backup if we didn't already make one and we pulled a new image
when: not run_backup and postgres_pulled_images is defined
- name: Create/Restart project services
community.docker.docker_compose:
project_src: "{{ project_dir }}"