Improve idempotency

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>
This commit is contained in:
Major Hayden 2018-03-07 16:02:33 -06:00
parent 96c01ad653
commit 391a951f70
No known key found for this signature in database
GPG Key ID: 737051E0C1011FB1
3 changed files with 11 additions and 4 deletions

View File

@ -20,5 +20,6 @@
retries: 5
delay: 2
until: _update | succeeded
changed_when: false
when:
- ansible_pkg_mgr == 'apt'

View File

@ -27,6 +27,7 @@
executable: /bin/bash
register: lxc_reverse_proxy
delegate_to: localhost
changed_when: false
when:
- nodepool.stat.exists | bool
tags:
@ -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
@ -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
@ -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
@ -126,6 +130,7 @@
executable: /bin/bash
register: _pypi_wheel_mirror
delegate_to: localhost
changed_when: false
when:
- nodepool.stat.exists | bool

View File

@ -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