ansible-role-docker/tasks/docker_setup.yml

44 lines
1.6 KiB
YAML
Raw Normal View History

2020-08-11 20:01:36 +02:00
---
- 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
2020-08-13 15:43:40 +02:00
tags: [ 'docker', 'docker_conf' ]
2020-08-11 20:01:36 +02:00
- 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
2020-08-13 15:43:40 +02:00
tags: [ 'docker', 'docker_conf' ]
2020-08-11 20:01:36 +02:00
- name: Create the docker service systemd directory
file: dest=/etc/systemd/system/docker.service.d state=directory mode=0755
when: ansible_service_mgr == 'systemd'
2020-08-13 16:15:41 +02:00
tags: [ 'docker', 'docker_systemd', 'docker_conf' ]
2020-08-11 20:01:36 +02:00
- 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
2020-08-13 16:15:41 +02:00
tags: [ 'docker', 'docker_systemd', 'docker_conf' ]
2020-08-11 20:01:36 +02:00
- name: systemd reload
command: systemctl daemon-reload
when: reload_systemd is defined and reload_systemd is changed
2020-08-13 16:15:41 +02:00
tags: [ 'docker', 'docker_systemd', 'docker_conf' ]
2020-08-11 20:01:36 +02:00
- name: Ensure that the service is started and enabled
service: name=docker state=started enabled=yes
when: docker_install
2020-08-11 20:01:36 +02:00
tags: docker
- block:
- name: Remove the docker user
user: name=docker state=absent
when: not docker_install
2020-08-11 20:01:36 +02:00
tags: docker