I tried Shell module too like below but it actually serach for vm*.log
file instead of all the vm.log files.
- name: Check whether vmware log file contains TDR
shell: grep 'TDR_DUMP' '{{guest_vm_path}}/{{item}}/vmware*.log'
with_items:
- '{{guest_list}}'
- '{{guest_name_poweredon}}'
ignore_errors: True
register: output
TASK [ESX_TDR_DUMP : debug]
*******************************************************************************************************************
ok: [xxxxx] => {
"output": {
"changed": true,
"failed": true,
"msg": "One or more items failed",
"results": [
{
"_ansible_item_result": true,
"_ansible_no_log": false,
"_ansible_parsed": true,
"changed": true,
"cmd": "grep 'TDR_DUMP'
'/vmfs/volumes/mag27_datastore/test1/vmware*.log'",
"delta": "0:00:00.021120",
"end": "2017-10-14 07:45:12.942906",
"failed": true,
"invocation": {
"module_args": {
"_raw_params": "grep 'TDR_DUMP'
'/vmfs/volumes/mag27_datastore/test1/vmware*.log'",
"_uses_shell": true,
"chdir": null,
"creates": null,
"executable": null,
"removes": null,
"warn": true
}
},
"item": "test1",
"rc": 2,
"start": "2017-10-14 07:45:12.921786",
"stderr": "grep:
/vmfs/volumes/mag27_datastore/test1/vmware*.log: No such file or directory",
"stderr_lines": [
"grep: /vmfs/volumes/mag27_datastore/test1/vmware*.log: No
such file or directory"
],
"stdout": "",
"stdout_lines": []
},
{
"_ansible_item_result": true,
"_ansible_no_log": false,
"_ansible_parsed": true,
"changed": true,
"cmd": "grep 'TDR_DUMP'
'/vmfs/volumes/mag27_datastore/test2/vmware*.log'",
"delta": "0:00:01.024557",
"end": "2017-10-14 07:45:14.937439",
"failed": true,
"invocation": {
-VM
On Saturday, October 14, 2017 at 7:35:10 AM UTC-7, Kai Stian Olstad wrote:
>
> On 14. okt. 2017 08:57, Vijay Misra wrote:
> > I have to search for a pattern string in the various log files located
> in
> > some directory on the host. how we can use regex kind of a thing with
> > command module or may be some other useful ansible way i am not aware
> about.
> >
> > here is my code which complains about vm*.log.
>
> command module is not running a shell so shell expansion like vm*.log
> will not work, you need to use the shell module.
>
> You could also do this with the find module.
>
>
> --
> 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 [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/34be2551-b1b9-464f-8dfe-74f04f7f0263%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.