2018-12-12 22:25:36 +00:00
|
|
|
---
|
|
|
|
- block:
|
2019-05-10 08:50:45 +00:00
|
|
|
- name: Install docker engine
|
2018-12-12 22:25:36 +00:00
|
|
|
package:
|
2019-05-10 08:50:45 +00:00
|
|
|
name: "{{ dockerengine_package }}"
|
2018-12-12 22:25:36 +00:00
|
|
|
state: installed
|
2019-05-10 08:48:08 +00:00
|
|
|
|
2019-05-12 15:26:30 +00:00
|
|
|
- name: Install dependencies
|
|
|
|
package:
|
|
|
|
name: "{{ item }}"
|
|
|
|
state: installed
|
|
|
|
loop: "{{ dockerengine_dependencies }}"
|
|
|
|
|
2019-05-10 08:48:08 +00:00
|
|
|
- name: Install python dependencies
|
|
|
|
pip:
|
|
|
|
name:
|
|
|
|
- docker
|
2019-05-10 08:50:45 +00:00
|
|
|
- docker-compose
|
2018-12-12 22:25:36 +00:00
|
|
|
|
|
|
|
- name: Add docker group
|
|
|
|
group:
|
|
|
|
name: docker
|
|
|
|
state: present
|
|
|
|
notify: __docker_restart
|
2019-06-10 11:56:17 +00:00
|
|
|
when: dockerengine_docker_group_enabled | bool
|
2018-12-12 22:25:36 +00:00
|
|
|
|
|
|
|
- name: Deploy config files to setup environment
|
|
|
|
template:
|
|
|
|
src: "{{ item.src }}"
|
|
|
|
dest: "{{ item.dest }}"
|
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
mode: 0644
|
|
|
|
with_items:
|
|
|
|
- { src: 'etc/sysconfig/docker.j2', dest: '/etc/sysconfig/{{ dockerengine_package }}' }
|
|
|
|
- { src: 'etc/sysconfig/docker-storage-setup.j2', dest: '/etc/sysconfig/{{ dockerengine_package }}-storage-setup' }
|
|
|
|
- { src: 'etc/containers/registries.conf.j2', dest: '/etc/containers/registries.conf' }
|
2019-01-06 16:28:02 +00:00
|
|
|
loop_control:
|
|
|
|
label: "{{ item.dest }}"
|
2018-12-12 22:25:36 +00:00
|
|
|
notify: __docker_restart
|
|
|
|
|
2019-07-16 14:55:25 +00:00
|
|
|
- name: Add namespace group
|
|
|
|
group:
|
2019-07-16 15:21:48 +00:00
|
|
|
name: "{{ dockerengine_nsremap_user }}"
|
2019-07-16 14:55:25 +00:00
|
|
|
state: "{{ 'present' if dockerengine_usernamespace_enabled | bool else 'absent' }}"
|
|
|
|
|
|
|
|
- name: Add namespace user
|
|
|
|
user:
|
2019-07-16 15:21:48 +00:00
|
|
|
name: "{{ dockerengine_nsremap_user }}"
|
|
|
|
group: "{{ dockerengine_nsremap_user }}"
|
2019-07-16 14:55:25 +00:00
|
|
|
shell: /sbin/nologin
|
|
|
|
state: "{{ 'present' if dockerengine_usernamespace_enabled | bool else 'absent' }}"
|
|
|
|
|
|
|
|
- name: Configure namespace id range
|
|
|
|
lineinfile:
|
|
|
|
dest: "{{ item }}"
|
2019-07-16 15:21:48 +00:00
|
|
|
regexp: "^{{ dockerengine_nsremap_user }}:"
|
|
|
|
line: "{{ dockerengine_nsremap_user }}:{{ dockerengine_nsremap_range_start }}:{{ dockerengine_nsremap_range_length }}"
|
2019-07-16 14:55:25 +00:00
|
|
|
state: "{{ 'present' if dockerengine_usernamespace_enabled | bool else 'absent' }}"
|
|
|
|
loop:
|
|
|
|
- /etc/subuid
|
|
|
|
- /etc/subgid
|
|
|
|
|
2018-12-12 22:25:36 +00:00
|
|
|
- name: Ensure docker engine is up and running
|
|
|
|
service:
|
|
|
|
name: "{{ dockerengine_package }}"
|
|
|
|
enabled: True
|
|
|
|
state: started
|
|
|
|
become: True
|
|
|
|
become_user: root
|