one email for multiple hosts

160 views
Skip to first unread message

Raj

unread,
Oct 13, 2021, 4:13:03 PM10/13/21
to Ansible Project
Hi All,

I am trying to send one email to team after job is successfully completed.  Issue is playbook sending (if inventory have 100 servers ). It is sending 100 emails.

I tried in my code:  delegate_to: localhost and run_once: true it doesn't help please provide your inputs it really helpful .

TIA
Raja  

Stefan Hornburg (Racke)

unread,
Oct 14, 2021, 1:28:05 AM10/14/21
to ansible...@googlegroups.com
That should work. Please provide your code.

Regards

           Racke

>
> TIA
> Raja
> --
> 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-proje...@googlegroups.com <mailto:ansible-proje...@googlegroups.com>.
> To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/b69b5eb1-7de3-4bce-80fd-2ca824fd07a0n%40googlegroups.com <https://groups.google.com/d/msgid/ansible-project/b69b5eb1-7de3-4bce-80fd-2ca824fd07a0n%40googlegroups.com?utm_medium=email&utm_source=footer>.


--
Ecommerce and Linux consulting + Perl and web application programming.
Debian and Sympa administration.

OpenPGP_0x5B93015BFA2720F8.asc
OpenPGP_signature

Raj

unread,
Oct 14, 2021, 9:12:24 AM10/14/21
to Ansible Project

Hi Racke,

This is my code

- name: Sending email to about SSL scan
  mail:
    host: xxxxx
    port: 25
    subject: xxxx
    body:  xxxx
    from: xxx
    to:
   # - xxxx
    - xxxx
  delegate_to: localhost
  run_once: true

Dick Visser

unread,
Oct 14, 2021, 10:21:19 AM10/14/21
to ansible...@googlegroups.com
This is just the one mail task. 
It must be part of a playbook, where other things happen as well, and which will reveal the cause.

Also, you say "I am trying to send one email to team after job is successfully completed".
I guess this "job" is the running of the playbook?




To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/f662886f-2a63-4988-a2b7-e15a4dfbfd16n%40googlegroups.com.


--
Dick Visser
Trust & Identity Service Operations Manager
GÉANT

Raja Natte

unread,
Oct 14, 2021, 11:03:33 AM10/14/21
to ansible...@googlegroups.com
Hi..


Yes it is running in same playbook. 

Dick Visser

unread,
Oct 14, 2021, 11:09:29 AM10/14/21
to ansible...@googlegroups.com

Stefan Hornburg (Racke)

unread,
Oct 14, 2021, 11:16:47 AM10/14/21
to ansible...@googlegroups.com
On 14/10/2021 15:12, Raj wrote:
>
> Hi Racke,
>
> This is my code
>
> - name: Sending email to about SSL scan
>   mail:
>     host: xxxxx
>     port: 25
>     subject: xxxx
>     body:  xxxx
>     from: xxx
>     to:
>    # - xxxx
>     - xxxx
>   delegate_to: localhost
>   run_once: true

The mail module apparently doesn't check its parameters. For example "from" is going to be ignored, as the correct parameter is "sender". Please double check your indentation. "run_once" should be working.

Regards

     Racke



> On Thursday, October 14, 2021 at 1:28:05 AM UTC-4 ra...@linuxia.de wrote:
>
> On 13/10/2021 22:13, Raj wrote:
> > Hi All,
> >
> > I am trying to send one email to team after job is successfully completed.  Issue is playbook sending (if inventory have 100 servers ). It is sending 100 emails.
> >
> > I tried in my code:  delegate_to: localhost and run_once: true it doesn't help please provide your inputs it really helpful .
>
> That should work. Please provide your code.
>
> Regards
>
>            Racke
>
> >
> > TIA
> > Raja
> > --
> > 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-proje...@googlegroups.com <mailto:ansible-proje...@googlegroups.com>.
> > To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/b69b5eb1-7de3-4bce-80fd-2ca824fd07a0n%40googlegroups.com <https://groups.google.com/d/msgid/ansible-project/b69b5eb1-7de3-4bce-80fd-2ca824fd07a0n%40googlegroups.com> <https://groups.google.com/d/msgid/ansible-project/b69b5eb1-7de3-4bce-80fd-2ca824fd07a0n%40googlegroups.com?utm_medium=email&utm_source=footer <https://groups.google.com/d/msgid/ansible-project/b69b5eb1-7de3-4bce-80fd-2ca824fd07a0n%40googlegroups.com?utm_medium=email&utm_source=footer>>.
>
>
> --
> Ecommerce and Linux consulting + Perl and web application programming.
> Debian and Sympa administration.
>
> --
> 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-proje...@googlegroups.com <mailto:ansible-proje...@googlegroups.com>.
> To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/f662886f-2a63-4988-a2b7-e15a4dfbfd16n%40googlegroups.com <https://groups.google.com/d/msgid/ansible-project/f662886f-2a63-4988-a2b7-e15a4dfbfd16n%40googlegroups.com?utm_medium=email&utm_source=footer>.
OpenPGP_0x5B93015BFA2720F8.asc
OpenPGP_signature

Raj

unread,
Oct 22, 2021, 10:09:01 AM10/22/21
to Ansible Project
Hi, VGM

my playbook call roles  ssl scan  ( final part is email to send once)  but it is sending 100 emails

---
- hosts: "{{ web }}"
  gather_facts: yes
  roles:
    - SSL_scan

Stefan Hornburg (Racke)

unread,
Oct 22, 2021, 10:19:17 AM10/22/21
to ansible...@googlegroups.com
On 22/10/2021 16:09, Raj wrote:
> Hi, VGM
>
> my playbook call roles  ssl scan  ( final part is email to send once)  but it is sending 100 emails

Did you ever check the indentation on your task sending email as advised?

delegate_to should really work.

Regards

            Racke
> > To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/b69b5eb1-7de3-4bce-80fd-2ca824fd07a0n%40googlegroups.com <https://groups.google.com/d/msgid/ansible-project/b69b5eb1-7de3-4bce-80fd-2ca824fd07a0n%40googlegroups.com> <https://groups.google.com/d/msgid/ansible-project/b69b5eb1-7de3-4bce-80fd-2ca824fd07a0n%40googlegroups.com?utm_medium=email&utm_source=footer <https://groups.google.com/d/msgid/ansible-project/b69b5eb1-7de3-4bce-80fd-2ca824fd07a0n%40googlegroups.com?utm_medium=email&utm_source=footer>>.
>
>
> --
> Ecommerce and Linux consulting + Perl and web application programming.
> Debian and Sympa administration.
>
> --
> 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-proje...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/f662886f-2a63-4988-a2b7-e15a4dfbfd16n%40googlegroups.com <https://groups.google.com/d/msgid/ansible-project/f662886f-2a63-4988-a2b7-e15a4dfbfd16n%40googlegroups.com?utm_medium=email&utm_source=footer>.
>
>
>
> --
> Dick Visser
> Trust & Identity Service Operations Manager
> GÉANT
> --
> 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-proje...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CAL8fbwNz4ToNKCBngPbHOtB4%3D%3DHbFvx%3DTCJ6%3D4CL-kSrgvrDUA%40mail.gmail.com <https://groups.google.com/d/msgid/ansible-project/CAL8fbwNz4ToNKCBngPbHOtB4%3D%3DHbFvx%3DTCJ6%3D4CL-kSrgvrDUA%40mail.gmail.com?utm_medium=email&utm_source=footer>.
>
> --
> 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-proje...@googlegroups.com.
>
> To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CA%2BuTAOgXB1y_ATqNWBtRXxNyVuysaVA8gBp3Scx8cJKFAR-nBA%40mail.gmail.com <https://groups.google.com/d/msgid/ansible-project/CA%2BuTAOgXB1y_ATqNWBtRXxNyVuysaVA8gBp3Scx8cJKFAR-nBA%40mail.gmail.com?utm_medium=email&utm_source=footer>.
>
>
>
> --
> Dick Visser
> Trust & Identity Service Operations Manager
> GÉANT
>
> --
> 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-proje...@googlegroups.com <mailto:ansible-proje...@googlegroups.com>.
> To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/5442881b-a03f-4997-aa38-bbf4a8d623den%40googlegroups.com <https://groups.google.com/d/msgid/ansible-project/5442881b-a03f-4997-aa38-bbf4a8d623den%40googlegroups.com?utm_medium=email&utm_source=footer>.
OpenPGP_signature

Raja Natte

unread,
Oct 22, 2021, 12:46:56 PM10/22/21
to ansible...@googlegroups.com
Yes..

No errors email sending included run one and delegate_to localhost

Thanks

Dick Visser

unread,
Oct 22, 2021, 1:55:49 PM10/22/21
to ansible...@googlegroups.com
So this mail task is part of that role?


--
Sent from a mobile device - please excuse the brevity, spelling and punctuation.

Raja Natte

unread,
Oct 22, 2021, 1:56:34 PM10/22/21
to ansible...@googlegroups.com

Dick Visser

unread,
Oct 22, 2021, 2:17:47 PM10/22/21
to ansible...@googlegroups.com
I think run_once only works when in a playbook task. Not when it's buried inside a role 

Reply all
Reply to author
Forward
0 new messages