On 21.07.2016 10:11, Kai Stian Olstad wrote:
On 21.07.2016 09:32, ishan jain wrote:
- I do not have extensive knowledhe of jinja2 templates and seems like
i
will have to learn a few things to create a report template
It will be rewarding in the end, you can do a lot of things with
jinja2 and templates.
Had some spare time at lunch and wrote a mockup to show one way to
accomplish this.
*Playbook:*
---
- hosts: all
tasks:
- name: Check if reboot is needed
stat: path=/var/run/reboot-required
register: need_reboot
- name: Generate report
template:
src=report.j2
dest=report.txt
deletate_to: localhost
run_once: true
*report.j2:*
Check 1 need reboot
{% for i in play_hosts | sort %}
{{ i }}: {{ hostvars[i]['need_reboot']['stat']['exists'] |
ternary('Yes', 'No') }}
{% endfor %}
Check 2 swap used
{% for i in play_hosts | sort %}
{{ i }}: {{ hostvars[i]['ansible_memory_mb']['swap']['used'] }} MB
{% endfor %}
Not tested, so bug can exist.
--
Kai Stian Olstad
--
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 ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/d1e8a602765e2fb114e8abb60e3a903b%40olstad.com.
For more options, visit https://groups.google.com/d/optout.