Split bind formula into two states; added map; added pillar examples

This commit is contained in:
Seth House 2013-09-03 15:51:19 -06:00
parent 499ea4cbd5
commit f43b760240
5 changed files with 87 additions and 24 deletions

View file

@ -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
<http://docs.saltstack.com/topics/conventions/formulas.html>`_.
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

17
bind/config.sls Normal file
View file

@ -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

View file

@ -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

14
bind/map.jinja Normal file
View file

@ -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')) %}

View file

@ -0,0 +1,13 @@
bind:
lookup:
pkgs:
- bind
service:
- named
bind:
config:
tmpl: salt://bind/files/named.conf
user: root
group: named
mode: 640