44 lines
1.1 KiB
YAML
44 lines
1.1 KiB
YAML
# vim: ft=yaml.ansible
|
|
---
|
|
- name: Copy Docker daemon config file
|
|
template:
|
|
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
|
|
service:
|
|
name: "{{ item }}"
|
|
enabled: false
|
|
state: "{{ 'restarted' if daemon_config.changed else 'started' }}"
|
|
loop:
|
|
- docker.socket
|
|
- docker.service
|
|
|
|
- name: Create base directory for Docker volumes
|
|
file:
|
|
name: "{{ base_volume }}"
|
|
owner: "{{ ansible_user }}"
|
|
mode: u=rwx,g=rx,o=rx
|
|
state: directory
|
|
|
|
- name: Create Docker network for services
|
|
docker_network:
|
|
name: services
|
|
ipam_config:
|
|
- subnet: 172.17.0.0/16
|
|
gateway: 172.17.0.1
|
|
state: present
|
|
|
|
- name: Deploy services
|
|
include_tasks: "services/{{ item.service }}.yml"
|
|
loop: "{{ services | dict2items(key_name='service') }}"
|
|
when: single_service is not defined
|
|
|
|
- name: Deploy single service
|
|
include_tasks: "services/{{ single_service }}.yml"
|
|
when: single_service is defined and
|
|
single_service in services
|