aboutsummaryrefslogtreecommitdiff
path: root/dns.yml
blob: 0fd753ae1d419eeaf75cb64187dfcaddc1f00d3f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
- name: Setup subdomain A records pointing to wendelstein
  inwx:
      domain: "{{item.partition('.')[2]}}"
      record: "{{item.partition('.')[0]}}"
      type: A
      value: "{{ hostvars['wendelstein']['ansible_default_ipv4']['address'] }}"
  loop: "{{subdomains}}"

- name: Setup dyndns A record
  inwx:
      domain: jaseg.de
      record: ns
      type: A
      value: "{{ hostvars['wendelstein']['ansible_default_ipv4']['address'] }}"

- name: Setup dyndns NS record
  inwx:
      domain: jaseg.de
      record: dyn
      type: NS
      value: 'ns.jaseg.de'

- name: Setup subdomain AAAA records pointing to wendelstein
  inwx:
      domain: "{{item.partition('.')[2]}}"
      record: "{{item.partition('.')[0]}}"
      type: AAAA
      value: "{{ hostvars['wendelstein']['ansible_default_ipv6']['address'] }}"
  loop: "{{subdomains}}"

- name: Setup jaseg.net subdomain MX records pointing to fastmail
  inwx:
      domain: "{{item.partition('.')[2]}}"
      record: "{{item.partition('.')[0]}}"
      type: MX
      priority: 10
      value: in1-smtp.messagingengine.com
  loop: "{{subdomains}}"

- name: Setup jaseg.net subdomain MX records pointing to fastmail
  inwx:
      domain: "{{item.partition('.')[2]}}"
      record: "{{item.partition('.')[0]}}"
      type: MX
      priority: 20
      value: in2-smtp.messagingengine.com
  loop: "{{subdomains}}"

- name: Setup sendgrid gateway
  inwx:
    domain: jaseg.de
    type: CNAME
    record: "{{item.split(' ')[0]}}"
    value: "{{item.split(' ')[1]}}"
  loop:
    - em6100.automation u14518136.wl137.sendgrid.net  
    - s1._domainkey.automation s1.domainkey.u14518136.wl137.sendgrid.net  
    - s2._domainkey.automation s2.domainkey.u14518136.wl137.sendgrid.net

- name: Set fastmail DNS entry template
  set_fact:
    fastmail_dns_entries:
    - {rtype: MX,    record: ".", prio: 10,     value: in1-smtp.messagingengine.com}
    - {rtype: MX,    record: ".", prio: 20,     value: in2-smtp.messagingengine.com}
    - {rtype: MX,    record: "*", prio: 10,     value: in1-smtp.messagingengine.com}
    - {rtype: MX,    record: "*", prio: 20,     value: in2-smtp.messagingengine.com}
    - {rtype: TXT,   record: ".",               value: "v=spf1 include:spf.messagingengine.com ?all"}
    - {rtype: CNAME, record: mesmtp._domainkey, value: mesmtp.jaseg.de.dkim.fmhosted.com}
    - {rtype: CNAME, record: fm1._domainkey,    value: fm1.jaseg.de.dkim.fmhosted.com}
    - {rtype: CNAME, record: fm2._domainkey,    value: fm2.jaseg.de.dkim.fmhosted.com}
    - {rtype: CNAME, record: fm3._domainkey,    value: fm3.jaseg.de.dkim.fmhosted.com}
    - {rtype: SRV,   record: _submission._tcp,  prio: 0, weight: 1, port: 587, value: smtp.fastmail.com}
    - {rtype: SRV,   record: _imap._tcp,        prio: 0, weight: 0, port: 0, value: "."}
    - {rtype: SRV,   record: _imaps._tcp,       prio: 0, weight: 1, port: 993, value: imap.fastmail.com}
    - {rtype: SRV,   record: _pop3._tcp,        prio: 0, weight: 0, port: 0, value: "."}
    - {rtype: SRV,   record: _pop3s._tcp,       prio: 10, weight: 1, port: 995, value: pop.fastmail.com}
    - {rtype: SRV,   record: _jmap._tcp,        prio: 0, weight: 1, port: 443, value: jmap.fastmail.com}
    - {rtype: SRV,   record: _carddav._tcp,     prio: 0, weight: 0, port: 0, value: "."}
    - {rtype: SRV,   record: _carddavs._tcp,    prio: 0, weight: 1, port: 443, value: carddav.fastmail.com}

- name: Setup fastmail DNS entries
  inwx:
      domain: "{{ item[1] }}"
      type: "{{ item[0]['rtype'] }}"
      record: "{{ item[0]['record'] | regex_replace('\\.*$', '') }}"
      priority: "{{ item[0].get('prio') | int }}"
      port: "{{ item[0].get('port') | int}}"
      weight: "{{ item[0].get('weight') | int }}"
      value: "{{ item[0]['value'] }}"
  loop: "{{ fastmail_dns_entries | product(fastmail_domains) | list }}"