From 7e1acfccdd9cab4969258ff1148dbece27e50a8b Mon Sep 17 00:00:00 2001 From: Kirill Malgichev Date: Tue, 7 Feb 2023 10:11:20 -0500 Subject: [PATCH 1/3] Fixing list_of_mail_to list generation The list_of_mail_to list (which is used for TO: filed for SMTP) is generated as: "to": "[] + [ 'name@domain.com' ]", , which causes problems with SMTP servers that are strictly follows RFC. This commit updating list_of_mail_to generation, so the final result should look like: "to": [ "name@domain.com", "first.last@domain.com" ], --- .../notifications/email-notify-list-of-users.yml | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/playbooks/notifications/email-notify-list-of-users.yml b/playbooks/notifications/email-notify-list-of-users.yml index 6636bcc00..bcec87fd1 100644 --- a/playbooks/notifications/email-notify-list-of-users.yml +++ b/playbooks/notifications/email-notify-list-of-users.yml @@ -3,6 +3,9 @@ - name: "Send HTML e-mail message (based on MD) to a list of users" hosts: mail-host gather_facts: no + vars: + list_of_mail_to: [] + tasks: - include_vars: file: "{{ email_content_file }}" @@ -14,9 +17,11 @@ markdown_content: "{{ body }}" - set_fact: mail: "{{ mail | combine({ 'subject': title, 'body': md_to_html.html_body_message }) }}" + - set_fact: - list_of_mail_to: "{{ list_of_mail_to | default([]) }} + [ '{{ item.email }}' ]" - with_items: - - "{{ list_of_users }}" + list_of_mail_to: "{{ list_of_mail_to | d([]) + [ item.email ] }}" + loop: "{{ list_of_users }}" + when: list_of_users is defined + - include_role: name: notifications/send-email From 60caa4d3cbc83628f041628675c746bdae3e8980 Mon Sep 17 00:00:00 2001 From: Kirill Malgichev Date: Wed, 8 Feb 2023 07:43:07 -0500 Subject: [PATCH 2/3] Minor updates after code review --- playbooks/notifications/email-notify-list-of-users.yml | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/playbooks/notifications/email-notify-list-of-users.yml b/playbooks/notifications/email-notify-list-of-users.yml index bcec87fd1..d37f28739 100644 --- a/playbooks/notifications/email-notify-list-of-users.yml +++ b/playbooks/notifications/email-notify-list-of-users.yml @@ -3,9 +3,6 @@ - name: "Send HTML e-mail message (based on MD) to a list of users" hosts: mail-host gather_facts: no - vars: - list_of_mail_to: [] - tasks: - include_vars: file: "{{ email_content_file }}" @@ -17,11 +14,8 @@ markdown_content: "{{ body }}" - set_fact: mail: "{{ mail | combine({ 'subject': title, 'body': md_to_html.html_body_message }) }}" - - - set_fact: - list_of_mail_to: "{{ list_of_mail_to | d([]) + [ item.email ] }}" - loop: "{{ list_of_users }}" - when: list_of_users is defined + list_of_mail_to: "{{ list_of_mail_to | default([]) + [ item.email ] }}" + loop: "{{ list_of_users|flatten(levels=1) }}" - include_role: name: notifications/send-email From 76db808dd6f198fdf4d200e76ff4313d55d4d558 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=98ystein=20Bedin?= Date: Thu, 9 Feb 2023 05:01:01 -0700 Subject: [PATCH 3/3] Update email-notify-list-of-users.yml --- playbooks/notifications/email-notify-list-of-users.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/playbooks/notifications/email-notify-list-of-users.yml b/playbooks/notifications/email-notify-list-of-users.yml index d37f28739..0a65378f1 100644 --- a/playbooks/notifications/email-notify-list-of-users.yml +++ b/playbooks/notifications/email-notify-list-of-users.yml @@ -14,8 +14,8 @@ markdown_content: "{{ body }}" - set_fact: mail: "{{ mail | combine({ 'subject': title, 'body': md_to_html.html_body_message }) }}" + - set_fact: list_of_mail_to: "{{ list_of_mail_to | default([]) + [ item.email ] }}" loop: "{{ list_of_users|flatten(levels=1) }}" - - include_role: name: notifications/send-email