ansible-roles/library/roles/docker/tasks/pkgs.yml

68 lines
2.4 KiB
YAML

---
- block:
- name: Add the Docker repository key
#apt_key: keyserver={{ docker_repo_keyserver }} id={{ docker_repo_key }} state=present
apt_key: url={{ docker_repo_key_url }} state=present
- name: Remove the obsolete docker repository
apt_repository: repo='{{ docker_repo_old }}' state=absent update_cache=yes
- name: Add the Docker repository
apt_repository: repo='{{ docker_repo }}' update_cache=yes
- name: Create the docker user
user: name=docker comment="Docker User" shell=/bin/bash home={{ docker_user_home }} system=yes
when: docker_run_as_docker_user
- name: Install Docker
apt: pkg={{ docker_packages }} state={{ docker_pkg_status }} update_cache=yes cache_valid_time=3600
- 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
- 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' ]
- 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' ]
- name: systemd reload
command: systemctl daemon-reload
when: reload_systemd is defined and reload_systemd is changed
tags: [ 'docker', 'docker_systemd' ]
- name: Ensure that the service is started and enabled
service: name=docker state=started enabled=yes
when: docker_install | bool
tags: docker
- block:
- name: Ensure that the service is stopped and disabled
service: name=docker state=stopped enabled=no
ignore_errors: True
- name: Remove the Docker package
apt: pkg={{ docker_packages }} state=absent
- name: Remove the docker user
user: name=docker state=absent
- name: Remove the Docker repository key
apt_key: keyserver={{ docker_repo_keyserver }} id={{ docker_repo_key }} state=absent
- name: Remove the Docker repository
apt_repository: repo='{{ docker_repo }}' state=absent update_cache=yes
when: not docker_install | bool
tags: docker