Print DNS entries at end of mailserver playbook

This commit is contained in:
Tunui Franken 2024-09-28 14:11:56 +02:00
parent 86983b241d
commit 45841ffd9f
6 changed files with 37 additions and 16 deletions

View file

@ -21,8 +21,10 @@
- role: mailserver_rspamd - role: mailserver_rspamd
tags: rspamd tags: rspamd
- role: mailserver_dkim - role: mailserver_dkim
tags: dkim tags: dkim, report
- role: mailserver_spf - role: mailserver_spf
tags: spf tags: spf, report
- role: mailserver_dmarc - role: mailserver_dmarc
tags: dmarc tags: dmarc, report
- role: mailserver_dns_report
tags: report

View file

@ -27,7 +27,3 @@
group: root group: root
mode: "644" mode: "644"
notify: Reload rspamd service notify: Reload rspamd service
- name: Print DKIM TXT record for the DNS zone
ansible.builtin.debug:
msg: "Don't forget to add this to your DNS zone:\n{{ dkim_txt_record.stdout }}"

View file

@ -24,7 +24,6 @@
- Fix DKIM key ownership - Fix DKIM key ownership
- Save DKIM TXT record to a file - Save DKIM TXT record to a file
- Add selector to DKIM selectors map - Add selector to DKIM selectors map
- Print DKIM TXT record for the DNS zone
- name: Copy dkim_signing local config - name: Copy dkim_signing local config
become: true become: true

View file

@ -3,7 +3,3 @@
- name: Set DMARC TXT record - name: Set DMARC TXT record
ansible.builtin.set_fact: ansible.builtin.set_fact:
dmarc_txt_record: "_dmarc.{{ virtual_domain }}. IN TXT \"v=DMARC1; p=reject; pct=100; adkim=s; rua=mailto:postmaster@{{ virtual_domain }}\"" dmarc_txt_record: "_dmarc.{{ virtual_domain }}. IN TXT \"v=DMARC1; p=reject; pct=100; adkim=s; rua=mailto:postmaster@{{ virtual_domain }}\""
- name: Print DMARC TXT record for the DNS zone
ansible.builtin.debug:
msg: "Don't forget to add this to your DNS zone:\n{{ dmarc_txt_record }}"

View file

@ -0,0 +1,32 @@
---
- name: Make sure any handlers have run
ansible.builtin.meta: flush_handlers
- name: Get current DKIM TXT files
become: true
ansible.builtin.find:
paths: /var/lib/rspamd/dkim/
patterns: "{{ virtual_domain }}.*.dns"
register: dkim_dir
- name: Get DKIM TXT record
become: true
ansible.builtin.slurp:
src: "{{ item.path }}"
with_items: "{{ dkim_dir.files }}"
register: dkim_txt_record_slurp
- name: Print DKIM TXT record for the DNS zone
ansible.builtin.debug:
msg: "Don't forget to add this to your DNS zone:\n{{ item.content | b64decode }}"
with_items:
- "{{ dkim_txt_record_slurp.results }}"
- name: Print SPF TXT record for the DNS zone
ansible.builtin.debug:
msg: "Don't forget to add this to your DNS zone:\n{{ spf_txt_record }}"
- name: Print DMARC TXT record for the DNS zone
ansible.builtin.debug:
msg: "Don't forget to add this to your DNS zone:\n{{ dmarc_txt_record }}"

View file

@ -9,7 +9,3 @@
- name: Set SPF TXT record - name: Set SPF TXT record
ansible.builtin.set_fact: ansible.builtin.set_fact:
spf_txt_record: "{{ virtual_domain }}. IN TXT \"v=spf1 ip4:{{ local_public_ip.content }} mx a ~all\"" spf_txt_record: "{{ virtual_domain }}. IN TXT \"v=spf1 ip4:{{ local_public_ip.content }} mx a ~all\""
- name: Print SPF TXT record for the DNS zone
ansible.builtin.debug:
msg: "Don't forget to add this to your DNS zone:\n{{ spf_txt_record }}"