Re: [ansible-project] Set up a check for the patching logs in the nodes
On 03.04.2018 07:48, Shreela Roy wrote: Hi All, 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 I saw I wrote file module when I meant find module back in March, sorry about that. --- - 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 }}" The contains: is regex so you need to use ".*COMPLETED.*" -- Kai Stian Olstad -- 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 ansible-project+unsubscr...@googlegroups.com. To post to this group, send email to ansible-project@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/b9bb1367ca8c3597eaf1b7d8b0156001%40olstad.com. For more options, visit https://groups.google.com/d/optout.
Re: [ansible-project] Set up a check for the patching logs in the nodes
Hi All, 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=3changed=0unreachable=0failed=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 }}" On Friday, 23 March 2018 17:32:31 UTC+5:30, Shreela Roy wrote: > Hi Kai/Team, > > Can you give me a small example of using file module for matching strings > in the file? > > On Tuesday, 20 February 2018 23:24:39 UTC+5:30, Kai Stian Olstad wrote: > >> On Tuesday, 20 February 2018 18.38.06 CET Shreela Roy wrote: >> > I am running an ansible playbook for patching the nodes from the >> control >> > server. I want to set up a check which would check for the word >> COMPLETED >> > in the file: >> > >> > something like: >> > /var/log/12-2017PM-PATCH.log| grep -o COMPLETED >> > >> > But cannot find the way out for checking each of the nodes and then if >> > successfully finds the word COMPLETED would reboot the servers one by >> one. >> > and leaves the server where its not completed. >> >> You can use file module, it has the option contain that will search for a >> string in the file. >> Register the output from find and then check that matched == 1 >> >> >> -- >> Kai Stian Olstad >> > -- 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 ansible-project+unsubscr...@googlegroups.com. To post to this group, send email to ansible-project@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/0908a9a7-76cc-42a8-8f8f-96e2b3b1e91f%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [ansible-project] Set up a check for the patching logs in the nodes
Hi Kai/Team, Can you give me a small example of using file module for matching strings in the file? On Tuesday, 20 February 2018 23:24:39 UTC+5:30, Kai Stian Olstad wrote: > On Tuesday, 20 February 2018 18.38.06 CET Shreela Roy wrote: > > I am running an ansible playbook for patching the nodes from the control > > server. I want to set up a check which would check for the word > COMPLETED > > in the file: > > > > something like: > > /var/log/12-2017PM-PATCH.log| grep -o COMPLETED > > > > But cannot find the way out for checking each of the nodes and then if > > successfully finds the word COMPLETED would reboot the servers one by > one. > > and leaves the server where its not completed. > > You can use file module, it has the option contain that will search for a > string in the file. > Register the output from find and then check that matched == 1 > > > -- > Kai Stian Olstad > -- 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 ansible-project+unsubscr...@googlegroups.com. To post to this group, send email to ansible-project@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/26dd522f-a886-4ebd-be00-00d0a4b3cd89%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [ansible-project] Set up a check for the patching logs in the nodes
On Tuesday, 20 February 2018 18.38.06 CET Shreela Roy wrote: > I am running an ansible playbook for patching the nodes from the control > server. I want to set up a check which would check for the word COMPLETED > in the file: > > something like: > /var/log/12-2017PM-PATCH.log| grep -o COMPLETED > > But cannot find the way out for checking each of the nodes and then if > successfully finds the word COMPLETED would reboot the servers one by one. > and leaves the server where its not completed. You can use file module, it has the option contain that will search for a string in the file. Register the output from find and then check that matched == 1 -- Kai Stian Olstad -- 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 ansible-project+unsubscr...@googlegroups.com. To post to this group, send email to ansible-project@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/1913122.pErsx49Mmo%40x1. For more options, visit https://groups.google.com/d/optout.
[ansible-project] Set up a check for the patching logs in the nodes
I am running an ansible playbook for patching the nodes from the control server. I want to set up a check which would check for the word COMPLETED in the file: something like: /var/log/12-2017PM-PATCH.log| grep -o COMPLETED But cannot find the way out for checking each of the nodes and then if successfully finds the word COMPLETED would reboot the servers one by one. and leaves the server where its not completed. -- 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 ansible-project+unsubscr...@googlegroups.com. To post to this group, send email to ansible-project@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/d56517dc-89af-49e1-a78c-8ba473ae1d7d%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.