diff options
author | Sam Doran <sdoran@redhat.com> | 2019-07-03 14:24:24 -0400 |
---|---|---|
committer | Toshio Kuratomi <a.badger@gmail.com> | 2019-07-17 15:37:46 -0700 |
commit | 3f0de5c438ac67e66277074d9a06baf3f6edbe83 (patch) | |
tree | f851fbc14f997d29fee75297fc812cd757e42673 | |
parent | 9b1575cfeb439ee4c353335409e6b82386001493 (diff) | |
download | ansible-3f0de5c438ac67e66277074d9a06baf3f6edbe83.tar.gz |
[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 d50c8c2b83e4ccf9b0bf4bdc4f26ebd2346df255)
Co-authored-by: Sam Doran <sdoran@redhat.com>
-rw-r--r-- | test/integration/targets/setup_docker/defaults/main.yml | 10 | ||||
-rw-r--r-- | test/integration/targets/setup_docker/tasks/Debian.yml | 11 | ||||
-rw-r--r-- | test/integration/targets/setup_docker/tasks/Fedora.yml | 10 | ||||
-rw-r--r-- | test/integration/targets/setup_docker/tasks/RedHat-7.yml (renamed from test/integration/targets/setup_docker/tasks/RedHat.yml) | 15 | ||||
-rw-r--r-- | test/integration/targets/setup_docker/tasks/RedHat-8.yml | 23 | ||||
-rw-r--r-- | test/integration/targets/setup_docker/tasks/Suse.yml | 2 | ||||
-rw-r--r-- | test/integration/targets/setup_docker/tasks/main.yml | 53 | ||||
-rw-r--r-- | test/integration/targets/setup_docker/vars/Debian.yml | 5 | ||||
-rw-r--r-- | test/integration/targets/setup_docker/vars/Fedora.yml | 5 | ||||
-rw-r--r-- | test/integration/targets/setup_docker/vars/RedHat-7.yml | 8 | ||||
-rw-r--r-- | test/integration/targets/setup_docker/vars/RedHat-8.yml | 9 | ||||
-rw-r--r-- | test/integration/targets/setup_docker/vars/Suse.yml | 2 | ||||
-rw-r--r-- | test/integration/targets/setup_docker/vars/Ubuntu-14.yml | 5 | ||||
-rw-r--r-- | test/integration/targets/setup_docker/vars/default.yml | 0 |
14 files changed, 120 insertions, 38 deletions
diff --git a/test/integration/targets/setup_docker/defaults/main.yml b/test/integration/targets/setup_docker/defaults/main.yml new file mode 100644 index 0000000000..9eeed89e38 --- /dev/null +++ b/test/integration/targets/setup_docker/defaults/main.yml @@ -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 diff --git a/test/integration/targets/setup_docker/tasks/Debian.yml b/test/integration/targets/setup_docker/tasks/Debian.yml index 4564eee49a..da81ac77b3 100644 --- a/test/integration/targets/setup_docker/tasks/Debian.yml +++ b/test/integration/targets/setup_docker/tasks/Debian.yml @@ -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: diff --git a/test/integration/targets/setup_docker/tasks/Fedora.yml b/test/integration/targets/setup_docker/tasks/Fedora.yml index 60e70d2ef1..aefc79ec4b 100644 --- a/test/integration/targets/setup_docker/tasks/Fedora.yml +++ b/test/integration/targets/setup_docker/tasks/Fedora.yml @@ -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 diff --git a/test/integration/targets/setup_docker/tasks/RedHat.yml b/test/integration/targets/setup_docker/tasks/RedHat-7.yml index 40e7fa2892..7a32d85612 100644 --- a/test/integration/targets/setup_docker/tasks/RedHat.yml +++ b/test/integration/targets/setup_docker/tasks/RedHat-7.yml @@ -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) diff --git a/test/integration/targets/setup_docker/tasks/RedHat-8.yml b/test/integration/targets/setup_docker/tasks/RedHat-8.yml new file mode 100644 index 0000000000..d6a775c197 --- /dev/null +++ b/test/integration/targets/setup_docker/tasks/RedHat-8.yml @@ -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' }}" diff --git a/test/integration/targets/setup_docker/tasks/Suse.yml b/test/integration/targets/setup_docker/tasks/Suse.yml index 3bd3d1dad1..bc4bd4f187 100644 --- a/test/integration/targets/setup_docker/tasks/Suse.yml +++ b/test/integration/targets/setup_docker/tasks/Suse.yml @@ -1,6 +1,6 @@ - name: Install docker 17 zypper: - name: docker>=17 + name: "{{ docker_packages }}" force: yes disable_gpg_check: yes update_cache: yes diff --git a/test/integration/targets/setup_docker/tasks/main.yml b/test/integration/targets/setup_docker/tasks/main.yml index 8e83992285..bee314e468 100644 --- a/test/integration/targets/setup_docker/tasks/main.yml +++ b/test/integration/targets/setup_docker/tasks/main.yml @@ -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 diff --git a/test/integration/targets/setup_docker/vars/Debian.yml b/test/integration/targets/setup_docker/vars/Debian.yml new file mode 100644 index 0000000000..e9ffb94159 --- /dev/null +++ b/test/integration/targets/setup_docker/vars/Debian.yml @@ -0,0 +1,5 @@ +docker_prereq_packages: + - apt-transport-https + - ca-certificates + - curl + - software-properties-common diff --git a/test/integration/targets/setup_docker/vars/Fedora.yml b/test/integration/targets/setup_docker/vars/Fedora.yml new file mode 100644 index 0000000000..be83c6be1f --- /dev/null +++ b/test/integration/targets/setup_docker/vars/Fedora.yml @@ -0,0 +1,5 @@ +docker_prereq_packages: + - dnf-plugins-core + +docker_packages: + - docker-ce diff --git a/test/integration/targets/setup_docker/vars/RedHat-7.yml b/test/integration/targets/setup_docker/vars/RedHat-7.yml new file mode 100644 index 0000000000..7166b1f573 --- /dev/null +++ b/test/integration/targets/setup_docker/vars/RedHat-7.yml @@ -0,0 +1,8 @@ +docker_prereq_packages: + - yum-utils + - device-mapper-persistent-data + - lvm2 + - libseccomp + +docker_pip_extra_packages: + - requests==2.6.0 diff --git a/test/integration/targets/setup_docker/vars/RedHat-8.yml b/test/integration/targets/setup_docker/vars/RedHat-8.yml new file mode 100644 index 0000000000..45e50102bf --- /dev/null +++ b/test/integration/targets/setup_docker/vars/RedHat-8.yml @@ -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 diff --git a/test/integration/targets/setup_docker/vars/Suse.yml b/test/integration/targets/setup_docker/vars/Suse.yml new file mode 100644 index 0000000000..ad0d515e2b --- /dev/null +++ b/test/integration/targets/setup_docker/vars/Suse.yml @@ -0,0 +1,2 @@ +docker_packages: + - docker>=17 diff --git a/test/integration/targets/setup_docker/vars/Ubuntu-14.yml b/test/integration/targets/setup_docker/vars/Ubuntu-14.yml new file mode 100644 index 0000000000..36ab54b9d9 --- /dev/null +++ b/test/integration/targets/setup_docker/vars/Ubuntu-14.yml @@ -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 diff --git a/test/integration/targets/setup_docker/vars/default.yml b/test/integration/targets/setup_docker/vars/default.yml new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/test/integration/targets/setup_docker/vars/default.yml |