The importance of pause:

In my last post I discussed how to interface with a vCenter via the vsphere_guest module to create a windows 2012 server from a template, how to set up the IP address with vmware_vm_shell then add features with win_feature.

One point I was remiss with was timing.  When ansible runs through a playbook, it will run from one task to another logically once the command responds as successful so if you attempt to go from vm creation straight into configuration management, it’s going to fail.  When creating virtual environments locally with vagrant, there are built in pauses and checks to ensure the environment is up and running before running the provisioner.  So when using  the vsphere module it will return a success on the creation before the machine has even had time to boot up.  So it’s a good idea to use the ansible pause: module to ensure that the VM is in a stable state before beginning with any configuration management work.

It’s also useful for other features that may respond with success before it’s had time to properly initialise.  I found this also with setting the IP.

If you find that after running a task, the next one fails, it may simply be down to the state of the previous task on the guest not being fully ready.

So make good use of the pause

Author: Aidan

An experienced Developer who transitioned into implementing Continuous Integration, Delivery and Improvement through the use of Agile and Lean, or to put it simply, The DevOps Specialist.

Leave a Reply

Your email address will not be published. Required fields are marked *