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.
Capabilities of OpenStack Customization Script For Automation (HP Cloud)
cloud init is very powerful. The screenshot of the thing we are talking about is this on screenshot :
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 :
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 :
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 :
A bit complex example to install Apache2 automatically is :
- [ 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 :
- wget http://wordpress.org/latest.tar.gz -P /tmp/
- tar -zxf /tmp/latest.tar.gz -C /var/www/
- mysql -e "create database wordpress; create user 'wpuser'@'localhost' identified by 'changemetoo'; grant all privileges on wordpress . \* to 'wpuser'@'localhost'; flush privileges;"
- mysql -e "drop database test; drop user 'test'@'localhost'; flush privileges;"
- mysqladmin -u root password 'changeme'
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.
Follow the Author of this article :