As I said , the documentation is about what your trying to do :
https://github.com/ansible-network/network-engine/blob/devel/docs/user_guide/command_parser.md,
but on show interfaces with a loop, not on a specific interface.
For your example, without loop, It should be something like this (not
tested) :
1°) playbook
hosts: Branch
gather_facts: false
connection: local
tasks:
- name: Facts
ios_command:
commands:
- show inter gi0/0
register: output
- command_parser:
file: "parser_templates/ios/show_interfaces.yaml"
content: "{{ output.stdout.0 }}"
- debug:
var: input_rate.matches
- debug:
var: output_rate.matches
2°) content of the template:
---
- name: parser meta data
parser_metadata:
version: 1.0
command: show interfaces <>
network_os: ios
- name: match input rate
pattern_match:
regex: "^ 5 minute input rate ([^,]+),"
register: input_rate
export: yes
- name: match output rate
pattern_match:
regex: "^ 5 minute output rate ([^,]+),"
register: output_rate
export: yes
value registered are regex group, in (), each group is stored in matches
dot is number.
command_parser read line by line and if the regex match, store the result
in a var than you can use in playbook only if you use export:yes.
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/fd0ba4f2-156a-4e5a-bec7-6f46e8e9cfa6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.