]> gitweb.fluxo.info Git - puppet-dhcp.git/commitdiff
lint + cosmetics
authorMathieu Bornoz <mathieu.bornoz@camptocamp.com>
Thu, 2 Aug 2012 09:24:52 +0000 (11:24 +0200)
committerMathieu Bornoz <mathieu.bornoz@camptocamp.com>
Thu, 2 Aug 2012 09:24:52 +0000 (11:24 +0200)
manifests/host.pp
manifests/params.pp
manifests/server/base.pp
manifests/server/debian.pp
manifests/shared-network.pp
manifests/subnet.pp

index d946ae969163c7967d8e9960033e9c83dd9e31d9..969ecc42130ff96be4dd6b0d36eff17612d9a955 100644 (file)
@@ -1,20 +1,28 @@
-/*
+# = Definition: dhcp::host
+#
+# Create dhcp configuration for a host
+#
+# Arguments:
+# *$mac*:           host MAC address (mandatory)
+# *$subnet*:        subnet in which we want to add this host
+# *$fixed_address*: host fixed address (if not set, takes $name)
+#
+#
+define dhcp::host (
+  $mac,
+  $subnet,
+  $ensure        = present,
+  $fixed_address = false,
+  $options       = false
+) {
 
-= Definition: dhcp::host
-Create dhcp configuration for a host
-
-Arguments:
- *$mac*:           host MAC address (mandatory)
- *$subnet*:        subnet in which we want to add this host
- *$fixed_address*: host fixed address (if not set, takes $name)
-
-*/
-define dhcp::host($ensure=present,$mac,$subnet,$fixed_address=false, $options=false) {
   include dhcp::params
-  concat::fragment {"dhcp.host.$name":
+
+  concat::fragment {"dhcp.host.${name}":
     ensure  => $ensure,
     target  => "${dhcp::params::config_dir}/hosts.d/${subnet}.conf",
-    content => template("dhcp/host.conf.erb"),
-    notify  => Service["dhcpd"],
+    content => template('dhcp/host.conf.erb'),
+    notify  => Service['dhcpd'],
   }
+
 }
index 4a8eaa11c40fb1955a8f8464aa836d814c402bb6..d14746cc20d507187c0442a4f7da09583cbc84aa 100644 (file)
@@ -1,22 +1,27 @@
-/*
+# = Class: dhcp::params
+#
+# Do NOT include this class - it won't do anything.
+# Set variables for names and paths
+#
+class dhcp::params {
 
-= Class: dhcp::params
-Do NOT include this class - it won't do anything.
-Set variables for names and paths
+  case $::operatingsystem {
 
-*/
-class dhcp::params {
-  case $operatingsystem {
     Debian: {
-      $config_dir = $lsbdistcodename? {
-        lenny   => "/etc/dhcp3",
-        squeeze => "/etc/dhcp",
+      $config_dir = $::lsbdistcodename? {
+        lenny   => '/etc/dhcp3',
+        squeeze => '/etc/dhcp',
       }
 
-      $srv_dhcpd = $lsbdistcodename? {
-        lenny   => "dhcp3-server",
-        squeeze => "isc-dhcp-server",
+      $srv_dhcpd = $::lsbdistcodename? {
+        lenny   => 'dhcp3-server',
+        squeeze => 'isc-dhcp-server',
       }
     }
+
+    default: {
+      fail "${name} is not available for ${operatingsystem}/${lsbdistcodename}"
+    }
+
   }
 }
index 53cbd7049658a6e0f47ea69de0ae83dd2c148e32..4e7d645565ffa4acd133af68fa696380d55d2e05 100644 (file)
@@ -1,26 +1,24 @@
-/*
-
-= Class dhcp::server::base
-Do NOT include this class - it won't work at all.
-Set variables for package name and so on.
-This class should be inherited in dhcp::server::$operatingsystem.
-
-*/
+# = Class dhcp::server::base
+#
+# Do NOT include this class - it won't work at all.
+# Set variables for package name and so on.
+# This class should be inherited in dhcp::server::$operatingsystem.
+#
 class dhcp::server::base {
 
   include dhcp::params
   include concat::setup
-  
-  package {"dhcp-server":
+
+  package {'dhcp-server':
     ensure => present,
     name   => $dhcp::params::srv_dhcpd,
   }
 
-  service {"dhcpd":
-    name    => $dhcp::params::srv_dhcpd,
+  service {'dhcpd':
     ensure  => running,
+    name    => $dhcp::params::srv_dhcpd,
     enable  => true,
-    require => Package["dhcp-server"],
+    require => Package['dhcp-server'],
   }
 
   concat {"${dhcp::params::config_dir}/dhcpd.conf":
@@ -29,39 +27,39 @@ class dhcp::server::base {
     mode  => '0644',
   }
 
-  concat::fragment {"00.dhcp.server.base":
+  concat::fragment {'00.dhcp.server.base':
     ensure  => present,
     target  => "${dhcp::params::config_dir}/dhcpd.conf",
-    require => Package["dhcp-server"],
-    notify  => Service["dhcpd"],
+    require => Package['dhcp-server'],
+    notify  => Service['dhcpd'],
   }
 
   file {"${dhcp::params::config_dir}/dhcpd.conf.d":
-    ensure => directory,
-    mode   => 0700,
+    ensure  => directory,
+    mode    => '0700',
     recurse => true,
     purge   => true,
     force   => true,
-    source  => "puppet:///modules/dhcp/empty"
+    source  => 'puppet:///modules/dhcp/empty'
   }
 
   file {"${dhcp::params::config_dir}/subnets":
-    ensure => directory,
-    require => Package["dhcp-server"],
-    notify  => Service["dhcpd"],
+    ensure  => directory,
     recurse => true,
     purge   => true,
     force   => true,
-    source  => "puppet:///modules/dhcp/empty"
+    source  => 'puppet:///modules/dhcp/empty',
+    require => Package['dhcp-server'],
+    notify  => Service['dhcpd'],
   }
 
   file {"${dhcp::params::config_dir}/hosts.d":
-    ensure => directory,
-    require => Package["dhcp-server"],
+    ensure  => directory,
     recurse => true,
     purge   => true,
     force   => true,
-    source  => "puppet:///modules/dhcp/empty"
+    source  => 'puppet:///modules/dhcp/empty',
+    require => Package['dhcp-server'],
   }
 
 }
index 3cc750872490e2b1ab8131f985d435d98fbb93c4..5d23bbe17c9c9170dd46cab603209ecb197c04ac 100644 (file)
@@ -1,21 +1,21 @@
-/*
-
-= Class: dhcp::server::debian
-Installs a dhcp server on debian system.
-
-This class should not be included as is, please include "dhcp::server" instead.
-
-*/
+# = Class: dhcp::server::debian
+#
+# Installs a dhcp server on debian system.
+#
+# This class should not be included as is,
+# please include "dhcp::server" instead.
+#
 class dhcp::server::debian inherits dhcp::server::base {
 
-  Concat::Fragment["00.dhcp.server.base"] {
+  Concat::Fragment['00.dhcp.server.base'] {
     content => template('dhcp/dhcpd.conf.debian.erb'),
   }
 
-  Service["dhcpd"] {
-    pattern => $lsbdistcodename ? {
-      squeeze => "/usr/sbin/dhcpd",
-      lenny   => "/usr/sbin/dhcpd3",
+  Service['dhcpd'] {
+    pattern => $::lsbdistcodename ? {
+      squeeze => '/usr/sbin/dhcpd',
+      lenny   => '/usr/sbin/dhcpd3',
     }
   }
+
 }
index 2154d37af9994508e600cdcd1e652902382bd2ad..9a02a5b8eb57eaa2cc585f4e4cfd83618e7c797d 100644 (file)
@@ -1,22 +1,25 @@
-/*
+# == Definition: dhcp::shared-network
+# Creates a shared-network
+#
+# Arguments:
+#  *$subnets* : subnet list to be included in the shared-network
+#
+# Warnings:
+#  - subnets must exists
+#  - subnets must have $is_shared set to true (default is false)
+#
+define dhcp::shared-network(
+  $ensure  = present,
+  $subnets = []
+) {
 
-== Definition: dhcp::shared-network
-Creates a shared-network
-
-Arguments:
-  *$subnets* : subnet list to be included in the shared-network
-
-Warnings:
-- subnets must exists
-- subnets must have $is_shared set to true (default is false)
-
-*/
-define dhcp::shared-network($ensure=present, $subnets=[]) {
   include dhcp::params
+
   concat::fragment {"shared-${name}":
     ensure  => $ensure,
     target  => "${dhcp::params::config_dir}/dhcpd.conf",
-    content => template("dhcp/shared-network.erb"),
+    content => template('dhcp/shared-network.erb'),
     require => Dhcp::Subnet[$subnets],
   }
+
 }
index 15afd53bb4a10e2d98849fa09fefbff3abc9abb8..18ffdc5c2fb56cc5ef8eb932c05b6337869e5aef 100644 (file)
@@ -1,40 +1,41 @@
-/*
-
-= 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
- *$is_shared*   : whether it's part of a shared network or not. Default: false
-
-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;'],
-  }
-}
-*/
+# = 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
+#  *$is_shared*   : whether it's part of a shared network or not. Default: false
+#
+# 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,
   $broadcast,
+  $ensure=present,
   $netmask=false,
   $routers=false,
   $subnet_mask=false,
   $domain_name=false,
   $other_opts=false,
-  $is_shared=false) {
+  $is_shared=false
+) {
+
   include dhcp::params
 
   concat {"${dhcp::params::config_dir}/hosts.d/${name}.conf":
@@ -44,13 +45,13 @@ define dhcp::subnet(
   }
 
   file {"${dhcp::params::config_dir}/subnets/${name}.conf":
-    ensure => $ensure,
-    owner  => root,
-    group  => root,
-    content => template("dhcp/subnet.conf.erb"),
-    notify  => Service["dhcpd"],
+    ensure  => $ensure,
+    owner   => root,
+    group   => root,
+    content => template('dhcp/subnet.conf.erb'),
+    notify  => Service['dhcpd'],
   }
-  
+
   if ! $is_shared {
     concat::fragment {"dhcp.${name}":
       ensure  => $ensure,