Using ansible to run AWS EC2ConfigService's sysprep

662 views
Skip to first unread message

Peter Mounce

unread,
Oct 4, 2014, 9:39:33 AM10/4/14
to ansible...@googlegroups.com
I'm using Ansible to bake Windows AMIs in AWS. It works well.

This involves running `& "c:\program files\Amazon\Ec2ConfigService\ec2config.exe" -sysprep` as the last step. This will sysprep the box and then shut it down so that one can `aws ec2 create-image` on it.

Trouble is, because it shuts the box down, winrm goes with it.

I was thinking about how I might do this, and so far the best I've come up with is to schedule a task for a few seconds from now that will run that command. Ansible ought to get a good response from winrm and return ok.

Before I do that, can anyone think of something better, or has anyone done this already?

Regards
Pete

James Cammarata

unread,
Oct 4, 2014, 9:56:46 PM10/4/14
to ansible...@googlegroups.com
Hi Peter,

You probably want to do a "fire and forget" async task on the system, and then use the wait_for module to determine when the system was done shutting down.

Hope that helps!

--
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/8ef9e388-31bb-4606-befa-6cafc33c07be%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Peter Mounce

unread,
Oct 5, 2014, 6:12:35 AM10/5/14
to ansible...@googlegroups.com

Thanks; that sounds way cleaner. I'll try that.

--
Sent from my phone. Please excuse typos and brevity, but never text speak.

You received this message because you are subscribed to a topic in the Google Groups "Ansible Project" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ansible-project/9W3lpPhRYBY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ansible-proje...@googlegroups.com.

To post to this group, send email to ansible...@googlegroups.com.

M Ghaleb

unread,
Oct 18, 2016, 2:46:04 PM10/18/16
to Ansible Project
HI Peter,

have you managed to do it? I can not connect to the EC2 instance afterwards (after spinning up the AMI)

any success on that?

Regards,

M G

Peter Mounce

unread,
Oct 19, 2016, 12:21:48 PM10/19/16
to ansible...@googlegroups.com
Hi M G

https://github.com/petemounce/ansible-modules-extras/blob/win_ec2config/windows/win_ec2config.ps1 and https://github.com/petemounce/ansible-modules-extras/blob/win_ec2config/windows/win_ec2config.py worked fine for me. There was a PR, but the contribution didn't cover enough of the ec2config configuration surface area to be considered worth merging, and I didn't have the bandwidth to make the additions at the time.

Best regards
Pete

--
You received this message because you are subscribed to a topic in the Google Groups "Ansible Project" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ansible-project/9W3lpPhRYBY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ansible-project+unsubscribe@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/a09601c5-2a0f-43c8-bd0b-aceb96255584%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages