[stable-2.7] Improve setup_docker tests to work with RHEL 8 GA (#58649)

- use include_vars to set appropriate packages and pip packages per distribution and version
- install an older version of Docker CE on RHEL 8 since a dependency is unavailable
- disable warnings on tasks that are ok
- skip tests for CentOS/RHEL 6.
(cherry picked from commit d50c8c2b83)

Co-authored-by: Sam Doran <sdoran@redhat.com>
pull/59313/head
Sam Doran 5 years ago committed by Toshio Kuratomi
parent 9b1575cfeb
commit 3f0de5c438

@ -0,0 +1,10 @@
docker_cli_version: '0.0'
docker_api_version: '0.0'
docker_py_version: '0.0'
docker_prereq_packages: []
docker_packages:
- docker-ce
docker_pip_extra_packages: []
docker_pip_packages:
- docker

@ -4,20 +4,15 @@
- name: Install pre-reqs
apt:
name: "{{ item }}"
name: "{{ docker_prereq_packages }}"
state: present
update_cache: yes
with_items:
- apt-transport-https
- ca-certificates
- curl
- software-properties-common
- name: Add gpg key
shell: curl -fsSL https://download.docker.com/linux/ubuntu/gpg >key && apt-key add key
- name: Add Docker repo
shell: add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
shell: add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
- block:
- name: Prevent service restart
@ -30,7 +25,7 @@
- name: Install Docker CE
apt:
name: docker-ce
name: "{{ docker_packages }}"
state: present
update_cache: yes
always:

@ -1,18 +1,20 @@
- name: Install Docker pre-reqs
dnf:
name: "{{ item }}"
name: "{{ docker_prereq_packages }}"
state: present
loop:
- dnf-plugins-core
- name: Add repository
command: dnf config-manager --add-repo https://download.docker.com/linux/fedora/docker-ce.repo
args:
warn: no
- name: Update cache
command: dnf makecache
args:
warn: no
- name: Install docker
dnf:
name: docker-ce
name: "{{ docker_packages }}"
state: present
enablerepo: docker-ce-test

@ -3,13 +3,8 @@
- name: Install Docker pre-reqs
yum:
name: "{{ item }}"
name: "{{ docker_prereq_packages }}"
state: present
loop:
- yum-utils
- device-mapper-persistent-data
- lvm2
- libseccomp
- name: Install epel repo which is missing on rhel-7 and is needed for pigz (needed for docker-ce 18)
yum:
@ -17,16 +12,22 @@
- name: Enable extras repository for RHEL on AWS
command: yum-config-manager --enable rhui-REGION-rhel-server-extras
args:
warn: no
- name: Add repository
command: yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
args:
warn: no
- name: Update cache
command: yum -y makecache fast
args:
warn: no
- name: Install docker
yum:
name: docker-ce
name: "{{ docker_packages }}"
state: present
- name: Make sure the docker daemon is running (failure expected inside docker container)

@ -0,0 +1,23 @@
# The RHEL extras repository must be enabled to provide the container-selinux package.
# See: https://docs.docker.com/engine/installation/linux/docker-ee/rhel/#install-using-the-repository
- name: Install Docker pre-reqs
dnf:
name: "{{ docker_prereq_packages }}"
state: present
- name: Set-up repository
command: dnf config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
args:
warn: no
- name: Install docker
dnf:
name: "{{ docker_packages }}"
state: present
- name: Make sure the docker daemon is running (failure expected inside docker container)
service:
name: docker
state: started
ignore_errors: "{{ ansible_virtualization_type == 'docker' }}"

@ -1,6 +1,6 @@
- name: Install docker 17
zypper:
name: docker>=17
name: "{{ docker_packages }}"
force: yes
disable_gpg_check: yes
update_cache: yes

@ -1,25 +1,35 @@
- vars:
is_rhel: "{{ ansible_os_family == 'RedHat' and ansible_distribution != 'Fedora' }}"
is_rhel6: "{{ is_rhel and ansible_distribution_major_version == '6' }}"
is_rhel7: "{{ is_rhel and ansible_distribution_major_version == '7' }}"
is_ubuntu14: "{{ ansible_distribution == 'Ubuntu' and ansible_distribution_major_version == '14' }}"
- name: Setup Docker
when: ansible_facts.distribution ~ ansible_facts.distribution_major_version not in ['CentOS6', 'RedHat6']
block:
- include_tasks: "{{ lookup('first_found', params) }}"
- name: Include distribution specific variables
include_vars: "{{ lookup('first_found', params) }}"
vars:
params:
- '{{ ansible_distribution }}.yml'
- '{{ ansible_os_family }}.yml'
when: not is_rhel6
files:
- "{{ ansible_facts.distribution }}-{{ ansible_facts.distribution_major_version }}.yml"
- "{{ ansible_facts.os_family }}-{{ ansible_facts.distribution_major_version }}.yml"
- "{{ ansible_facts.distribution }}.yml"
- "{{ ansible_facts.os_family }}.yml"
- default.yml
paths:
- vars
- name: Install Python requirements
- name: Include distribution specific tasks
include_tasks: "{{ lookup('first_found', params) }}"
vars:
# Inttalling requests >=2.12.0 on Ubuntu 14.04 breaks certificate validation. We restrict to an older version
# to ensure out get_url tests work out fine. This is only an issue if pyOpenSSL is also installed.
# Not sure why RHEL7 needs this specific version
extra_packages: "{{ '' if not (is_rhel7 or is_ubuntu14) else ',requests==2.6.0' }}"
params:
files:
- "{{ ansible_facts.distribution }}-{{ ansible_facts.distribution_major_version }}.yml"
- "{{ ansible_facts.os_family }}-{{ ansible_facts.distribution_major_version }}.yml"
- "{{ ansible_facts.distribution }}.yml"
- "{{ ansible_facts.os_family }}.yml"
paths:
- tasks
- name: Install Python requirements
pip:
state: present
name: 'docker{{ extra_packages }}'
name: "{{ docker_pip_packages | union(docker_pip_extra_packages) }}"
extra_args: "-c {{ role_path }}/../../../runner/requirements/constraints.txt"
# Detect docker CLI, API and docker-py versions
@ -39,9 +49,9 @@
ignore_errors: yes
- set_fact:
docker_cli_version: "{{ (docker_cli_version_stdout.stdout | default('0.0')) or '0.0' }}"
docker_api_version: "{{ docker_api_version_stdout.stdout or '0.0' }}"
docker_py_version: "{{ docker_py_version_stdout.stdout or '0.0' }}"
docker_cli_version: "{{ docker_cli_version_stdout.stdout | default('0.0') }}"
docker_api_version: "{{ docker_api_version_stdout.stdout | default('0.0') }}"
docker_py_version: "{{ docker_py_version_stdout.stdout | default('0.0') }}"
- debug:
msg: "Docker CLI version: {{ docker_cli_version }}; Docker API version: {{ docker_api_version }}; docker-py library version: {{ docker_py_version }}"
@ -51,12 +61,15 @@
- name: "Remove all ansible-test-* docker containers"
shell: 'docker ps --no-trunc --format {% raw %}"{{.Names}}"{% endraw %} | grep "^ansible-test-" | xargs -r docker rm -f'
register: docker_containers
- name: "Remove all ansible-test-* docker volumes"
shell: 'docker volume ls --format {% raw %}"{{.Name}}"{% endraw %} | grep "^ansible-test-" | xargs -r docker volume rm -f'
register: docker_volumes
- name: "Remove all ansible-test-* docker networks"
shell: 'docker network ls --no-trunc --format {% raw %}"{{.Name}}"{% endraw %} | grep "^ansible-test-" | xargs -r docker network rm'
register: docker_networks
- name: Cleaned docker resources
debug:
var: docker_resources
@ -70,15 +83,19 @@
- name: List all docker containers
command: docker ps --no-trunc -a
register: docker_containers
- name: List all docker volumes
command: docker volume ls
register: docker_volumes
- name: List all docker networks
command: docker network ls --no-trunc
register: docker_networks
- name: List all docker images
command: docker images --no-trunc -a
register: docker_images
- name: Still existing docker resources
debug:
var: docker_resources

@ -0,0 +1,5 @@
docker_prereq_packages:
- apt-transport-https
- ca-certificates
- curl
- software-properties-common

@ -0,0 +1,5 @@
docker_prereq_packages:
- dnf-plugins-core
docker_packages:
- docker-ce

@ -0,0 +1,8 @@
docker_prereq_packages:
- yum-utils
- device-mapper-persistent-data
- lvm2
- libseccomp
docker_pip_extra_packages:
- requests==2.6.0

@ -0,0 +1,9 @@
docker_prereq_packages:
- dnf-utils
- device-mapper-persistent-data
- lvm2
- libseccomp
# Docker CE > 3:18.09.1 requires containerd.io >= 1.2.2-3 which is unavaible at this time
docker_packages:
- docker-ce-3:18.09.1

@ -0,0 +1,2 @@
docker_packages:
- docker>=17

@ -0,0 +1,5 @@
docker_pip_extra_packages:
# Installing requests >=2.12.0 on Ubuntu 14.04 breaks certificate validation. We restrict to an older version
# to ensure out get_url tests work out fine. This is only an issue if pyOpenSSL is also installed.
# Not sure why RHEL7 needs this specific version
- requests==2.6.0
Loading…
Cancel
Save