# Starting Stopped AWS EC2 Instances from Ansible Tower

**URL:** <https://forum.ansible.com/t/starting-stopped-aws-ec2-instances-from-ansible-tower/28665>\
**Category:** Ansible Project\
**Tags:** aws\
**Created:** [September 27, 2018, 3:29pm UTC](https://forum.ansible.com/t/starting-stopped-aws-ec2-instances-from-ansible-tower/28665 "2018-09-27T15:29:17Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![John\_Peters](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/john_peters/32/9637_2.png) [@John\_Peters](https://forum.ansible.com/u/John_Peters)\
**Post date:** [September 27, 2018, 3:29pm UTC](https://forum.ansible.com/t/starting-stopped-aws-ec2-instances-from-ansible-tower/28665/1 "2018-09-27T15:29:17Z")

</div>

Any clue as to how to accomplish this?

My Ansible Tower inventory has a list of hosts in it, all in ‘stopped’ state.

I’d like to use that inventory, assign it to a playbook, that will loop through each machine in the inventory, from the **localhost** , and issue a command to start the instance to AWS.

I’ve tried several different ways to do this, but to no avail.

It seems that because I’m specifying an inventory to the job, and that inventory only has stopped instances in it, there’s no way to execute a task on the localhost, loop through that inventory, and start them, one by one?

Here is some code that contains all the different lines I’ve tried…

---

<div class="post-metadata">

**Author:** ![Kuldip\_Madnani1](https://avatars.discourse-cdn.com/v4/letter/k/91b2a8/32.png) [@Kuldip\_Madnani1](https://forum.ansible.com/u/Kuldip_Madnani1)\
**Post date:** [September 27, 2018, 3:52pm UTC](https://forum.ansible.com/t/starting-stopped-aws-ec2-instances-from-ansible-tower/28665/2 "2018-09-27T15:52:29Z")

</div>

If gather\_facts is false and node is unreachable, how are you going to retrieve hostvars[item][‘ec2\_id’] ? Is it statically declared in your inventory file?
