From e009f80ffce5975d69018b8badd46297c7a90ec6 Mon Sep 17 00:00:00 2001 From: Mark Goddard Date: Thu, 18 Jan 2024 10:14:46 +0000 Subject: [PATCH] CI: Fix linters-devel and devstack tests The linters-devel job fails with: ansible-test sanity: error: argument --skip-test: invalid choice: 'metaclass-boilerplate' (choose from 'action-plugin-docs', ...) The functional test fails with: The conditional check 'info1.volumes | selectattr("id", "equalto", "{{ info.volumes.0.id }}") | list | length == 1' failed. The error was: Conditional is marked as unsafe, and cannot be evaluated. This is due to a change in Ansible 2.17 preventing embedded templates from referencing unsafe data [1]. [1] https://docs.ansible.com/ansible/latest/porting_guides/porting_guide_9.html#playbook Change-Id: I2f8411cac1403568afb13c2b96ba452c4c81f126 --- ci/roles/volume/tasks/volume_info.yml | 2 +- tools/run-ansible-sanity.sh | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/ci/roles/volume/tasks/volume_info.yml b/ci/roles/volume/tasks/volume_info.yml index e6164e3e..4f8e3204 100644 --- a/ci/roles/volume/tasks/volume_info.yml +++ b/ci/roles/volume/tasks/volume_info.yml @@ -37,7 +37,7 @@ - name: Check info assert: that: - - info1.volumes | selectattr("id", "equalto", "{{ info.volumes.0.id }}") | list | length == 1 + - info1.volumes | selectattr("id", "equalto", info.volumes.0.id) | list | length == 1 - info1.volumes.0.name == 'ansible_test' - info1.volumes.0.status == None diff --git a/tools/run-ansible-sanity.sh b/tools/run-ansible-sanity.sh index 1c0d0205..30c2c97e 100755 --- a/tools/run-ansible-sanity.sh +++ b/tools/run-ansible-sanity.sh @@ -28,9 +28,19 @@ cp -a ${TOXDIR}/{plugins,meta,tests,docs} ${ANSIBLE_COLLECTIONS_PATH}/ansible_co cd ${ANSIBLE_COLLECTIONS_PATH}/ansible_collections/openstack/cloud/ echo "Running ansible-test with version:" ansible --version +# Ansible-core 2.17 dropped support for the metaclass-boilerplate and future-import-boilerplate tests. +# TODO(mgoddard): Drop this workaround when ansible-core 2.16 is EOL. +ANSIBLE_VER=$(python3 -m pip show ansible-core | awk '$1 == "Version:" { print $2 }') +ANSIBLE_MAJOR_VER=$(echo "$ANSIBLE_VER" | sed 's/^\([0-9]\)\..*/\1/g') +SKIP_TESTS="" +if [[ $ANSIBLE_MAJOR_VER -eq 2 ]]; then + ANSIBLE_MINOR_VER=$(echo "$ANSIBLE_VER" | sed 's/^2\.\([^\.]*\)\..*/\1/g') + if [[ $ANSIBLE_MINOR_VER -le 16 ]]; then + SKIP_TESTS="--skip-test metaclass-boilerplate --skip-test future-import-boilerplate" + fi +fi ansible-test sanity -v \ --venv \ --python ${PY_VER} \ - --skip-test metaclass-boilerplate \ - --skip-test future-import-boilerplate \ + $SKIP_TESTS \ plugins/ docs/ meta/