«

»

Nutanix AHV and Linux VM Guest Customization

Ihave received a few questions lately regarding Linux VM customization when using Nutanix AHV formerly known as Acropolis Hypervisor. This blog post will show how easy it is to get going with the well known Linux customization tool cloud-init and the showcase will be the following:

  • Set VM hostname
  • Set VM FQDN Name
  • Update the /etc/hosts file with hostname and FQDN
  • Install Apache Web Server
  • Run a specific script

If you want to clone and make changes to a Windows based VM running on AHV you should can read Nutanix AHV & Windows Server Guest Customisation

Some preparation has to be done with the VM we will use as a base VM / Template VM but it only includes to install the cloud-init software which is a quick and simple task by using the below yum command:

  • yum -y install cloud-init
    screen-shot-2016-11-30-at-17-02-19

When installation is complete you can power down the VM by using one of the following options:

  • Command “shutdown -h now” from within the VM
  • Command “acli vm.off <vm-name>” from any Nutanix CVM
  • Using the PRISM UI Power options

I’ll be using the following cloud-init configuration which i placed in a plain text file:

screen-shot-2016-11-30-at-22-05-34

Now time for the VM clone operation.

  • Just highlight the VM in PRISM UI and click Clone and the wizard will appear.
    screen-shot-2016-11-30-at-23-14-22

    • Give the VM a name (no print screen included) and scroll down to the Custom Script section and click the Custom Script check box. As you can see below you have multiple options to provide your cloud-init configuration and i selected “Upload a file”
      screen-shot-2016-11-30-at-22-31-30
      T
      he other available options are placing a file on ADFS or simply type the script in the textbox.
    • When done just hit Save and the VM which i called client01 will be created.
      screen-shot-2016-11-30-at-22-31-14
    • Power on the client01 VM
      screen-shot-2016-11-30-at-22-30-48

Now the VM has successfully been created and powered on so let’s verify that cloud-init was successful. Depending on how many tasks you put in the cloud-init specification it might take a while for this process to complete but in my case is should not take more than a few minutes

  • Either open the VM console to see cloud-init in action or wait until the VM is available on the network. I’m using DHCP so i just waited for an IP to be assigned to the VM
    screen-shot-2016-11-30-at-23-07-54
  • Connected to the VM via SSH to do the verification and as you can see it seem like the hostname was set correctly:
    screen-shot-2016-11-30-at-22-21-20

    • hostname verification
      screen-shot-2016-11-30-at-22-21-53 screen-shot-2016-11-30-at-22-21-40
    • FQDN verification
      screen-shot-2016-11-30-at-22-29-05
    • dnsdomainname verification
      screen-shot-2016-11-30-at-22-28-41
    • /etc/hosts verification
      screen-shot-2016-11-30-at-22-22-08
    • Apache/httpd verification
      screen-shot-2016-11-30-at-22-23-38
    • That the script was completed and created the three (urandombase.dat, urandombasecopy1.dat and urandombasedcopy2.dat) expected files in the /data01 directory
      screen-shot-2016-11-30-at-22-24-22

If you want to take a closer look at the cloud-init process you can read the its log file, cloud-init.log, which can be found in the standard Linux log file directory /var/log.

Short list of cloud-init related files:

  • /etc/cloud/cloud.cfg – Cloudinit configuration file
  • /var/log/cloud-init.log – Cloudinit log file
  • /var/lib/cloud/instance/boot-finished – File created when cloudinit is finished
  • /var/lib/cloud/data/result.json – Cloudinit process information

Below is the log file generated during my cloud-init process:

Dec 1 01:19:13 netbackup-lin-tmpl cloud-init: Cloud-init v. 0.7.5 running ‘init-local’ at Thu, 01 Dec 2016 06:19:13 +0000. Up 9.47 seconds.
Dec 1 01:19:14 netbackup-lin-tmpl cloud-init: 2016-12-01 01:19:14,043 – DataSourceNoCloud.py[WARNING]: device /dev/sr1 with label=cidata not avalid seed.
Dec 1 01:19:19 netbackup-lin-tmpl cloud-init: Cloud-init v. 0.7.5 running ‘init’ at Thu, 01 Dec 2016 06:19:19 +0000. Up 15.66 seconds.
Dec 1 01:19:19 netbackup-lin-tmpl cloud-init: ci-info: ++++++++++++++++++++++++++Net device info++++++++++++++++++++++++++
Dec 1 01:19:19 netbackup-lin-tmpl cloud-init: ci-info: +——–+——+————-+—————+——————-+
Dec 1 01:19:19 netbackup-lin-tmpl cloud-init: ci-info: | Device | Up | Address | Mask | Hw-Address |
Dec 1 01:19:19 netbackup-lin-tmpl cloud-init: ci-info: +——–+——+————-+—————+——————-+
Dec 1 01:19:19 netbackup-lin-tmpl cloud-init: ci-info: | lo: | True | 127.0.0.1 | 255.0.0.0 | . |
Dec 1 01:19:19 netbackup-lin-tmpl cloud-init: ci-info: | eth0: | True | 10.a.b.49 | 255.255.255.0 | 52:54:00:7f:a0:23 |
Dec 1 01:19:19 netbackup-lin-tmpl cloud-init: ci-info: +——–+——+————-+—————+——————-+
Dec 1 01:19:19 netbackup-lin-tmpl cloud-init: ci-info: +++++++++++++++++++++++++++++++Route info+++++++++++++++++++++++++++++++
Dec 1 01:19:19 netbackup-lin-tmpl cloud-init: ci-info: +——-+————-+————+—————+———–+——-+
Dec 1 01:19:19 netbackup-lin-tmpl cloud-init: ci-info: | Route | Destination | Gateway | Genmask | Interface | Flags |
Dec 1 01:19:19 netbackup-lin-tmpl cloud-init: ci-info: +——-+————-+————+—————+———–+——-+
Dec 1 01:19:19 netbackup-lin-tmpl cloud-init: ci-info: | 0 | 0.0.0.0 | 10.a.b.1 | 0.0.0.0 | eth0 | UG |
Dec 1 01:19:19 netbackup-lin-tmpl cloud-init: ci-info: | 1 | 10.a.b.0 | 0.0.0.0 | 255.255.255.0 | eth0 | U |
Dec 1 01:19:19 netbackup-lin-tmpl cloud-init: ci-info: +——-+————-+————+—————+———–+——-+
Dec 1 01:19:20 netbackup-lin-tmpl cloud-init: 2016-12-01 01:19:20,126 – DataSourceNoCloud.py[WARNING]: device /dev/sr1 with label=cidata not avalid seed.
Dec 1 01:19:21 netbackup-lin-tmpl cloud-init: Cloud-init v. 0.7.5 running ‘modules:config’ at Thu, 01 Dec 2016 06:19:20 +0000. Up 16.88 seconds.
Dec 1 01:19:21 netbackup-lin-tmpl cloud-init: Loaded plugins: fastestmirror, langpacks
Dec 1 01:19:30 netbackup-lin-tmpl cloud-init: Determining fastest mirrors
Dec 1 01:19:30 netbackup-lin-tmpl cloud-init: * base: mirror.nexcess.net
Dec 1 01:19:30 netbackup-lin-tmpl cloud-init: * extras: mirror.sjc02.svwh.net
Dec 1 01:19:30 netbackup-lin-tmpl cloud-init: * updates: mirror.keystealth.org
Dec 1 01:19:49 netbackup-lin-tmpl cloud-init: Metadata Cache Created
Dec 1 01:19:49 netbackup-lin-tmpl cloud-init: Loaded plugins: fastestmirror, langpacks
Dec 1 01:19:49 netbackup-lin-tmpl cloud-init: Loading mirror speeds from cached hostfile
Dec 1 01:19:49 netbackup-lin-tmpl cloud-init: * base: mirror.nexcess.net
Dec 1 01:19:49 netbackup-lin-tmpl cloud-init: * extras: mirror.sjc02.svwh.net
Dec 1 01:19:49 netbackup-lin-tmpl cloud-init: * updates: mirror.keystealth.org
Dec 1 01:19:50 netbackup-lin-tmpl cloud-init: Resolving Dependencies
Dec 1 01:19:50 netbackup-lin-tmpl cloud-init: –> Running transaction check
Dec 1 01:19:50 netbackup-lin-tmpl cloud-init: —> Package httpd.x86_64 0:2.4.6-40.el7.centos.4 will be installed
Dec 1 01:19:50 netbackup-lin-tmpl cloud-init: –> Processing Dependency: httpd-tools = 2.4.6-40.el7.centos.4 for package: httpd-2.4.6-40.el7.centos.4.x86_64
Dec 1 01:19:50 netbackup-lin-tmpl cloud-init: –> Processing Dependency: /etc/mime.types for package: httpd-2.4.6-40.el7.centos.4.x86_64
Dec 1 01:19:50 netbackup-lin-tmpl cloud-init: –> Running transaction check
Dec 1 01:19:50 netbackup-lin-tmpl cloud-init: —> Package httpd-tools.x86_64 0:2.4.6-40.el7.centos.4 will be installed
Dec 1 01:19:50 netbackup-lin-tmpl cloud-init: —> Package mailcap.noarch 0:2.1.41-2.el7 will be installed
Dec 1 01:19:51 netbackup-lin-tmpl cloud-init: –> Finished Dependency Resolution
Dec 1 01:19:51 netbackup-lin-tmpl cloud-init: Dependencies Resolved
Dec 1 01:19:51 netbackup-lin-tmpl cloud-init: ================================================================================
Dec 1 01:19:51 netbackup-lin-tmpl cloud-init: Package Arch Version Repository Size
Dec 1 01:19:51 netbackup-lin-tmpl cloud-init: ================================================================================
Dec 1 01:19:51 netbackup-lin-tmpl cloud-init: Installing:
Dec 1 01:19:51 netbackup-lin-tmpl cloud-init: httpd x86_64 2.4.6-40.el7.centos.4 updates 2.7 M
Dec 1 01:19:51 netbackup-lin-tmpl cloud-init: Installing for dependencies:
Dec 1 01:19:51 netbackup-lin-tmpl cloud-init: httpd-tools x86_64 2.4.6-40.el7.centos.4 updates 83 k
Dec 1 01:19:51 netbackup-lin-tmpl cloud-init: mailcap noarch 2.1.41-2.el7 base 31 k
Dec 1 01:19:51 netbackup-lin-tmpl cloud-init: Transaction Summary
Dec 1 01:19:51 netbackup-lin-tmpl cloud-init: ================================================================================
Dec 1 01:19:51 netbackup-lin-tmpl cloud-init: Install 1 Package (+2 Dependent packages)
Dec 1 01:19:51 netbackup-lin-tmpl cloud-init: Total download size: 2.8 M
Dec 1 01:19:51 netbackup-lin-tmpl cloud-init: Installed size: 9.6 M
Dec 1 01:19:51 netbackup-lin-tmpl cloud-init: Downloading packages:
Dec 1 01:19:53 netbackup-lin-tmpl cloud-init: ——————————————————————————–
Dec 1 01:19:53 netbackup-lin-tmpl cloud-init: Total 1.7 MB/s | 2.8 MB 00:01
Dec 1 01:19:53 netbackup-lin-tmpl cloud-init: Running transaction check
Dec 1 01:19:53 netbackup-lin-tmpl cloud-init: Running transaction test
Dec 1 01:19:53 netbackup-lin-tmpl cloud-init: Transaction test succeeded
Dec 1 01:19:53 netbackup-lin-tmpl cloud-init: Running transaction
Dec 1 01:19:53 netbackup-lin-tmpl cloud-init: Installing : mailcap-2.1.41-2.el7.noarch 1/3
Dec 1 01:19:54 netbackup-lin-tmpl cloud-init: Installing : httpd-tools-2.4.6-40.el7.centos.4.x86_64 2/3
Dec 1 01:19:54 netbackup-lin-tmpl cloud-init: Installing : httpd-2.4.6-40.el7.centos.4.x86_64 3/3
Dec 1 01:19:54 netbackup-lin-tmpl cloud-init: Verifying : httpd-tools-2.4.6-40.el7.centos.4.x86_64 1/3
Dec 1 01:19:54 netbackup-lin-tmpl cloud-init: Verifying : mailcap-2.1.41-2.el7.noarch 2/3
Dec 1 01:19:55 netbackup-lin-tmpl cloud-init: Verifying : httpd-2.4.6-40.el7.centos.4.x86_64 3/3
Dec 1 01:19:55 netbackup-lin-tmpl cloud-init: Installed:
Dec 1 01:19:55 netbackup-lin-tmpl cloud-init: httpd.x86_64 0:2.4.6-40.el7.centos.4
Dec 1 01:19:55 netbackup-lin-tmpl cloud-init: Dependency Installed:
Dec 1 01:19:55 netbackup-lin-tmpl cloud-init: httpd-tools.x86_64 0:2.4.6-40.el7.centos.4 mailcap.noarch 0:2.1.41-2.el7
Dec 1 01:19:55 netbackup-lin-tmpl cloud-init: Complete!
Dec 1 01:19:55 netbackup-lin-tmpl cloud-init: Cloud-init v. 0.7.5 running ‘modules:final’ at Thu, 01 Dec 2016 06:19:55 +0000. Up 51.22 seconds.
Dec 1 01:19:55 netbackup-lin-tmpl cloud-init: Start creating the basefile urandombase.dat from from /dev/urandom
Dec 1 01:21:16 netbackup-lin-tmpl cloud-init: Done creating the urandombase.dat file from /dev/urandom and now starting to create the copies
Dec 1 01:21:21 netbackup-lin-tmpl cloud-init: done creating file copy 1
Dec 1 01:21:25 netbackup-lin-tmpl cloud-init: done creating file copy 2
Dec 1 01:21:25 netbackup-lin-tmpl cloud-init: Finished creating 2 files from urandombase.dat
Dec 1 01:21:25 netbackup-lin-tmpl cloud-init: ci-info: no authorized ssh keys fingerprints found for user centos.
Dec 1 01:21:25 netbackup-lin-tmpl cloud-init: Cloud-init v. 0.7.5 finished at Thu, 01 Dec 2016 06:21:25 +0000. Datasource DataSourceConfigDriveNet [net,ver=2][source=/dev/sr1]. Up 141.68 seconds

 

2 pings

Comments have been disabled.