ansible/roles/docker_watchtower/tasks/main.yml

57 lines
1.2 KiB
YAML
Raw Normal View History

---
- name: "Install dependencies"
ansible.builtin.apt:
pkg:
- docker.io
- apparmor # if not installed, Docker will complain
- name: "Create directories for Watchtower"
ansible.builtin.file:
path: "{{ item }}"
state: directory
owner: root
group: root
mode: '0750'
recurse: true
with_items:
- "{{ docker_volumes_dir }}/watchtower"
- name: "Template .env files for Watchtower"
ansible.builtin.template:
src: "{{ item }}.j2"
dest: "{{ docker_volumes_dir }}/watchtower/{{ item }}"
force: true
owner: root
group: root
mode: '0660'
with_items:
- watchtower.env
notify: restart-watchtower-docker
- name: "Template systemd unit files for Watchtower"
ansible.builtin.template:
src: "{{ item }}.j2"
dest: "/etc/systemd/system/{{ item }}"
force: true
owner: root
group: root
mode: '0644'
with_items:
- watchtower.service
register: unit
notify: restart-watchtower-docker
- name: "Reload systemd units"
ansible.builtin.systemd:
daemon_reload: yes
when: unit.changed
- name: "Enable systemd units for Watchtower"
ansible.builtin.systemd:
state: started
enabled: true
name: "{{ item }}"
with_items:
- watchtower.service