Installing Ansible/AWX ready for VMware Automation on Unbuntu 8.04LTS

I have just started to look into using Ansible for automating some of the tasks we current use on customer infrastructure, from VM template deployment to the install/configure of bespoke applications within the VM.

For my testlab i though i would install ansible and the relevant VMware required modules like Python SDK for VMware and pyvmomi. I also installed AWX to provide a GUI for the task scheduler and to better understand how Ansible Tower works.

To get started with the installation we deploy a simple unbuntu 8.04LTS server using the default options (The VM specs are 2vcpu 16GB ram and a 120GB VMDK). I then ran through the process below to get ansible/AWX and of course Vmware SDK for Python installed. We have a number or requirements as we are running AWX in a docker (it should be noted that i prefer to put this in /opt but that a personal thing)

1
2
3
4
5
6
7
8
9
10
apt-add-repository --yes --update ppa:ansible/ansible
apt install ansible -y
apt install docker.io
apt install python-pip -y
pip install docker
pip install docker-composer
apt install nodejs npm -y
npm install npm --global
cd /opt
git clone https://github.com/ansible/awx.git

At this stage we can install AWX however if we were to use the default options the postgress data would be placed in /tmp which means it would be reset every reboot and we would loose out current configuration, as shown below I prefer to edit the inventory and put it to /opt/pgdocker. (again this is personal choice and you can put it anywhere you want)

1
2
3
4
5
cd /opt
mkdir pgdocker
cd awx/installer
edit inventory change postgres data files location to /opt/pgdocker
ansible-playbook -i inventory install.yml

You should now be able to visit http:\\(your servername) and login with a username of admin and a password of password

Next we want to install the VMware SDK for python and pyvmomi for ansible.

1
2
3
4
5
6
cd /opt
clone https://github.com/vmware/vsphere-automation-sdk-python.git
cd vsphere-automation-sdk-python
pip install --upgrade --force-reinstall -r requirements.txt --extra-index-url file:///opt/vsphere-automation-sdk-python/lib

pip install pyvmomi

Congrats you now have Ansible/AWX/Python all ready for working with Vsphere.

I will be doing an article covering some of the basics of using Ansible and VMware together in another post.

vExpert 2019

For the second year running I have been lucky enough to be awarded the VMware vExpert award. I’m proud of the contributions im able to make to this amazing virtualisation community. The vExpert list is constantly growing, and it’s amazing to continue to be part of this list of experts and community.

vExperts demonstrate significant contributions to the community and a willingness to share their expertise with others.

Export A Running VM From vCloud

Late last year i wrote about identifying chain linked VM’s within the vCloud environment, since then ive had to export a number of virtual machines from vCloud back to native vSphere.

For some of the process we need to use the ManagedBy.PS1 powershell script provided by VMware in this artice (its attached) https://kb.vmware.com/s/article/2032366

The script that i wrote to do this is below

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# Export VM script for vCloud (required ManagedBy Script from VMware)

# Variables for the vApp Decommission.
$disablespec = New-Object VMware.Vim.VirtualMachineConfigSpec
$disablespec.vAppConfigRemoved = $True

# Text file with list of VM's we want to export from vCloud
$vms = Get-Content "vms.txt"

Foreach ($vm in $vms) {

$vm = "$vm"

Write-Host "Cleaning UUID UP :" $vm
#Remove vCloud UUID settings in vmx configuration
Get-AdvancedSetting -entity "$vm" -Name cloud.uuid|Remove-AdvancedSetting

Write-Host "Unlinking VM from vCloud Management :" $vm
# Unlink managed by
Invoke-Expression -Command '.\ManagedBy.ps1 -Cmd Clear -VMs $vm'

Write-Host "Removing vApp Flag :" $vm
#Remove vApp Flag
$vm = Get-VM $vm | Get-View
$vm.ReconfigVM($disablespec)

}

This successfully cleans up the VM removing the UUID in advanced settings are un-linking it from vcloud, it also changes the VM from a vApp to a standard VM. What you will be left with is the same VM with a (UUID reference number after it). Should you wish to remove this UUID referance number you can do afterwards with the script below, however check your backup technology before hand as it may see the changes as a new system and remove your historical references.

1
2
3
4
5
6
7
8
9
10
11
# Same text file that was used for the vCloud Export
$vms = Get-Content "vms.txt"

Foreach ($vm in $vms) {

    $vm = "$vm"
    Write-Host "Current VM Name :" $vm
    $newvm = $vm.Substring(0, $vm.IndexOf('('))
    Write-Host "New VM Name :" $newvm
    Set-VM -VM $vm -Name $newvm
}

And that should be it.

Horizon Composer Install on Windows 2016 (Rollback Issue)

Interesting one today, installing horizon composer on a windows 2016 virtual machine. All the usual checks done for the ODBC settings etc, however constantly getting a rollback error message. After digging around in the logs i spotted error 1603., which after a quick check though the VMware knowledge base i found the following article https://kb.vmware.com/s/article/58887?lang=en_US Seems its a well know issue with thankfully a quick fix.

Power Down the virtual machine in question

Edit the virtual machine and disable Secure boot

Install Composer

Once installed shut down the virtual machine again

Re-enable secure boot.

 

So far its working for me.

vSphere 6.7 Update 1 Available

You have probably already seen this in the news already but vSphere 6.7 Update 1 has now released to download. Link Is below in case you need it:

vSphere 6.7 Update 1 Download Link

 

Also to get a bit more info on whats under the hood on the updated vSphere web client i would recommend the following:

https://blogs.vmware.com/vsphere/2018/10/fully-featured-vsphere-client-in-vsphere-6-7-update-1.html?src=so_5a314d05e49f5&cid=70134000001SkJn

https://docs.vmware.com/en/VMware-vSphere/6.5/rn/vsphere-client-65-html5-functionality-support.html

 

ISSUES

So far VEEAM is the only thing ive heard so far that has an issue: https://www.veeam.com/kb2784

New Release: PowerCLI 11.0.0

New version of  PowerCLI released version 11

Heres a brief breakdown of the updates included:

  • Added a new Security module
  • Added new cmdlets for Host Profiles
  • Added a new cmdlet to interact with NSX-T in VMware Cloud on AWS
  • Support for vSphere 6.7 Update 1
  • Support for NSX-T 2.3
  • Support for Horizon View 7.6
  • Support for vCloud Director 9.5
  • Multiplatform support for the Cloud module
  • Updated the Get-ErrorReport cmdlet
  • Removed the PCloud module
  • Removed the HA module

Dont forget its easy to update your powercli version (see below)

1
Update-Module VMware.PowerCLI

 

And finally heres a link to the vmware article with all the info

https://blogs.vmware.com/PowerCLI/2018/10/new-release-powercli-11-0-0.html

vCloud Identifying Chain Linked VM’s

Currently working on a project to decommission a very old non updated vcloud infrastructure for a customer who wants to move back to vsphere. They don’t really utilize the full vCloud feature set as it was put in as part of a larger project that never came to fruition.  Part of the first step should be to see what chain linked virtual machines we have, as if not when we attempt to migrate them away we are just going to give ourselves a world of pain. The PowerCLI below should identify all the virtual machines within the VDC’s and how long the chain length is.

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
if( (Get-Module -Name "VMware.VimAutomation.Cloud" -ErrorAction SilentlyContinue) -eq $null)

{Import-Module VMware.VimAutomation.Cloud}

Connect-CIServer -Server "your vcloud director fqdn" -ErrorAction Stop

$VApps = Get-CIVApp

Foreach($vapp in $VApps){

$vms = $vapp.ExtensionData.children.vm

foreach($vm in $vms){

$CL = $vm.VCloudExtension.any.VirtualDisksMaxChainLength

if($CL -gt 1){

$info = $vm.Name + " chain length=" + $CL

$info}

}}

PowerCli List HBA WWN’s

Whenever you get storage masked to your esxi node/cluster you always going to need to know what HBA WWN addresses are (assuming your using HBA not iSCSI etc) here is a quick powercli hba statement you can use to refresh your memory

 

For a cluster the following:

1
Get-Cluster clustername | Get-VMhost | Get-VMHostHBA -Type FibreChannel | Select VMHost,Device,@{N="WWN";E={"{0:X}" -f $_.PortWorldWideName}} | Sort VMhost,Device

 

And if you want to do a single host:

1
Get-VMhost -Name hostname| Get-VMHostHBA -Type FibreChannel | Select VMHost,Device,@{N="WWN";E={"{0:X}" -f $_.PortWorldWideName}} | Sort VMhost,Device

 

 

Perennial Reserved RDM’s

I got asked a couple of days about why an esxi server was taking roughly 45 mins to come back up after a reboot. Looking at the node when it eventually came back up showed that it had a number of RDM’s that were associated to virtual machines. Those virtual machines were mostly Windows RDM’s  used for MSCS. What was happening is that when esxi was booting it could see all theses luns and was trying to read the header, it was that delay in its attempts to read the header that was causing the 5 min boot time.

What was needed was to reserve those luns so that they were ignored on the boot scan. Using the powercli below we can define the target cluster, scan through the virtual machines within an identify all the raw devices and mark then as reserved.  It will then do this on each nodes in the cluster which reduced your boot time from say 45mins to a few minutes (depending on your hardware)

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
$TargetCluster = "Cluster Name"

$VMhosts = Get-Cluster $TargetCluster| Get-VMHost

$RDMDisks = Get-VM -Location $TargetCluster | Get-HardDisk -DiskType "RawPhysical","RawVirtual" | Select ScsiCanonicalName

foreach($VMhost in $VMhosts) {
Write-Host "Connected To Server : " $VMhost
$esxcli = Get-ESXCLI -VMHost $VMhost
foreach($RDMDisk in $RDMDisks) {
Write-Host "Setting Perennially Reserved On : " $RDMDisk
$esxcli.storage.core.device.setconfig($false, ($RDMDisk.ScsiCanonicalName), $true)
}
}

Studing For VCP6-NV (2V0-642) (UPDATE – I Passed ?)

Quick update i took the exam on Friday morning and happy to say passed with a score of 433 (300 is the pass mark).

Personally i think it was a tricky exam but not as difficult as i anticipated it to be, i used the references ive already mentioned before and bolstered it up with 2 pluralsight courses i got access to on a 6 month trial basis.

I’m not going to go into the question i was given but i would say if you follow the links ive provided and the VMware blueprint  you should be ok.

 

 

« Older posts