Tuesday, February 4, 2020

Parsing output from parse genie - ansible

Hi all, I'm looking for some assistance parsing some output I'm getting from the parse genie module for Cisco. Please see my playbook below.

---
- name: Show interfaces
hosts: switches
gather_facts: no
connection: local
debugger: on_failed

vars_prompt:
  - name: "mgmt_username"
prompt: "Username"
private: no
  - name: "mgmt_password"
prompt: "Password"

tasks:

    - name: include parse genie role
include_role:
name: clay584.parse_genie

    - name: define provider
set_fact:
provider:
host: ""
username: ""
password: ""

    - name: show interfaces
ios_command:
provider: ""
commands: show interfaces description | ex SWAW
register: interface_description

    - name: set facts on interface_description
set_fact:
genie1: ""

My output looks like this

ok: [10.189.11.81] => {

"msg": {

"interfaces": {

"Ap1/0/1": {

"description": "",

"protocol": "up",

"status": "up"

},

"FortyGigabitEthernet1/1/1": {

"description": "",

"protocol": "down",

"status": "down"

},

"FortyGigabitEthernet1/1/2": {

"description": "",

"protocol": "down",

"status": "down"

},

"GigabitEthernet0/0": {

"description": "",

"protocol": "up",

"status": "up"

},

"GigabitEthernet1/0/1": {

"description": "",

"protocol": "down",

"status": "down"

},

"GigabitEthernet1/0/10": {

"description": "< TEST-ACCESS >",

"protocol": "down",

"status": "down"

},

I'm looking to just grab interface names such as "GigabitEthernet1/0/1" in my output so I can loop them into another task to make changes to those ports. Any thoughts on how to properly do that?



No comments:

Post a Comment