Quantcast
Channel: Service Management Automation – Trond's Working!
Viewing all articles
Browse latest Browse all 9

A finished example of “smart” SMA runbook publishing

$
0
0

UPDATE 24.09.2014: I got some feedback on these posts regarding SMA and publishing using PowerShell, which pointed me to SMART, which is a collection of scripts for doing various SMA-related things. SMART has it’s own publish-to-SMA script, which you of course can use instead of mine. There’s a couple of things I don’t like so much with SMART; firstly that it expects you to store runbooks inside xml files. From a developer perspective, that’s a step in the wrong direction IMHO. We’re trying to get away from XML, not run towards it. Also, the SMART import scripts simply publish everything twice (as far as I can see) in order to get around the need to publish everything in the right order. You are of course free to use whichever method you’d like, but I prefer the one I’m outlining here. It’s lighter weight, stays true to PowerShell and it’s way way faster. Whichever you choose, the important thing is to end up with a process where you can get your runbooks into source control, not who wrote the script. All is good!

In case you read my last blog post, here is some example code in a more finished form.

To demonstrate, this is my folder of runbooks I’d like to publish:
2014-09-22 17_15_38-wftest

The structure is the same as I used in my previous post, so here is the required order in which to publish these runbooks:
sma2

So, let’s test this thing. This is what happened on the first run:
2014-09-22 17_12_38-Windows PowerShell ISE

Since none of the runbooks were already in SMA, each of them got published. If you note the line beginning with “PUBLISH” you’ll see that the script did everything in the required order.

If I just run everything again, the script won’t publish anything, as every runbook is already published:
2014-09-22 17_12_59-Windows PowerShell ISE

Now, the hard part: I’ve made a sligth adjustment to the wf3 runbook file. This should cause my script to update wf3, but also notify wf1 and wf5 that they need to get updated, since they reference wf3. Again, this seems to work as it should:
2014-09-22 17_21_55-Windows PowerShell ISE

Note that wf3, and then wf1 and wf5 are published.

So there. I ‘m happy with this, and hopefully it will provide you with some value as well. Youc an wire up this script inside a CI server or simply run it against your own folder structure containing your runbooks whenever you’ve made an update. Happy automating!

Here’s the script containing the required functions:
https://gist.github.com/trondhindenes/d6133106c30cb7d5b922


Viewing all articles
Browse latest Browse all 9

Trending Articles