Cloud-init is a set of init scripts for cloud instances. Cloud instances need special scripts to run during initialization to retrieve and install ssh keys and to let the user run various scripts. EC2 users might already be familiar with this tool as its pre-configured on most Linux distributions available on the AWS marketplace.
CloudStack users instead have relied on 2 scripts, cloudstack-set-guest-password and cloudstack-set-guest-sshkey, for setting SSH and admin password for instances running on the CloudStack IaaS platform. While these scripts do the job, they are shell scripts running as individual services and do only a single function. Adding more functionality would mean creating additional standalone scripts with lots of code duplication.
Cloud-init on the other hand is a Python framework and already has a long list of modules that can re-size the filesystem, update hostname, add apt repositories and even trigger chef/puppet runs. Wouldn’t it be nice to use cloud-init on Cloudstack IaaS platform also. Just like on EC2!!!
Thanks to Cosmin Luta, Cloud-init 0.6.3 onwards can now fetch instance meta-data from the CloudStack Virtual Router. Since new features/modules are being added to Cloud-init all the time, it’s best to use the latest releases. CentOS/RHEL users can get updated RPMS from repos.fedorapeople.org
To use cloud-init on CentOS/RHEL 6.x,
- Add the EPEL repo
$ rpm -ivh http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm Retrieving http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm Preparing... ########################################### [100%] 1:epel-release ########################################### [100%]
- Add the cloud-init repo at http://repos.fedorapeople.org/repos/openstack/cloud-init/epel-6/
[epel-cloud-init] name=CloudInit-$releasever baseurl=http://repos.fedorapeople.org/repos/openstack/cloud-init/epel-$releasever/ enabled=1 gpgcheck=1
- Install cloud-init
$ yum install cloud-init Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: mirror.leapswitch.com * epel: epel.mirror.net.in * extras: mirror.leapswitch.com * updates: mirror.leapswitch.com Setting up Install Process Resolving Dependencies --> Running transaction check ---> Package cloud-init.noarch 0:0.7.2-2.el6 will be installed --> Finished Dependency Resolution Dependencies Resolved ========================================================= Package Arch Version Repository Size ========================================================= Installing: cloud-init noarch 0.7.2-2.el6 init 412 k Transaction Summary ========================================================= Install 1 Package(s) Total download size: 412 k Installed size: 1.3 M Is this ok [y/N]: y Downloading Packages: cloud-init-0.7.2-2.el6.noarch.rpm | 412 kB 00:02 Running rpm_check_debug Running Transaction Test Transaction Test Succeeded Running Transaction Warning: RPMDB altered outside of yum. Installing : cloud-init-0.7.2-2.el6.noarch 1/1 Verifying : cloud-init-0.7.2-2.el6.noarch 1/1 Installed: cloud-init.noarch 0:0.7.2-2.el6 Complete! $ rpm -qi cloud-init Name : cloud-init Relocations: (not relocatable) Version : 0.7.2 Vendor: Red Hat, Inc. Release : 2.el6 Build Date: Wed 26 Jun 2013 05:37:52 AM EDT Install Date: Mon 28 Oct 2013 06:12:47 AM EDT Build Host: ppc-012.build.bos.redhat.com Group : System Environment/Base Source RPM: cloud-init-0.7.2-2.el6.src.rpm Size : 1414362 License: GPLv3 Signature : (none) Packager : Red Hat, Inc. <http://bugzilla.redhat.com/bugzilla> URL : http://launchpad.net/cloud-init Summary : Cloud instance init scripts Description : Cloud-init is a set of init scripts for cloud instances. Cloud instances need special scripts to run during initialization to retrieve and install ssh keys and to let the user run various scripts.
- Add datasource_list: [‘CloudStack’] to the top of /etc/cloud/cloud.cfg. If you fail to set the correct data source, cloud-init will default to using 169.254.169.254 as the meta-data source IP instead of the Virtual Router.
datasource_list: ['CloudStack']
- Verify the rest of cloud.cfg defaults before rebooting. WARNING: The defaults will disable password login for SSH (ssh_pwauth: 0)
So can Cloud-init replace cloud-set-guest scripts?
Cloud-init was able to set the SSH key correctly on my CentOS 6.4 test instance environment (blog post coming soon) so it should be possible to deprecate cloudstack-guest-set-sshkey script atleast.
Will be testing the cloudstack-guest-set-password functionality also soon. It would also be nice if the “resizefs” was able to resize the data disk now that CloudStack provide an API for resizing volumes
6 replies on “Cloud-init Supports CloudStack As Data Source”
[…] earlier blog post on installing Cloud-init on CloudStack CentOS/RHEL guest […]
[…] The installation and configuration of cloud-init for CentOS is in this blog post. […]
Here’s a kickstart for generating CentOS templates. It also relies on cloud-init and one more thing that I do is move the set-password script from init and into a cloud-init specific “run per boot” section.
http://li.nux.ro/download/cloudstack/ks/CentOS6_64bit_password_sshkey.ks
The cloud-init repo listed here is no longer valid. Could you possibly supply an updated location? Thank you =)
Hi,
cloud-init is in EPEL proper now, http://dl.fedoraproject.org/pub/epel/6/
Thank you =)