I need to run a Playbook with Inventory file, which is password protected. I know that we can give password by prompt (when running the playbook) or using secret file which have the password of inventory.
My question is "is there a way to specify inventory file's password within the playbook"
The vault password can be exported to the machine where you want to run the ansible playbook (like a local machine or Jenkins, etc.) and run the playbook as follows:
To export the ansible vault password
Then you can use it in two ways, either directly.
By using the Python OS module, you can read from the environment and then pass it to the Ansible Playbook.
where
vault_password.pyhas this code: