forked from infra/ansible
communishift: add ability to dry run notification sender
Signed-off-by: David Kirwan <davidkirwanirl@gmail.com>
This commit is contained in:
parent
7522b50a64
commit
9f15813840
2 changed files with 21 additions and 2 deletions
|
|
@ -5,6 +5,9 @@
|
|||
# Run notifications only:
|
||||
# ansible-playbook .../communishift_send_email_notifications.yml --tags communishift_send_notifications
|
||||
#
|
||||
# Dry run (FASJSON + per-project preview, no SMTP mail):
|
||||
# ansible-playbook .../communishift_send_email_notifications.yml --tags communishift_send_notifications -e communishift_email_notifications_dry_run=true
|
||||
#
|
||||
- hosts: localhost
|
||||
user: root
|
||||
gather_facts: false
|
||||
|
|
@ -34,7 +37,7 @@
|
|||
|
||||
- name: Summary of Communishift projects notified # noqa: run-once[task]
|
||||
ansible.builtin.debug:
|
||||
msg: "{%- set ns = namespace(names=[]) %}{%- for item in communishift_projects | dict2items | sort(attribute='value.name') %}{%- if not (item.value.do_not_delete | default(false)) %}{%- set _ = ns.names.append(item.value.name) %}{%- endif %}{%- endfor %} Communishift notification run complete. Emails were sent for {{ ns.names | length }} project(s): {{ ns.names | join(' ') }}"
|
||||
msg: "{%- set ns = namespace(names=[]) %}{%- for item in communishift_projects | dict2items | sort(attribute='value.name') %}{%- if not (item.value.do_not_delete | default(false)) %}{%- set _ = ns.names.append(item.value.name) %}{%- endif %}{%- endfor %} {% if communishift_email_notifications_dry_run | default(false) %}Communishift notification dry run complete (no email sent). Would notify {{ ns.names | length }} project(s): {{ ns.names | join(' ') }}{% else %}Communishift notification run complete. Emails were sent for {{ ns.names | length }} project(s): {{ ns.names | join(' ') }}{% endif %}"
|
||||
run_once: true
|
||||
tags:
|
||||
- communishift_send_notifications
|
||||
|
|
|
|||
|
|
@ -28,6 +28,22 @@
|
|||
headers:
|
||||
- Reply-To=admin@fedoraproject.org
|
||||
charset: us-ascii
|
||||
when: "not should_not_delete"
|
||||
when:
|
||||
- not should_not_delete
|
||||
- not communishift_email_notifications_dry_run | default(false)
|
||||
tags:
|
||||
- communishift_send_notifications
|
||||
|
||||
- name: Communishift notification email (dry-run preview, mail not sent)
|
||||
ansible.builtin.debug:
|
||||
msg:
|
||||
dry_run: true
|
||||
project: "{{ item.value.name }}"
|
||||
to: infrastructure@lists.fedoraproject.org
|
||||
bcc: "{{ communishift_project_emails[item.value.name]['email_list'] }}"
|
||||
subject: "Fedora Communishift Notification for project: {{ item.value.name }}"
|
||||
when:
|
||||
- not should_not_delete
|
||||
- communishift_email_notifications_dry_run | default(false)
|
||||
tags:
|
||||
- communishift_send_notifications
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue