fixes
diff --git a/README.md b/README.md
index 46f89c1..7d195aa 100644
--- a/README.md
+++ b/README.md
@@ -9,9 +9,19 @@
isc_dhcp:
server:
enabled: true
+ omapi_port: 7911
+ authoritative: true
interfaces:
- name: eth0
- name: eth1
+ domain_name: domain.com
+ name_servers:
+ - ns1.domain.com
+ host:
+ node1:
+ mac: 00:11:22:33:44:55:66
+ address: 192.168.0.1
+ hostname: domain.com
## Read more
diff --git a/files/defaults.Debian b/files/defaults.Debian
index 186270b..3d91884 100644
--- a/files/defaults.Debian
+++ b/files/defaults.Debian
@@ -1,13 +1,11 @@
+{%- from "isc_dhcp/map.jinja" import server with context %}
+
# Path to dhcpd's config file (default: /etc/dhcp/dhcpd.conf).
-#DHCPD_CONF=/etc/dhcp/dhcpd.conf
+DHCPD_CONF=/etc/dhcp/dhcpd.conf
# Path to dhcpd's PID file (default: /var/run/dhcpd.pid).
#DHCPD_PID=/var/run/dhcpd.pid
-# Additional options to start dhcpd with.
-# Don't use options -cf or -pf here; use DHCPD_CONF/ DHCPD_PID instead
-#OPTIONS=""
-
# On what interfaces should the DHCP server (dhcpd) serve DHCP requests?
# Separate multiple interfaces with spaces, e.g. "eth0 eth1".
-INTERFACES="{% for interface in salt['pillar.get']('isc_dhcp:server:interfaces', []) %}{{ interface.name }}{% if not loop.last %} {% endif %}{% endfor %}"
\ No newline at end of file
+INTERFACES="{{ server.interfaces|join(' ') }}"
\ No newline at end of file
diff --git a/files/defaults.RedHat b/files/defaults.RedHat
new file mode 100644
index 0000000..f3712e0
--- /dev/null
+++ b/files/defaults.RedHat
@@ -0,0 +1,4 @@
+{%- from "isc_dhcp/map.jinja" import server with context %}
+
+# Command line options here
+DHCPDARGS=" {{ server.interfaces|join(' ') }}"
\ No newline at end of file
diff --git a/files/dhcpd.conf b/files/dhcpd.conf
index 8681c92..13375a6 100644
--- a/files/dhcpd.conf
+++ b/files/dhcpd.conf
@@ -4,32 +4,48 @@
omapi-port {{ server.omapi_port }};
{% endif -%}
+{%- if server.ddns_updates is defined %}
+
+ddns-updates on;
+ddns-update-style interim;
+
+update-static-leases on;
+use-host-decl-names on;
+
+{#
+# Key from bind
+include "<%= @dnsupdatekey %>";
+<% @dnsdomain.each do |dom| -%>
+zone <%= dom %>. {
+ primary <%= @nameservers.first %>;
+ key <%= @dnskeyname%>;
+}
+#}
+
+{%- else -%}
+
ddns-update-style {{ server.ddns_update_style|default('none') }};
-{%- if server.ddns_updates is defined %}
-ddns-updates {{ server.ddns_updates }};
-{%- endif -%}
+{%- endif %}
{%- if server.update_static_leases is defined %}
update-static-leases {{ server.update_static_leases }};
-{%- endif -%}
+{%- endif %}
{%- if server.use_host_decl_names is defined %}
use-host-decl-names {{ server.use_host_decl_names }};
-{{- "\n" }}
-{%- endif -%}
+{%- endif %}
-{%- if server.zones is defined -%}
-{%- for zone in server.dhcpd.zones|default({}) %}
-zone {{ zone.name }} {
+{%- for zone_name, zone in server.zone.iteritems() %}
+
+zone {{ zone_name }} {
primary {{ zone.primary }};
{%- if 'key' in zone %}
key {{ zone.key|default('rndc-key') }};
{%- endif %}
}
-{{- "\n" }}
-{%- endfor -%}
-{%- endif %}
+
+{%- endfor %}
default-lease-time {{ server.default_lease_time|default('600') }};
max-lease-time {{ server.max_lease_time|default('7200') }};
@@ -50,36 +66,29 @@
{{- "\n" }}
{%- endif -%}
-{%- if server.allow is defined -%}
- {%- for a in server.dhcpd.allow|default([]) %}
-allow {{ a }};
- {%- endfor -%}
-{{ "\n" }}
-{%- endif -%}
+option domain-name "{{ server.domain_name }}";
+option domain-name-servers {{ server.name_servers|join( ', ') }};
-{%- if server.deny is defined -%}
- {%- for d in server.dhcpd.deny|default([]) %}
-deny {{ d }};
- {%- endfor -%}
-{{ "\n" }}
-{%- endif -%}
+allow booting;
+allow bootp;
-{%- if server.ignore is defined -%}
- {%- for i in server.ignore|default([]) %}
-ignore {{ i }};
- {%- endfor -%}
-{{ "\n" }}
-{%- endif -%}
+option fqdn.no-client-update on; # set the "O" and "S" flag bits
+option fqdn.rcode2 255;
+option pxegrub code 150 = text ;
-{%- set options = server.default_options|default([]) -%}
+{#
-{%- if server.dhcpd.options is defined -%}
- {%- do options.extend(server.dhcpd.options) -%}
-{%- endif -%}
+<% if has_variable?( 'pxeserver' ) &&
+ has_variable?( 'pxefilename' ) &&
+ @pxeserver &&
+ @pxefilename -%>
+# PXE Handoff.
+next-server <%= @pxeserver %>;
+filename "<%= @pxefilename %>";
+<% end -%>
-{%- for o in options %}
-option {{ o }};
-{%- endfor -%}
-{%- set options = [] -%}
+#}
-{%- endif -%}
+include "{{ server.config.dir }}/dhcpd.hosts";
+
+{%- endif -%}
\ No newline at end of file
diff --git a/files/dhcpd.hosts b/files/dhcpd.hosts
new file mode 100644
index 0000000..835da14
--- /dev/null
+++ b/files/dhcpd.hosts
@@ -0,0 +1,11 @@
+{%- from "isc_dhcp/map.jinja" import server with context %}
+
+{%- for host_name, host in server.host.iteritems() %}
+
+host {{ host_name }} {
+ hardware ethernet {{ host.mac }};
+ fixed-address {{ host.address }};
+ ddns-hostname "{{ host.hostname }}";
+}
+
+{%- endfor %}
diff --git a/files/dhcpd.pool b/files/dhcpd.pool
new file mode 100644
index 0000000..d6df787
--- /dev/null
+++ b/files/dhcpd.pool
@@ -0,0 +1,20 @@
+#################################
+# <%= @name %>
+#################################
+subnet <%= @network %> netmask <%= @mask %> {
+<% if @range -%>
+ pool
+ {
+ range <%= @range %>;
+ }
+<% end -%>
+
+ option subnet-mask <%= @mask %>;
+<% if @gateway -%>
+ option routers <%= @gateway %>;
+<% end -%>
+<% if @pxeserver -%>
+ next-server <%= @pxeserver %>;
+<% end -%>
+}
+
diff --git a/map.jinja b/map.jinja
index 16af0eb..ce2f346 100644
--- a/map.jinja
+++ b/map.jinja
@@ -6,9 +6,11 @@
logging:
facility: local7
defaults_config: /etc/default/isc-dhcp-server
+ config_dir: /etc/dhcp
dhcpd_config: /etc/dhcp/dhcpd.conf
hosts_config: /etc/dhcp/dhcpd.hosts
subnets_config: /etc/dhcp/dhcpd.subnets
+ zone: {}
FreeBSD:
pkgs:
- isc-dhcp42-server
@@ -16,9 +18,11 @@
logging:
facility: local7
defaults_config: /etc/rc.conf.d/dhcpd
+ config_dir: /usr/local/etc
dhcpd_config: /usr/local/etc/dhcpd.conf
hosts_config: /usr/local/etc/dhcpd.hosts
subnets_config:/usr/local/etc/dhcpd.subnets
+ zone: {}
RedHat:
pkgs:
- dhcp
@@ -26,6 +30,13 @@
logging:
facility: local7
defaults_config: /etc/sysconfig/dhcpd
+ zone: {}
+Darwin:
+ pkgs:
+ - dhcp
+ service: org.macports.dhcpd
+ config_dir: /opt/local/etc/dhcp
+ zone: {}
{%- endload %}
{%- set server = salt['grains.filter_by'](raw_server, merge=salt['pillar.get']('isc_dhcp:server')) %}