I’ve been doing a lot of work with the Release Candidate of System Center Orchestrator, so it’s always interesting to see what other orchestration products are capable of. I recently read a blog post on Creating Workflow Loops in vCenter Orchestrator and I was struck by just how complicated it is to do relatively simple tasks, with lots of really arcane syntax to work with.
It’s probably worth taking a look at how System Center Orchestrator would accomplish a similar task. First, we start with a new empty runbook. I’m going to use a text file as an input into the runbook, but we could just as easily prompt for user input, or even better store the list of servers to be patched in a change control record in a service desk system (of course it doesn’t have to be the Microsoft service desk, that’s one of the strengths of the Orchestrator platform).
We’re going to build a runbook that looks like this.
First we drag out a standard Read Line activity from the palette on the right from the Text File Management category. Then we’ll grab a Get VM List activity from the VMware vSphere. We can then join the two activities together by hovering over the activity, clicking the arrow that appears and then drag it to the next activity. We’ll repeat the process dragging out a Compare Values activity, and then finally a Take VM Snapshot activity. We’ve now built the structure of our runbook, and we can go about customising the activities.
First we’ll specify the text file to read in. Double click the Read Line activity, and you can enter the properties. I’ve used an ASCII format text file that just contains a list of VM Names, and the 1-END tells the activity to read from the first line to the end of the file.
The Get-VMList activity doesn’t need much customisation, it just needs to be told which vSphere connection to use (defined in the Runbook Designer under Options…VMware vSphere).
The Compare Values activity allows us to compare two text or numeric values – we are going to use this to match our list of VM’s to snapshot from the text file against the list of VM’s returned from vSphere. We’re going to use one of the real key features of Orchestrator, which is the concept of published data. Each activity preceding this one returns data onto the databus, and any activity following can take advantage of the published data. We’re going to use the Line Text returned from the Read Line activity, and the VM Names returned from the Get VM List activity. In the Test area, we right click and choose Subscribe…Published Data. We select from the drop down at the top the Read Line activity, and choose the Line Text option
We then right click in the pattern field and subscribe Published Data again, and choose the Get VM List activity.
We’ll end up with a Compare Values task that looks like this. (By default we do a text comparison, if you want to compare numbers, the general tab allows you to select that.)
We can then customise the Take VM Snapshot activity to customise the behaviour. Again, we’ll use some published data to identify which VM’s to snapshot. Up to now we’ve been working with VM names, but the snapshot activity actually requires a VM Path parameter – not to worry, the VM Path is returned along with the VM Name as part of the Get VM List published data.
The final step in the puzzle is to customise our link so that the snapshot task only runs for VM’s that match the list of VM’s in the text file. To do this, we double click the link object between the Compare Values & Take VM Shapshot activities. This brings up a dialog that allows us to set the conditions when we will execute the next step – by default it will proceed should the task succeed, but success in this case is simply that the task ran. We will change it by clicking the text that says “Compare Values” and select the Comparison result published data. We will then change the criteria to true by clicking the text that says value, and entering true in the popup.
The great thing about this runbook is that it will loop by itself, you don’t need to keep track of the loops (you might still want to maintain the state of the loop so you can restart the runbook should it strike an error) and without any strange syntax we’ve built an easy to understand & debug runbook. The looping was handled automatically as part of the runbook, and we performed a relatively complex text comparison very quickly.
Compare this to the vCenter Orchestrator example, and you’ll see that using System Center Orchestrator you’ll be up and running with your runbooks much faster.