Hello guys i have a really little experience working with ansible, but today my boss told me that i should write ansible playbook for checking disk space in the production machines
we have a 15 machines and i want to enter each of them, then execute the ‘df -h’ command, then send output to the email.
can you give me a template of this playook? like this
host
command <df -h>
SendToEmail <emails…>
thank you and have a nice day!
I think you’re overthinking it. If you need a script to regularly get disk utilization ansible is overkill at best. You could use pssh to accomplish the same thing. The email part of this is a separate beast altogether.
ansible all -i inventory/your-machines -a "df -h" > output.txt
mailx -a output.txt -s "Disk Report" user@domain.com```
If you really wanted to waste your time you could include mailx in a playbook as a local_action.