aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--manifests/definitions/dhcp-subnet.pp58
-rw-r--r--templates/subnet.conf.erb25
2 files changed, 50 insertions, 33 deletions
diff --git a/manifests/definitions/dhcp-subnet.pp b/manifests/definitions/dhcp-subnet.pp
index 46c55ae..066f538 100644
--- a/manifests/definitions/dhcp-subnet.pp
+++ b/manifests/definitions/dhcp-subnet.pp
@@ -1,22 +1,43 @@
+/*
+
+= Definition: dhcp::subnet
+Creates a subnet
+
+Arguments:
+ *$broadcast* : subnet broadcast (mandatory)
+ *$netmask* : subnet netmask (if not set, takes eth0 netmask)
+ *$routers* : subnet routers (array) (if not set, takes eth0 IP)
+ *$subnet_mask* : netmask sent to dhcp guests (if not set, takes $netmask, or netmask_eth0)
+ *$domain_name* : subnet domain name (if not set, takes server domain)
+ *$other_opts* : any other DHCPD option, as an array
+
+Example:
+
+node "dhcp.domain.ltd" {
+ $dhcpd_domain_name = 'domain.ltd'
+ $dhcpd_dns_servers = '10.27.21.1, 10.26.21.1'
+ include dhcp
+
+ dhcp::subnet {"10.27.20.0":
+ ensure => present,
+ broadcast => "10.27.20.255",
+ other_opts => ['filename "pxelinux.0";', 'next-server 10.27.10.1;'],
+ }
+}
+*/
define dhcp::subnet(
$ensure=present,
- $bcast,
- $dns,
+ $broadcast,
$netmask=false,
- $domain_name=false,
- $inc=false,
- $routeurs=false,
- $netbios_dns=false,
+ $routers=false,
$subnet_mask=false,
- $other_opt=false,
- $deny=false) {
- include dhcp::variables
+ $domain_name=false,
+ $other_opts=false) {
+ include dhcp::params
- if $inc {
- $to_inc = "${dhcp::variables::config_dir}/hosts.d/${name}.conf"
- }
+ $to_include = "${dhcp::params::config_dir}/hosts.d/${name}.conf"
- file {"${dhcp::variables::config_dir}/subnets/${name}.conf":
+ file {"${dhcp::params::config_dir}/subnets/${name}.conf":
ensure => $ensure,
owner => root,
group => root,
@@ -24,10 +45,15 @@ define dhcp::subnet(
notify => Service["dhcpd"],
}
- common::concatfilepart {"${name}":
- file => "${dhcp::variables::config_dir}/dhcpd.conf",
+ common::concatfilepart {"dhcp.${name}":
+ file => "${dhcp::params::config_dir}/dhcpd.conf",
ensure => $ensure,
- content => "include \"${dhcp::variables::config_dir}/subnets/${name}.conf\";\n",
+ content => "include \"${dhcp::params::config_dir}/subnets/${name}.conf\";\n",
}
+ common::concatfilepart {"00.dhcp.${name}.base":
+ file => $to_include,
+ ensure => $ensure,
+ content => "# File managed by puppet\n",
+ }
}
diff --git a/templates/subnet.conf.erb b/templates/subnet.conf.erb
index a0a9d29..c7c690d 100644
--- a/templates/subnet.conf.erb
+++ b/templates/subnet.conf.erb
@@ -5,35 +5,26 @@ subnet <%=name%> netmask <%=netmask%> {
<% else -%>
subnet <%=name%> netmask <%=netmask_eth0%> {
<% end -%>
-<% if routeurs -%>
- option routers <%=routeurs%>;
+<% if routers and not routers.empty? -%>
+ option routers routers.collect! {|i| "#{i}" }.join(",");
<% else -%>
option routers <%=network_eth0%>;
<% end -%>
<% if subnet_mask -%>
option subnet-mask <%=subnet_mask%>;
-<% else -%>
+<% else if netmask -%>
option subnet-mask <%=netmask%>;
+<% else -%>
+ option subnet-mask <%=netmask_eth0%>;
<% end -%>
- option broadcast-address <%=bcast%>;
- option domain-name-servers <%=dns%>;
+ option broadcast-address <%=broadcast%>;
<% if domain_name -%>
option domain-name "<%=domain_name%>";
<% else -%>
option domain-name "<%=domain%>";
<% end -%>
-<% if netbios_dns -%>
- option netbios-name-servers <%=netbios_dns%>;
-<% else -%>
- option netbios-name-servers <%=network_eth0%>;
-<% end -%>
-<% if deny -%>
- deny <%=deny%>;
-<% end -%>
-<% if inc -%>
include "<%=to_inc%>";
+<% if other_opts and not other_opts.empty? -%>
+<%= other_opts.collect! {|i| " #{i}" }.join(";\n") %>
<% end -%>
-<% if other_opt and not other_opt.empty? -%>
-<%= other_opt.collect! {|i| " #{i}" }.join("\n") -%>
-<% end %>
}