init.sls 2.0 KB

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