Need Help with writing ansible playbook

30 views
Skip to first unread message

Отель Элеон

unread,
Oct 20, 2017, 12:19:09 AM10/20/17
to Ansible Project
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 <ip address>
command <df -h>
SendToEmail <emails...>
thank you and have a nice day!

Ken Jenney

unread,
Oct 20, 2017, 1:11:08 AM10/20/17
to Ansible Project
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" us...@domain.com
```
If you really wanted to waste your time you could include mailx in a playbook as a local_action.
Reply all
Reply to author
Forward
0 new messages