With the vSphere 5 release VMware decided to drop some operating systems using the guest customization wizard. This was already announced with the 4.1 release notes and has gone active now. I guess VMware had the idea that in time people would replace them with supported guest systems.

Quote from the KB:

Starting with vSphere 5.0, the support for customization of these operating systems is deprecated:

  • Debian (All versions)
  • Ubuntu (All versions)
  • Red Hat Enterprise Linux 2.1 Update 1-7
  • Red Hat Enterprise Linux 3.0 Update 1-9
  • SUSE Linux Enterprise Server 8.0 Service Pack 3
  • SUSE Linux Enterprise Server 9.0 Service Pack 1-4
  • Windows 2000 (All versions)

More information can be found in this KB.

Honestly I think that certain guest systems which have been dropped where needed/outdated… Unfortunately I don’t agree on dropping Debian and Ubuntu. I know quite some people who prefer these above Fedora, SUSE, Red Hat,…

With the change this means that if you deploy a template or clone a VM which is from the Debian/Ubuntu type you won’t be able to change the hostname and IP settings by using the wizard or certain PowerCLI commands (Guest-Customization).

I decided to find a small/dirty solution for this. Keep in mind that this is an example on how you can “re-create” the wizard and if wanted even expand it… The example is done by using a Debian 6 template with 1 NIC but it also works with Ubuntu.

First install a clean Debian/Ubuntu VM with 1 NIC (remember VMware tools).

Once the install is finished, login to the VM and make a Bash script with the following code:

#!/bin/bash

HOSTNAME=$1
IP=$2
SUBNET=$3
GATEWAY=$4

rm -rf /etc/udev/rules.d/70-persistent-net.rules

echo $HOSTNAME > /etc/hostname

echo "# This file describes the network interfaces available on your system" > /etc/network/interfaces
echo "# and how to activate them. For more information, see interfaces(5)." >> /etc/network/interfaces
echo "" >> /etc/network/interfaces
echo "# The loopback network interface" >> /etc/network/interfaces
echo "auto lo" >> /etc/network/interfaces
echo "iface lo inet loopback" >> /etc/network/interfaces
echo ""  >> /etc/network/interfaces
echo "auto eth0" >> /etc/network/interfaces
echo "iface eth0 inet static" >> /etc/network/interfaces
echo "  address $IP" >> /etc/network/interfaces
echo "  netmask $SUBNET" >> /etc/network/interfaces
echo "  gateway $GATEWAY" >> /etc/network/interfaces

rm -rf /root/customization.sh

Place this under /root, save it as “customization.sh” and make sure it is executable (chmod +x /root/customization.sh).

You can always place it somewhere else if wanted, just change the path in the last line.

Save it and shutdown your VM. Convert it to a template and the first part is done.

Next we will be creating the PowerCLI script:

# Start configuration
# vCenter details
$vcenter = "localhost"

# Config VM peripherals
$vmname = "vm-guestclone"
$ip = "192.168.0.100"
$netmask = "255.255.255.0"
$gateway = "192.168.0.1"

# VM user - must be root user
$GuestCred = "root"
$GuestPass = "temppass"

# VM Deployment Details
$destination_host = "host01.local.lab"
$template_name = "tpl-debian6-clean"
$datastore_name = "LOCAL01"
# End configuration

# PowerOn function, checks if VM is running and if needed start it
function PowerOn-VM {
    param ([string] $vm)

    if ($vm -eq "" ) {
		Write-Host "No VM defined."
	}

    if ((Get-VM $vm).powerstate -eq "PoweredOn" ) {
        Write-Host "$vm is already powered on."
		return "ok"
	} else {
        Start-VM -VM (Get-VM $vm) -Confirm:$false
        Write-Host "Starting $vm now."
        do {
            $status = (Get-vm $vm | Get-View).Guest.ToolsRunningStatus
			sleep 10
        } until ($status -eq "guestToolsRunning")
		
        return "ok"
    }
}

Connect-VIServer -Server $vcenter

New-VM -Name $vmname -Template $template_name -VMHost $destination_host -Datastore $datastore_name

$poweron = PowerOn-VM $vmname

if ($poweron -eq "ok") {
	Write-Host "$vmname started."
}

$command = "/root/customization.sh $vmname $ip $netmask $gateway"
Invoke-VMScript -VM $vmname -ScriptText $command -GuestUser $GuestCred -GuestPassword $GuestPass -ScriptType Bash

Restart-VMGuest -VM $vmname

Disconnect-VIServer -Server $vcenter -Confirm:$false

As seen in the script by using Invoke-VMscript we pass 4 parameters to the Bash script:

  1. Hostname
  2. IP
  3. Subnet
  4. Gateway

The script will clone the template and start the VM. As soon as the VMware tools are running the Bash script is called to configure the hostname and network and finally a reboot happens.

Just change the top parameters and run the script and you’ll have a Debian/Ubuntu template deployed and customized. The result can be seen in the screenshot below.

Debian customization

Keep in mind this is a basic example and nothing VLAN based is added or extra guest scripts. This script can be extended to fill your own needs. I just hope this small solution gets you started.

Enjoy!

Veeam Backup & Replication is a great tool for backing up your virtual environment. U can use it to backup certain virtual machines or your whole environment by simply creating backup jobs in which u add virtual machines. Veeam has the option which sends an e-mail if a backup was successful or failed.

Sadly there is one thing I couldn’t find and it’s an option to check which virtual machines are being backed up and which are not in a virtual environment.

After some thinking I decided to combine Veeam and PowerCLI as a solution to my problem.

When a job is created there is an advanced option to add a note to a virtual machine which can be used for scripts.

When creating a job click “Advanced” when the following screen appears.

Once the advanced settings open, go to the notifications tab and select “Set successful backup details to this VM attribute”. Change the value from “Notes” to “Backup”.

Every time the job finishes successful Veeam will add an annotation called “Backup” to the virtual machine as seen on the picture below.

Below is a script which will collect all virtual machines in the defined vCenter and run a check on the backup annotation. This will perform a check if the backup was successful in the past 2 days. Finally it will send an overview in plain text via mail.

Please change the required settings on top of the script!

# Set the vCenter Server
$vcenter = "localhost"
# Set the SMTP Server address
$SMTPSRV = "<SMTP SERVER>"
# Set the Email address to receive from
$EmailFrom = "veeam@foonet.be"
# Set the Email address to send the email to
$EmailTo = "<RECEIVER>"
# Set the Email subject
$EmailSubject = "Veeam Backup Information"

# SMTPmail function
function Send-SMTPmail($to, $from, $subject, $smtpserver, $body) {
	$mailer = new-object Net.Mail.SMTPclient($smtpserver)
	$msg = new-object Net.Mail.MailMessage($from,$to,$subject,$body)
	$msg.IsBodyHTML = $false
	$mailer.send($msg)
}

# Get Backedup function
function Get-Backedup ($vm) {
	$val = $vm.CustomFields |where {$_.key -eq "Backup" } | select -Property Value
	$today = Get-Date -Format "d/MM/yyyy"
	$yesterday = get-date -format "d/MM/yyyy" -displayhint date ((get-date).adddays(-1))
	$backupDate = $val.Value
	if ( $backupDate -like "*$today*" -or $backupDate -like "*$yesterday*"  ) {
		$res = 1
	} else {
		$res = 0
	} 
	return ( $res )
}

Connect-VIServer $vcenter | Out-Null

$vms = Get-VM

$resultok=@()
$resultnotok=@()

foreach ($vm in $vms) {
	if (Get-Backedup($vm)) {
		$resultok += "$vm `r`n"
	} else {
		$resultnotok += "$vm `r`n"
	}
}

$body = "==================================================`r`n"
$body += "Backup report $vcenter:`r`n"
$body += "==================================================`r`n`r`n"
$body += "The following VMs have NOT been backed up:`r`n"
$body += "---------------------------------------------------------------`r`n"
$body += $resultnotok | Sort-Object
$body += "`r`n`r`nThe following VMs have been backed up:`r`n"
$body += "--------------------------------------------------------`r`n"
$body += $resultok | Sort-Object

send-SMTPmail -to $EmailTo -from $EmailFrom -subject $EmailSubject -smtpserver $SMTPSRV -body $body

That’s it. Feel free to improve the script or give hints and tips!