diff options
author | Chris Houseknecht <chouseknecht@ansible.com> | 2017-07-06 15:22:04 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-07-06 15:22:04 +0200 |
commit | 6af53cf0ef28d18ff17e241627b8566e799eaf73 (patch) | |
tree | 047720a8ca1e2540bea2c9d4c2235e624d0e2a89 /test/integration/targets/docker_secret/tasks | |
parent | Add vendor neutral parameter fail_on_missing_module (#26482) (diff) | |
download | ansible-6af53cf0ef28d18ff17e241627b8566e799eaf73.tar.xz ansible-6af53cf0ef28d18ff17e241627b8566e799eaf73.zip |
Adds docker_secret module (#26469)
Diffstat (limited to 'test/integration/targets/docker_secret/tasks')
6 files changed, 203 insertions, 0 deletions
diff --git a/test/integration/targets/docker_secret/tasks/Fedora.yml b/test/integration/targets/docker_secret/tasks/Fedora.yml new file mode 100644 index 0000000000..c1b1c840e1 --- /dev/null +++ b/test/integration/targets/docker_secret/tasks/Fedora.yml @@ -0,0 +1,17 @@ +- name: Install Docker pre-reqs + dnf: + name: "{{ item }}" + state: present + items: + - 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 fast + +- name: Install docker + dnf: + name: docker-ce + state: present diff --git a/test/integration/targets/docker_secret/tasks/OpenSuse.yml b/test/integration/targets/docker_secret/tasks/OpenSuse.yml new file mode 100644 index 0000000000..9288fa0792 --- /dev/null +++ b/test/integration/targets/docker_secret/tasks/OpenSuse.yml @@ -0,0 +1,11 @@ +- name: Template repo + template: + src: virt.repo.j2 + dest: /etc/zypp/repos.d/virt.repo + +- name: Install docker 17 + zypper: + name: docker-17.04.0_ce-203.6.x86_64 + force: yes + disable_gpg_check: yes + update_cache: yes diff --git a/test/integration/targets/docker_secret/tasks/RedHat.yml b/test/integration/targets/docker_secret/tasks/RedHat.yml new file mode 100644 index 0000000000..51f466d564 --- /dev/null +++ b/test/integration/targets/docker_secret/tasks/RedHat.yml @@ -0,0 +1,21 @@ +- name: Install Docker pre-reqs + yum: + name: "{{ item }}" + state: present + items: + - yum-utils + - device-mapper-persistent-data + - lvm2 + - python-crypto + - libseccomp + +- name: Add repository + command: yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo + +- name: Update cache + command: yum -y makecache fast + +- name: Install docker + yum: + name: docker-ce + state: present diff --git a/test/integration/targets/docker_secret/tasks/Ubuntu.yml b/test/integration/targets/docker_secret/tasks/Ubuntu.yml new file mode 100644 index 0000000000..8646409de1 --- /dev/null +++ b/test/integration/targets/docker_secret/tasks/Ubuntu.yml @@ -0,0 +1,36 @@ +- 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" + +- name: Install Docker CE + apt: + name: docker-ce + state: present + update_cache: yes diff --git a/test/integration/targets/docker_secret/tasks/main.yml b/test/integration/targets/docker_secret/tasks/main.yml new file mode 100644 index 0000000000..a71923aaa4 --- /dev/null +++ b/test/integration/targets/docker_secret/tasks/main.yml @@ -0,0 +1,14 @@ +- 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 + 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 new file mode 100644 index 0000000000..c49dafca10 --- /dev/null +++ b/test/integration/targets/docker_secret/tasks/test_secrets.yml @@ -0,0 +1,104 @@ +- 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 + ignore_errors: yes + +- name: Enable swarm mode + command: docker swarm init + when: output.rc == 0 + notify: disable_swarm + +- name: Parameter name should be required + docker_secret: + state: present + ignore_errors: yes + register: output + +- name: assert failure when called with no name + assert: + that: + - 'output.failed' + - 'output.msg == "missing required arguments: name"' + +- name: Test parameters + docker_secret: + name: foo + state: present + ignore_errors: yes + register: output + +- name: assert failure when called with no data + assert: + that: + - 'output.failed' + - 'output.msg == "state is present but the following are missing: data"' + +- name: Create secret + docker_secret: + name: db_password + data: opensesame! + state: present + register: output + +- name: Create variable secret_id + set_fact: + secret_id: "{{ output.secret_id }}" + +- name: Inspect secret + command: "docker secret inspect {{ secret_id }}" + register: inspect + +- debug: var=inspect + +- name: assert secret creation succeeded + assert: + that: + - "'db_password' in inspect.stdout" + - "'ansible_key' in inspect.stdout" + +- name: Create secret again + docker_secret: + name: db_password + data: opensesame! + state: present + register: output + +- name: assert create secret is idempotent + assert: + that: + - not output.changed + +- name: Update secret + docker_secret: + name: db_password + data: newpassword! + state: present + register: output + +- name: assert secret was updated + assert: + that: + - output.changed + - output.secret_id != secret_id + +- name: Remove secret + docker_secret: + name: db_password + state: absent + +- name: Check that secret is removed + command: "docker secret inspect {{ secret_id }}" + register: output + ignore_errors: yes + +- name: assert secret was removed + assert: + that: + - output.failed |