--- - name: Get DKIM key slurp: src: "/etc/dkimkeys/{{ item }}.txt" register: key_file loop: "{{ mail_domains }}" - name: Show key files debug: msg: "{{ item['content'] | b64decode | regex_replace('^.*\\\"(.*)\\\".*$', '\\1', multiline=True) | regex_replace('[\\s\\n\\t\\\"]*', '', multiline=True)}}" loop: "{{ key_file['results'] }}" when: - "'.local' not in item['item']" - item['item'] | regex_findall('\.') | length == 1 - name: Add DKIM key record for domain synthesio.ovh.domain: endpoint: "{{ ovh_endpoint }}" application_key: "{{ ovh_application_key }}" application_secret: "{{ ovh_application_secret }}" consumer_key: "{{ ovh_consumer_key }}" domain: "{{ item['item'] }}" value: "{{ item['content'] | b64decode | regex_replace('^.*\\\"(.*)\\\".*$', '\\1', multiline=True) | regex_replace('[\\s\\n\\t\\\"]*', '', multiline=True)}}" record_type: "DKIM" name: "{{ dkim_selector }}._domainkey" record_ttl: 10 append: false loop: "{{ key_file['results'] }}" when: - "'.local' not in item['item']" - item['item'] | regex_findall('\.') | length == 1