best way to wait for AWS metadata to resolve?

21 views
Skip to first unread message

Jim Robinson

unread,
Aug 18, 2019, 8:52:42 PM8/18/19
to Ansible Project
I'm not sure whether this is something ansible can do out of the box or not.

I am looking for a way to pause execution of a playbook until certain pieces of metadata become available from AWS.

Basically I'm starting an ec2 instance inside a firewalled VPC in AWS and when it's ready it sets a few tag values.

I'd like to be able to construct tasks that spin up this ec2 instance, wait until it sees those tags are available (or times out), and then continue.

Is this possible using the standard ansible toolkit, or am I (a) going about this all wrong, or (b) going to need to reach for a custom coded module?

Karl Auer

unread,
Aug 18, 2019, 9:03:12 PM8/18/19
to ansible-project
There's a wait option on ec2 instance creation that will stop the playbook until the instance is up. Not sure what exactly it is testing, but I've seen it there.

A primitive alternative is just to stick a one-minute (or whatever is needed) delay into the playbook.

You can also put a delay loop in. See this link and seach for "Retrying":


Regards, K.


--
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 view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/749822ac-0100-4bb8-83e5-f28ee777a1b3%40googlegroups.com.


--
Karl Auer

Email  : ka...@2pisoftware.com
Website: http://2pisoftware.com


GPG/PGP : 301B 1F4E 624D AD99 242C 7A68 EC24 7113 E854 4A4E
Previous:
958A 2647 6C44 D376 3D63 86A5 FFB2 20BC 0257 5816

Dick Visser

unread,
Aug 19, 2019, 3:41:21 AM8/19/19
to ansible...@googlegroups.com
On Mon, 19 Aug 2019 at 03:03, Karl Auer <ka...@2pisoftware.com> wrote:
>
> There's a wait option on ec2 instance creation that will stop the playbook until the instance is up. Not sure what exactly it is testing, but I've seen it there.

The wait option checks if the instance id already exists:

https://github.com/ansible/ansible/blob/devel/lib/ansible/modules/cloud/amazon/ec2.py#L1234-L1240

I guess this is "the right thing".


--
Dick Visser
Trust & Identity Service Operations Manager
GÉANT

Jim Robinson

unread,
Aug 19, 2019, 7:50:00 AM8/19/19
to Ansible Project
Thanks folks,

The 'wait: true' option is one I have already put into the role, but it is returning before the boot-up sequence has completed.

I think what I'll try to do is move the logic for waiting into the boot-up scripts themselves, so that I can spin them all up at once and have then wait on the primary to serve up the metadata needed.

Reply all
Reply to author
Forward
0 new messages