Hi,
I am new to this community and new ansible as so please excuse me of my
stupid mistakes.
referring to peter's webinar i am trying to collect device information
using reguler expressions.it seems it through me error as bellow:-
TASK [network_facts : set hostname fact]
********************************************************************************************************************
task path: /etc/ansible/roles/network_facts/tasks/ios.yaml:14
fatal: [8.8.8.8]: FAILED! => {
"msg": "Unexpected templating type error occurred on ({{
output.stdout[2] | regex_search('^hostname (.+)$', '\\\\1') | first }}):
'NoneType' object is not iterable"
}
fatal: [5.5.5.5]: FAILED! => {
"msg": "Unexpected templating type error occurred on ({{
output.stdout[2] | regex_search('^hostname (.+)$', '\\\\1') | first }}):
'NoneType' object is not iterable"
}
to retry, use: --limit @/etc/ansible/facts.retry
PLAY RECAP
**************************************************************************************************************************************************
5.5.5.5 : ok=2 changed=0 unreachable=0
failed=1
8.8.8.8 : ok=2 changed=0 unreachable=0
failed=1
i can confirm that ansible is able to login on the device and is able
excute the required commend to collect the information but it seems reguler
expression is not correct.
Here is my play book:
---
- name: collect device facts and display OS version
hosts: "{{ inventory | default('all') }}"
gather_facts: no
connection: local
roles:
- { role: network_facts }
tasks:
- debug: msg="Node {{ hostname }} is type {{ device_os }} running
software version {{ version }}"
================================================================================
below is task yml file:-
---
- name: collect output from ios device
ios_command:
commands:
- show version
- show interfaces
- show running-config
provider: "{{ ios_provider }}"
register: output
# common facts
#
- name: set hostname fact
set_fact: hostname="{{ output.stdout[2] | regex_search('^hostname (.+)$',
'\\1') | first }}"
- name: set interfaces fact
set_fact: interfaces="{{ output.stdout[1] |
regex_findall('^[L|G|A|B|C|D||M|N|P|T|V]\\S+') }}"
- name: set version fact
set_fact: version="{{ output.stdout[0] | regex_search('Version (\\S+),',
'\\1') | first }}"
- name: set config fact
set_fact: config="{{ output.stdout[2] }}"
- name: set config_lines fact
set_fact: config_lines="{{ config.split('\n') }}"
Regards/Surjeet
--
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/d674db41-aaaf-400d-99a6-1282c156de10%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.