Can Heat run a script after the VM(s) are successfully booted?

asked 2014-06-06 21:49:05 -0500 gravatar image

Hi, I wonder if Heat can run a script in a VM AFTER it is successfully booted. I know it is possible to pass a script by user-data, but it doesn't seem to fit my purpose (because user-data run a script DURING the VM is booting). I am looking for a feature that can perform actions after the specified resources are successfully provisioned, e.g. SSH to a newly provisioned VM and run a script on it.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2014-06-07 06:55:57 -0500

larsks gravatar image

Heat cannot by itself ssh into your system to run a script after it boots. However, I think you can probably do what you want using user-data: have your user-data script install a script on your system that runs at the appropriate time, either via the standard init mechanism, using rc.local, cron, or any other similar solution.

For example, pass in a user-data block with contents like:


cat >> /etc/rc.local <<'EOF'
echo Look ma no hands > /var/tmp/flagfile

This would append the echo ... line to /etc/rc.local, so that it would run at the end of the boot process.

edit flag offensive delete link more


Thanks for the response.

I think your propose is a good walk-around. However, it doesn't seem to solve my problem. I want Heat to run a script after it finishes provisioning resources. For example, get two VMs, and then ssh to each VM and ping the other one after both VMs are up. gravatar ( 2014-07-11 16:16:52 -0500 )edit

You can't do that directly; Heat doesn't really have a model for "run a script on the local system" (because for most deployments, you would never want this for obvious security reasons -- in a multi-tenant environment, you do not want people executing commands on the heat server). (continued...)

larsks gravatar imagelarsks ( 2014-10-10 13:12:29 -0500 )edit

You could have Heat boot up an additional server, and provide that server with the appropriate script via user_data. You would probably want to use WaitCondition resources to synchronize this with the configuration of the other two servers.

larsks gravatar imagelarsks ( 2014-10-10 13:13:21 -0500 )edit

Hi, I am trying to run the script in the similar way you explained but it does not take effect. Could you please advice on what the problem might be ?

This is my script: !/bin/bash echo "Hello World" > /tmp/test.txt

I checked console logs and never found these lines getting executed

drn gravatar imagedrn ( 2015-11-25 03:20:22 -0500 )edit

Get to know Ask OpenStack

Resources for moderators

Question Tools

1 follower


Asked: 2014-06-06 21:49:05 -0500

Seen: 2,686 times

Last updated: Jun 07 '14