diff --git a/test/integration/targets/docker_secret/meta/main.yml b/test/integration/targets/docker_secret/meta/main.yml new file mode 100644 index 0000000000..07da8c6dda --- /dev/null +++ b/test/integration/targets/docker_secret/meta/main.yml @@ -0,0 +1,3 @@ +--- +dependencies: + - setup_docker diff --git a/test/integration/targets/docker_secret/tasks/main.yml b/test/integration/targets/docker_secret/tasks/main.yml index a71923aaa4..7ecf918155 100644 --- a/test/integration/targets/docker_secret/tasks/main.yml +++ b/test/integration/targets/docker_secret/tasks/main.yml @@ -1,14 +1,2 @@ -- include: RedHat.yml - when: ansible_os_family == 'RedHat' and ansible_distribution != 'Fedora' and ansible_distribution_major_version != '6' - -- include: Fedora.yml - when: ansible_distribution == 'Fedora' - -- include: OpenSuse.yml - when: ansible_os_family == 'Suse' - -- include: Ubuntu.yml - when: ansible_os_family == 'Debian' - -- include: test_secrets.yml +- include_tasks: test_secrets.yml when: ansible_os_family != 'RedHat' or ansible_distribution_major_version != '6' diff --git a/test/integration/targets/docker_secret/tasks/test_secrets.yml b/test/integration/targets/docker_secret/tasks/test_secrets.yml index c1b0a43166..a76ecd30eb 100644 --- a/test/integration/targets/docker_secret/tasks/test_secrets.yml +++ b/test/integration/targets/docker_secret/tasks/test_secrets.yml @@ -1,10 +1,3 @@ -- name: Install Python requirements - pip: - state: present - name: "{{ item }}" - with_items: - - docker==2.1.0 - - name: Check if already in swarm shell: docker node ls 2>&1 | grep 'docker swarm init' register: output diff --git a/test/integration/targets/docker_swarm/aliases b/test/integration/targets/docker_swarm/aliases index 309f4b4664..2b3832dde5 100644 --- a/test/integration/targets/docker_swarm/aliases +++ b/test/integration/targets/docker_swarm/aliases @@ -1,5 +1,4 @@ shippable/posix/group2 skip/osx skip/freebsd -skip/rhel destructive diff --git a/test/integration/targets/docker_swarm/meta/main.yml b/test/integration/targets/docker_swarm/meta/main.yml new file mode 100644 index 0000000000..07da8c6dda --- /dev/null +++ b/test/integration/targets/docker_swarm/meta/main.yml @@ -0,0 +1,3 @@ +--- +dependencies: + - setup_docker diff --git a/test/integration/targets/docker_swarm/tasks/Fedora.yml b/test/integration/targets/docker_swarm/tasks/Fedora.yml deleted file mode 100644 index 60e70d2ef1..0000000000 --- a/test/integration/targets/docker_swarm/tasks/Fedora.yml +++ /dev/null @@ -1,18 +0,0 @@ -- name: Install Docker pre-reqs - dnf: - name: "{{ item }}" - state: present - loop: - - dnf-plugins-core - -- name: Add repository - command: dnf config-manager --add-repo https://download.docker.com/linux/fedora/docker-ce.repo - -- name: Update cache - command: dnf makecache - -- name: Install docker - dnf: - name: docker-ce - state: present - enablerepo: docker-ce-test diff --git a/test/integration/targets/docker_swarm/tasks/OpenSuse.yml b/test/integration/targets/docker_swarm/tasks/OpenSuse.yml deleted file mode 100644 index cd625d8cf0..0000000000 --- a/test/integration/targets/docker_swarm/tasks/OpenSuse.yml +++ /dev/null @@ -1,11 +0,0 @@ -- name: Template repo - template: - src: virt.repo.j2 - dest: /etc/zypp/repos.d/virt.repo - -- name: Install docker 17 - zypper: - name: docker>=17 - force: yes - disable_gpg_check: yes - update_cache: yes diff --git a/test/integration/targets/docker_swarm/tasks/Ubuntu.yml b/test/integration/targets/docker_swarm/tasks/Ubuntu.yml deleted file mode 100644 index cb03052109..0000000000 --- a/test/integration/targets/docker_swarm/tasks/Ubuntu.yml +++ /dev/null @@ -1,57 +0,0 @@ -- name: Get OS version - shell: uname -r - register: os_version - -- name: Install packages for Trusty - apt: - name: "{{ item }}" - state: present - update_cache: yes - with_items: - - "linux-image-extra-{{ os_version.stdout }}" - - linux-image-extra-virtual - when: ansible_distribution_release == 'trusty' - -- name: Install pre-reqs - apt: - name: "{{ item }}" - 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" - -- block: - - name: Prevent service restart - copy: - content: exit 101 - dest: /usr/sbin/policy-rc.d - backup: yes - mode: 0755 - register: policy_rc_d - - - name: Install Docker CE - apt: - name: docker-ce - state: present - update_cache: yes - always: - - name: Restore /usr/sbin/policy-rc.d (if needed) - command: mv {{ policy_rc_d.backup_file }} /usr/sbin/policy-rc.d - when: - - "'backup_file' in policy_rc_d" - - - name: Remove /usr/sbin/policy-rc.d (if needed) - file: - path: /usr/sbin/policy-rc.d - state: absent - when: - - "'backup_file' not in policy_rc_d" diff --git a/test/integration/targets/docker_swarm/tasks/main.yml b/test/integration/targets/docker_swarm/tasks/main.yml index 2c37d7ada3..65e3b7ff33 100644 --- a/test/integration/targets/docker_swarm/tasks/main.yml +++ b/test/integration/targets/docker_swarm/tasks/main.yml @@ -1,11 +1,2 @@ -- include: Fedora.yml - when: ansible_distribution == 'Fedora' - -- include: OpenSuse.yml - when: ansible_os_family == 'Suse' - -- include: Ubuntu.yml - when: ansible_os_family == 'Debian' - -- include: test_swarm.yml +- include_tasks: test_swarm.yml when: ansible_os_family != 'RedHat' or ansible_distribution_major_version != '6' diff --git a/test/integration/targets/docker_swarm/tasks/test_swarm.yml b/test/integration/targets/docker_swarm/tasks/test_swarm.yml index c5dca3bfa0..9e6bf80844 100644 --- a/test/integration/targets/docker_swarm/tasks/test_swarm.yml +++ b/test/integration/targets/docker_swarm/tasks/test_swarm.yml @@ -1,10 +1,3 @@ -- name: Install Python requirements - pip: - state: present - name: "{{ item }}" - with_items: - - docker==2.7.0 - - name: Test parameters with state=present docker_swarm: state: present diff --git a/test/integration/targets/docker_swarm/templates/virt.repo.j2 b/test/integration/targets/docker_swarm/templates/virt.repo.j2 deleted file mode 100644 index 4d8f380b51..0000000000 --- a/test/integration/targets/docker_swarm/templates/virt.repo.j2 +++ /dev/null @@ -1,7 +0,0 @@ -[Virtualization_containers] -name=Virtualization:containers (openSUSE_Leap_{{ ansible_distribution_version }}) -type=rpm-md -baseurl=http://download.opensuse.org/repositories/Virtualization:/containers/openSUSE_Leap_{{ ansible_distribution_version }}/ -gpgcheck=1 -gpgkey=http://download.opensuse.org/repositories/Virtualization:/containers/openSUSE_Leap_{{ ansible_distribution_version }}/repodata/repomd.xml.key -enabled=1 diff --git a/test/integration/targets/docker_secret/tasks/Ubuntu.yml b/test/integration/targets/setup_docker/tasks/Debian.yml similarity index 100% rename from test/integration/targets/docker_secret/tasks/Ubuntu.yml rename to test/integration/targets/setup_docker/tasks/Debian.yml diff --git a/test/integration/targets/docker_secret/tasks/Fedora.yml b/test/integration/targets/setup_docker/tasks/Fedora.yml similarity index 100% rename from test/integration/targets/docker_secret/tasks/Fedora.yml rename to test/integration/targets/setup_docker/tasks/Fedora.yml diff --git a/test/integration/targets/docker_secret/tasks/RedHat.yml b/test/integration/targets/setup_docker/tasks/RedHat.yml similarity index 94% rename from test/integration/targets/docker_secret/tasks/RedHat.yml rename to test/integration/targets/setup_docker/tasks/RedHat.yml index 44deafb233..40e7fa2892 100644 --- a/test/integration/targets/docker_secret/tasks/RedHat.yml +++ b/test/integration/targets/setup_docker/tasks/RedHat.yml @@ -33,4 +33,4 @@ service: name: docker state: started - ignore_errors: yes + ignore_errors: "{{ ansible_virtualization_type == 'docker' }}" diff --git a/test/integration/targets/docker_secret/tasks/OpenSuse.yml b/test/integration/targets/setup_docker/tasks/Suse.yml similarity index 100% rename from test/integration/targets/docker_secret/tasks/OpenSuse.yml rename to test/integration/targets/setup_docker/tasks/Suse.yml diff --git a/test/integration/targets/setup_docker/tasks/main.yml b/test/integration/targets/setup_docker/tasks/main.yml new file mode 100644 index 0000000000..c92988aea5 --- /dev/null +++ b/test/integration/targets/setup_docker/tasks/main.yml @@ -0,0 +1,18 @@ +- 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' }}" + block: + - include_tasks: "{{ lookup('first_found', params) }}" + vars: + params: + - '{{ ansible_distribution }}.yml' + - '{{ ansible_os_family }}.yml' + when: not is_rhel6 + + - name: Install Python requirements + vars: + extra_packages: "{{ '' if not is_rhel7 else ',requests==2.6.0' }}" + pip: + state: present + name: 'docker{{ extra_packages }}' diff --git a/test/integration/targets/docker_secret/templates/virt.repo.j2 b/test/integration/targets/setup_docker/templates/virt.repo.j2 similarity index 100% rename from test/integration/targets/docker_secret/templates/virt.repo.j2 rename to test/integration/targets/setup_docker/templates/virt.repo.j2