diff --git a/README.rst b/README.rst index 29c9d8b..6b1273d 100644 --- a/README.rst +++ b/README.rst @@ -1,7 +1,38 @@ +==== bind ==== -bind ----- +Formulas to set up and configure the bind DNS server. -Set up a caching bind nameserver +.. note:: + + See the full `Salt Formulas installation and usage instructions + `_. + +Available states +================ + +.. contents:: + :local: + +``bind`` +-------- + +Install the bind package and start the bind service. + +``bind.config`` +--------------- + +Manage the bind configuration file. + +Example Pillar: + +.. code:: yaml + + bind: + config: + name: /etc/named.conf + source: salt://bind/files/named.conf + user: root + group: named + mode: 640 diff --git a/bind/config.sls b/bind/config.sls new file mode 100644 index 0000000..a8ee571 --- /dev/null +++ b/bind/config.sls @@ -0,0 +1,17 @@ +{% from "bind/map.jinja" import map with context %} + +include: + - bind + +bind_config: + file: + - managed + - name: {{ map.config }} + - source: {{ salt['pillar.get']('bind:config:tmpl', 'salt://bind/files/named.conf') }} + - user: {{ salt['pillar.get']('bind:config:user', 'root') }} + - group: {{ salt['pillar.get']('bind:config:group', 'named') }} + - mode: {{ salt['pillar.get']('bind:config:mode', '640') }} + - require: + - pkg: bind + - watch_in: + - service: bind diff --git a/bind/init.sls b/bind/init.sls index 55fe58f..d4dc1f2 100644 --- a/bind/init.sls +++ b/bind/init.sls @@ -1,22 +1,10 @@ -bind9: - pkg.installed: - {% if grains['os_family'] == 'Debian' %} - - pkgs: - - bind9 - - bind9-doc - - bind9utils - {% else %} - - name: bind - file.managed: - - name: /etc/named.conf - - source: salt://bind/files/named.conf - - user: root - - group: named - - mode: 640 - - require: - - pkg: bind9 - service.running: - - name: named +{% from "bind/map.jinja" import map with context %} + +bind: + pkg: + - installed + - pkgs: {{ map.pkgs|json }} + service: + - running + - name: {{ map.service }} - enable: True - - watch: - - file: bind9 diff --git a/bind/map.jinja b/bind/map.jinja new file mode 100644 index 0000000..775642b --- /dev/null +++ b/bind/map.jinja @@ -0,0 +1,14 @@ +{% set map = salt['grains.filter_by']({ + 'Debian': { + 'pkgs': ['bind9', 'bind9utils'], + 'service': 'named', + + 'config': '/etc/named.conf', + }, + 'RedHat': { + 'pkgs': ['bind'], + 'service': 'named', + + 'config': '/etc/named.conf', + }, +}, merge=salt['pillar.get']('bind:lookup')) %} diff --git a/pillar.example b/pillar.example index e69de29..8b5d1ee 100644 --- a/pillar.example +++ b/pillar.example @@ -0,0 +1,13 @@ +bind: + lookup: + pkgs: + - bind + service: + - named + +bind: + config: + tmpl: salt://bind/files/named.conf + user: root + group: named + mode: 640