2022-12-22 19:18:27 +00:00
|
|
|
# vim: ft=yaml.ansible
|
2022-12-21 21:25:10 +00:00
|
|
|
---
|
2022-12-28 16:55:35 +00:00
|
|
|
- name: Copy Docker daemon config file
|
2023-03-22 18:31:21 +00:00
|
|
|
ansible.builtin.template:
|
2022-12-28 16:55:35 +00:00
|
|
|
src: daemon.json.j2
|
|
|
|
dest: /etc/docker/daemon.json
|
|
|
|
owner: root
|
|
|
|
mode: u=rw,g=r,o=r
|
|
|
|
register: daemon_config
|
|
|
|
|
|
|
|
- name: Disable and (re)start Docker daemon
|
2023-03-22 18:31:21 +00:00
|
|
|
ansible.builtin.service:
|
2022-12-28 16:55:35 +00:00
|
|
|
name: "{{ item }}"
|
|
|
|
enabled: false
|
|
|
|
state: "{{ 'restarted' if daemon_config.changed else 'started' }}"
|
|
|
|
loop:
|
|
|
|
- docker.socket
|
|
|
|
- docker.service
|
|
|
|
|
2022-12-22 19:18:27 +00:00
|
|
|
- name: Create base directory for Docker volumes
|
2023-03-22 18:31:21 +00:00
|
|
|
ansible.builtin.file:
|
2022-12-22 19:18:27 +00:00
|
|
|
name: "{{ base_volume }}"
|
|
|
|
owner: "{{ ansible_user }}"
|
|
|
|
mode: u=rwx,g=rx,o=rx
|
|
|
|
state: directory
|
|
|
|
|
2022-12-28 16:51:02 +00:00
|
|
|
- name: Create Docker network for services
|
2023-03-22 18:31:21 +00:00
|
|
|
community.docker.docker_network:
|
2022-12-28 16:51:02 +00:00
|
|
|
name: services
|
|
|
|
ipam_config:
|
2022-12-28 17:03:57 +00:00
|
|
|
- subnet: 172.16.0.0/16
|
|
|
|
gateway: 172.16.0.1
|
2022-12-28 16:51:02 +00:00
|
|
|
state: present
|
|
|
|
|
2022-12-21 21:25:10 +00:00
|
|
|
- name: Deploy services
|
2023-03-22 18:31:21 +00:00
|
|
|
ansible.builtin.include_tasks: services/{{ item.key }}.yml
|
2023-01-03 21:30:22 +00:00
|
|
|
loop: "{{ services | dict2items }}"
|
2022-12-25 23:29:46 +00:00
|
|
|
when: single_service is not defined
|
2022-12-21 21:25:10 +00:00
|
|
|
|
|
|
|
- name: Deploy single service
|
2023-03-22 18:31:21 +00:00
|
|
|
ansible.builtin.include_tasks: services/{{ single_service }}.yml
|
2022-12-21 21:25:10 +00:00
|
|
|
when: single_service is defined and
|
2022-12-25 23:29:46 +00:00
|
|
|
single_service in services
|