What I want to achieve here is check the log file: 12-2017PM-PATCH.log
and find for the word COMPLETED in it and return to me the output for each server where I searched for the log.
What would be the syntax to put the search string in contains parameter and patterns parameter. Please please help me. I tried as below, need your guidance
-sh-4.1$ ansible-playbook ip360_mod_02042018.yml
SUDO password:
PLAY [all] *************************************************************************************************************************************************************
TASK [Gathering Facts]
*************************************************************************************************************************************************
ok: [10.54.38.37]
TASK [check the Logs to find if patching completed]
********************************************************************************************************************
ok: [10.54.38.37]
TASK [print matches]
***************************************************************************************************************************************************
ok: [10.54.38.37] => {
"msg": {
"changed": false,
"examined": 222,
"failed": false,
"files": [],
"matched": 0,
"msg": ""
}
}
PLAY RECAP
*************************************************************************************************************************************************************
10.54.38.37
: ok=3 changed=0
unreachable=0 failed=0
-sh-4.1$ cat ip360_mod_02042018.yml
---
- hosts: all
become: true
tasks:
- name: check the Logs to find if patching completed
find:
paths: "/var/log"
recurse: yes
follow: True
patterns: "*PATCH.*"
#use_regex: True
contains: "*COMPLETED*"
register: success_patch_logs
- name: print matches
debug:
msg: "{{ success_patch_logs }}"