python - parse_cli_textfsm 过滤器需要安装 TextFSM 库

标签 python ansible centos python-textfsm

我正在尝试在我正在编写的剧本中使用 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 }}"

每次我运行剧本时,我都会收到错误消息。
{"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)


最佳答案

Q: ""parse_cli_textfsm filter requires TextFSM library to be installed"



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

关于python - parse_cli_textfsm 过滤器需要安装 TextFSM 库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61246701/

相关文章:

python - 在 python 中使用 notify-send 显示多行通知

python - Pandas - 如何删除包含少于标题的字段的行

python - 向 XBMC-Plugin 添加上下文菜单

ansible - 在循环中注册多个变量

apache - 如何在 Centos 中为所有项目设置通用的一个 Nginx 服务器 block (虚拟主机)

php - 在 CentOS 中升级到 PHP 7 禁用 SimpleXML mod

python - 如何根据 pandas 或 numpy 中的条件从数组中提取值?

ansible - 创建并使用组,无需重启

kubernetes - ansible验证k8s部署成功

python - mod_wsgi 测试 wsgi 运行良好,应用程序给出 HTTP 500