init.sls 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. #
  2. # Authoritive FFHO DNS Server configuration (dns01/dns02 anycast)
  3. #
  4. {% set roles = salt['pillar.get']('nodes:' ~ grains['id'] ~ ':roles', []) %}
  5. include:
  6. - dns-server
  7. # Bind options
  8. /etc/bind/named.conf.options:
  9. file.managed:
  10. {% if 'dns-recursor' in roles %}
  11. - source: salt://dns-server/auth/named.conf.options.recursor
  12. {% else %}
  13. - source: salt://dns-server/auth/named.conf.options
  14. {% endif %}
  15. - template: jinja
  16. - require:
  17. - pkg: bind9
  18. - watch_in:
  19. - cmd: rndc-reload
  20. # Configure authoritive zones in local config
  21. /etc/bind/named.conf.local:
  22. file.managed:
  23. - source: salt://dns-server/auth/named.conf.local
  24. - require:
  25. - pkg: bind9
  26. - watch_in:
  27. - cmd: rndc-reload
  28. # Create zones directory
  29. /etc/bind/zones/:
  30. file.directory:
  31. - makedirs: true
  32. - user: root
  33. - group: root
  34. - mode: 755
  35. - require:
  36. - pkg: bind9
  37. # Create directory for static zone files
  38. /etc/bind/zones/static:
  39. file.directory:
  40. - makedirs: true
  41. - user: root
  42. - group: root
  43. - mode: 755
  44. - require:
  45. - pkg: bind9
  46. - file: /etc/bind/zones/
  47. # Copy zonefiles
  48. /etc/bind/zones/static/_tree:
  49. file.recurse:
  50. - name: /etc/bind/zones/static
  51. - source: salt://dns-server/auth/zones
  52. - file_mode: 644
  53. - dir_mode: 755
  54. - user: root
  55. - group: root
  56. - watch_in:
  57. - cmd: rndc-reload
  58. # Create directory for generated zone files
  59. /etc/bind/zones/generated:
  60. file.directory:
  61. - makedirs: true
  62. - user: root
  63. - group: root
  64. - mode: 755
  65. - require:
  66. - pkg: bind9
  67. - file: /etc/bind/zones/
  68. {% set nodes_config = salt['pillar.get'] ('nodes', {}) %}
  69. {% set sites_config = salt['pillar.get'] ('sites', {}) %}
  70. {% set zones = salt['ffho_net.generate_DNS_entries'] (nodes_config, sites_config) %}
  71. {% for zone, entries in zones.items () %}
  72. /etc/bind/zones/generated/{{ zone }}.zone:
  73. file.managed:
  74. - source: salt://dns-server/auth/zone.gen.tmpl
  75. - template: jinja
  76. - context:
  77. zone: {{ zone }}
  78. nodes_config: {{ nodes_config }}
  79. sites_config: {{ sites_config }}
  80. - require:
  81. - file: /etc/bind/zones/generated
  82. - watch_in:
  83. - cmd: rndc-reload
  84. {% endfor %}