Utilize Ansible for opening and closing tickets with ServiceNow - Part 2.

Opening and closing tickets is a very common step in network operations. This article is part two in a series covering the role Ansible can play in ticket automation. This time we’ll cover handling incidents in ServiceNow and adding output to your tickets right from your routers and switches.

You can see part one of this blog series here: Part 1

This blog will expand farther into the capabilities of the snow_record module. In the playbook below, the table parameter will determine what type of ticket will be opened ie.. change_request or incident etc…​ I have specified that at the top of the playbook under vars. The show version task is using the ios_command module to execute a command on a 3560 Cisco switch and storing the output as a variable named comments. This variable is then being used in the comments parameter for our ServiceNow incident task.

playbook

In an effort to use best practices, this time the ServiceNow incident task in our playbook will use variables for all of the parameters. The variables can be included in our playbook or a separate vars file. I use both options in this scenario. Because I’m storing passwords in incident_vars.yml, a good practice would be to encrypt this file using Ansible Vault.

incident_vars.yml

secrets

Playbook run

run

If you were to log into your instance of ServiceNow and view the incidents>all section. You should see your incident (INC0010029) at the top. You should notice that the short description has been filled out by our playbook task. (This is a test created by Ansible).

dashboard

You can see in the comments section the output from our show version command, notice the IOS version, model, as well as uptime of the device. You could run any command not just show version. I’m sure you can imagine what other data would be valuable to list inside your tickets.

notes

There is a lot of text from the show version command. Keep in mind, you can filter this output and only record the specific data points you want. This can be done with the ansible-network.network-engine role and custom parsers.

If your interested in learning more about parsers and the ansible-network.network-engine role. Stay tuned, I will go deeper into filtering the output in Part 3 of this series.

TheNetwork.Engineer - May 28 2018 - Colin McCarthy

Free DevOps Resources


Get DevOps news, tutorials and resources in your inbox. A perfect way If you want to get started with devops. Like you, we don't like spam.