I am trying to have a playbook run automatically at weekly intervals through a cronjob.
The playbook is run manually through the following command:
ansible-playbook -K BackupLogsX.yml
Upon running the command, I am prompted for 'become' and 'ssh' passwords.
How can I store these credentials in a vault with Ansible and direct the playbook to use them automatically? The vault password would also have to be passed to Ansible so as not to prompt the user for any credentials, and thus allow the task to be run automatically.
Below is the depth of my understanding: I've created a file to be encrypted with Ansible's vault
ansible-vault create Credentials.yml
And then once the password file is created, it can be referenced via the following command:
ansible-playbook --vault-password-file /path/to/Credentials.yml BackupLogsX.yml
I am unsure as to how that document (Credentials.yml) would be formatted, as well as how to incorporate those variables into the playbook. From there, my understanding drops off quickly, as I can't seem to find a comprehensive explanation on https://docs.ansible.com or elsewhere.
What I am looking to achieve is a playbook that can be run automatically via a cronjob, that automatically pulls the requisite credentials to be able to accomplish the tasks.
If my understanding is in error, please correct as necessary. Thanks!