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 | 2eef80c | 2014-09-22 12:26:55 +0200 | [diff] [blame] | 6 | - pkgs: {{ server.pkgs }} |
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: |
Ales Komarek | 4caeea9 | 2014-09-22 12:32:16 +0200 | [diff] [blame^] | 16 | - pkg: bind_packages |
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: |
Ales Komarek | 99658ee | 2014-09-22 12:27:56 +0200 | [diff] [blame] | 35 | - name: {{ server.local_config }} |
Ales Komarek | 4caeea9 | 2014-09-22 12:32:16 +0200 | [diff] [blame^] | 36 | - source: 'salt://bind/files/named.conf.local' |
Ales Komarek | 882ac7b | 2014-07-14 10:47:56 +0200 | [diff] [blame] | 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: |
Ales Komarek | 99658ee | 2014-09-22 12:27:56 +0200 | [diff] [blame] | 52 | - name: {{ server.config }} |
Ales Komarek | 4caeea9 | 2014-09-22 12:32:16 +0200 | [diff] [blame^] | 53 | - source: 'salt://bind/files/named.conf.Debian' |
Ales Komarek | fbfa168 | 2014-09-22 11:31:14 +0200 | [diff] [blame] | 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: |
Ales Komarek | 99658ee | 2014-09-22 12:27:56 +0200 | [diff] [blame] | 65 | - name: {{ server.local_config }} |
Ales Komarek | 4caeea9 | 2014-09-22 12:32:16 +0200 | [diff] [blame^] | 66 | - source: 'salt://bind/files/named.conf.local' |
Ales Komarek | fbfa168 | 2014-09-22 11:31:14 +0200 | [diff] [blame] | 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: |
Ales Komarek | 99658ee | 2014-09-22 12:27:56 +0200 | [diff] [blame] | 78 | - name: {{ server.options_config }} |
Ales Komarek | 4caeea9 | 2014-09-22 12:32:16 +0200 | [diff] [blame^] | 79 | - source: 'salt://bind/files/named.conf.options' |
Ales Komarek | fbfa168 | 2014-09-22 11:31:14 +0200 | [diff] [blame] | 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: |
Ales Komarek | 99658ee | 2014-09-22 12:27:56 +0200 | [diff] [blame] | 91 | - name: {{ server.default_zones_config }} |
Ales Komarek | 4caeea9 | 2014-09-22 12:32:16 +0200 | [diff] [blame^] | 92 | - source: 'salt://bind/files/named.conf.default-zones' |
Ales Komarek | fbfa168 | 2014-09-22 11:31:14 +0200 | [diff] [blame] | 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 | |
Ales Komarek | 882ac7b | 2014-07-14 10:47:56 +0200 | [diff] [blame] | 115 | {%- endif %} |
| 116 | |
| 117 | bind_service: |
| 118 | service.running: |
Ales Komarek | fbfa168 | 2014-09-22 11:31:14 +0200 | [diff] [blame] | 119 | - name: {{ server.service }} |
| 120 | - enable: true |
| 121 | - reload: true |
| 122 | - require: |
| 123 | - pkg: bind_packages |
| 124 | |
Ales Komarek | 5b8ee92 | 2014-09-22 12:28:51 +0200 | [diff] [blame] | 125 | setup_rndc: |
| 126 | cmd.run: |
| 127 | - name: /usr/sbin/rndc-confgen -r /dev/urandom -a -c {{ server.rndc_key }} |
| 128 | - require: |
| 129 | - pkg: bind_packages |
| 130 | |
| 131 | {{ server.rndc_key }}: |
| 132 | file.managed: |
| 133 | - user: root |
| 134 | - mode: 0640 |
| 135 | - require: |
| 136 | - cmd: setup_rndc |
| 137 | |
Ales Komarek | fbfa168 | 2014-09-22 11:31:14 +0200 | [diff] [blame] | 138 | {%- endif %} |