【问题标题】:parse_cli_textfsm filter requires TextFSM library to be installedparse_cli_textfsm 过滤器需要安装 TextFSM 库
【发布时间】:2020-04-16 17:34:00
【问题描述】:

我正在尝试在我正在编写的剧本中使用 Textfsm。

- name: PLAY1 - Gather Data
  hosts: cisco_ios_switches
  gather_facts: False

  tasks: 
    - name: Get CDP Facts
      ios_command:
        commands:
        - show cdp nei details
      register: cdp_nei_output

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

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

每次我运行 playbook 时都会收到错误消息。 {"msg": "parse_cli_textfsm 过滤器需要安装 TextFSM 库"}

我已经完成了 Textfsm 的 pip 安装。 我正在使用 Centos。

解释器设置为 [全部:变量] ansible_python_interpreter="/usr/bin/python3"

ansible.cfg 包含

interpreter_python = /usr/bin/python
gathering = explicit
inventory = inv.yml
retry_files_enabled = False
host_key_checking = False
filter_plugins = plugins/filter/
log_path = /var/log/ansible.log
library = /home/XXXXXXX/ansible-dev/modules 
action_plugins = ../napalm_ansible/plugins/action```

Textfsm is installed in modules directory.
Ansible is running inside a virtualenv.

ansible 2.9.5
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/home/XXXXXX/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3.6/site-packages/ansible
  executable location = /usr/bin/ansible
  python version = 3.6.8 (default, Nov 21 2019, 19:31:34) [GCC 8.3.1 20190507 (Red Hat 8.3.1-4)


【问题讨论】:

    标签: python ansible centos python-textfsm


    【解决方案1】:

    问:“”parse_cli_textfsm 过滤器需要安装 TextFSM 库”

    A:安装 Centos 包python-textfsm。我猜是 pip 没有正确设置路径。

    【讨论】:

    • 我在搜索说明后尝试安装centos包。我将文件下载到本地下载目录,然后运行以下命令。 rpm –i python-textfsm-0.3.2-9.el8.src.rpm 我似乎只是得到了使用信息。然而一个
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-05-13
    • 1970-01-01
    • 2021-04-06
    • 2014-02-25
    • 2017-12-20
    • 1970-01-01
    相关资源
    最近更新 更多