[Playbook]
---
- hosts: all
connection: local
gather_facts: no
tasks:
- name: Take infos
ios_command :
host: "{{ ansible_host}}"
username: xxxxx
password: xxxxxx
timeout: xxxx
commands:
- show version
- exit
register: result
- name: get output
copy:
content: "{{ result.stdout_lines[0] | join('\n') }}"
dest: "resultat/{{ ansible_host }}.txt"
- name: check version
shell: ./verif.sh
[output]
Cisco Identity Services Engine Patch
---------------------------------------------
Version : xxxx
Install Date : xxxxxxxxx
Cisco Identity Services Engine Patch
---------------------------------------------
Version : xxxxxxxx
Install Date : xxxxxxx
verif.sh:
grep 'Version : x' resultat/$1.txt
if [ "$?" = "0" ]
then
echo "$1 --> OK" >> resultat/resultat.txt
else
echo "$1 --> KO" >> resultat/resultat.txt
fi
Actually I just want to check that the line Version 5 for example exists in my.txt file without going through a script. And by the way it's a CISCO ISE