ansible-collection-mozout/examples/dns.yml
2026-11-28 15:28:06 +02:00

45 lines
1 KiB
YAML

---
# Point a domain to a server: A record for the domain and www, MX and SPF.
- name: DNS
hosts: localhost
gather_facts: false
vars:
domain: example.com
server_ip: 203.0.113.10
tasks:
- name: Address records
mozout.cloud.dns_record:
domain: "{{ domain }}"
name: "{{ item }}"
type: A
value: "{{ server_ip }}"
ttl: 3600
solo: true
loop: ["@", "www"]
- name: Mail
mozout.cloud.dns_record:
domain: "{{ domain }}"
name: "@"
type: MX
value: "mail.{{ domain }}"
priority: 10
- name: SPF
mozout.cloud.dns_record:
domain: "{{ domain }}"
name: "@"
type: TXT
value: "v=spf1 mx -all"
- name: The zone now
mozout.cloud.dns_info:
domain: "{{ domain }}"
register: zone
- name: Show it
ansible.builtin.debug:
msg: "{{ item.name }} {{ item.type }} {{ item.value }}"
loop: "{{ zone.records }}"
loop_control:
label: "{{ item.id }}"