Ansible AWX and TEXTFSM

16 views
Skip to first unread message

Richard Lucht

unread,
Jan 11, 2021, 10:00:00 AM1/11/21
to Ansible Project
Hello,

I have been having some great success with TextFSM and Python.  I am now trying to use it in Ansible.

I have installed the ntc-templates onto my server running ansible awx and when I run this demo script I get this error:

    "msg": "parse_cli_textfsm filter requires TextFSM library to be installed",
    "_ansible_no_log": false

I have verified that the templates folder does exist in this location 

---
- name: "PLAY 1: DEMO OF TEXTFSM"
  hosts: all
  connection: network_cli
  gather_facts: no
  vars:
      ansible_network_os: ios
  tasks:
    - name: "TASK 1: GET COMMAND OUTPUT"
      ios_command:
        commands:
          - show lldp neighbors
      register: lldp_output

    - name: "TASK 2: REGISTER OUTPUT TO DEVICE_NEIGHBORS VARIABLE"
      set_fact:
        device_neighbors: "{{ lldp_output.stdout[0] | parse_cli_textfsm('~/ntc-templates/templates/cisco_ios_show_lldp_neighbors.textfsm') }}"

    - name: "TASK 3: PRINT OUTPUT"
      debug:
        msg: "{{ device_neighbors }}"

    - name: "TASK 4: PRINT NEIGHBORS"
      debug:
        msg: "{{ item['LOCAL_INTERFACE'] }}: {{ item['NEIGHBOR'] }}"
      loop: "{{ device_neighbors }}"
      loop_control:
        label: "{{ item['LOCAL_INTERFACE'] }}"
Reply all
Reply to author
Forward
0 new messages