one email for multiple hosts

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

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

Hi Racke,

This is my code

  • name: Sending email to about SSL scan
    mail:
    host: xxxxx
    port: 25
    body: xxxx
    to:

- xxxx

  • xxxx
    delegate_to: localhost
    run_once: true

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?

Hi…

Yes it is running in same playbook.

So, post that playbook

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

Hi, VGM

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

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

Yes…

No errors email sending included run one and delegate_to localhost

Thanks

So this mail task is part of that role?

Yes

I think run_once only works when in a playbook task. Not when it’s buried inside a role