Thanks Brian for the reply, I will try the same and get back to you.
On Tue, Mar 23, 2021 at 9:26 PM Brian Coca <[email protected]> wrote: > You can modify the mail task to send per group: > > - name: send mail to chetan > mail: > host: relay.services > port: 25 > from: [email protected] > to: "{{web_email}}" > subject: uptime for {{item}} > body: |- > {% for server in group_names[item] %} > {% if hostvars[server]['up_time.stdout'] | default (0) > |int >= 5 %} > {{ server }} - {{"has"}} > {{hostvars[server]['up_time.stdout'] }} {{"days uptime. Consider > rebooting for better performance"}} > {% endif %} > {% endfor %} > become: no > loop: ['lab', 'web', 'db'] > delegate_to: localhost > run_once: true > > Another way, in you existing play change: > > hosts: '{{target|default("all")}}' > > And create new play: > inorder.yml > > - import_playbook: send_mail.yml > vars: > target: lab > > - import_playbook: send_mail.yml > vars: > target: web > > - import_playbook: send_mail.yml > vars: > target: db > > > -- > ---------- > Brian Coca > > -- > You received this message because you are subscribed to a topic in the > Google Groups "Ansible Project" group. > To unsubscribe from this topic, visit > https://groups.google.com/d/topic/ansible-project/0E7YoyU2LoM/unsubscribe. > To unsubscribe from this group and all its topics, send an email to > [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/ansible-project/CACVha7fK7eaF5gdqZJxG6gVqZa92rC3Pju5n4x70AaQJeAuYpQ%40mail.gmail.com > . > -- 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 view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CAFV88bYNbtO4tD9GR7%3DiK7djpUUJEeEvzG4cfv8mFwsEzwy2pg%40mail.gmail.com.
