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