From 7238ccf32f392fb7805e1ae2f3f951c39237de57 Mon Sep 17 00:00:00 2001 From: Bartek Grzybowski Date: Thu, 13 Jun 2019 11:41:24 +0200 Subject: Add cleanup stage to 'nexus' role test List of docker images to download/cleanup by the prepare and cleanup stages is now defined in one place (prepare-nexus role defaults) for clarity and ease of management. Change-Id: I4c18912fd8c5eadc4d68e1bc10f5c2251d58634e Issue-ID: OOM-1915 Signed-off-by: Bartek Grzybowski --- ansible/roles/nexus/molecule/default/cleanup.yml | 8 ++++ .../molecule/default/cleanup.yml | 5 +- ansible/test/roles/cleanup-nexus/defaults | 1 + ansible/test/roles/cleanup-nexus/tasks/main.yml | 7 +++ ansible/test/roles/prepare-nexus/defaults/main.yml | 13 +++++ ansible/test/roles/prepare-nexus/tasks/main.yml | 55 ++++------------------ 6 files changed, 42 insertions(+), 47 deletions(-) create mode 100644 ansible/roles/nexus/molecule/default/cleanup.yml create mode 120000 ansible/test/roles/cleanup-nexus/defaults create mode 100644 ansible/test/roles/cleanup-nexus/tasks/main.yml create mode 100644 ansible/test/roles/prepare-nexus/defaults/main.yml diff --git a/ansible/roles/nexus/molecule/default/cleanup.yml b/ansible/roles/nexus/molecule/default/cleanup.yml new file mode 100644 index 00000000..1517e53e --- /dev/null +++ b/ansible/roles/nexus/molecule/default/cleanup.yml @@ -0,0 +1,8 @@ +--- +- name: Cleanup + hosts: all + ignore_unreachable: true + vars_files: + - ../../defaults/main.yml + roles: + - cleanup-nexus diff --git a/ansible/test/play-infrastructure/molecule/default/cleanup.yml b/ansible/test/play-infrastructure/molecule/default/cleanup.yml index 107ec8ca..008543bd 100644 --- a/ansible/test/play-infrastructure/molecule/default/cleanup.yml +++ b/ansible/test/play-infrastructure/molecule/default/cleanup.yml @@ -1,7 +1,10 @@ --- - name: Cleanup - hosts: all + hosts: infrastructure ignore_unreachable: true + vars_files: + - ../../../../roles/nexus/defaults/main.yml roles: - cleanup-nginx + - cleanup-nexus - cleanup-vncserver diff --git a/ansible/test/roles/cleanup-nexus/defaults b/ansible/test/roles/cleanup-nexus/defaults new file mode 120000 index 00000000..d9144aae --- /dev/null +++ b/ansible/test/roles/cleanup-nexus/defaults @@ -0,0 +1 @@ +../prepare-nexus/defaults/ \ No newline at end of file diff --git a/ansible/test/roles/cleanup-nexus/tasks/main.yml b/ansible/test/roles/cleanup-nexus/tasks/main.yml new file mode 100644 index 00000000..1d1e811b --- /dev/null +++ b/ansible/test/roles/cleanup-nexus/tasks/main.yml @@ -0,0 +1,7 @@ +--- +- name: Remove saved docker images + delegate_to: localhost + file: + path: "{{ item.archive_path }}" + state: absent + loop: "{{ prepare_nexus_images }}" diff --git a/ansible/test/roles/prepare-nexus/defaults/main.yml b/ansible/test/roles/prepare-nexus/defaults/main.yml new file mode 100644 index 00000000..be6bd523 --- /dev/null +++ b/ansible/test/roles/prepare-nexus/defaults/main.yml @@ -0,0 +1,13 @@ +--- +prepare_nexus_images: + - name: "{{ nexus3_image }}" # name already contains tag so it's ommited in this list element + archive_path: /tmp/nexus.tar + dest: "{{ infra_images_path }}/{{ nexus3_image_tar }}" + - name: nexus3.onap.org:10001/busybox + tag: latest + archive_path: /tmp/busybox.tar + dest: "{{ aux_data_path }}/busybox.tar" + - name: nexus3.onap.org:10001/aaionap/haproxy + tag: 1.2.4 + archive_path: /tmp/haproxy.tar + dest: "{{ aux_data_path }}/aaionap-haproxy.tar" diff --git a/ansible/test/roles/prepare-nexus/tasks/main.yml b/ansible/test/roles/prepare-nexus/tasks/main.yml index 5eb1b7d3..951bc28e 100644 --- a/ansible/test/roles/prepare-nexus/tasks/main.yml +++ b/ansible/test/roles/prepare-nexus/tasks/main.yml @@ -18,53 +18,16 @@ - "{{ infra_images_path }}" - "{{ aux_data_path }}" -- name: Download and archive nexus docker image for the nexus role to use +- name: Download and archive docker images for the nexus role to use delegate_to: localhost docker_image: - name: "{{ nexus3_image }}" - archive_path: /tmp/nexus.tar + name: "{{ item.name }}" + tag: "{{ item.tag | default('latest') }}" # Tag given in 'name' has precedence over the one declared here + archive_path: "{{ item.archive_path }}" + loop: "{{ prepare_nexus_images }}" -- name: Download and tag additional (busybox) docker image for the nexus role to populate into - delegate_to: localhost - docker_image: - name: busybox - tag: latest - repository: nexus3.onap.org:10001/busybox - -- name: Save busybox image - delegate_to: localhost - docker_image: - name: nexus3.onap.org:10001/busybox - tag: latest - pull: false - archive_path: /tmp/busybox.tar - -- name: Download and tag additional (aaionap/haproxy) docker image for the nexus role to populate into nexus - delegate_to: localhost - docker_image: - name: aaionap/haproxy - tag: 1.2.4 - repository: nexus3.onap.org:10001/aaionap/haproxy - -- name: Save haproxy image - delegate_to: localhost - docker_image: - name: nexus3.onap.org:10001/aaionap/haproxy - tag: 1.2.4 - pull: false - archive_path: /tmp/haproxy.tar - -- name: Copy nexus image to node - copy: - src: /tmp/nexus.tar - dest: "{{ infra_images_path }}/{{ nexus3_image_tar }}" - -- name: Copy busybox image to node - copy: - src: /tmp/busybox.tar - dest: "{{ aux_data_path }}/busybox.tar" - -- name: Copy haproxy image to node +- name: Copy docker images to node copy: - src: /tmp/haproxy.tar - dest: "{{ aux_data_path }}/aaionap-haproxy.tar" + src: "{{ item.archive_path }}" + dest: "{{ item.dest }}" + loop: "{{ prepare_nexus_images }}" -- cgit 1.2.3-korg