Closed skinlayers closed 7 years ago
@skinlayers did you have something like this in the pillar of the minion:
pdns.sls
pdns.url: "http://192.168.10.65:8081"
pdns.server_id: "localhost"
pdns.api_key: "f5d2abcd"
top.sls:
base:
'minion':
- pdns.sls
Ah! That did it! I assumed the pillar structure was:
pdns:
url: "http://192.168.10.65:8081"
server_id: "localhost"
api_key: "f5d2abcd"
It may be worth making a comment in the example pillar to clarify.
I came across one other issue with using the powerdns _state and documentation. I could add a SOA and 'A' records, but I got errors when trying to add a 'CNAME' or 'NS' record. I eventually figured out that their records need to end with a period ('.'). So, I recommend adding 'CNAME' and 'NS' record examples to the sls.example state, though this could probably be fixed in the _module. IIRC, there's code in there that will append a '.' when it is needed. Here's what my working pillar and states look like now:
pdnsapi python module:
pip.installed:
- name: pdnsapi >= 0.3.0b3
- reload_modules: True
- require:
- cmd: /usr/bin/python /usr/local/sbin/get-pip.py
{% for domain, conf in salt['pillar.get']('powerdns:domains', []).items() %}
{{ domain }}.present:
powerdns.zone_present:
- name: {{ domain }}
- require:
- pip: pdnsapi >= 0.3.0b3
{{ domain }}.SOA:
powerdns.record_present:
- zone: {{ domain }}
- name: {{ domain }}
- record_type: 'SOA'
- records:
- {{ conf["primary-nameserver"] }}. {{ conf["email"] }}. {{ conf["serial"] }} 10800 3600 604800 300
- require:
- powerdns: {{ domain }}.present
{% for ns in conf['ns-records'] %}
{{ domain }}.NS:
powerdns.record_present:
- zone: {{ domain }}
- name: {{ domain }}
- record_type: 'NS'
- records:
- {{ ns }}.
- require:
- powerdns: {{ domain }}.present
{% endfor %}
{% for host, ip in conf['a-records'].items() %}
{{ host }}.{{ domain }}.A:
powerdns.record_present:
- zone: {{ domain }}
- name: {{ host }}.{{ domain }}
- record_type: 'A'
- records:
- {{ ip }}
- require:
- powerdns: {{ domain }}.present
{% endfor %}
{% for alias, fqdn in conf['cname-records'].items() %}
{{ host }}.{{ domain }}.CNAME:
powerdns.record_present:
- zone: {{ domain }}
- name: {{ host }}.{{ domain }}
- record_type: 'CNAME'
- records:
- {{ fqdn }}.
- require:
- powerdns: {{ domain }}.present
{% endfor %}
{% endfor %}
pillar:
powerdns:
domains:
zone.domain.net:
serial: 1
primary-nameserver: ns1.zone.domain.net
email: hostmaster.zone.domain.net
ns-records:
- ns1.zone.domain.net
cname-records:
salt: ns1.zone.domain.net
a-records:
debian-8-base: 192.168.99.4
ns1: 192.168.99.5
{% for index in range(3) %}
redis-{{ index }}: 192.168.99.1{{ index }}
{% endfor %}
{% for index in range(3) %}
cassandra-{{ index }}: 192.168.99.1{{ index + 5 }}
{% endfor %}
@skinlayers You should consider submitting your state as a patch, good stuff! Perhaps submit it as manage_zones.sls or something? Only thing I would do different is change 'domains' to 'zones', but that is just a nit really.
_module/powerdns.py mentions passing pdns.url, pdns.server_id, pdns.api_key to a pillar, but I have been unable to determine how. It appears this is required for the sls.example state to work.
records.sls state:
salt state.apply output: