Hi,

You should use the line in file module, only specify the path and line. 
This way it will append it to the file.

Op donderdag 27 juli 2017 02:08:53 UTC+2 schreef Vijay Misra:
>
>
>   Hi ,
>
>    I am trying to use ansible as a test tool. at the end of each 
> sucess/faiure i want to append a string at the end of a file and this file 
> can be used as a test report.
> i Have tried this code but it did not log anything in the file.
>
> - debug: msg="HPQC Create snapshot of a vGPU VM on ESX"
>   when: taskresult|succeeded
> - debug: msg="HPQC Failed Create snapshot of a vGPU VM on ESX"
>   when: taskresult|failed
>
>
> - shell: echo "HPQC Passed Create snapshot of a vGPU VM on ESX" >> results.txt
>   when: taskresult|succeeded
> - shell: echo "HPQC Failed Create snapshot of a vGPU VM on ESX" >> results.txt
>   when: taskresult|failed
>
>
>   when i run with -vvvv switch, I get the following output but nothing is 
> appended in the file locataed at /etc/ansible/ directoery( I am running 
> playbook from /etc/ansible directory)
>
>  
> changed: [] => {
>     "changed": true, 
>     "cmd": "echo \"HPQC Passed Create snapshot of a vGPU VM on ESX\" >> 
> results.txt", 
>     "delta": "0:00:00.017046", 
>     "end": "2017-07-27 00:07:14.100974", 
>     "invocation": {
>         "module_args": {
>             "_raw_params": "echo \"HPQC Passed Create snapshot of a vGPU VM 
> on ESX\" >> results.txt", 
>             "_uses_shell": true, 
>             "chdir": null, 
>             "creates": null, 
>             "executable": null, 
>             "removes": null, 
>             "warn": true
>         }
>     }, 
>     "rc": 0, 
>     "start": "2017-07-27 00:07:14.083928", 
>     "stderr": "", 
>     "stderr_lines": [], 
>     "stdout": "", 
>     "stdout_lines": []
> }
>
> TASK [ESX_VM_SnapRestore : command] 
> ************************************************************************************************************************************************************************
> task path: /etc/ansible/roles/ESX_VM_SnapRestore/tasks/main.yml:41
> skipping: [1] => {
>     "changed": false, 
>     "skip_reason": "Conditional result was False", 
>     "skipped": true
> }
>
> Thanks for your help.
>
> -VM
>
>

-- 
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/ae9c331d-18c8-420c-8d9e-6126b4fbf615%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to