Skip to content

Commit

Permalink
Improve idempotency
Browse files Browse the repository at this point in the history
These discovery tasks always show up as "changed" in the Ansible
output. This patch ensures that they are not labeled as changed
when they are run.

The patch also fixes the idempotency check grep so that it works
properly with multiple hosts. Previously, if *any* of the hosts
finished with no changes/failures, the entire job was marked as
passing the idempotency tests.

Depends-On: I17748b0dd2307fd9bee705140c67883140090298
Change-Id: Ie414d32d39fdeeedd77fe94b57a09ba344084ec1
Signed-off-by: Major Hayden <major@mhtx.net>
  • Loading branch information
major committed Mar 7, 2018
1 parent 96c01ad commit 391a951
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
1 change: 1 addition & 0 deletions common-tasks/test-force-package-cache-update.yml
Expand Up @@ -20,5 +20,6 @@
retries: 5
delay: 2
until: _update | succeeded
changed_when: false
when:
- ansible_pkg_mgr == 'apt'
5 changes: 5 additions & 0 deletions common-tasks/test-set-nodepool-vars.yml
Expand Up @@ -27,6 +27,7 @@
executable: /bin/bash
register: lxc_reverse_proxy
delegate_to: localhost
changed_when: false
when:
- nodepool.stat.exists | bool
tags:
Expand All @@ -46,6 +47,7 @@
executable: /bin/bash
register: uca_repo_url
delegate_to: localhost
changed_when: false
when:
- ansible_pkg_mgr == 'apt'
- nodepool.stat.exists | bool
Expand All @@ -67,6 +69,7 @@
executable: /bin/bash
register: centos_mirror_url
delegate_to: localhost
changed_when: false
when:
- ansible_pkg_mgr in ['yum', 'dnf']
- nodepool.stat.exists | bool
Expand All @@ -89,6 +92,7 @@
executable: /bin/bash
register: _opensuse_mirror
delegate_to: localhost
changed_when: false
when:
- ansible_pkg_mgr == 'zypper'
- nodepool.stat.exists | bool
Expand Down Expand Up @@ -126,6 +130,7 @@
executable: /bin/bash
register: _pypi_wheel_mirror
delegate_to: localhost
changed_when: false
when:
- nodepool.stat.exists | bool

Expand Down
9 changes: 5 additions & 4 deletions test-ansible-functional.sh
Expand Up @@ -135,12 +135,13 @@ if [ "${TEST_IDEMPOTENCE}" == "true" ]; then
# Execute the test playbook
execute_ansible_playbook

# Check the output log for changed/failed tasks
if grep -q "changed=0.*failed=0" ${ANSIBLE_LOG_PATH}; then
echo "Idempotence test: pass"
else
# Exit with a failure if we find "changed" or "failed" followed by anything
# other than a zero.
if grep -qP '(changed|failed)=(?!0)' ${ANSIBLE_LOG_PATH}; then
echo "Idempotence test: fail"
exit 1
else
echo "Idempotence test: pass"
fi

fi

0 comments on commit 391a951

Please sign in to comment.