Improved EC2 multiple account support

Continuing the discussion from https://github.com/ansible/ansible/pull/5156.

I don’t see anything stopping users from creating directories and symlinking to a shared script. That’s basically what I’m doing using my symlink technique, just without separate directories. The main issue I was trying to solve is being able to refer to use multiple accounts, which isn’t easily accomplished using the boto config file. Once that issue is solved, the techniques in which a user can refer to the different accounts/environments are many.

For example, you could use my wrapper script technique and refer to different ec2.ini files, or you could use your suggested technique of different folders. I actually prefer leaving that part a bit open and simply suggesting techniques. Different users will prefer different ways of referring to their inventory files, but if the ec2.py inventory script doesn’t allow you to override your credentials, your options for supporting different accounts per environment is pretty limited.

I’m a little bit confused about the statement “Users can also make use of named vars files for pulling different credentials.”, though. Am I incorrect in thinking that you currently have to have the credentials defined fully ahead of time for the ec2.py script to pull in the inventory? That is, can you even use named vars for defining account credentials?

Hi John,

You could accomplish the same thing with a wrapper script as I mentioned. I personally chose not to use a function to switch environments because I wanted to reduce the number of steps (and general setup) required to run the playbooks. Anyone using the playbooks would have to setup their profile to define the function and then setup the credentials. By allowing the credentials to live in the ec2.ini config file, you can run playbooks without any setup. I know it’s not ideal to store credentials in a repository, but it’s a compromise that, in my experience, many people are willing to make for the sake of simplicity.

For regular development and prototyping, though, I love the idea of being able to quickly and easily switch out the boto config using a function. Thanks for the tip!