Issue
I am using the aws_ec2 inventory plugin and would like to pass the boto_profile in as a var at runtime.
I am trying to run the following command:
ansible-playbook playbook.yml --extra-vars profile=foo
Inside my aws_ec2.yml
plugin file I have:
boto_profile: "{{ profile }}"
This returns the error:
The config profile ({{ profile }}) could not be found
I am able to use the profile
var inside my playbook. I am using the ec2
module with profile: "{{ profile }}"
That seems to work if I define a static inventory.
Is it possible to pass the profile
var into the dynamic inventory file?
Solution
Jinja2 templates are not applicable to inventory configuration files.
Use environment variable AWS_PROFILE
or AWS_DEFAULT_PROFILE
to set profile at runtime.
Like: AWS_PROFILE=foo ansible-playbook playbook.yml
Answered By - Konstantin Suvorov Answer Checked By - Gilberto Lyons (WPSolving Admin)