Itential Automation Gateway

Take Your Ansible Playbooks to the Next Level

Overview

Enables Network Teams to Organize, Share, & Run Ansible Playbooks for Network Automation

Ansible has become a very popular tool for networking teams to learn to use because of its support for a wide variety of network modules from the top vendors in the industry. These network modules handle the work of interfacing with a network device, normally using the command line interface, and include the underlying logic of ensuring the intended command was executed and formatting the output in a more programming-friendly presentation. Writing the underlying code to accomplish these functions is not trivial, and having this heavy lifting already done allows network practitioners, who may not have a programming background, to get started building network-centric automations in Playbooks.

As more and more network practitioners turn to automations, like Ansible Playbooks, as part of their standard tools for daily work, it becomes a challenge to share and publish these valuable assets to the larger networking team.

  • How can we create a library of common network automation Playbooks that the team can explore?
  • How can I share my network Playbook with a colleague and make sure it’s the latest version?
  • Is there a way to make a network automation Playbook available as a self service API?

In order to overcome this challenge, Itential’s Automation Gateway provides a perfect platform for network teams, with members at any Ansible experience level to organize, share, and run their Ansible Playbooks from a secure application. Members can explore the library of Playbooks and view their contents to understand exactly how they work, and even run them across test or live environments. Network automation needs to be more widely understood and utilized so moving assets like Playbooks into a dedicated platform that the entire networking team can access is an important step in your network automation journey.

Onboard & View Your Playbooks

By onboarding your Ansible Playbook into Itential’s Automation Gateway, it will be organized and made available in the application to other members of your team. Your colleagues can open the Playbook and examine it to help understand how it works, and even safely test it in a lab environment.

In Automation Gateway, you can quickly view the available library of Ansible Playbooks.

  • On the left side, click “Ansible”
  • Under the Ansible category, click “Playbooks”
  • View the list of Playbooks under the main section

If you click on one of the available playbooks, you will see several tabs available. Most of us will want to see what the contents of a Playbook looks like, especially if you’re just starting out with network automation. Doing this is easy in Automation Gateway, as we will see.

  • Click on a playbook, “ios-show-ver” is what we use in our example.
  • Click on the “Playbook” tab at the top of the screen
  • View the contents of the Playbook file, and see what makes it tick!
You’ll notice that the playbook uses the network CLI to pass a command to a Cisco ios device. In this case, the command line is a simple “show version”, which makes for a straightforward and simple example. After that, the output of the “show version” command is displayed. The Playbook specifies that this will be run across all devices in the inventory, but when it’s run in Automation Gateway, we can define a single host (or list of hosts) to run a Playbook against, which is great for testing in a lab environment.
#ansible-playbook -i inventory.yml ios-show-ver.yml
---
- connection: network_cli
  gather_facts: no
  hosts: all

  tasks:
    - name: show ver
      register: result
      ios_command:
        commands:
          - command: show version

    - name: print result
      debug: 
        var: result.stdout_lines

Running an Ansible Playbook from IAG

Let’s Execute this example script and see the output.

  • Click on the “Execute” tab at the top
  • Under “Hosts”, enter the full or partial hostname of a device in the Ansible inventory. Automation Gateway federates your Ansible device inventory and automatically makes those names available in this field.
  • At the bottom, click the “Run” button

Reviewing the Output

In a moment, you will see the output from the Playbook on the screen. It’s important to highlight a few items from this output. The output is formatted as a JSON object, which makes it much easier for a program to parse through. For comparison, look at the value of the “stdout” key, which is the entire output in a single line. Now look at the value of the “stdout_lines” key, which is the same text, but separated into a line by line array of strings. Notice that even a simple formatting change like this makes parsing through large amounts of data much better for applications and programs. Also notice that the key named “status” provides a direct way to check whether the command was executed correctly.

These may seem like small details, but they are important to understand as we start using more and more network automations and integrating them into other systems. For instance, if we wanted to allow another program or system to have access to this Playbook, we could make it available through a RESTful API. The program accessing the API will receive output in a JSON object (as we’ve seen), and can then make use of that data. This forms the basis for publishing Playbooks externally to enable Self-Service network automations.

Run the Playbook from an API

We can test the ability to Execute a Playbook through an API within Automation Gateway.

  • Click the 3 lines, and select API-Documentation 2.0
  • In the API Documentation window, scroll down to the section titled “Playbooks”
  • Click on the entry that says “Execute a playbook”
  • Then click on “Try it out”
  • Edit the “Playbook Parameters” section to enter the correct parameter for a host. In this case, let’s use the “CORE-ATL-0″ as the network device hostname.
  • Under “Playbookname” enter the name of the playbook (ios-show-ver)
  • Click “Execute”

With Itential’s Automation Gateway, network teams have an application where they can create a growing library of Network Automation Playbooks and foster a culture of collaboration, which will multiply the benefits of network automation.

Scroll down a bit further in the API Documentation window and look at the responses. If everything worked, you will see the script’s output in the sectionlabelled 200, which is a successful response code, and you will see a JSON object with similar output as we saw earlier.

If there were any errors, they will populate in the 400, 404, or 500 sections, which are error response codes. If you receive one of these errors, you may need to check “Playbook parameters” section and verify the “Playbook name” was entered correctly.

Know Your Network. Automate Your Network.

Get Started with Itential Today.