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>
(cherry picked from commit 391a951f70
)
This commit is contained in:
parent
c607b30c14
commit
4ab3f6c00b
|
@ -20,5 +20,6 @@
|
|||
retries: 5
|
||||
delay: 2
|
||||
until: _update | succeeded
|
||||
changed_when: false
|
||||
when:
|
||||
- ansible_pkg_mgr == 'apt'
|
||||
|
|
|
@ -128,12 +128,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
|
||||
|
|
Loading…
Reference in New Issue