I was solving a mock problem and saw that the answer was wrong. I need an exact answer.
Ansible Advanced courses
Mock EXams - Lab exam2 - Q4
Q4. Write a playbook to copy the secret file located at /home/thor/playbooks/secret_file.txt
to all remote hosts at location: /root/.secret_file.txt
Your playbook must be located at: /home/thor/playbooks/copy_secrets.yml
Use inventory file: /home/thor/playbooks/inventory
. The secret file is encrypted, please use the vault password from the script /home/thor/playbooks/get_vault_pass.py
while you execute the playbook.
Solution
- hosts: all
tasks:- name: copy a secret file to remote hosts
copy:
src: secret_file.txt
dest: /root/.secret_file.txt
- name: copy a secret file to remote hosts
Result
[thor@ansible-controller playbooks]$ ansible-playbook -i inventory copy_secrets.yml
PLAY [all] ***************************************************************************************************************************************************************************
TASK [copy a secret file to remote hosts] ********************************************************************************************************************************************
fatal: [node00]: FAILED! => {“msg”: “A vault password or secret must be specified to decrypt /home/thor/playbooks/secret_file.txt”}
fatal: [node01]: FAILED! => {“msg”: “A vault password or secret must be specified to decrypt /home/thor/playbooks/secret_file.txt”}
to retry, use: --limit @/home/thor/playbooks/copy_secrets.retry
PLAY RECAP ***************************************************************************************************************************************************************************
node00 : ok=0 changed=0 unreachable=0 failed=1
node01 : ok=0 changed=0 unreachable=0 failed=1