From d9d0f35034276af9e0652a23ac1995e64448ee77 Mon Sep 17 00:00:00 2001 From: Tunui Franken Date: Sun, 29 Sep 2024 11:47:35 +0200 Subject: [PATCH] Write report to a local file instead of printing the DNS records --- roles/mailserver_dns_report/tasks/main.yml | 29 +++++++++++++++------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/roles/mailserver_dns_report/tasks/main.yml b/roles/mailserver_dns_report/tasks/main.yml index dc02acc..1b4bbc6 100644 --- a/roles/mailserver_dns_report/tasks/main.yml +++ b/roles/mailserver_dns_report/tasks/main.yml @@ -17,16 +17,27 @@ 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 }}" +- name: Define DNS record content + ansible.builtin.set_fact: + dns_record_text: "DNS RECORDS NEEDED FOR MAILSERVER\n" + +- name: Set DKIM TXT record for the DNS record file + ansible.builtin.set_fact: + dns_record_text: "{{ dns_record_text }}\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: Set SPF TXT record for the DNS record file + ansible.builtin.set_fact: + dns_record_text: "{{ dns_record_text }}\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 }}" +- name: Set DMARC TXT record for the DNS record file + ansible.builtin.set_fact: + dns_record_text: "{{ dns_record_text }}\n{{ dmarc_txt_record }}" + +- name: Write DNS records to a local '/tmp/mailserver_dns_records.txt' file + ansible.builtin.copy: + content: "{{ dns_record_text }}" + dest: /tmp/mailserver_dns_records.txt + mode: "644" + delegate_to: localhost