]> gitweb.fluxo.info Git - puppet-dhcp.git/commitdiff
(dhcp::subnet and associated tmpl) updated documentation and removed many options
authorCédric Jeanneret <cedric.jeanneret@camptocamp.com>
Fri, 5 Nov 2010 13:48:26 +0000 (14:48 +0100)
committerCédric Jeanneret <cedric.jeanneret@camptocamp.com>
Fri, 5 Nov 2010 13:48:26 +0000 (14:48 +0100)
I decided to remove many options of the definition, and to replace them
with a single array.

manifests/definitions/dhcp-subnet.pp
templates/subnet.conf.erb

index 46c55ae50570f51b9244cbaca2d7f50344f59946..066f53893755cc0d7265661f44e85e299f107802 100644 (file)
@@ -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",
+  }
 }
index a0a9d29a2ec7183b25960bc1e3b9729fcdab3c4d..c7c690dd4bbdf8d0b51ded7fa3e6a965f7ecedec 100644 (file)
@@ -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 %>
 }