Pass variables to ansible playbooks

ansible

I need to pull a build from S3 on my target machine. Therefore I need to pass the S3 key and secret to the ansible playbook somehow.

I know that I could define them in

  • the inventory
  • the playbook itself

but I really don't want to store credentials there.

Can I use environment variables from the local machine (or something similar) in an ansible playbook?

Best Answer

$ENV(SOMEVAR) or {{ lookup('env', 'SOMEVAR') }} (1.1+) should work. You could also use vars_prompt to request it at playbook runtime.

Related Topic