Solution answer is wrong

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

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

Hi @jhmoon1611

You need to use the vault password file to achieve this task

[thor@ansible-controller playbooks]$ ansible-playbook -i inventory copy_secrets.yml --vault-password-file get_vault_pass.py