Runbook as a Service Manager Console Task
I recently ran across the question of “How Can I Launch a Runbook from a Console Task?” in this forum thread:
I started thinking about how this could be useful in certain scenarios and how this would work. I decided to figure this out and blog about it so here it is. First you will need a tool that can connect to Orchestrators web service and start runbooks. There is such a tool called Orchestrator Remote Tools 2.51.
With this tool you also have the ability to discover information about runbooks on an Orchestrator server, pass parameters to the tool and see the status on if the runbook started successfully or failed. This tool has a GUI and command line interface.
This tool only discovers runbooks that have an “Initialize Data” activity. This tool launches runbooks looking to a generated .XML template with information about the runbook or it can launch runbooks directly without the XML template file (CLI mode only). for The tool consists of three components:
- UI Generator (ORTUIGenerator.exe): This is what discovers all your runbooks and allows you to browse them. You also use this component to generate the XML template files.
- Remote Runbook Launcher (ORTRunbookLauncher.exe): Is the graphical way to launch runbooks.
- Remote Runbook Launcher CLI (ORTRunbookLauncherCLI.exe): Is the command line way to launch runbooks.
You can learn more about the tool here:
It can be downloaded here:
Let’s work with the tool to prepare for using it with Service Manager. Create a share on your Service Manager management server. This can be something like \\SMSERVER\ORT\.
Copy the Orchestrator Remote Tools into it. You should have the following:
Now click on ORTUIGenerator.exe . You will see this popup message:
Click OK. This is telling you it is the first time you have run the tool and you need to put in your Orchestrator settings.
You will see the following window and will need to complete all the fields.
NOTE: Once you put in the data base server it will automatically pull in the Orchestrator database. If your SCORCH DB is not named Orchestrator you will be able to click the drop down and select it.
Click Save when you are done. Clicking Save will create a Config.xml file in your ORT directory.
Now the UI Generator window will pop up. This is the window you use to generate the .XML template file.
On the left hand side you are able to browse through the discovered runbooks. Keep in mind it only finds runbooks that have an “Initialize Data” activity. To configure the template for a runbook browse to it on the right hand side, select it and click the “Get details for the selected runbook” button. It will then expose the settings of the “Initialize Data” activity for the runbook on the right hand side. Here is where you can configure values for the parameters and give the runbook a description for those that will be running it. Note you are not required to configure values for the parameters. When you are ready to generate the .XML template click on the “Create Runbook Launcher configuration file” button.
You should now have a policy_template.xml in your ORT directory. By default when you run ORTRunbookLauncher.exe or ORTRunbookLauncherCLI.exe the policy_template.xml will be used allowing you to only have settings for one runbook at a time. You can elect to use another file by using the /ORTXML switch. What this does is allows you to store multiple XML templates in the same directory by different names and launch the specific one you want.
The /ORTXML switch only works using ORTRunbookLauncherCLI.exe as it is passed as a parameter. Another way around this if you are stuck on using the GUI component is to create multiple folders and put the exe’s, config file in each folder as it will have its own policy_template.xml file. That however could become a nightmare to manage and requires more space. I recommend using the /ORTXML switch.
Let’s look at the GUI component. In the ORT folder launch ORTRunbookLauncher.exe. The Runbook Launcher window will pop up. It should look similar to the following screenshot.
Input the parameters and click “Start Runbook” button.
It is that easy to remotely launch a runbook using this tool. Using the ORTRunbookLauncherCLI.exe is basically doing the same thing except it is running from a command line allowing you to pass in the values for the parameters right in the command. The syntax for starting a runbook using the ORTRunbookLauncherCLI.exe would look like this:
ORTRunbookLauncherCLI.exe /LastName=Sinatra /Location=”Building 45″ /Department=Sales /Title=”VP of Sales” /FirstName=Frank /SamAccount=Franks /”Reporting To”=”John Adams”
NOTE: If the parameters’ names or values have spaces, you need to enclose them using double quotes.
Ok, so now let’s combine the tool with Service Manager and its CMDB. Think about all the possibilities. There are a lot of useful scenarios in which these two could be utilized. A couple of possibilities I can think of off the top of my head are: Pass a user from Service Managers CMDB to this tool as a parameter and have a runbook disable a user in AD, pick up a computer from the CMDB pass it as a parameter to a runbook and move the computer from one OU to another in AD.
I don’t see this tool as a replacement for using Runbooks with Service Requests in Service Manager. I see this as more of a way to give the administrative team a quick and easy way to launch runbooks without ever leaving the Service Manager console.
Let’s look at how we can bring the Orchestrator Remote Tools and Service Manager together, create a console task and accomplish a task.
For this blog post we are going to use a very simple disable user runbook. To do this we need to create a console task using the ORT tool. Use the following steps to do this:
In the Service Manager console go to \Library\Library\Tasks on the right hand side under Tasks click on Create Task.
On the Create a Task window click Next on the first screen.
On the second screen give the task a name and description if you want. Select a Target class and select a management pack or create a new one.
I recommend storing this in a new management pack just for these ORT tasks.
NOTE: For this blog I selected the User CI for Target class. We are going to use this to pass to the runbook as a parameter.
On the next screen check a category or categories and click next. The category you select will determine where this console task will show in the Service Manager console.
On this next screen this is where things get exciting. This is where we put the command and the parameters for it.
We are going to use the ORTRunbookLauncherCLI.exe component and use CI data from the CMDB to pass as the value for the Username parameter to be passed over to the runbook.
First in the “Full path to command” field put in the UNC to the ORT share that we created earlier such as \\SMSERVER\ORT\ORTRunbookLauncherCLI.exe.
NOTE: The reason we made a share and set it up this way is so that we don’t have to copy the files local for every Service Manager console install.
Then in the “Parameters” field put in the following syntax:
/Username=” ” /ORTXML=Disable_User.xml
Highlight the space in between the quotes after /Username= and click the “Insert Property” button. A window will pop up with available classes and properties. Select a class and the property you want. For this blog post I selected User and Display Name.
Click the Add button and the syntax for the Display Name property should will be added in between the quotes after /Username=. It should look like this:
Notice we used the /ORTXML switch in the Parameters field. This switch points to a different .XML template named Disable_User.xml. This is what gives us the ability to use many .XML templates and have many console tasks using the ORT tool if we want to.
Make sure you put \\SMSERVER\ORT\ the “Working directory”. You need this because ORTRunbookLauncherCLI.exe will look in this directory for the .XML template.
Tick the “Show output when this task is run” checkbox. This will show you if the runbook starts successfully or if there are any issues.
The following screenshot visually breaks all this down. Click Next to move to the next screen.
On the Summary screen click Next to build the console task.
Once that is done navigate to \Configuration Items\Configuration Items\Users. You will see that the “Disable User Runbook” is now displayed as a console task under tasks on the right hand side of the console. Go ahead and click on a user in in the users list and click the new console task. A Console Task Output window for the Disable User Runbook will pop up and show you the status of the task as shown in the following screenshot.
- Created on .