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
This commit is contained in:
parent
ce79c8eb27
commit
d50c8c2b83
14 changed files with 101 additions and 47 deletions
10
test/integration/targets/setup_docker/defaults/main.yml
Normal file
10
test/integration/targets/setup_docker/defaults/main.yml
Normal file
|
@ -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)
|
||||
include_role:
|
||||
|
@ -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)
|
|
@ -3,19 +3,17 @@
|
|||
|
||||
- name: Install Docker pre-reqs
|
||||
dnf:
|
||||
name:
|
||||
- dnf-utils
|
||||
- device-mapper-persistent-data
|
||||
- lvm2
|
||||
- libseccomp
|
||||
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-ce
|
||||
name: "{{ docker_packages }}"
|
||||
state: present
|
||||
|
||||
- name: Make sure the docker daemon is running (failure expected inside docker container)
|
|
@ -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,28 +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_rhel8: "{{ is_rhel and ansible_distribution_major_version == '8' }}"
|
||||
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 and not is_rhel8
|
||||
- include_tasks: RHEL8.yml
|
||||
when: is_rhel8
|
||||
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: Include distribution specific tasks
|
||||
include_tasks: "{{ lookup('first_found', params) }}"
|
||||
vars:
|
||||
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
|
||||
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' }}"
|
||||
pip:
|
||||
state: present
|
||||
name: 'docker{{ extra_packages }}'
|
||||
name: "{{ docker_pip_packages | union(docker_pip_extra_packages) }}"
|
||||
extra_args: "-c {{ remote_constraints }}"
|
||||
|
||||
# Detect docker CLI, API and docker-py versions
|
||||
|
@ -42,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 }}"
|
||||
|
@ -54,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
|
||||
|
@ -73,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
|
||||
|
|
5
test/integration/targets/setup_docker/vars/Debian.yml
Normal file
5
test/integration/targets/setup_docker/vars/Debian.yml
Normal file
|
@ -0,0 +1,5 @@
|
|||
docker_prereq_packages:
|
||||
- apt-transport-https
|
||||
- ca-certificates
|
||||
- curl
|
||||
- software-properties-common
|
5
test/integration/targets/setup_docker/vars/Fedora.yml
Normal file
5
test/integration/targets/setup_docker/vars/Fedora.yml
Normal file
|
@ -0,0 +1,5 @@
|
|||
docker_prereq_packages:
|
||||
- dnf-plugins-core
|
||||
|
||||
docker_packages:
|
||||
- docker-ce
|
8
test/integration/targets/setup_docker/vars/RedHat-7.yml
Normal file
8
test/integration/targets/setup_docker/vars/RedHat-7.yml
Normal file
|
@ -0,0 +1,8 @@
|
|||
docker_prereq_packages:
|
||||
- yum-utils
|
||||
- device-mapper-persistent-data
|
||||
- lvm2
|
||||
- libseccomp
|
||||
|
||||
docker_pip_extra_packages:
|
||||
- requests==2.6.0
|
9
test/integration/targets/setup_docker/vars/RedHat-8.yml
Normal file
9
test/integration/targets/setup_docker/vars/RedHat-8.yml
Normal file
|
@ -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
|
2
test/integration/targets/setup_docker/vars/Suse.yml
Normal file
2
test/integration/targets/setup_docker/vars/Suse.yml
Normal file
|
@ -0,0 +1,2 @@
|
|||
docker_packages:
|
||||
- docker>=17
|
5
test/integration/targets/setup_docker/vars/Ubuntu-14.yml
Normal file
5
test/integration/targets/setup_docker/vars/Ubuntu-14.yml
Normal file
|
@ -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
|
0
test/integration/targets/setup_docker/vars/default.yml
Normal file
0
test/integration/targets/setup_docker/vars/default.yml
Normal file
Loading…
Reference in a new issue