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
|
- name: Assure docker service is running
|
||||||
become: yes
|
become: true
|
||||||
service:
|
service:
|
||||||
name: docker
|
name: docker
|
||||||
enabled: yes
|
enabled: yes
|
||||||
@ -9,7 +9,7 @@
|
|||||||
listen: Restart docker
|
listen: Restart docker
|
||||||
|
|
||||||
- name: Correct group ownership on docker sock
|
- name: Correct group ownership on docker sock
|
||||||
become: yes
|
become: true
|
||||||
file:
|
file:
|
||||||
path: /var/run/docker.sock
|
path: /var/run/docker.sock
|
||||||
group: "{{ docker_group }}"
|
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
|
- name: Sanity check for distro selection
|
||||||
fail:
|
fail:
|
||||||
msg: >-
|
msg: >-
|
||||||
This role is not known to be compatible with this distro. Check the inventory and deployment
|
This role is not known to be compatible with this distro and no packages have been provided
|
||||||
target settings. Make sure facts are being gathered prior to executing this role.
|
for installation. Check the inventory and deployment target settings. Make sure facts are
|
||||||
|
being gathered prior to executing this role.
|
||||||
when:
|
when:
|
||||||
- not (docker_distro_vars_loaded | bool)
|
- not (docker_distro_vars_loaded | bool)
|
||||||
|
- (docker_distro_packages | length) < 1
|
||||||
|
|
||||||
- name: Sanity check for distro install
|
- name: Sanity check for distro install
|
||||||
fail:
|
fail:
|
||||||
@ -53,54 +55,11 @@
|
|||||||
- (docker_mirror_base_url | length) < 1
|
- (docker_mirror_base_url | length) < 1
|
||||||
- use_upstream_docker | bool
|
- use_upstream_docker | bool
|
||||||
|
|
||||||
- name: Upstream block
|
- include_tasks: "docker-{{ (use_upstream_docker | bool) | ternary('upstream', 'distro') }}.yaml"
|
||||||
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
|
|
||||||
|
|
||||||
- name: Flush handlers before role exit
|
- name: Flush handlers before role exit
|
||||||
meta: flush_handlers
|
meta: flush_handlers
|
||||||
|
|
||||||
- name: Reset ssh connection to pick up docker group
|
|
||||||
meta: reset_connection
|
|
||||||
|
|
||||||
- name: Validate ability to talk with docker
|
- name: Validate ability to talk with docker
|
||||||
command: docker ps
|
command: docker ps
|
||||||
changed_when: false
|
changed_when: false
|
||||||
|
@ -1,17 +1,16 @@
|
|||||||
|
---
|
||||||
|
|
||||||
- name: Install pre-reqs
|
- name: Install pre-reqs
|
||||||
package:
|
package:
|
||||||
name: "{{ _docker_upstream_distro_required_packages }}"
|
name: "{{ _docker_upstream_distro_required_packages }}"
|
||||||
state: present
|
state: present
|
||||||
become: yes
|
|
||||||
|
|
||||||
- name: Add docker GPG key
|
- name: Add docker GPG key
|
||||||
become: yes
|
|
||||||
apt_key:
|
apt_key:
|
||||||
data: "{{ docker_gpg_key }}"
|
data: "{{ docker_gpg_key }}"
|
||||||
|
|
||||||
# TODO(mordred) We should add a proxy cache mirror for this
|
# TODO(mordred) We should add a proxy cache mirror for this
|
||||||
- name: Add docker apt repo
|
- name: Add docker apt repo
|
||||||
become: yes
|
|
||||||
template:
|
template:
|
||||||
dest: /etc/apt/sources.list.d/docker.list
|
dest: /etc/apt/sources.list.d/docker.list
|
||||||
group: root
|
group: root
|
||||||
@ -19,10 +18,4 @@
|
|||||||
owner: root
|
owner: root
|
||||||
src: sources.list.j2
|
src: sources.list.j2
|
||||||
|
|
||||||
- name: Install docker
|
- include_tasks: upstream-package-installation.yaml
|
||||||
become: yes
|
|
||||||
apt:
|
|
||||||
name: "{{ docker_upstream_distro_packages }}"
|
|
||||||
state: present
|
|
||||||
update_cache: yes
|
|
||||||
notify: Restart docker
|
|
||||||
|
@ -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:
|
package:
|
||||||
name: "{{ _docker_upstream_distro_required_packages }}"
|
name: "{{ _docker_upstream_distro_required_packages }}"
|
||||||
state: present
|
state: present
|
||||||
become: yes
|
|
||||||
|
|
||||||
- name: Create tmp gpg key file
|
- name: Create tmp gpg key file
|
||||||
copy:
|
copy:
|
||||||
@ -18,17 +17,11 @@
|
|||||||
|
|
||||||
# TODO(mordred) We should add a proxy cache mirror for this
|
# TODO(mordred) We should add a proxy cache mirror for this
|
||||||
- name: Add docker repo
|
- name: Add docker repo
|
||||||
become: yes
|
template:
|
||||||
copy:
|
|
||||||
dest: /etc/yum.repos.d/docker-ce.repo
|
dest: /etc/yum.repos.d/docker-ce.repo
|
||||||
group: root
|
group: root
|
||||||
mode: 0644
|
mode: 0644
|
||||||
owner: root
|
owner: root
|
||||||
src: "{{ docker_repo_template }}"
|
src: "{{ docker_repo_template }}"
|
||||||
|
|
||||||
- name: Install docker
|
- include_tasks: upstream-package-installation.yaml
|
||||||
become: yes
|
|
||||||
package:
|
|
||||||
name: "{{ docker_upstream_distro_packages }}"
|
|
||||||
state: present
|
|
||||||
notify: Restart docker
|
|
||||||
|
@ -16,4 +16,4 @@ _docker_upstream_distro_packages:
|
|||||||
|
|
||||||
docker_distro_vars_loaded: true
|
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
|
- docker-ce-cli
|
||||||
- containerd.io
|
- containerd.io
|
||||||
|
|
||||||
docker_repo_template: docker-ce-centos.repo
|
docker_repo_template: docker-ce-centos.repo.j2
|
||||||
|
|
||||||
docker_distro_vars_loaded: true
|
docker_distro_vars_loaded: true
|
||||||
|
|
||||||
|
@ -7,4 +7,11 @@ _docker_upstream_distro_required_packages: []
|
|||||||
|
|
||||||
_docker_upstream_distro_packages: []
|
_docker_upstream_distro_packages: []
|
||||||
|
|
||||||
|
docker_repo_template: null
|
||||||
|
|
||||||
docker_distro_vars_loaded: true
|
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
|
- docker-ce-cli
|
||||||
- containerd.io
|
- containerd.io
|
||||||
|
|
||||||
docker_repo_template: docker-ce-centos.repo
|
docker_repo_template: docker-ce-centos.repo.j2
|
||||||
|
|
||||||
docker_distro_vars_loaded: true
|
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