# trying using ec2 module from python but inventory is missing

**URL:** <https://forum.ansible.com/t/trying-using-ec2-module-from-python-but-inventory-is-missing/18262>\
**Category:** Ansible Project\
**Created:** [May 19, 2015, 5:57pm UTC](https://forum.ansible.com/t/trying-using-ec2-module-from-python-but-inventory-is-missing/18262 "2015-05-19T17:57:58Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![pawel\_kaminski](https://avatars.discourse-cdn.com/v4/letter/p/47e85d/32.png) [@pawel\_kaminski](https://forum.ansible.com/u/pawel_kaminski)\
**Post date:** [May 19, 2015, 5:57pm UTC](https://forum.ansible.com/t/trying-using-ec2-module-from-python-but-inventory-is-missing/18262/1 "2015-05-19T17:57:58Z")

</div>

hi,  
I tried to find similar problem on this forum or through google but I was redirected to ansible cmd.

I am writing python tool that can modify ec2 resources. I started with sec groups. here is sample code I try to execute

`  
properties = {}  
runner = ansible.Runner(  
module\_name=“ec2\_group”,  
complex\_args={

```auto
    "rules": properties["rules"],

```

```auto
    "rules_egress": properties["rules_egress"],
    "vpc_id": properties["vpcId"],
    "name": properties["name"],
    "description": properties["descr"]

```

},  
forks=10,  
inventory=Inventory(“local\_action”)  
)

return runner.run()  
`

off course it fails with **ansible.errors.AnsibleError: Unable to find an inventory file, specify one with -i** which would probably make sense when run directly using ansible cli, but I have no idea how I should code it from python.  
the documentation or examples are non-existence or it is very hard to find them

here is a role part from my yaml file

`

| |

---

<div class="post-metadata">

**Author:** ![pawel\_kaminski](https://avatars.discourse-cdn.com/v4/letter/p/47e85d/32.png) [@pawel\_kaminski](https://forum.ansible.com/u/pawel_kaminski)\
**Post date:** [May 19, 2015, 9:51pm UTC](https://forum.ansible.com/t/trying-using-ec2-module-from-python-but-inventory-is-missing/18262/2 "2015-05-19T21:51:47Z")

</div>

I am really frustrated 🙂  
running playbook from terminal would be something like

`ansible-playbook -i stage defienition.yml --private-key=~/.ssh/key.pem`

where stage is a directory containing [h](https://github.com/codewise/voluum-deployment/blob/master/voluum-test/stage/hosts)osts file containing

`  
[local]  
127.0.0.1

`

I keep trying change my previous code

---

<div class="post-metadata">

**Author:** ![pawel\_kaminski](https://avatars.discourse-cdn.com/v4/letter/p/47e85d/32.png) [@pawel\_kaminski](https://forum.ansible.com/u/pawel_kaminski)\
**Post date:** [May 19, 2015, 10:15pm UTC](https://forum.ansible.com/t/trying-using-ec2-module-from-python-but-inventory-is-missing/18262/3 "2015-05-19T22:15:28Z")

</div>

OOOk I figure it out,
