I'm not a big expert on Syntax, but try changing the debug Task to this:
- name: Debug
debug: var=myEcho.stdout
I have a similar thing in one of my playbooks and it works. I hope this
helps.
On Monday, 12 October 2015 15:14:03 UTC+2, Doron Shai wrote:
>
> Hi All,
>
> I am new to ansible, and i have a script which i use on many hosts.
>
> The command i execute is
>
>
> *ansible-playbook main.yml -i hosts*
>
>
> here is my code in the main.yml
>
>
> *---*
>
> *- hosts: group*
>
> * sudo: true*
>
> * user: root*
>
>
> * tasks:*
>
> * - name: Clean logs*
>
> * script: Clean.sh*
>
> * register: myEcho*
>
>
> * - name: Debug*
>
> * debug: msg="{{ myEcho.stdout_lines }}"*
>
>
> Here is the script that i execute using the Ansible task:
>
> *echo '====================== cb-backend-00 ======================'*
>
> *echo '======================== CleanLogsOld ========================='*
>
> *du -h /opt/test/logs/logs.old/ --max-depth=0*
>
> *if ls /opt/test/logs/logs.old/* 1> /dev/null 2>&1; then*
>
> * echo "There are files under the Old Logs Folder"*
>
> * rm -rf /opt/test/logs/logs.old/**
>
> *else*
>
> * echo "====== No Files exist under the Old Logs folder"*
>
> *fi*
>
> *exit*
>
>
> Here is the output that i get:
>
> *PLAY [group]
> ******************************************************************** *
>
>
> *GATHERING FACTS
> *************************************************************** *
>
> *ok: [20.152.30.10]*
>
>
> *TASK: [Clean BVT]
> ************************************************************* *
>
> *changed: [20.152.30.10]*
>
>
> *TASK: [Debug]
> ***************************************************************** *
>
> *ok: [20.152.30.10] => {*
>
> * "msg": "[]"*
>
> *}*
>
>
> *PLAY RECAP
> ******************************************************************** *
>
> *20.152.30.10 : ok=3 changed=1 unreachable=0
> failed=0 *
>
>
>
> What do i miss? Why I can not see all the echo commands that I wrote?
>
> Thanks,
> Doron
>
--
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/a15206f9-b529-4f26-83af-5508a01edbe6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.