1
0
Fork 0
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:
David Kirwan 2026-05-01 13:48:50 +01:00
commit 9f15813840
Signed by untrusted user: dkirwan
GPG key ID: A5893AB6474AC37D
2 changed files with 21 additions and 2 deletions

View file

@ -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

View file

@ -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