Is there a way to tell via API when a cloud-config script is complete?

July 6, 2018 67 views

I've been using the droplet api to determine when a droplet is in the active state.

However, the droplet often transitions to active before the cloud-config runcmd commands have completed.

Ideally, I'd like to hit an endpoint that tells me if the cloud-config script (or, whatever was in user_data) has completed. Is there such a thing?

1 Answer

Hello friend!

Currently the API only interacts with our platform, where the script executes on the server itself. This will mean that the API considers everything to be complete with the droplet moves to an active state. You're right to note that this doesn't help you to know when everything you've queued up is actually complete, as the cloud-config script runs on the droplet after the droplet is in an active state.

What I propose is that you have the cloud-config script make an external call as a last step to signal it's completion. As it goes in a top down order, the last action completing should signal that the previous actions were completed (not necessarily successfully or in the intended way, but completed regardless).

I can give an example of something I might do. Let's say the purpose of my droplet is a web server. I might have it write a file in /var/www/html as the last action, and have my script check for that file every X seconds, declaring the function to be complete after finding that file (maybe adding in a timeout in case of failure).

Kind Regards,

Have another answer? Share your knowledge.