Ask Your Question
0

Run a default script soon after Instance creation?

asked 2017-03-30 00:23:20 -0500

ShubhamMeshram gravatar image

updated 2017-03-30 00:38:09 -0500

If I launch an instance for the first time, I want to run a small script of commands in it.

For example if I need to change the hostname of the VM or want it to display the output of ifconfig when it starts up or any command or script for that matter.

How can I do this?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2017-03-30 00:42:55 -0500

Most likely, your instance has cloudinit built-in. You can put your script in a file, ensure it starts with #!/bin/bash, then submit it like this openstack server create --user-data YOUR-SCRIPT-FILE .... I can recommend a very nice presentation on cloudinit held at the Tokyo summit in October 2015.

edit flag offensive delete link more

Comments

openstack server create --image cirros-0.3.5-x86_64-uec --flavor m1.tiny MyFirstInstance

if that is the command to create an instance should I append --user-data YOUR-SCRIPT-FILE to the end of the command?

ShubhamMeshram gravatar imageShubhamMeshram ( 2017-03-30 00:47:13 -0500 )edit

I think it needs to come before the instance name, but why don't you look up the documentation?

Bernd Bausch gravatar imageBernd Bausch ( 2017-03-30 01:03:25 -0500 )edit

I didn't really find a solution to my question in the link you provided. Please help me do this

ShubhamMeshram gravatar imageShubhamMeshram ( 2017-04-03 00:12:02 -0500 )edit

In your answer, what do you mean by --user-data?

ShubhamMeshram gravatar imageShubhamMeshram ( 2017-04-03 00:12:48 -0500 )edit

Did you watch the video? What is it that you don't understand?

--user-data is a parameter to the openstack server create command.

Bernd Bausch gravatar imageBernd Bausch ( 2017-04-03 00:35:24 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Get to know Ask OpenStack

Resources for moderators

Question Tools

1 follower

Stats

Asked: 2017-03-30 00:23:20 -0500

Seen: 275 times

Last updated: Mar 30 '17