Making sure an EC2 instance is running

26 views
Skip to first unread message

James Carroll

unread,
Apr 15, 2014, 10:59:39 AM4/15/14
to ansible...@googlegroups.com
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:

---
- name: Make sure the machine is awake:
     module: ec2
     state: running
     wait: True

- name: Fire the process
  shell: ./etc/myutils/backup.sh

Thanks,
James

__________________________________________________________________
The information contained in this email message and any attachment may be privileged, confidential, proprietary or otherwise protected from disclosure. If the reader of this message is not the intended recipient, you are hereby notified that any dissemination, distribution, copying or use of this message and any attachment is strictly prohibited. If you have received this message in error, please notify us immediately by replying to the message and permanently delete it from your computer and destroy any printout thereof.

Michael DeHaan

unread,
Apr 15, 2014, 5:35:57 PM4/15/14
to ansible...@googlegroups.com
Possible suggestion:

- hosts: localhost
  tasks:
     - fail: msg="{{ host }} not running"
       when: item in groups['all']
       with_items:
           - host1.example.com
           - host2.example.com

# rest of playbook could go here


--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/a017cd16-c061-43a1-bd61-5aea5d323cd2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Michael DeHaan

unread,
Apr 15, 2014, 5:36:15 PM4/15/14
to ansible...@googlegroups.com
That should say "item not in groups['all']" BTW ...


Reply all
Reply to author
Forward
0 new messages