44 lines
1.6 KiB
YAML
44 lines
1.6 KiB
YAML
---
|
|
- name: Docker configuration and service management
|
|
block:
|
|
- name: Install the Docker default options
|
|
template: src=docker-default.j2 dest={{ docker_defaults_file }} owner=root group=root mode=0644
|
|
when: ansible_service_mgr != 'systemd'
|
|
notify: Restart docker
|
|
tags: [ 'docker', 'docker_conf' ]
|
|
|
|
- name: Install the Docker daemon config
|
|
template: src=daemon.json.j2 dest=/etc/docker/daemon.json owner=root group=root mode=0644
|
|
notify: Restart docker
|
|
tags: [ 'docker', 'docker_conf' ]
|
|
|
|
- name: Create the docker service systemd directory
|
|
file: dest=/etc/systemd/system/docker.service.d state=directory mode=0755
|
|
when: ansible_service_mgr == 'systemd'
|
|
tags: [ 'docker', 'docker_systemd', 'docker_conf' ]
|
|
|
|
- name: Install the Docker additional systemd unit
|
|
template: src=docker-systemd-override.conf.j2 dest=/etc/systemd/system/docker.service.d/override.conf owner=root group=root mode=0644
|
|
when: ansible_service_mgr == 'systemd'
|
|
notify: Restart docker
|
|
register: reload_systemd
|
|
tags: [ 'docker', 'docker_systemd', 'docker_conf' ]
|
|
|
|
- name: systemd reload
|
|
command: systemctl daemon-reload
|
|
when: reload_systemd is defined and reload_systemd is changed
|
|
tags: [ 'docker', 'docker_systemd', 'docker_conf' ]
|
|
|
|
- name: Ensure that the service is started and enabled
|
|
service: name=docker state=started enabled=yes
|
|
|
|
when: docker_install
|
|
tags: docker
|
|
|
|
- block:
|
|
- name: Remove the docker user
|
|
user: name=docker state=absent
|
|
|
|
when: not docker_install
|
|
tags: docker
|