Utilize Ansible for opening and closing tickets with ServiceNow - Part 3.
This article is part three in a series covering the role Ansible can play in ticket automation. This time we’ll cover parsing the command output data your adding to your tickets.
In the last blog we had a lot of text from the show version command end up in our ticket.
We can filter this output and only record the specific data points we choose. This can be done with the ansible-network.network-engine role and custom parsers. In this blog we are going to use this specific parser show_version.yaml from the network-engine github repo.
You will structure your repo like this
On line 48 of show_version.yaml you can find the name of the dictionary we need to use in our debug.
The parser takes the command output and creates a dictionary. The data points you want to use later in your playbook, are now parameters of system_facts.
What I would like to do is add some fields in the ServiceNow change_request template, then add the version and uptime to every change request Ansible creates.
In ServiceNow this is done under Configure > Form Layout.
You can see below that I have added two new fields IOS Version & Device Up Time.
If we take a look at a snippet of the record dictionary the ServiceNow API sends back, it now has the the two new fields. "u_device_up_time" & "u_ios_version"
We can use these new fields in the data section of our snow_record module. Here is a complete playbook that will run the show version command, parse the output and add the parameters into the new fields for us.
The new fields are now populated in our ServiceNow change request.
If you’re interested in learning more, stay tuned for Part 4 of this series. We will continue to build a framework for fully automating our network tickets.
TheNetwork.Engineer - July 8 2018 - Colin McCarthy