Ask Your Question
0

Howto execute one global script when VM creation/boot in OpenStack

asked 2018-01-24 08:06:46 -0500

cesarjorgemartinez gravatar image

updated 2018-01-25 10:58:07 -0500

Hi,

I need to execute one global script when VM creation/boot in OpenStack. Example: openstack server create myserver ... Then that the OpenStack instance execute one script that is the same for all this OpenStack instance.

I do not mean to use "--user-data", because this is for apply one custom (and local) script.

How do I do this?

One example of this is the following:

I have one OpenStack enviroment. With many tenants, many VM by tenant, multiple projects.

Then, for all VMs for this OpenStack enviuronment, when I create/boot one other VM (from one image without personalizations, without sensible information), then always need do the same tasks, example: curl -o /path/generalcert.cert http://myprivateurl/generalcert.cer echo "Welcome private banner" > /etc/motd etc.....

For to do these tasks: - I can use --user-data "myprovisionscript.sh". But, all people working in the same OpenStack environment, need to use same script, and known it, and maintain for all. - I need (configuring of any form the OpenStack Server), that this common script run transparently for all users when any user create/boot any instance, without specify --user-data, only using "openstack server create myserver ...". In this way, that these common tasks are maintained by the OpenStack administrator.

I read a bit that exist "meta-data", "vendor-data", etc. I do not know if it is possible to use this to add a script that always runs when create/boot one VM.

Regards, Cesar Jorge

edit retag flag offensive close merge delete

Comments

You could use -—user-data globalscript.yaml. Or perhaps I don’t understand what you mean by global or local.

Bernd Bausch gravatar imageBernd Bausch ( 2018-01-24 08:52:36 -0500 )edit

4 answers

Sort by » oldest newest most voted
0

answered 2018-02-13 06:24:21 -0500

cesarjorgemartinez gravatar image

updated 2018-02-13 06:27:43 -0500

Hi, reading the possibilities: I can use one metadata propoerty in a image (using openstack image set --property myproperty=value), and when I create a VM from this image, that the VM can read this property?

Regards

edit flag offensive delete link more

Comments

Nova uses some image metadata for scheduling decisions, but afaik the instance doesn’t see it.

Bernd Bausch gravatar imageBernd Bausch ( 2018-02-13 08:04:17 -0500 )edit

Hum, I had thought about defining a property globally. Example for VBox: getextradata global|<uuid|vmname> <key>|enumerate

setextradata global|<uuid|vmname> <key>

cesarjorgemartinez gravatar imagecesarjorgemartinez ( 2018-02-13 09:50:32 -0500 )edit

Then, depending on the value of one global property, I get this value, as url of the script to execute inside VM

cesarjorgemartinez gravatar imagecesarjorgemartinez ( 2018-02-13 09:51:40 -0500 )edit

Vbox extradata seems to be exactly the same thing as instance metadata in OpenStack.

VBoxManage setextradata Fedora5 installdate 2006.01.01

is equivalent to

openstack server set —property installdate=2006.01.01 Fedora5
Bernd Bausch gravatar imageBernd Bausch ( 2018-02-14 05:53:07 -0500 )edit

Vbox getextradata doesn’t have an exact equivalent, but you can say something like

openstack server show Fedora5 | grep property

(I don’t have a cloud available to check the precise syntax).

Bernd Bausch gravatar imageBernd Bausch ( 2018-02-14 05:56:51 -0500 )edit
0

answered 2018-02-13 23:36:34 -0500

Launch a VM with volume attached ,install or modify your configuration in the VM.Delete the instance ,volume still exists .Upload volume to image and use this image for further VM creation

edit flag offensive delete link more
0

answered 2018-01-25 21:26:26 -0500

OpenStack doesn’t interfere with the software that runs on the VM. You can set meta data, which is one or more key-value pairs, on an instance. You can provide an SSH key to the instance, or a user data script. All these things, however, don’t change the software that runs on the instance or the data on the instance.

Rather, the instance must process this information. For example, SSH keys and user data are usually processed with cloud-init. Even though you can “inject” files, this term is misleading, and in reality the instance pulls those files; they are not forcibly added to the instance from outside.

In short, if each instance needs to do the same thing, you need to either build some custom code into the image, or provide data to cloud-init (which is included in practically all cloud images). Which brings us back to user-data.

I suppose your problem would be solved if you could define default user-data, which would be added to an instance even without the —user-data option. AFAIK this is not possible.

edit flag offensive delete link more
0

answered 2018-01-25 10:44:37 -0500

cesarjorgemartinez gravatar image

I refined my question a bit...

edit flag offensive delete link more

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

Stats

Asked: 2018-01-24 08:06:46 -0500

Seen: 197 times

Last updated: Feb 13