# Making sure an EC2 instance is running

**URL:** <https://forum.ansible.com/t/making-sure-an-ec2-instance-is-running/15020>\
**Category:** Ansible Project\
**Created:** [April 15, 2014, 2:59pm UTC](https://forum.ansible.com/t/making-sure-an-ec2-instance-is-running/15020 "2014-04-15T14:59:39Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![James\_Carroll](https://avatars.discourse-cdn.com/v4/letter/j/e36b37/32.png) [@James\_Carroll](https://forum.ansible.com/u/James_Carroll)\
**Post date:** [April 15, 2014, 2:59pm UTC](https://forum.ansible.com/t/making-sure-an-ec2-instance-is-running/15020/1 "2014-04-15T14:59:39Z")

</div>

Howdy all,  
I’m trying to create a playbook that would insure that a certain set of EC2 instances is running before initiating a process. I’ve played with the EC2 dynamic inventory but it seems to return only instances that are already running and I didn’t see anything in the ini that would tell it to pull everything. As a second question, assuming I can get the complete list is “running” a valid state/parameter for the EC2 module. Something like:

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [April 15, 2014, 9:35pm UTC](https://forum.ansible.com/t/making-sure-an-ec2-instance-is-running/15020/2 "2014-04-15T21:35:57Z")

</div>

Possible suggestion:

- hosts: localhost  
tasks:
- fail: msg=“{{ host }} not running”  
when: item in groups[‘all’]  
with\_items:
- [host1.example.com](http://host1.example.com)
- [host2.example.com](http://host2.example.com)

# rest of playbook could go here

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [April 15, 2014, 9:36pm UTC](https://forum.ansible.com/t/making-sure-an-ec2-instance-is-running/15020/3 "2014-04-15T21:36:15Z")

</div>

That should say “item not in groups[‘all’]” BTW …
