mirror of
https://github.com/ansible/ansible.git
synced 2026-07-29 16:35:20 +02:00
Fix ansible-vault integration test for missing vault ids (#83777)
* Fix broken, circumvented test for missing vault ids * verify the command returns a non-zero exit code Co-authored-by: Matt Clay <matt@mystile.com>
This commit is contained in:
co-authored by
Matt Clay
parent
9a54ba5a39
commit
fe7e68bfcb
@@ -552,21 +552,22 @@ sudo chmod 000 "${MYTMPDIR}/unreadable"
|
||||
ansible-vault encrypt_string content
|
||||
ansible-vault encrypt_string content --encrypt-vault-id id3
|
||||
|
||||
set +e
|
||||
|
||||
# Try to use a missing vault password file
|
||||
ansible-vault encrypt_string content --encrypt-vault-id id1 2>&1 | tee out.txt
|
||||
test $? -ne 0
|
||||
grep out.txt -e '[WARNING]: Error getting vault password file (id1)'
|
||||
grep out.txt -e "ERROR! Did not find a match for --encrypt-vault-id=id2 in the known vault-ids ['id3']"
|
||||
if ansible-vault encrypt_string content --encrypt-vault-id id1 > out.txt 2>&1; then
|
||||
echo "command did not fail"
|
||||
exit 1
|
||||
fi
|
||||
grep out.txt -e '\[WARNING\]: Error getting vault password file (id1)'
|
||||
grep out.txt -e "ERROR! Did not find a match for --encrypt-vault-id=id1 in the known vault-ids \['id3'\]"
|
||||
|
||||
# Try to use an inaccessible vault password file
|
||||
ansible-vault encrypt_string content --encrypt-vault-id id2 2>&1 | tee out.txt
|
||||
test $? -ne 0
|
||||
grep out.txt -e "[WARNING]: Error in vault password file loading (id2)"
|
||||
grep out.txt -e "ERROR! Did not find a match for --encrypt-vault-id=id2 in the known vault-ids ['id3']"
|
||||
if ansible-vault encrypt_string content --encrypt-vault-id id2 > out.txt 2>&1; then
|
||||
echo "command did not fail"
|
||||
exit 1
|
||||
fi
|
||||
grep out.txt -e "\[WARNING\]: Error in vault password file loading (id2)"
|
||||
grep out.txt -e "ERROR! Did not find a match for --encrypt-vault-id=id2 in the known vault-ids \['id3'\]"
|
||||
|
||||
set -e
|
||||
unset ANSIBLE_VAULT_IDENTITY_LIST
|
||||
|
||||
# 'real script'
|
||||
|
||||
Reference in New Issue
Block a user