# trouble with ec2 inventory script

**URL:** <https://forum.ansible.com/t/trouble-with-ec2-inventory-script/12089>\
**Category:** Ansible Project\
**Tags:** ansible-project\
**Created:** [November 15, 2012, 1:05pm UTC](https://forum.ansible.com/t/trouble-with-ec2-inventory-script/12089 "2012-11-15T13:05:39Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Michael\_DeHaan](https://avatars.discourse-cdn.com/v4/letter/m/c4cdca/32.png) [@Michael\_DeHaan](https://forum.ansible.com/u/Michael_DeHaan)\
**Post date:** [November 15, 2012, 1:05pm UTC](https://forum.ansible.com/t/trouble-with-ec2-inventory-script/12089/1 "2012-11-15T13:05:39Z")

</div>

> Also, what's the proper way to tell ansible to use a given pem file to  
> access a given ec2 host? As far as I understand reading the docs  
> ~/.ssh/config is no longer used, and I've seen some examples where the info  
> is both stuck into ssh-agent and a playbook  
> ([https://github.com/coopernurse/ansible-demo](https://github.com/coopernurse/ansible-demo)). Is there a generally accepted  
> way of doing this?

Per host pem files are currently not supported, it assumes you use the  
same one for all hosts, I would accept patches for an  
ansible\_ssh\_private\_key inventory variable that works somewhat like  
ansible\_ssh\_host or ansible\_ssh\_port. Make sure to modify both the  
paramiko and ssh connection types.

(there is also the --private-key option and the config file way to set  
that globally)

(In the example you linked I don't see where that's referenced in the  
playbook, either)

So yeah, a patch would be welcome.

---

<div class="post-metadata">

**Author:** ![Peter\_Sankauskas](https://avatars.discourse-cdn.com/v4/letter/p/ea666f/32.png) [@Peter\_Sankauskas](https://forum.ansible.com/u/Peter_Sankauskas)\
**Post date:** [November 15, 2012, 5:07pm UTC](https://forum.ansible.com/t/trouble-with-ec2-inventory-script/12089/2 "2012-11-15T17:07:51Z")

</div>

Actually, this completely separate from SSH.

The AWS\_ACCESS\_KEY\_ID and AWS\_SECRET\_ACCESS\_KEY are used to make API calls to AWS.

What you need to do is go to:

> [https://portal.aws.amazon.com/gp/aws/securityCredentials](https://portal.aws.amazon.com/gp/aws/securityCredentials)

and create an Access Key (if you don’t have one already). Then use those 2 keys with the EC2 inventory script.

You can test the EC2 inventory script is working by executing it. So if you replaced your ansible hosts file with it, you can just execute

> /etc/ansible/hosts

and you will see JSON output of all instances you have running.

Peter Sankauskas
