Isolate installation mode
The role variables were making generalizations on distro package and installation methods. This change further breaks things out, now explicitly supporting ubuntu, debian, fedora, and redhat(centos). Change-Id: Ib1749721b32b21ba1ab661a64097d79037e416f3 Signed-off-by: Kevin Carter <kecarter@redhat.com>
This commit is contained in:
parent
ab2d368b17
commit
fb41492e4a
@ -1,7 +1,7 @@
|
||||
---
|
||||
|
||||
- name: Assure docker service is running
|
||||
become: yes
|
||||
become: true
|
||||
service:
|
||||
name: docker
|
||||
enabled: yes
|
||||
@ -9,7 +9,7 @@
|
||||
listen: Restart docker
|
||||
|
||||
- name: Correct group ownership on docker sock
|
||||
become: yes
|
||||
become: true
|
||||
file:
|
||||
path: /var/run/docker.sock
|
||||
group: "{{ docker_group }}"
|
||||
|
14
roles/install-docker/tasks/docker-distro.yaml
Normal file
14
roles/install-docker/tasks/docker-distro.yaml
Normal file
@ -0,0 +1,14 @@
|
||||
---
|
||||
|
||||
- name: Distro block
|
||||
become: true
|
||||
block:
|
||||
- name: Install docker
|
||||
package:
|
||||
name: "{{ docker_distro_packages }}"
|
||||
state: present
|
||||
when:
|
||||
- not (use_upstream_docker | bool)
|
||||
notify: Assure docker service is running
|
||||
|
||||
- include_tasks: docker-setup.yaml
|
16
roles/install-docker/tasks/docker-setup.yaml
Normal file
16
roles/install-docker/tasks/docker-setup.yaml
Normal file
@ -0,0 +1,16 @@
|
||||
---
|
||||
|
||||
- name: Ensure "docker" group exists
|
||||
group:
|
||||
name: "{{ docker_group }}"
|
||||
state: present
|
||||
|
||||
- name: Add user to docker group
|
||||
user:
|
||||
name: "{{ ansible_user }}"
|
||||
groups:
|
||||
- "{{ docker_group }}"
|
||||
append: yes
|
||||
|
||||
- name: Reset ssh connection to pick up docker group
|
||||
meta: reset_connection
|
13
roles/install-docker/tasks/docker-upstream.yaml
Normal file
13
roles/install-docker/tasks/docker-upstream.yaml
Normal file
@ -0,0 +1,13 @@
|
||||
---
|
||||
|
||||
- name: Upstream block
|
||||
become: true
|
||||
block:
|
||||
- name: Set up docker mirrors
|
||||
include_role:
|
||||
name: use-docker-mirror
|
||||
|
||||
- name: Install docker-ce from upstream
|
||||
include_tasks: "upstream-{{ ansible_pkg_mgr }}.yaml"
|
||||
|
||||
- include_tasks: docker-setup.yaml
|
@ -17,10 +17,12 @@
|
||||
- name: Sanity check for distro selection
|
||||
fail:
|
||||
msg: >-
|
||||
This role is not known to be compatible with this distro. Check the inventory and deployment
|
||||
target settings. Make sure facts are being gathered prior to executing this role.
|
||||
This role is not known to be compatible with this distro and no packages have been provided
|
||||
for installation. Check the inventory and deployment target settings. Make sure facts are
|
||||
being gathered prior to executing this role.
|
||||
when:
|
||||
- not (docker_distro_vars_loaded | bool)
|
||||
- (docker_distro_packages | length) < 1
|
||||
|
||||
- name: Sanity check for distro install
|
||||
fail:
|
||||
@ -53,54 +55,11 @@
|
||||
- (docker_mirror_base_url | length) < 1
|
||||
- use_upstream_docker | bool
|
||||
|
||||
- name: Upstream block
|
||||
when:
|
||||
- use_upstream_docker | bool
|
||||
block:
|
||||
- name: Set up docker mirrors
|
||||
include_role:
|
||||
name: use-docker-mirror
|
||||
|
||||
- name: Install docker-ce from upstream
|
||||
include_tasks: "upstream-{{ ansible_pkg_mgr }}.yaml"
|
||||
rescue:
|
||||
- name: Notice
|
||||
debug:
|
||||
msg: >-
|
||||
The upstream installation of docker has failed, falling back to the distro packages.
|
||||
|
||||
- name: Re-Set the use upstream flag
|
||||
set_fact:
|
||||
use_upstream_docker: false
|
||||
|
||||
- name: Install docker
|
||||
become: yes
|
||||
package:
|
||||
name: "{{ docker_distro_packages }}"
|
||||
state: present
|
||||
when:
|
||||
- not (use_upstream_docker | bool)
|
||||
notify: Assure docker service is running
|
||||
|
||||
- name: Ensure "docker" group exists
|
||||
group:
|
||||
name: "{{ docker_group }}"
|
||||
state: present
|
||||
|
||||
- name: Add user to docker group
|
||||
become: yes
|
||||
user:
|
||||
name: "{{ ansible_user }}"
|
||||
groups:
|
||||
- "{{ docker_group }}"
|
||||
append: yes
|
||||
- include_tasks: "docker-{{ (use_upstream_docker | bool) | ternary('upstream', 'distro') }}.yaml"
|
||||
|
||||
- name: Flush handlers before role exit
|
||||
meta: flush_handlers
|
||||
|
||||
- name: Reset ssh connection to pick up docker group
|
||||
meta: reset_connection
|
||||
|
||||
- name: Validate ability to talk with docker
|
||||
command: docker ps
|
||||
changed_when: false
|
||||
|
@ -1,17 +1,16 @@
|
||||
---
|
||||
|
||||
- name: Install pre-reqs
|
||||
package:
|
||||
name: "{{ _docker_upstream_distro_required_packages }}"
|
||||
state: present
|
||||
become: yes
|
||||
|
||||
- name: Add docker GPG key
|
||||
become: yes
|
||||
apt_key:
|
||||
data: "{{ docker_gpg_key }}"
|
||||
|
||||
# TODO(mordred) We should add a proxy cache mirror for this
|
||||
- name: Add docker apt repo
|
||||
become: yes
|
||||
template:
|
||||
dest: /etc/apt/sources.list.d/docker.list
|
||||
group: root
|
||||
@ -19,10 +18,4 @@
|
||||
owner: root
|
||||
src: sources.list.j2
|
||||
|
||||
- name: Install docker
|
||||
become: yes
|
||||
apt:
|
||||
name: "{{ docker_upstream_distro_packages }}"
|
||||
state: present
|
||||
update_cache: yes
|
||||
notify: Restart docker
|
||||
- include_tasks: upstream-package-installation.yaml
|
||||
|
@ -0,0 +1,8 @@
|
||||
---
|
||||
|
||||
- name: Install docker
|
||||
package:
|
||||
name: "{{ docker_upstream_distro_packages }}"
|
||||
state: present
|
||||
update_cache: yes
|
||||
notify: Restart docker
|
@ -4,7 +4,6 @@
|
||||
package:
|
||||
name: "{{ _docker_upstream_distro_required_packages }}"
|
||||
state: present
|
||||
become: yes
|
||||
|
||||
- name: Create tmp gpg key file
|
||||
copy:
|
||||
@ -18,17 +17,11 @@
|
||||
|
||||
# TODO(mordred) We should add a proxy cache mirror for this
|
||||
- name: Add docker repo
|
||||
become: yes
|
||||
copy:
|
||||
template:
|
||||
dest: /etc/yum.repos.d/docker-ce.repo
|
||||
group: root
|
||||
mode: 0644
|
||||
owner: root
|
||||
src: "{{ docker_repo_template }}"
|
||||
|
||||
- name: Install docker
|
||||
become: yes
|
||||
package:
|
||||
name: "{{ docker_upstream_distro_packages }}"
|
||||
state: present
|
||||
notify: Restart docker
|
||||
- include_tasks: upstream-package-installation.yaml
|
||||
|
@ -16,4 +16,4 @@ _docker_upstream_distro_packages:
|
||||
|
||||
docker_distro_vars_loaded: true
|
||||
|
||||
_docker_mirror_base_url: "https://{{ docker_download_fqdn }}/linux/ubuntu"
|
||||
_docker_mirror_base_url: "https://{{ docker_download_fqdn }}/linux/debian"
|
||||
|
@ -11,7 +11,7 @@ _docker_upstream_distro_packages:
|
||||
- docker-ce-cli
|
||||
- containerd.io
|
||||
|
||||
docker_repo_template: docker-ce-centos.repo
|
||||
docker_repo_template: docker-ce-centos.repo.j2
|
||||
|
||||
docker_distro_vars_loaded: true
|
||||
|
||||
|
@ -7,4 +7,11 @@ _docker_upstream_distro_required_packages: []
|
||||
|
||||
_docker_upstream_distro_packages: []
|
||||
|
||||
docker_repo_template: null
|
||||
|
||||
docker_distro_vars_loaded: true
|
||||
|
||||
_docker_mirror_base_url: null
|
||||
|
||||
# OpenSUSE has no upstream mirror
|
||||
use_upstream_docker: false
|
||||
|
@ -13,7 +13,7 @@ _docker_upstream_distro_packages:
|
||||
- docker-ce-cli
|
||||
- containerd.io
|
||||
|
||||
docker_repo_template: docker-ce-centos.repo
|
||||
docker_repo_template: docker-ce-centos.repo.j2
|
||||
|
||||
docker_distro_vars_loaded: true
|
||||
|
||||
|
19
roles/install-docker/vars/ubuntu.yaml
Normal file
19
roles/install-docker/vars/ubuntu.yaml
Normal file
@ -0,0 +1,19 @@
|
||||
---
|
||||
|
||||
_docker_distro_packages:
|
||||
- docker.io
|
||||
|
||||
_docker_upstream_distro_required_packages:
|
||||
- apt-transport-https
|
||||
- ca-certificates
|
||||
- curl
|
||||
- software-properties-common
|
||||
|
||||
_docker_upstream_distro_packages:
|
||||
- docker-ce
|
||||
- docker-ce-cli
|
||||
- containerd.io
|
||||
|
||||
docker_distro_vars_loaded: true
|
||||
|
||||
_docker_mirror_base_url: "https://{{ docker_download_fqdn }}/linux/ubuntu"
|
Loading…
Reference in New Issue
Block a user