dhcpd.conf.j2 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  1. ## dhcpd.conf
  2. {% if dhcp_use_ansible_managed %}# {{ ansible_managed }}{% endif %}
  3. # Do not edit manually
  4. {% if dhcp_omapi_port is defined %}
  5. omapi-port {{ dhcp_omapi_port }};
  6. {% endif %}
  7. # option definitions common to all supported networks...
  8. {% if dhcp_common_domain is defined %}
  9. option domain-name "{{ dhcp_common_domain }}";
  10. {% endif %}
  11. {% if dhcp_common_nameservers is defined %}
  12. option domain-name-servers {{ dhcp_common_nameservers }};
  13. {% endif %}
  14. {% if dhcp_common_default_lease_time is defined %}
  15. default-lease-time {{ dhcp_common_default_lease_time }};
  16. {% endif %}
  17. {% if dhcp_common_max_lease_time is defined %}
  18. max-lease-time {{ dhcp_common_max_lease_time }};
  19. {% endif %}
  20. # Dynamic DNS
  21. ddns-updates {{ dhcp_ddns_updates | ternary("on", "off") }};
  22. ddns-update-style {{ dhcp_ddns_update_style }};
  23. {{ dhcp_ddns_client_updates | ternary("allow", "ignore") }} client-updates;
  24. {{ dhcp_ddns_unknown_clients | ternary("allow", "ignore") }} unknown-clients;
  25. update-static-leases {{ dhcp_ddns_update_static_leases | ternary("on", "off") }};
  26. {% if dhcp_ddns_keys is defined %}
  27. {% for key in dhcp_ddns_keys %}
  28. key {{ key.name }} {
  29. algorithm hmac-md5;
  30. secret {{ key.value }};
  31. }
  32. {% endfor %}
  33. {% endif %}
  34. {% if dhcp_ddns_zones is defined %}
  35. {% for zone in dhcp_ddns_zones %}
  36. zone {{ zone.name }}. {
  37. primary {{ zone.primary }};
  38. key {{ zone.key }};
  39. }
  40. {% endfor %}
  41. {% endif %}
  42. {% if dhcp_common_authoritative is defined %}
  43. # If this DHCP server is the official DHCP server for the local
  44. # network, the authoritative directive should be uncommented.
  45. authoritative;
  46. {% endif %}
  47. {% if dhcp_common_log_facility is defined %}
  48. # Use this to send dhcp log messages to a different log file (you also
  49. # have to hack syslog.conf to complete the redirection).
  50. log-facility {{ dhcp_common_log_facility }};
  51. {% endif %}
  52. {% if dhcp_common_options is defined %}
  53. {% if dhcp_common_enable_pxe_boot %}
  54. filename "{{ dhcp_common_pxe_boot_file }}";
  55. next-server {{ dhcp_common_pxe_boot_server }};
  56. {% endif %}
  57. #DHCP options
  58. {% for o in dhcp_common_options %}
  59. option {{ o }};
  60. {% endfor %}
  61. {% endif %}
  62. {% if dhcp_common_parameters is defined %}
  63. #DHCP parameters
  64. {% for p in dhcp_common_parameters %}
  65. {{ p }};
  66. {% endfor %}
  67. {% endif %}
  68. {% if dhcp_classes is defined %}
  69. # Classes
  70. {% for c in dhcp_classes %}
  71. class "{{ c.name }}" {
  72. {{ c.rule }};
  73. {% if c.options is defined %}
  74. {% for i in c.options %}
  75. option {{ i.opt }};
  76. {% endfor %}
  77. {% endif %}
  78. }
  79. {% endfor %}
  80. {% endif %}
  81. {% if dhcp_hosts is defined %}
  82. # Hosts
  83. {% for h in dhcp_hosts %}
  84. host {{ h.name }} {
  85. hardware ethernet {{ h.mac_address }};
  86. ddns-hostname {{ h.name }};
  87. {% if h.fixed_address is defined %}
  88. fixed-address {{ h.fixed_address }};
  89. {% endif %}
  90. {% if h.routers is defined %}
  91. option routers {{ h.routers }};
  92. {% endif %}
  93. {% if h.broadcast_address is defined %}
  94. option broadcast-address {{ h.broadcast_address }};
  95. {% endif %}
  96. {% if h.domain_nameservers is defined %}
  97. option domain-name-servers {{ h.domain_nameservers }};
  98. {% endif %}
  99. {% if h.domain_name is defined %}
  100. option domain-name "{{ h.domain_name }}";
  101. {% endif %}
  102. {% if h.default_lease_time is defined %}
  103. default-lease-time {{ h.default_lease_time }};
  104. {% endif %}
  105. {% if h.max_lease_time is defined %}
  106. max-lease-time {{ h.max_lease_time }};
  107. {% endif %}
  108. {% if h.parameters is defined %}
  109. {% for p in h.parameters %}
  110. {{ p }};
  111. {% endfor %}
  112. {% endif %}
  113. }
  114. {% endfor %}
  115. {% endif %}
  116. {% if dhcp_subnets is defined %}
  117. # Subnets
  118. {% for s in dhcp_subnets %}
  119. subnet {{ s.base }} netmask {{ s.netmask }} {
  120. {% if s.interface is defined %}
  121. interface "{{ s.interface }}";
  122. {% endif %}
  123. {% if s.range_start is defined %}
  124. range {{ s.range_start }} {{ s.range_end }};
  125. {% endif %}
  126. {% if s.routers is defined %}
  127. option routers {{ s.routers }};
  128. {% endif %}
  129. {% if s.broadcast_address is defined %}
  130. option broadcast-address {{ s.broadcast_address }};
  131. {% endif %}
  132. {% if s.domain_nameservers is defined %}
  133. option domain-name-servers {{ s.domain_nameservers }};
  134. {% endif %}
  135. {% if s.domain_name is defined %}
  136. option domain-name "{{ s.domain_name }}";
  137. {% endif %}
  138. {% if s.ntp_servers is defined %}
  139. option ntp-servers {{ s.ntp_servers }};
  140. {% endif %}
  141. {% if s.default_lease_time is defined %}
  142. default-lease-time {{ s.default_lease_time }};
  143. {% endif %}
  144. {% if s.max_lease_time is defined %}
  145. max-lease-time {{ s.max_lease_time }};
  146. {% endif %}
  147. {% if s.pools is defined %}
  148. {% for p in s.pools %}
  149. pool {
  150. {% if p.rule is defined %}
  151. {{ p.rule }};
  152. {% endif %}
  153. range {{ p.range_start }} {{ p.range_end }};
  154. {% if p.parameters is defined %}
  155. {% for param in p.parameters %}
  156. {{ param }};
  157. {% endfor %}
  158. {% endif %}
  159. }
  160. {% endfor %}
  161. {% endif %}
  162. {% if s.parameters is defined %}
  163. {% for p in s.parameters %}
  164. {{ p }};
  165. {% endfor %}
  166. {% endif %}
  167. }
  168. {% endfor %}
  169. {% endif %}
  170. {% if dhcp_shared_networks is defined %}
  171. # Shared networks
  172. {% for n in dhcp_shared_networks %}
  173. shared-network {{ n.name }} {
  174. {% if n.interface is defined %}
  175. interface "{{ n.interface }}";
  176. {% endif %}
  177. {% for s in n.subnets %}
  178. subnet {{ s.base }} netmask {{ s.netmask }} {
  179. {% if s.range_start is defined %}
  180. range {{ s.range_start }} {{ s.range_end }};
  181. {% endif %}
  182. {% if s.routers is defined %}
  183. option routers {{ s.routers }};
  184. {% endif %}
  185. {% if s.broadcast_address is defined %}
  186. option broadcast-address {{ s.broadcast_address }};
  187. {% endif %}
  188. {% if s.domain_nameservers is defined %}
  189. option domain-name-servers {{ s.domain_nameservers }};
  190. {% endif %}
  191. {% if s.domain_name is defined %}
  192. option domain-name "{{ s.domain_name }}";
  193. {% endif %}
  194. {% if s.ntp_servers is defined %}
  195. option ntp-servers {{ s.ntp_servers }};
  196. {% endif %}
  197. {% if s.default_lease_time is defined %}
  198. default-lease-time {{ s.default_lease_time }};
  199. {% endif %}
  200. {% if s.max_lease_time is defined %}
  201. max-lease-time {{ s.max_lease_time }};
  202. {% endif %}
  203. {% if s.pools is defined %}
  204. {% for p in s.pools %}
  205. pool {
  206. {% if p.rule is defined %}
  207. {{ p.rule }};
  208. {% endif %}
  209. range {{ p.range_start }} {{ p.range_end }};
  210. {% if p.parameters is defined %}
  211. {% for param in p.parameters %}
  212. {{ param }};
  213. {% endfor %}
  214. {% endif %}
  215. }
  216. {% endfor %}
  217. {% endif %}
  218. {% if s.parameters is defined %}
  219. {% for param in s.parameters %}
  220. {{ param }};
  221. {% endfor %}
  222. {% endif %}
  223. }
  224. {% endfor %}
  225. {% if n.pools is defined %}
  226. {% for p in n.pools %}
  227. pool {
  228. {{ p.rule }};
  229. range {{ p.range_start }} {{ p.range_end }};
  230. {% if p.parameters is defined %}
  231. {% for param in p.parameters %}
  232. {{ param }};
  233. {% endfor %}
  234. {% endif %}
  235. }
  236. {% endfor %}
  237. {% endif %}
  238. {% if n.parameters is defined %}
  239. {% for p in n.parameters %}
  240. {{ p }};
  241. {% endfor %}
  242. {% endif %}
  243. }
  244. {% endfor %}
  245. {% endif %}
  246. {% if dhcp_ifelse is defined %}
  247. # If else clauses
  248. {% for ie in dhcp_ifelse %}
  249. if {{ ie.condition }} {
  250. {{ ie.val }}
  251. }{% if ie.else is defined %}{% for e in ie.else %} else {
  252. {{ e.val }}
  253. }{% endfor %}
  254. {% endif %}
  255. {% endfor %}
  256. {% endif %}