Itential Automation Gateway

Using Automation Gateway with Ansible’s Network Modules

Overview

An Easy Way to Explore, Test, & Run Ansible’s Library of Network Modules

Whether you’re a Network Practitioner who is just starting the Network Automation journey, or you’ve been down this path for some time (and have the scars to prove it), you’re probably aware of the fact that Ansible is a very popular network automation tool. Today, there are over 60 network-specific modules available that cover all of the major network vendors. These modules handle the work of speaking natively to a network device, typically using CLI as the underlying method, and captures and formats the output so it can be used in a more programmatic way. This accomplishes a lot of the heavy lifting of automation over CLI, especially compared to tools of the past or writing your own code to do this.

Another reason Ansible has become widely used in network automation is that it doesn’t require users to be programmers in order to start using existing Playbooks or building them from scratch. While it doesn’t require a programming background, it does still have a significant barrier to entry in learning YAML, the framework that it uses for playbooks, and the structures and formats required to build complex Ansible playbooks and Roles.

If you’re getting started in network automation, you’re probably asking some of these questions:

  • Is there an easy way for myself, and my team, to get started with Ansible networking modules?
  • Is there an easy way to explore Ansible Networking Modules?
  • Is there an easy way to test and run them without writing an entire playbook?

In Automation Gateway, we have a tightly coupled integration with Ansible and we have made all of the network modules available within the platform in an easy way to explore, test, and run. It makes for a perfect way for new users to network automation to understand Ansible network modules and experienced Ansible users to test different module functions without iterating overbuilding and modifying playbooks.

View Available Ansible Modules

First, let’s take a look at all of the Ansible modules available in Automation Gateway.

  • On the left side, click on Ansible and you’ll see several categories, select Modules

You’ll see a list of over 60 network modules, from different vendors. These are categorized by network OS name, and you can click on a vendor OS directly, or use the Search function to narrow down the selections.

  • Search for ios and click the ios category to see a list of modules available.

Understanding the Default Decoration

Under the category of “ios”, you will see a list of all the related ios networking modules, prefixed with ios_. If you click on any of these modules, you will notice that any required inputs have been pre-defined, so that they can be executed directly from the Automation Gateway instead of the command line. In Ansible, most networking modules have an entry that returns a set of facts about the device–typically items like software version, model, serial number, etc.
  • Click on ios_facts-Read through the Parameter Descriptions to see what the module requires as inputs

Running an Ansible Module from IAG

Now that we understand decorating a module, we can run a module directly and see how it all works.

  • At the top of the main window, Click on Execute tab
  • Under “Hosts” you can enter the hostname of a Cisco IOS device in your Ansible inventory. Here we use “CORE-ATL-0″.
  • In the “gather_subset” section, click on the + sign to add a row
  • In that row, enter “default”, which tells the module to send us all of the default information about the device.
  • Finally, click “Run” at the bottom

Without writing a playbook to leverage the module, we were able to run it directly from within Automation Gateway and get the facts about this Cisco ios device. In the output, you’ll notice that multiple variables are set with the facts of the device. These variables are prefixed with “ansible_net_” and would be available within a playbook. You can also see the status of the call (SUCCESS) and various other information that can be easily used programmatically.

These parameters are defined by a JSON Schema, and the process of creating this JSON Schema to define the required parameters needed for any automation asset in IAG is called “decorating” the asset. Itential creates a default decoration for Ansible modules, so that they can be directly executed in the application, or even through an API.

  • To see the JSON Schema for this module, click on the “Edit” button in the main window.
  • When you are finished viewing the decoration, click “Cancel”
[
{
"module": "ios_facts",
"task": "ios_facts",
"host": "CORE–ATL–0",
"status": "SUCCESS",
"argument_warnings": null,
"results": {
"ansible_facts": {
"ansible_network_resources": {},
"ansible_net_gather_network_resources": [],
"ansible_net_gather_subset": [
"default"
],
"ansible_net
_system": "ios","ansible_net_model": "CSR1000V",
"ansible_net_image": "bootflash:packages.conf",
"ansible_net_version": "03.16.04a.S",
"ansible_net_hostname": "CORE–ATL–0",
"ansible_net_api": "cliconf",
"ans
ible_net_python_version": "3.6.8",
"ansible_net_iostype": "IOS–XE",
"ansible_net_serialnum": "92QN4DDHCQA"
},
"warnings": [
],
"changed": false
}
}
]

Run an Ansible Module from an API

As we mentioned earlier, once an automation asset is decorated in Automation Gateway, it can be made available through an API call. We can test this within the application and see how it would work.

  • First, click on the 3 horizontal lines in the upper left corner and select “API Documentation-2.0”
  • Scroll down the new window until you see the section labelled “Modules”
  • Click on the entry “Execute a module”
  • Click on “Try it out.”
  • Edit Module Parameters and input a JSON module that has the required hostname and default argument, as defined by the previous decoration
  • Specify the module name to execute, as it appears in the list: ios_facts
  • Click the “Execute” button and scroll down to look at the output, which can now be used via an API call through Automation Gateway

As you can see, by leveraging your library of existing Ansible assets with Itential’s Automation Gateway, networking teams gain a powerful way to quickly learn about Ansible network modules, test them, and publish them without the need for building existing playbooks. And as your team creates more playbooks, these assets can be organized, shared and published across the team as well. If you’re interested in how to do that, we cover that here:

Know Your Network. Automate Your Network.

Get Started with Itential Today.