Parsing Ansible中cisco iosxr命令运行模式匹配时出现问题
我有一个正则表达式,它匹配某个单词后面的所有内容。当我在剧本中调用此模式匹配时,我得到以下错误:Parsing Ansible中cisco iosxr命令运行模式匹配时出现问题,parsing,networking,ansible,cisco,ansible-galaxy,Parsing,Networking,Ansible,Cisco,Ansible Galaxy,我有一个正则表达式,它匹配某个单词后面的所有内容。当我在剧本中调用此模式匹配时,我得到以下错误: *ERROR! no action detected in task. This often indicates a misspelled module name, or incorrect module path. The error appears to be in '/etc/ansible/REGEX.yml': line 12, column 6, but may be elsewhere
*ERROR! no action detected in task. This often indicates a misspelled module name, or incorrect module path.
The error appears to be in '/etc/ansible/REGEX.yml': line 12, column 6, but may
be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:*
show int bundle-ether 21 | inc clearing
- name: get time
^ here
代码如下:
---
- hosts: SCRING
gather_facts: true
connection: network_cli
tasks:
- name: show int | inc clearing
iosxr_command:
commands:
show int bundle-ether 21 | inc clearing
- name: get time
pattern_match:
regex: "(?<=counters ).*$"
export: yes
register: last
- debug:
msg: "{{ inventory_hostname }} counters last cleared - {{ last }}"
---
-主持人:涂鸦
收集事实:真实
连接:网络\u cli
任务:
-名称:show int | inc清算
iosxr_命令:
命令:
显示int bundle ether 21 | inc清除
-姓名:获取时间
模式匹配:
regex:(?我怀疑“command”的语法有问题。你能试试下面的方法吗
commands: show int bundle-ether 21
或
在第二次尝试中为命令添加了连字符(-)。我能够通过创建单独的yaml文件进行解析来运行该命令
见下文:
- name: parser meta data
parser_metadata:
version: 1.0
command: show int bundle-ether 20 | inc clearing
network_os: iosxr
- name: get time
pattern_match:
regex: "(?<=counters ).*$"
match_all: yes
register: last
export: yes
AND
---
- hosts: SCRING
gather_facts: false
connection: network_cli
roles:
- ansible-network.network-engine
tasks:
- name: show int | inc clearing
iosxr_command:
commands:
- show int bundle-ether 20 | inc clearing
register: clearing
- name: PARSE
command_parser:
file: "parser_templates/last_cleared.yml"
content: "{{ clearing.stdout[0] }}"
- debug:
msg: "{{ inventory_hostname }} counters last cleared - {{ last }}"
-名称:解析器元数据
parser\u元数据:
版本:1.0
命令:显示int bundle ether 20 | inc清除
网络操作系统:iosxr
-姓名:获取时间
模式匹配:
正则表达式:“(?我从未听说过ansible的pattern_match
模块,我现在的搜索没有收集到任何结果。看起来您的本地ansible安装也不知道该模块。您从何处获取此示例?您确定没有丢失库文件夹中某个角色提供的自定义模块吗?此处是我找到的例子之一,也是Ansible中的,Ansible中的,我又读了一遍,哈。看来使用模式匹配的唯一方法是调用一个单独的文件,从你的playbook中进行解析,运行IOS命令并调试输出(或写入新文件).现在正在做这件事。不幸的是,这两件事都不走运。同样的错误。
- name: parser meta data
parser_metadata:
version: 1.0
command: show int bundle-ether 20 | inc clearing
network_os: iosxr
- name: get time
pattern_match:
regex: "(?<=counters ).*$"
match_all: yes
register: last
export: yes
AND
---
- hosts: SCRING
gather_facts: false
connection: network_cli
roles:
- ansible-network.network-engine
tasks:
- name: show int | inc clearing
iosxr_command:
commands:
- show int bundle-ether 20 | inc clearing
register: clearing
- name: PARSE
command_parser:
file: "parser_templates/last_cleared.yml"
content: "{{ clearing.stdout[0] }}"
- debug:
msg: "{{ inventory_hostname }} counters last cleared - {{ last }}"