This blog post was originally posted on the ShapeBlue website: http://www.shapeblue.com/recovery-of-vms-to-new-cloudstack-instance
We recently came across a very unusual issue where a client had a major security breach on their network. As well as lots of other damage their CloudStack infrastructure was maliciously damaged beyond recovery. Luckily the hackers hadn’t manage to damage the backend XenServer hypervisors so they were quite happily still running user VMs and Virtual Routers, just not under CloudStack control. Read More
I recently did a talk on CloudStack / CloudPlatform, zero touch VMware ESXi / Citrix XenServer builds and Ansible automation at the Glasgow Virtualisation User Group meeting. Great day, lots of useful information from end users and vendors, as well as some interesting cloud and virtualisation discussions. Thanks to Mike, Brendon and Gavin for the invite, was good to catch up.
Slide deck up on Slideshare:
Cloudmonkey is distributed with Apache CloudStack, and allows for command line configuration of CloudStack resources – i.e. configuration of zones, networks, pods, clusters as well as adding hypervisors, primary and secondary storage.
Using an Ansible playbook to run CloudMonkey isn’t necessarily a good idea – writing a proper shell script with it’s own variable input will allow for much more dynamic configuration – Ansible doesn’t offer proper scripting capabilities after all.
Anyway, the following playbook will configure a CloudStack zone, adding pod, cluster, hypervisors and storage.
Pre-reqs as follows:
As with any Ansible playbook the CloudStack playbook is fairly self explanatory and self-documenting. In short the following will install Apache CloudStack version 4.3 or 4.4 with all required components as well as CloudMonkey for later configuration.
The playbook is written for CentOS base OS for all roles, with CloudStack using XenServer hypervisors and NFS storage.
The playbook relies on tags to separate the various tasks and roles, these are as follows:
Quick followup on the previous build script posts. In short the following will write host specific config files based on spreadsheet data, writing to files based on hostname in column 1 – in the following example “xs62cn1.cfg”.
So, in short, a spreadsheet with the following entries:
will result in a new config file xs62cn1.cfg with the following entries:
'Exports spreadsheet data to config files
Dim intCol, intRow, arrHeaders(), intMaxcols, strOutputbuffer, objFSO, strFilename, arrFilename, objFile
intRow = 2
intCol = 1
Set objFSO = CreateObject("Scripting.FileSystemObject")
While Cells(1, intCol) <> ""
ReDim Preserve arrHeaders(UBound(arrHeaders) + 1)
arrHeaders(intCol - 1) = Cells(1, intCol)
intCol = intCol + 1
intCol = intCol - 1
intMaxcols = intCol
While Cells(intRow, 1) <> ""
strFilename = Left(Cells(intRow, 1), InStr(Cells(intRow, 1), ".") - 1) & ".cfg"
Set objFile = objFSO.CreateTextFile(strFilename, True)
For intCol = 1 To intMaxcols
strOutputbuffer = strOutputbuffer & arrHeaders(intCol - 1) & "=" & Chr(34) & Cells(intRow, intCol) & Chr(34) & ";" & Chr(10)
strOutputbuffer = ""
intRow = intRow + 1
MsgBox "All done"
Scripted builds for Xenserver 6.2 is outlined in http://support.citrix.com/servlet/KbServlet/download/34970-102-706044/installation.pdf. Xenserver build scripts run in the bash shell so are a bit more flexible than in ESXi. The following scripts allow for host specific dynamic zero touch builds – mainly for larger environments but can be used for any number of hosts.
All files discussed in this post can be found on https://github.com/dagsonstebo/Citrix-Xenserver-6.2-zero-touch-build-scripts.
PXE boot process
The PXE boot process for Xenserver builds is as follows:
- Host is PXE booted from pxelinux.cfg menu, each host specific menu entry specifies host specific XML answer file.
- Host specific XML answer file specifies hostname and post build script.
- Post build script preloads actual build script, patches and drivers as well as host specific configuration file.
- Upon reboot build script configures host.
I.e. for each host we require a XML answer file and a host configuration file.
The menu config for Xenserver 6.2 is as follows:
LABEL XS62CN1 Xen 6.2
append xenserver62/xen.gz dom0_max_vcpus=1-2 dom0_mem=752M,max:752M \
com1=115200,8n1 console=com1,vga --- xenserver62/vmlinuz xencons=hvc \
console=hvc0 console=tty0 answerfile=http://192.168.0.100/xs62cn1.xml \
-answerfile install --- xenserver62/install.img
The answer file specifies (see install guide for all options):
- Install location
- Keyboard mapping
- Install file location
- Root password
- Post install script
- NIC used during installation