Here is the part 4 of System Center 2012 Orchestrator Runbook concept series.
In this blog post we’ll start to cover designing basic and complex runbooks.
Orchestrator lets you to configure conditions with Smart Links. Smart Links connect individual activities in a runbook and support precedence between two activities.
Also as soon as previous activity finishes, these links invoke next activity. Best part is you can set link conditions to determine the direction of workflow.
For example you can monitor a folder and trigger next activity for each changed and deleted files within that folder. At this situation, you can split in two your workflow to configure separated activities for changed and deleted triggers. For example;
If monitor file activity notices a change event, then smart link will redirect entire workflow through upside activities.
If monitor file activity notices a delete event, then smart link will redirect flow through downside activities.
Look at the simple design;
For such a scenario, here are the basic configuration steps;
Monitor File activity monitors C:Test folder for
Changed and Deleted items.
If you click first link;
you’ll notice that link will invoke next activity (Append Line) if Monitor File activity returns Success value. Please note that this is the default value for each Smart Link.
Include tab specifies conditions that enable data to flow to the next activity.
Exclude tab specifies the conditions that cause data to be excluded from the next activity. By default if an activity fails, link will not invoke next activity.
Also on Options tab you can configure link width and color. This is important for especially complex runbooks to highlight failover scenarios.
Trigger Delay sets the number of seconds that you want the smart link to wait before invoking the next step in the runbook.
In this runbook example, Append Line activity is not a mandatory, you can carry changed and deleted values from monitor activity to the links directly. But i just used it to show up triggered events.
It appends a line to the C:Status.txt file with a value of Change Type from Monitor File activity.
Publishing data is also covered in my following article:
Now here is the magic starts. Click to Smart link to set a custom condition.
I want to set a condition as Status.txt from Append Line activity has a line of “Changed”. This provides that link will invoke next activity (Send Event Log Message) if specified condition is true.
Same condition for other smart link. This provides that link will invoke next activity (Send Email) if specified condition is true.
So if I change any file within C:Test folder, smart link condition will redirect flow through the upper link and send an event log.
Let’s test with RunBook Tester.
Monitor file checks for changed and deleted files in C:Test
I changed a file within C:Test folder and saved it.
Orchestrator triggers the change and hops to the next activity.
Append Line activity appends “Changed” string to the status.txt file.
Now only matched link condition will continue on its way.
As you see below, Send Event Log Message is invoked by the upper smart link.
Here is the log file created by Orchestrator.
Because filtering in smart links is based on published datas from previous activities, you can also use smart link conditions with PowerShell based runbooks.
Here is an another example. It simply reads a text file to get required links. Then it checks for links with Select-String cmdlet and directs flow to the related side. Rest of workflow is about copying files to the remote servers and deleting source downloaded files.
Read Line activity just reads two lines.
Links.txt file includes two different URL to download filea or fileb from Internet.
To find out which link (FileA or FileB) is provided within txt file, I wrote a little custom PowerShell script.
It scans text file and search for DownloadfileA or DownloadFileB strings. If there is a line that includes one of those strings, (not null), StatusA or StatusB variables get filea or fileb values.
To pass these variable values to the next activity and links, simply configure them as Published Data.
Now I can tell to my smart links that to filter only for StatusA and StatusB static values.
Finally, if there is a URL in Links.txt file that has a string “downloadfilea”, smart link will redirect flow through upper activities. For links that includes downloadfilea string will flow through below activities.
Before finishing blog post, final important activity is Junction. It allows you to wait for multiple branches in a runbook to complete before continuing past the junction.
Junction activity can also publish data again from any branch so that downstream activities past the Junction activity can consume the data. Data from different branches than the one you selected will not be available