【发布时间】:2020-02-25 22:58:53
【问题描述】:
我有一个正则表达式可以匹配某个单词之后的所有内容。当我在剧本中调用此 pattern_match 时,出现以下错误:
*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 }}"
【问题讨论】:
-
我从未听说过用于 ansible 的
pattern_match模块,我现在的搜索没有收集到任何结果。看起来您的本地 ansible 安装也不知道该模块。你是从哪里得到这个例子的?您确定您没有丢失库文件夹中某个角色提供的自定义模块吗? -
这是我找到的一个例子 - termlen0.github.io/2018/07/15/observations
-
也来自 Ansible - 来自 Ansible - github.com/ansible-network/network-engine/blob/devel/docs/…
-
我又读了一遍,哈。看起来使用 pattern_match 的唯一方法是调用一个单独的文件,该文件从你的 playbook 中运行 IOS 命令并调试输出(或写入新文件)。现在正在处理这个问题。
标签: parsing networking ansible cisco ansible-galaxy