docker: simplify, use dist-based vars
This commit is contained in:
parent
873d670016
commit
060434541c
2 changed files with 12 additions and 27 deletions
4
roles/docker/defaults/main.yml
Normal file
4
roles/docker/defaults/main.yml
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
---
|
||||||
|
docker_pkgs:
|
||||||
|
Ubuntu: docker.io
|
||||||
|
Fedora: moby-engine
|
|
@ -1,32 +1,13 @@
|
||||||
---
|
---
|
||||||
|
# depends on create-user role / create_username var
|
||||||
|
|
||||||
- name: install docker
|
- name: "Install Docker"
|
||||||
package:
|
ansible.builtin.package:
|
||||||
name: docker
|
name: "{{ docker_pkgs[ansible_distribution] }}"
|
||||||
state: latest
|
state: present
|
||||||
when: ansible_distribution in ["CentOS", "Fedora", "Red Hat Enterprise Linux", "RedHat"] and not is_atomic
|
|
||||||
register: docker_installed
|
|
||||||
|
|
||||||
- name: add {{ username }} to 'dockerroot' group
|
- name: Enable/start docker
|
||||||
user:
|
ansible.builtin.service:
|
||||||
name: "{{ username }}"
|
|
||||||
groups: dockerroot
|
|
||||||
append: yes
|
|
||||||
when: ansible_distribution in ["CentOS", "Red Hat Enterprise Linux", "RedHat"] and not is_atomic
|
|
||||||
|
|
||||||
|
|
||||||
- name: copy daemon.json
|
|
||||||
copy:
|
|
||||||
src: roles/docker/files/daemon.json
|
|
||||||
dest: /etc/docker/daemon.json
|
|
||||||
owner: root
|
|
||||||
group: root
|
|
||||||
mode: 0644
|
|
||||||
when: ansible_distribution in ["CentOS", "Red Hat Enterprise Linux", "RedHat"] and not is_atomic
|
|
||||||
|
|
||||||
- name: enable/start docker
|
|
||||||
service:
|
|
||||||
name: docker
|
name: docker
|
||||||
state: started
|
state: started
|
||||||
enabled: yes
|
enabled: true
|
||||||
when: ansible_distribution in ["CentOS", "Fedora", "Red Hat Enterprise Linux", "RedHat"] and not is_atomic
|
|
||||||
|
|
Loading…
Reference in a new issue