Ales Komarek | fbfa168 | 2014-09-22 11:31:14 +0200 | [diff] [blame] | 1 | {%- from "bind/map.jinja" import server with context %} |
| 2 | {%- if server.enabled %} |
Ales Komarek | 882ac7b | 2014-07-14 10:47:56 +0200 | [diff] [blame] | 3 | |
| 4 | bind_packages: |
| 5 | pkg.installed: |
Ales Komarek | fbfa168 | 2014-09-22 11:31:14 +0200 | [diff] [blame] | 6 | - pkgs: {{ server.pkg }} |
Ales Komarek | 882ac7b | 2014-07-14 10:47:56 +0200 | [diff] [blame] | 7 | |
| 8 | named_directory: |
| 9 | file.directory: |
Ales Komarek | fbfa168 | 2014-09-22 11:31:14 +0200 | [diff] [blame] | 10 | - name: {{ server.named_dir }} |
| 11 | - user: {{ server.user }} |
| 12 | - group: {{ server.group }} |
| 13 | - mode: 775 |
| 14 | - makedirs: True |
| 15 | - require: |
| 16 | - pkg: bind |
Ales Komarek | 882ac7b | 2014-07-14 10:47:56 +0200 | [diff] [blame] | 17 | |
Ales Komarek | fbfa168 | 2014-09-22 11:31:14 +0200 | [diff] [blame] | 18 | {%- if grains.os_family == 'RedHat' %} |
| 19 | |
Ales Komarek | 882ac7b | 2014-07-14 10:47:56 +0200 | [diff] [blame] | 20 | bind_config: |
| 21 | file.managed: |
Ales Komarek | fbfa168 | 2014-09-22 11:31:14 +0200 | [diff] [blame] | 22 | - name: {{ server.config }} |
| 23 | - source: 'salt://bind/files/named.conf.RedHat' |
| 24 | - template: jinja |
| 25 | - user: {{ server.user }} |
| 26 | - group: {{ server.group }} |
| 27 | - mode: 640 |
| 28 | - require: |
| 29 | - pkg: bind_packages |
| 30 | - watch_in: |
| 31 | - service: bind_service |
Ales Komarek | 882ac7b | 2014-07-14 10:47:56 +0200 | [diff] [blame] | 32 | |
| 33 | bind_local_config: |
| 34 | file.managed: |
| 35 | - name: {{ map.local_config }} |
| 36 | - source: 'salt://bind/files/redhat/named.conf.local' |
| 37 | - template: jinja |
Ales Komarek | fbfa168 | 2014-09-22 11:31:14 +0200 | [diff] [blame] | 38 | - user: {{ server.user }} |
| 39 | - group: {{ server.group }} |
| 40 | - mode: 644 |
Ales Komarek | 882ac7b | 2014-07-14 10:47:56 +0200 | [diff] [blame] | 41 | - require: |
Ales Komarek | fbfa168 | 2014-09-22 11:31:14 +0200 | [diff] [blame] | 42 | - pkg: bind_packages |
Ales Komarek | 882ac7b | 2014-07-14 10:47:56 +0200 | [diff] [blame] | 43 | - watch_in: |
Ales Komarek | fbfa168 | 2014-09-22 11:31:14 +0200 | [diff] [blame] | 44 | - service: bind_service |
Ales Komarek | 882ac7b | 2014-07-14 10:47:56 +0200 | [diff] [blame] | 45 | |
Ales Komarek | fbfa168 | 2014-09-22 11:31:14 +0200 | [diff] [blame] | 46 | {%- endif %} |
| 47 | |
| 48 | {%- if grains['os_family'] == 'Debian' %} |
| 49 | |
Ales Komarek | 882ac7b | 2014-07-14 10:47:56 +0200 | [diff] [blame] | 50 | bind_config: |
Ales Komarek | fbfa168 | 2014-09-22 11:31:14 +0200 | [diff] [blame] | 51 | file.managed: |
| 52 | - name: {{ map.config }} |
| 53 | - source: 'salt://bind/files/debian/named.conf.Debian' |
| 54 | - template: jinja |
| 55 | - user: {{ server.user }} |
| 56 | - group: {{ server.group }} |
| 57 | - mode: 644 |
| 58 | - require: |
| 59 | - pkg: bind_packages |
| 60 | - watch_in: |
| 61 | - service: bind_service |
Ales Komarek | 882ac7b | 2014-07-14 10:47:56 +0200 | [diff] [blame] | 62 | |
| 63 | bind_local_config: |
Ales Komarek | fbfa168 | 2014-09-22 11:31:14 +0200 | [diff] [blame] | 64 | file.managed: |
| 65 | - name: {{ map.local_config }} |
| 66 | - source: 'salt://bind/files/debian/named.conf.local' |
| 67 | - template: jinja |
| 68 | - user: {{ server.user }} |
| 69 | - group: {{ server.group }} |
| 70 | - mode: 644 |
| 71 | - require: |
| 72 | - pkg: bind_packages |
| 73 | - watch_in: |
| 74 | - service: bind_service |
Ales Komarek | 882ac7b | 2014-07-14 10:47:56 +0200 | [diff] [blame] | 75 | |
| 76 | bind_options_config: |
Ales Komarek | fbfa168 | 2014-09-22 11:31:14 +0200 | [diff] [blame] | 77 | file.managed: |
| 78 | - name: {{ map.options_config }} |
| 79 | - source: 'salt://bind/files/debian/named.conf.options' |
| 80 | - template: jinja |
| 81 | - user: {{ server.user }} |
| 82 | - group: {{ server.group }} |
| 83 | - mode: 644 |
| 84 | - require: |
| 85 | - pkg: bind_packages |
| 86 | - watch_in: |
| 87 | - service: bind_service |
Ales Komarek | 882ac7b | 2014-07-14 10:47:56 +0200 | [diff] [blame] | 88 | |
| 89 | bind_default_zones: |
Ales Komarek | fbfa168 | 2014-09-22 11:31:14 +0200 | [diff] [blame] | 90 | file.managed: |
| 91 | - name: {{ map.default_zones_config }} |
| 92 | - source: 'salt://bind/files/debian/named.conf.default-zones' |
| 93 | - template: jinja |
| 94 | - user: {{ server.user }} |
| 95 | - group: {{ server.group }} |
| 96 | - mode: 644 |
| 97 | - require: |
| 98 | - pkg: bind_packages |
| 99 | - watch_in: |
| 100 | - service: bind_service |
Ales Komarek | 882ac7b | 2014-07-14 10:47:56 +0200 | [diff] [blame] | 101 | |
| 102 | /var/log/bind9: |
Ales Komarek | fbfa168 | 2014-09-22 11:31:14 +0200 | [diff] [blame] | 103 | file.directory: |
| 104 | - user: {{ server.user }} |
| 105 | - group: {{ server.group }} |
| 106 | - mode: 775 |
| 107 | - template: jinja |
Ales Komarek | 882ac7b | 2014-07-14 10:47:56 +0200 | [diff] [blame] | 108 | |
| 109 | /etc/logrotate.d/bind9: |
Ales Komarek | fbfa168 | 2014-09-22 11:31:14 +0200 | [diff] [blame] | 110 | file.managed: |
| 111 | - source: salt://bind/files/logrotate |
| 112 | - user: root |
| 113 | - group: root |
| 114 | |
| 115 | setup_rndc: |
| 116 | cmd.run: |
| 117 | - name: /usr/sbin/rndc-confgen -r /dev/urandom -a -c {{ server.rndc_key }} |
| 118 | - require: |
| 119 | - pkg: bind_packages |
| 120 | |
| 121 | {{ server.rndc_key }} |
| 122 | file.managed: |
| 123 | - user: root |
| 124 | - mode: 0640 |
| 125 | - require: |
| 126 | - cmd: setup_rndc |
Ales Komarek | 882ac7b | 2014-07-14 10:47:56 +0200 | [diff] [blame] | 127 | |
| 128 | {%- endif %} |
| 129 | |
| 130 | bind_service: |
| 131 | service.running: |
Ales Komarek | fbfa168 | 2014-09-22 11:31:14 +0200 | [diff] [blame] | 132 | - name: {{ server.service }} |
| 133 | - enable: true |
| 134 | - reload: true |
| 135 | - require: |
| 136 | - pkg: bind_packages |
| 137 | |
| 138 | {%- endif %} |