parse_cli_textfsm筛选器需要安装textfsm库

2024-09-27 17:41:55 发布

您现在位置:Python中文网/ 问答频道 /正文

我正试图在我正在写的剧本中使用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 filter需要安装textfsm库”}

我已经完成了Textfsm的pip安装。 我用的是Centos

解释器设置为 [全部:vars] ansible_python_解释器=“/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)



Tags: namelogmodulesfalsebinusrpluginsneighbors

热门问题