vps/roles/mailserver/tasks/update.yml

79 lines
2.1 KiB
YAML
Raw Normal View History

- name: "Create {{ project_dir }} project directory"
2024-03-16 13:49:47 +01:00
file:
path: "{{ project_dir }}"
2024-03-16 13:49:47 +01:00
state: directory
- name: Template docker-compose.yaml to project directory
template:
src: docker-compose.yaml
dest: "{{ project_dir }}/docker-compose.yaml"
owner: "{{ host_uid }}"
group: "{{ host_uid }}"
2024-03-16 13:49:47 +01:00
mode: '640'
- name: "Create directory {{ volumes['mailserver_datadir'] }} with correct permissions"
file:
path: "{{ volumes['mailserver_datadir'] }}"
state: directory
owner: "{{ users['mailserver'] + uid_shift }}"
group: "{{ users['mailserver'] + uid_shift }}"
mode: '770'
become: true
- name: Set limited permissions on certificate directories
file:
path: "/etc/{{ item }}"
state: directory
owner: root
group: root
mode: '751'
become: true
loop:
- letsencrypt
- letsencrypt/live
- letsencrypt/archive
- name: Set limited permissions on certificate directories
file:
path: "/etc/letsencrypt/{{ item }}/mail.{{ domain }}"
state: directory
owner: root
group: "{{ host_uid }}"
mode: '550'
become: true
loop:
- live
- archive
- name: Set limited permissions on certificate key file
file:
path: "/etc/letsencrypt/live/mail.{{ domain }}/privkey.pem"
owner: root
group: "{{ host_uid }}"
mode: '640'
become: true
- name: Pull project services
community.docker.docker_compose:
project_src: "{{ project_dir }}"
2024-03-16 13:49:47 +01:00
recreate: never
pull: true
debug: true
when: docker_pull_images | bool
register: mailserver_docker_compose_pull_result
- name: Display pulled image(s) name
set_fact:
mailserver_pulled_images: "{{ mailserver_pulled_images | default([]) + [item.pulled_image.name] }}"
loop: "{{ mailserver_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 mailserver_pulled_images is defined
- name: Create/Restart project services
community.docker.docker_compose:
project_src: "{{ project_dir }}"