ceph-container-common: modify requirement flow

Until now it was not possible to install a specific container package
because it was somehow hardcoded.
This patch allows to override the container package name (docker.io
vs docker-ce) and refacts the package installation. This could be
achieve via the container_package_name variable.
Instead of using one task per distribution we can set the package and
service name in vars. This allows to have a unified package task.
Also refactorize the debian_prerequisites tasks because the content
was outdated.

https://docs.docker.com/install/linux/docker-ce/debian/
https://docs.docker.com/install/linux/docker-ce/ubuntu/

Resolves: #3609

Signed-off-by: Dimitri Savineau <dsavinea@redhat.com>
(cherry picked from commit 8105a1cefb)
pull/3892/head
Dimitri Savineau 2019-04-16 09:33:02 -04:00 committed by mergify[bot]
parent f1e04835f4
commit f770917517
7 changed files with 45 additions and 138 deletions

View File

@ -1,70 +1,22 @@
---
- name: uninstall old docker versions
package:
name: ['docker', 'docker-engine', 'docker.io', 'containerd', 'runc']
state: absent
- name: allow apt to use a repository over https (debian)
package:
name: ['apt-transport-https', 'ca-certificates', 'curl', 'software-properties-common']
state: present
name: ['apt-transport-https', 'ca-certificates', 'software-properties-common']
update_cache: yes
register: result
until: result is succeeded
- name: add docker's gpg key
apt_key:
url: https://apt.dockerproject.org/gpg
state: present
url: 'https://download.docker.com/linux/{{ ansible_distribution | lower }}/gpg'
register: result
until: result is succeeded
- name: add docker and debian testing repository
- name: add docker repository
apt_repository:
repo: "{{ item }}"
state: present
update_cache: no
register: add_docker_apt_repo
with_items:
- "deb https://apt.dockerproject.org/repo/ debian-{{ ansible_distribution_release }} main"
- "deb http://http.us.debian.org/debian/ testing contrib main"
- name: update apt cache
apt:
update_cache: yes
when: add_docker_apt_repo | changed
register: update_docker_apt_cache
until: update_docker_apt_cache | success
retries: 5
delay: 2
- name: install pip from testing on debian
package:
name: python-pip
state: present
default_release: testing
update_cache: yes
register: result
until: result is succeeded
- name: install docker-py via pip for debian
pip:
name: docker-py
state: latest
register: result
until: result is succeeded
tags:
- skip_ansible_lint
- name: install docker on debian
package:
name: "{{ 'docker-ce' if ansible_architecture == 'aarch64' else 'docker-engine' }}"
state: present
update_cache: yes
register: result
until: result is succeeded
# NOTE (jimcurtis): need at least version 1.9.0 of six or we get:
# re:NameError: global name 'DEFAULT_DOCKER_API_VERSION' is not defined
- name: install six via pip
pip:
name: six
version: 1.9.0
register: result
until: result is succeeded
repo: "deb https://download.docker.com/linux/{{ ansible_distribution | lower}} {{ ansible_distribution_release }} stable"

View File

@ -1,45 +1,18 @@
---
- name: include specific variables
include_vars: "{{ item }}"
with_first_found:
- "{{ ansible_distribution }}-{{ ansible_distribution_major_version }}.yml"
- "{{ ansible_os_family }}.yml"
- name: include remove_ceph_udev_rules.yml
include_tasks: remove_ceph_udev_rules.yml
- name: debian based systems tasks
block:
- name: include debian_prerequisites.yml
include_tasks: debian_prerequisites.yml
tags:
with_pkg
- name: install python-six
package:
name: python-six
state: present
update_cache: yes
register: result
until: result is succeeded
tags:
with_pkg
include_tasks: debian_prerequisites.yml
when:
- ansible_distribution == 'Debian'
- name: ubuntu based systems tasks
block:
- name: install docker on ubuntu
package:
name: ['docker.io', 'python-docker']
state: present
update_cache: yes
register: result
until: result is succeeded
- name: install python3-docker on bionic
package:
name: python3-docker
state: present
update_cache: yes
register: result
until: result is succeeded
when: ansible_lsb.codename == 'bionic'
when:
- ansible_distribution == 'Ubuntu'
- ansible_os_family == 'Debian'
- container_package_name == 'docker-ce'
tags:
with_pkg
@ -55,53 +28,16 @@
tags:
with_pkg
- name: red hat 7 based systems tasks
block:
- name: install python-docker-py on red hat / centos
package:
name: ['docker', 'python-docker-py']
state: present
register: result
until: result is succeeded
tags:
with_pkg
- name: install container package
package:
name: ['{{ container_package_name }}', '{{ container_binding_name }}']
update_cache: true
tags:
with_pkg
- name: pause after docker install before starting (on openstack vms)
pause: seconds=5
when:
- ceph_docker_on_openstack
tags:
with_pkg
- name: start docker service
service:
name: docker
state: started
enabled: yes
tags:
with_pkg
when:
- ansible_os_family == 'RedHat'
- ansible_distribution_major_version == '7'
- name: red hat 8 based systems tasks
block:
- name: install podman
package:
name: 'podman'
state: present
register: result
until: result is succeeded
tags:
with_pkg
when:
- ansible_os_family == 'RedHat'
- ansible_distribution_major_version == '8'
- name: start docker service
- name: start container service
service:
name: docker
name: '{{ container_service_name }}'
state: started
enabled: yes
tags:

View File

@ -0,0 +1,4 @@
---
container_package_name: docker-ce
container_service_name: docker
container_binding_name: python-docker

View File

@ -0,0 +1,3 @@
---
container_package_name: podman
container_binding_name: podman

View File

@ -0,0 +1,4 @@
---
container_package_name: docker
container_service_name: docker
container_binding_name: python-docker-py

View File

@ -0,0 +1,4 @@
---
container_package_name: docker.io
container_service_name: docker
container_binding_name: python-docker

View File

@ -0,0 +1,4 @@
---
container_package_name: docker.io
container_service_name: docker
container_binding_name: python3-docker