From 5ca536313a4743b4564e965bbb01afe59527209c Mon Sep 17 00:00:00 2001 From: Shane McDonald Date: Fri, 19 Nov 2021 08:17:16 +0000 Subject: [PATCH] Add test for DEFAULT_AWX_VERSION --- molecule/default/molecule.yml | 1 + molecule/default/tasks/awx_test.yml | 25 +++++++++++++++++++++++++ molecule/kind/converge.yml | 2 ++ molecule/kind/molecule.yml | 1 + 4 files changed, 29 insertions(+) diff --git a/molecule/default/molecule.yml b/molecule/default/molecule.yml index ef23e519..58f50eed 100644 --- a/molecule/default/molecule.yml +++ b/molecule/default/molecule.yml @@ -23,6 +23,7 @@ provisioner: localhost: awx_image: ${AWX_TEST_IMAGE:-""} awx_version: ${AWX_TEST_VERSION:-""} + default_awx_version: "{{ lookup('url', 'https://api.github.com/repos/ansible/awx/releases/latest') | from_json | json_query('tag_name') }}" ansible_python_interpreter: '{{ ansible_playbook_python }}' config_dir: ${MOLECULE_PROJECT_DIRECTORY}/config samples_dir: ${MOLECULE_PROJECT_DIRECTORY}/config/samples diff --git a/molecule/default/tasks/awx_test.yml b/molecule/default/tasks/awx_test.yml index b2d0ccfd..7a68fa87 100644 --- a/molecule/default/tasks/awx_test.yml +++ b/molecule/default/tasks/awx_test.yml @@ -19,6 +19,31 @@ register: admin_pw_secret - block: + - name: Get pod details + k8s_info: + namespace: '{{ namespace }}' + kind: Pod + label_selectors: + - app.kubernetes.io/name = example-awx + register: awx_pod + when: not awx_version + + - name: Exract tags from images + set_fact: + image_tags: | + {{ awx_pod.resources[0].spec.containers | + map(attribute='image') | + map('regex_search', default_awx_version) }} + when: not awx_version + + - fail: + msg: | + It looks like you may have broken the DEFAULT_AWX_VERSION functionality. + This is an environment variable that is set via build arg when releasing awx-operator. + when: + - not awx_version + - default_awx_version not in image_tags + - name: Launch Demo Job Template awx.awx.job_launch: name: Demo Job Template diff --git a/molecule/kind/converge.yml b/molecule/kind/converge.yml index 4c19fb4c..0fa6aaf5 100644 --- a/molecule/kind/converge.yml +++ b/molecule/kind/converge.yml @@ -10,6 +10,8 @@ build: path: '{{ project_dir }}' pull: no + args: + DEFAULT_AWX_VERSION: '{{ default_awx_version }}' name: '{{ operator_image }}' tag: latest push: no diff --git a/molecule/kind/molecule.yml b/molecule/kind/molecule.yml index 1b9aae48..aa7f2774 100644 --- a/molecule/kind/molecule.yml +++ b/molecule/kind/molecule.yml @@ -26,6 +26,7 @@ provisioner: awx_image: ${AWX_TEST_IMAGE:-""} awx_version: ${AWX_TEST_VERSION:-""} ansible_python_interpreter: '{{ ansible_playbook_python }}' + default_awx_version: "{{ lookup('url', 'https://api.github.com/repos/ansible/awx/releases/latest') | from_json | json_query('tag_name') }}" config_dir: ${MOLECULE_PROJECT_DIRECTORY}/config samples_dir: ${MOLECULE_PROJECT_DIRECTORY}/config/samples project_dir: ${MOLECULE_PROJECT_DIRECTORY}