I can’t seem to figure out how to encrypt the password for the first question.
the closest
ansible-vault encrypt_string ‘d3v3l0p3r’ --vault-password-file=secrets/vault.txt
and
ansible-vault encrypt_string --vault-password-file=secrets/vault.txt ‘d3v3l0p3r’ --name ‘dev_pass’
and more but none gave me answer (or at list one that worked).
I suspect something has changed with the user module since this mock exam question was created. I spent 2 hours working through this one question and dearly hope I don’t have to have this level of Ansible knowledge for the exam–good practice though
So, because the vaulted password becomes plaintext when called, and the user module requires a hashed password you have to use a filter. Because of some deeper issues you have to use the string filter before password_hash:
This first error means you are sending a plaintext password (or one that has been decrypted from ansible-vault):
[WARNING]: The input password appears not to have been hashed. The 'password' argument must be encrypted for this module to work properly.
This second error happens on some (all?) versions of Ansible (2.7.10 currently in the Mock Exam 1 labs) when you use {{ variable | password_hash('sha512') }} without the string filter in between (for more details see https://github.com/ansible/ansible/issues/24425). I can’t tell if it’s been fixed or if the string filter is the appropriate method going forward.
fatal: [node00]: FAILED! => {"msg": "Unexpected templating type error occurred on ({{ admin_pass | password_hash('sha512')}}): must be string, not AnsibleVaultEncryptedUnicode"}