{"id":347,"date":"2016-09-02T06:00:00","date_gmt":"2016-09-02T14:00:00","guid":{"rendered":"https:\/\/andrewwippler.com\/?p=347"},"modified":"2016-08-28T15:44:08","modified_gmt":"2016-08-28T23:44:08","slug":"provisioning-vms-with-cloud-init","status":"publish","type":"post","link":"https:\/\/andrewwippler.com\/2016\/09\/02\/provisioning-vms-with-cloud-init\/","title":{"rendered":"Provisioning VMs with cloud init"},"content":{"rendered":"

One of the easiest ways to deploy a virtual machine in oVirt is first to install the OS then turn it into a template. This will allow you to copy that template to deploy new instances. One mundane task after a new template is copied to a new instance is logging in, changing the IP, setting the hostname, setting up Puppet, running puppet, etc. cloud-init<\/code> is the tool designed to fix that mundane task process by allowing those steps to be automated. oVirt\/RHEV (as well as OpenStack, AWS, and others) allow you to pass in user data which is then supplied to cloud-init<\/code> after the template is copied over and turned on. This allows for scripting on the new VM – easing deployment.<\/p>\n

For my environment, I wanted a CentOS 7 template. To have that, I must first install CentOS on a new VM and seal it (Windows calls this Sysprep). Before I seal it, I must install cloud-init<\/code> and any other tools I might use for deployment – such as puppet<\/code>. Here are the steps to obtain just that:<\/p>\n

<\/p>\n

* Install CentOS 7.2 Minimal on any new VM. Ensure to have LVM partitioning as you may want to extend the disk later. I have found that 10 GB is a good starting size.<\/p>\n

* Install your base files – things you cannot live without (i.e. vim<\/code>,puppet<\/code>, etc).<\/p>\n

* Seal the VM per RedHat instructions<\/a>. I suggest following the instructions for sysunconfig:<\/p>\n

    \n
  1. Log in to the virtual machine.<\/li>\n
  2. Remove ssh host keys:\n
    # rm -rf \/etc\/ssh\/ssh_host_*<\/pre>\n<\/li>\n
  3. Set HOSTNAME=localhost.localdomain<\/code> in \/etc\/sysconfig\/network<\/code> for Red Hat Enterprise Linux 6\/CentOS 6 or \/etc\/hostname<\/code> for Red Hat Enterprise Linux 7\/CentOS 7.<\/li>\n
  4. Remove the HWADDR<\/code> line and UUID<\/code> line from \/etc\/sysconfig\/network-scripts\/ifcfg-eth*<\/code>.<\/li>\n
  5. Optionally, delete all the logs from \/var\/log<\/code> and build logs from \/root<\/code>.<\/li>\n
  6. Run sys-unconfig<\/code><\/li>\n<\/ol>\n

    sys-unconfig<\/code> will turn off the VM when it is completed. When it is turned off, right click the VM and select copy to template.<\/p>\n","protected":false},"excerpt":{"rendered":"

    One of the easiest ways to deploy a virtual machine in oVirt is first to install the OS then turn it into a template. This will allow you to copy that template to deploy new instances. One mundane task after a new template is copied to a new instance is logging in, changing the IP, […]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"advanced_seo_description":"","jetpack_seo_html_title":"","jetpack_seo_noindex":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false}}},"categories":[6,11],"tags":[17,60,61,62,32],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack-related-posts":[],"jetpack_sharing_enabled":true,"jetpack_likes_enabled":true,"_links":{"self":[{"href":"https:\/\/andrewwippler.com\/wp-json\/wp\/v2\/posts\/347"}],"collection":[{"href":"https:\/\/andrewwippler.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/andrewwippler.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/andrewwippler.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/andrewwippler.com\/wp-json\/wp\/v2\/comments?post=347"}],"version-history":[{"count":9,"href":"https:\/\/andrewwippler.com\/wp-json\/wp\/v2\/posts\/347\/revisions"}],"predecessor-version":[{"id":368,"href":"https:\/\/andrewwippler.com\/wp-json\/wp\/v2\/posts\/347\/revisions\/368"}],"wp:attachment":[{"href":"https:\/\/andrewwippler.com\/wp-json\/wp\/v2\/media?parent=347"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/andrewwippler.com\/wp-json\/wp\/v2\/categories?post=347"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/andrewwippler.com\/wp-json\/wp\/v2\/tags?post=347"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}