OpenStack Customization Script For Automation (HP Cloud)

Advertisement

Placement of Cloud init Script is Present via Web GUI in Horizon. Here is the Basics of OpenStack Customization Script For Automation in HP Cloud. Possibly you have heard about Cloud Automation, OpenStack Heat Templates. If you are not understanding about which thing we are talking about – this is blank field that is given as option in the Launch Instance popup menu in Horizon. The option name “Post Creation” which sits beside – [Details] [Access & Security] [Networking] as forth option. OpenStack is written in Python. We can use the OpenStack Python Client Tools from desktop to inject our script or can use the Web GUI of Horizon. We are avoiding terminologies to make it usable to the ordinary users. We are working with Ubuntu instances for this guide.

Just to make you 100% assured, the cloud init is enabled in HP Cloud. SSH to your any existing instance (do not worry, nothing will be destroyed) when you were never aware of cloud-init. Run these commands to see the output :

Vim

1

2

cat/etc/cloud/cloud.cfg

cat/var/log/cloud-init-output.log

The last one will give you the idea – cloud init is enabled. So, for the next instance, if you use a script; you can use the same script few billion times for creation of instances ready with the softwares you need, like creation of an instance running Nginx.

cloud init is the default VM bootstrapping system on Debian (and Ubuntu), Fedora and Red Hat Enterprise Linux. This guide in technical word is about using CloudInit inside OpenStack Heat.

cloud init documentation is unreadable for practical purpose. We know that the OpenStack Heat implements injection in Python for the VMs. This injection is possible by passing information to the VM. This is decoded by Cloud-Init.
It is too big matter from the point of an ordinary user to understand how it happens. HP Cloud actually has extensive docs for this part :

Vim

1

http://docs.hpcloud.com/als/v1/admin/cluster/cloud-init/#copy to text editor first

A very basic script to run apt-get upgrade on first boot is :

Vim

1

2

#cloud-config

apt_upgrade:true

A bit complex example to install Apache2 automatically is :

Vim

1

2

3

4

5

#cloud-config

packages:

-apache2

runcmd:

-[a2ensite,"000-default"]

Size is the limitation from GUI. 16 KB is the limit.

OpenStack Customization Script For Automation (HP Cloud)

So, if we run this untested script, we will get a ready to use LAMP server running WordPress :

The above example is by Rackspace. Practically you’ll get examples of using cloud init from Amazon’s huge number of user scripts plus there are the Heat templates from Rackspace – doing a bit reverse engineering will make them working on HP Cloud or OpenStack own installations.