If you are using ansible with AWS, you ar eprobably familiar with the ec2.py, an external invnetory script.
because API calls to AWS are time consuming, the inventory is built and cached locally.
Now when I run
python ec2.py --boto-profile 1234 list
I see in the cache directory another subdirectory
profile_1234
If I do the same with another profile, I have another subdir.
Now as described in
http://docs.ansible.com/ansible/intro_dynamic_inventory.html#example-aws-ec2-external-inventory-script
when I run ansible with the command
AWS_PROFILE=1234 ansible -i ec2.py …
that build another cache
at the top level of the cache directory.
IT DOESN’T USE the cache in the subdir.
Now, the problem is that if I change account ‘quickly’, the cache stay the same and is not reflecting the inventory of the account I just switched to.
1/ Is there a way to pass parameters to an external inventory script on the ‘ansible’ command line?
i.e. --inventory=‘ec2.py --boto-profile 7009’
??? Maybe I can use a wrapper around ec2.py ???
2/ Is there a way to tell ansible to force a refresh of the ec2.py cache?
Best,