How to make sure that cloud-init finished running?


is there any way to detect when cloud-init has finished running from bash?

I am using packer to create an image, and I do some init from there to get to a point where later I run puppet and other things that require my cloud-config settings to have finished running.

Is there a way to say something like:

while cloudconfigrunning; do
sleep 1

Ideally I would want to have a way that is platform agnostic.

Show comments

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

now you can use cloud init cli

$ cloud-init status
status: done


When cloud-init is finished running, it touches the file /var/lib/cloud/instance/boot-finished Checking for its existence is probably the simplest option. If you need to check that cloud-init finished without any error, you can also look at /var/lib/cloud/data/result.json A successful run would look like:

 "v1": {
  "errors": [], 
  "datasource": "DataSourceDigitalOcean"

While an unsuccessful one (this was just a bash script with exit 1) would look like:

 "v1": {
  "errors": [
   "('scripts-user', RuntimeError('Runparts: 1 failures in 1 attempted commands',))"
  "datasource": "DataSourceDigitalOcean"

For more complex uses, the phone_home module lets you POST to an arbitrary url with data about the system.

cloud-init status -w should do it.