Git Product home page Git Product logo

voxpupuli / puppet-dhcp Goto Github PK

View Code? Open in Web Editor NEW
42.0 127.0 134.0 619 KB

Puppet module for deploying dhcp

Home Page: https://forge.puppet.com/puppet/dhcp

License: Apache License 2.0

Ruby 55.22% Puppet 30.84% HTML 13.13% Dockerfile 0.72% Pascal 0.09%
linux-puppet-module puppet hacktoberfest archlinux-puppet-module centos-puppet-module debian-puppet-module redhat-puppet-module ubuntu-puppet-module

puppet-dhcp's Introduction

DHCP module for Puppet

Build Status Release Puppet Forge Puppet Forge - downloads Puppet Forge - endorsement Puppet Forge - scores puppetmodule.info docs Apache-2.0 License

Overview

Installs and manages a DHCP server.

Features

  • Multiple subnet support
  • Host reservations
  • Secure dynamic DNS updates when combined with Bind
  • Can create a dummy (ignored) subnet so that the server can be used only as a helper-address target

Usage

Define the server and the zones it will be responsible for.

class { 'dhcp':
  service_ensure => running,
  dnsdomain      => [
    'dc1.example.net',
    '1.0.10.in-addr.arpa',
  ],
  nameservers  => ['10.0.1.20'],
  ntpservers   => ['us.pool.ntp.org'],
  interfaces   => ['eth0'],
  dnsupdatekey => '/etc/bind/keys.d/rndc.key',
  dnskeyname   => 'rndc-key',
  require      => Bind::Key['rndc-key'],
  pxeserver    => '10.0.1.50',
  pxefilename  => 'pxelinux.0',
  omapi_port   => 7911,
}

dhcp::pool

Define the pool attributes. This example will create a pool, which serves IPs of two different ranges in the same network.

May be passed as a hash into the DHCP class.

dhcp::pool{ 'ops.dc1.example.net':
  network => '10.0.1.0',
  mask    => '255.255.255.0',
  range   => ['10.0.1.10 10.0.1.100', '10.0.1.200 10.0.1.250' ],
  gateway => '10.0.1.1',
}

dhcp::ignoredsubnet

Define a subnet that will be ignored - useful for making the DHCP server only respond to requests forwarded by switches etc.

May be passed as a hash into the DHCP class.

dhcp::ignoredsubnet{ 'eth0':
  network => '10.0.0.0',
  mask    => '255.255.255.0',
}

dhcp::host

Create host reservations.

May be passed as a hash into the DHCP class.

dhcp::host { 'server1':
  comment            => 'Optional descriptive comment',
  mac                => '00:50:56:00:00:01',
  ip                 => '10.0.1.51',
  # Optionally override subnet/global settings for some hosts.
  default_lease_time => 600,
  max_lease_time     => 900,
  # Optionally declare event statements in any combination.
  on_commit => [
    'set ClientIP = binary-to-ascii(10, 8, ".", leased-address)',
    'execute("/usr/local/bin/my_dhcp_helper.sh", ClientIP)'
  ],
  on_release => [
    'set ClientIP = binary-to-ascii(10, 8, ".", leased-address)',
    'log(concat("Released IP: ", ClientIP))'
  ],
  on_expiry => [
    'set ClientIP = binary-to-ascii(10, 8, ".", leased-address)',
    'log(concat("Expired IP: ", ClientIP))'
  ]
}

parameters

Parameters are available to configure pxe or ipxe

Boot ipxe from pxe. When configured this overrides pxefilename. For more information see ipxe.org.

class { 'dhcp':
  ipxe_filename  => 'undionly.kpxe',
  ipxe_bootstrap => 'bootstrap.kpxe',
  pxeserver      => '10.0.1.50',
}

The following is the list of all parameters available for this class.

Parameter Data Type Default Value
authoritative Boolean true
ddns_update_static String 'on'
ddns_update_style String 'interim'
ddns_update_optimize String 'on'
default_lease_time Integer 43200
dhcp_conf_ddns String 'INTERNAL_TEMPLATE'
dhcp_conf_extra String 'INTERNAL_TEMPLATE'
dhcp_conf_fragments Hash {}
dhcp_conf_header String 'INTERNAL_TEMPLATE'
dhcp_conf_ntp String 'INTERNAL_TEMPLATE'
dhcp_conf_pxe String 'INTERNAL_TEMPLATE'
dhcp_dir String $dhcp::params::dhcp_dir
dhcpd_conf_filename String 'dhcpd.conf'
dnsdomain Array undef
dnskeyname String undef
dnssearchdomains Array []
dnsupdatekey String undef
extra_config String ''
globaloptions String ''
interface String 'NOTSET'
interfaces Array undef
ipxe_bootstrap String undef
ipxe_filename String undef
ldap_base_dn String 'dc=example, dc=com'
ldap_debug_file String undef
ldap_method String 'dynamic'
ldap_password String ''
ldap_port Integer 389
ldap_server String 'localhost'
ldap_username String 'cn=root, dc=example, dc=com'
logfacility String 'daemon'
manage_service Boolean true
max_lease_time Integer 86400
mtu Integer undef
nameservers Array []
nameservers_ipv6 Array []
ntpservers Array []
omapi_algorithm String HMAC-MD5
omapi_key String undef
omapi_name String undef
omapi_port Integer undef
option_code150_label String pxegrub
option_code150_value String text
package_provider String $dhcp::params::package_provider
packagename String $dhcp::params::packagename
manage_package Boolean true
pxefilename String undef
pxeserver String undef
service_ensure Enum running
servicename String $dhcp::params::servicename
use_ldap Boolean false
dhcp_classes Hash {}
hosts Hash {}
ignoredsubnets Hash {}
pools Hash {}
pools6 Hash {}

Contributors

Zach Leslie [email protected] Ben Hughes [email protected] Sam Dunster [email protected] Garrett Honeycutt [email protected] Matt Kirby [email protected]

puppet-dhcp's People

Contributors

alelindq avatar alexjfisher avatar aquister avatar barn avatar bastelfreak avatar bbriggs avatar bmjen avatar daenney avatar dhoppe avatar domcleal avatar ekohl avatar ghoneycutt avatar hunner avatar igalic avatar jyaworski avatar kenyon avatar mattkirby avatar mergwyn avatar mj avatar nanliu avatar pecastro avatar root-expert avatar sircubbi avatar smortex avatar tiernap avatar tom-krieger avatar tphoney avatar tragiccode avatar treydock avatar zilchms avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

puppet-dhcp's Issues

Indefinite lease time broken by #219

Affected Puppet, Ruby, OS and module versions/distributions

  • Puppet: All
  • Ruby: All
  • Distribution: All
  • Module version: 4.0.0

How to reproduce (e.g Puppet code you use)

class { 'dhcp':
  default_lease_time => -1,
  max_lease_time     => -1,
}

What are you seeing

error

What behavior did you expect instead

isc dhcp supports indefinite timeout as -1

Output log

Error: Could not retrieve catalog from remote server: Error 500 on SERVER: Server Error: Evaluation Error: Error while evaluating a Resource Statement, Class[Dhcp]:
parameter 'default_lease_time' expects an Integer[1] value, got Integer[-1, -1]
parameter 'max_lease_time' expects an Integer[1] value, got Integer[-1, -1] (file: test.pp, line: 16, column: 3) on node test.local

Any additional information you'd like to impart

isc dhcp supports indefinite leases by setting timeout to -1

Boot filename per client architecture

Add a parameter to set per-architecture (boot) filenames in the DHCP config, e.g.

option architecture code 93 = unsigned integer 16 ;
if option architecture = 00:00 {
  filename "pxelinux.0";
} elsif option architecture = 00:06 {
  filename "shim.efi";
} else {
  filename "mypxefilename";
}

In theforeman/dhcp, a $bootfiles hash has filenames keyed by architecture codes: theforeman/puppet-dhcp@6d01407

Add support of shared-network option

That's good work Guys, but I have a one question.

Are you going to support shared-network option in dhcp::pools module?
In my opinion this is very important feature especially when you have many small subnets in many VLANs

Cheers!
Pawel

bootp is disabled upon failover configuration, while this should not be

Affected Puppet, Ruby, OS and module versions/distributions

  • Module version: latest (3.3.0 at the time of bug reporting)

How to reproduce (e.g Puppet code you use)

Configure DHCP with failover module

What are you seeing

bootp is disabled by default, as by
#126

What behaviour did you expect instead

The pull refer to https://linux.die.net/man/5/dhcpd.conf
But this chapter does not reflect anymore the current configuration, at least from Debian Stretch.

https://manpages.debian.org/testing/isc-dhcp-server/dhcpd.conf.5.en.html (ref: v4.3)
https://kb.isc.org/docs/isc-dhcp-41-manual-pages-dhcpdconf#configuring-failover
https://kb.isc.org/docs/isc-dhcp-44-manual-pages-dhcpdconf#configuring-failover

It should be sufficient to remove the bootp related line

Support subclass ?

Affected Puppet, Ruby, OS and module versions/distributions

  • Puppet: 4
  • Ruby:
  • Distribution: Debian Stretch
  • Module version: 3.2.0

How to reproduce (e.g Puppet code you use)

Use subclass

What are you seeing

Subclass is not managed in this module

What behaviour did you expect instead

Allow use of "subclass" method
https://www.isc.org/wp-content/uploads/2017/08/dhcp41options.html

subclass "vendor-classes" "SUNW.Ultra-5_10" { 
vendor-option-space SUNW; 
option SUNW.root-path "/export/root/sparc"; 
}

Output log

Any additional information you'd like to impart

Question on support for Puppet 8

Hi,

Is there a plan to release a version of this module that is compatible with Puppet 8?

Currently in metadata.json the version requirements on Puppet are as following: ">= 7.0.0 < 8.0.0"
The concat and stdlib versions would also need to be incremented.

Thanks,
Maureen

DHCPDARGS from /etc/sysconfig/dhcpd not used on RHEL7.

It would be useful to add arbitrary arguments to the /etc/sysconfig/dhcpd file, but this file is not consumed by the systemd service. It seems on RHEL6 the system V init script would be left intact so that this file would be used.

How to reproduce (e.g Puppet code you use)

On RHEL 7, use dhcp module and the interfaces should appear on the command line.

What are you seeing

The interfaces are not specified on the command line.

What behaviour did you expect instead

The interfaces to be enumerated on the command line.

Output log

Any additional information you'd like to impart

It would be useful to add arbitrary arguments to the /etc/sysconfig/dhcpd file.

add unit tests

This module has no tests, so it's hard to merge PR's... here's some initial tests. they need expansion, but it's a starting point.

INTERFACES default option deprecated on Debian 9

Affected Puppet, Ruby, OS and module versions/distributions

  • Puppet: PE 2017.3
  • Ruby: PE ruby
  • Distribution: Debian 9 (stretch)
  • Module version: 3.2.0

How to reproduce (e.g Puppet code you use)

Configure IPv4 range to be served from a Debian 9 system.

What are you seeing

/etc/default/isc-dhcp-server contains an INTERFACES variable. Latest versions appear to have split that up between INTERFACESv4 and INTERFACESv6 so one may server each on differing interfaces as required.

What behaviour did you expect instead

Expected running servive, but systemd sees it as a failure.

Output log

Mar 11 20:46:22 desktop puppet-agent[16440]: (/Stage[main]/Dhcp/Service[isc-dhcp-server]) Mar 11 20:46:20 desktop systemd[1]: Stopping LSB: DHCP server...
Mar 11 20:46:22 desktop puppet-agent[16440]: (/Stage[main]/Dhcp/Service[isc-dhcp-server]) Mar 11 20:46:20 desktop isc-dhcp-server[16583]: Stopping ISC DHCPv4 server: dhcpd.
Mar 11 20:46:22 desktop puppet-agent[16440]: (/Stage[main]/Dhcp/Service[isc-dhcp-server]) Mar 11 20:46:20 desktop systemd[1]: Stopped LSB: DHCP server.
Mar 11 20:46:22 desktop puppet-agent[16440]: (/Stage[main]/Dhcp/Service[isc-dhcp-server]) Mar 11 20:46:20 desktop systemd[1]: Starting LSB: DHCP server...
Mar 11 20:46:22 desktop puppet-agent[16440]: (/Stage[main]/Dhcp/Service[isc-dhcp-server]) Mar 11 20:46:20 desktop isc-dhcp-server[16596]: DHCPv4 interfaces are no longer set by the INTERFACES variable in
Mar 11 20:46:22 desktop puppet-agent[16440]: (/Stage[main]/Dhcp/Service[isc-dhcp-server]) Mar 11 20:46:20 desktop isc-dhcp-server[16596]: /etc/default/isc-dhcp-server. Please use INTERFACESv4 instead.
Mar 11 20:46:22 desktop puppet-agent[16440]: (/Stage[main]/Dhcp/Service[isc-dhcp-server]) Mar 11 20:46:20 desktop isc-dhcp-server[16596]: Migrating automatically for now, but this will go away in the futu
Mar 11 20:46:22 desktop puppet-agent[16440]: (/Stage[main]/Dhcp/Service[isc-dhcp-server]) Mar 11 20:46:20 desktop isc-dhcp-server[16596]: Launching IPv4 server only.
Mar 11 20:46:22 desktop puppet-agent[16440]: (/Stage[main]/Dhcp/Service[isc-dhcp-server]) Mar 11 20:46:20 desktop dhcpd[16607]: Internet Systems Consortium DHCP Server 4.3.5
Mar 11 20:46:22 desktop puppet-agent[16440]: (/Stage[main]/Dhcp/Service[isc-dhcp-server]) Mar 11 20:46:20 desktop dhcpd[16607]: Copyright 2004-2016 Internet Systems Consortium.
Mar 11 20:46:22 desktop puppet-agent[16440]: (/Stage[main]/Dhcp/Service[isc-dhcp-server]) Mar 11 20:46:20 desktop dhcpd[16607]: All rights reserved.
Mar 11 20:46:22 desktop puppet-agent[16440]: (/Stage[main]/Dhcp/Service[isc-dhcp-server]) Mar 11 20:46:20 desktop dhcpd[16607]: For info, please visit https://www.isc.org/software/dhcp/
Mar 11 20:46:22 desktop puppet-agent[16440]: (/Stage[main]/Dhcp/Service[isc-dhcp-server]) Mar 11 20:46:20 desktop dhcpd[16607]: Wrote 0 deleted host decls to leases file.
Mar 11 20:46:22 desktop puppet-agent[16440]: (/Stage[main]/Dhcp/Service[isc-dhcp-server]) Mar 11 20:46:20 desktop dhcpd[16607]: Wrote 0 new dynamic host decls to leases file.
Mar 11 20:46:22 desktop puppet-agent[16440]: (/Stage[main]/Dhcp/Service[isc-dhcp-server]) Mar 11 20:46:20 desktop dhcpd[16607]: Wrote 29 leases to leases file.
Mar 11 20:46:22 desktop puppet-agent[16440]: (/Stage[main]/Dhcp/Service[isc-dhcp-server]) Mar 11 20:46:22 desktop isc-dhcp-server[16596]: Starting ISC DHCPv4 server: dhcpdcheck syslog for diagnostics. ...
Mar 11 20:46:22 desktop puppet-agent[16440]: (/Stage[main]/Dhcp/Service[isc-dhcp-server]) Mar 11 20:46:22 desktop isc-dhcp-server[16596]: failed!
Mar 11 20:46:22 desktop puppet-agent[16440]: (/Stage[main]/Dhcp/Service[isc-dhcp-server]) Mar 11 20:46:22 desktop systemd[1]: isc-dhcp-server.service: Control process exited, code=exited status=1
Mar 11 20:46:22 desktop puppet-agent[16440]: (/Stage[main]/Dhcp/Service[isc-dhcp-server]) Mar 11 20:46:22 desktop systemd[1]: Failed to start LSB: DHCP server.
Mar 11 20:46:22 desktop puppet-agent[16440]: (/Stage[main]/Dhcp/Service[isc-dhcp-server]) Mar 11 20:46:22 desktop systemd[1]: isc-dhcp-server.service: Unit entered failed state.
Mar 11 20:46:22 desktop puppet-agent[16440]: (/Stage[main]/Dhcp/Service[isc-dhcp-server]) Mar 11 20:46:22 desktop systemd[1]: isc-dhcp-server.service: Failed with result 'exit-code'.

Any additional information you'd like to impart

allow dhcp to run without domain-name-servers option

Affected Puppet, Ruby, OS and module versions/distributions

  • Puppet: PE 2016.2.1
  • Ruby: 1.8.7.374
  • Distribution: CentOS 6
  • Module version: 0.4.0

How to reproduce (e.g Puppet code you use)

class { "dhcp":
  [...other options...]
  nameservers        => [],
  dnsdomain          => [],
}

What are you seeing

dhcp does not run, because option domain-name-servers is empty (if you set nameservers to undef instead it will add the google nameservers)

What behaviour did you expect instead

generate a dhcpd.conf without "option domain-name-servers" and "option domain-name"

Any additional information you'd like to impart

simple fix would be the following:

diff --git a/environments/production/modules/dhcp/templates/dhcpd.conf-header.erb b/environments/production/modules/dhcp/templates/dhcpd.conf-header.erb
index 9f12b2a..bae1d36 100644
--- a/environments/production/modules/dhcp/templates/dhcpd.conf-header.erb
+++ b/environments/production/modules/dhcp/templates/dhcpd.conf-header.erb
@@ -13,8 +13,12 @@ log-facility <%= @logfacility %>;
 # ----------
 # Options
 # ----------
+<% if @dnsdomain_real and !@dnsdomain_real.empty? -%>
 option domain-name "<%= @dnsdomain_real.first %>";
+<% end -%>
+<% if @nameservers and @nameservers.is_a? Array and [email protected]? -%>
 option domain-name-servers <%= @nameservers.join(', ') %>;
+<% end -%>
 option fqdn.no-client-update on;  # set the "O" and "S" flag bits
 option fqdn.rcode2 255;
 option pxegrub code 150 = text;

however, properly allow to supply undef to those options would be better (but might break the usage for people who would like to have the google-servers as default). At least there need to be the possibility to not supply nameservers at all.

Could not find dependent Service[dhcpd] for File[/etc/systemd/system/dhcpd.service] when manage_service is false

Hi all,

while trying to use this module in combination with pacemaker, I've discovered that if manage_service is false, then File[/etc/systemd/system/dhcpd.service] cannot "notify" the Service['dhcpd'].

Error: Failed to apply catalog: Could not find dependent Service[dhcpd] for File[/etc/systemd/system/dhcpd.service] at /opt/mdc/puppet/puppet_3rd_party/modules/dhcp/manifests/init.pp:181

FIX:

diff --git manifests/init.pp manifests/init.pp
index 23ac4f3..0d56344 100644
--- manifests/init.pp
+++ manifests/init.pp
@@ -183,7 +183,7 @@ class dhcp (
       owner   => 'root',
       group   => 'root',
       mode    => '0644',
-      notify  => Service[$servicename],
+      notify  => $service_notify_real,
       content => template('dhcp/dhcpd.service'),
     }
   } else {

In the end, thank you for the great job
Dan

No dependency on Module Concat

Hi,

Just walking through a howto to setup Razor and as part of this process installed the puppetlabs-dhcp. This has a clean install of puppet and puppetmaster. Following the guide these are the commands I have run:

puppet module install puppetlabs-razor
puppet apply /etc/puppet/modules/razor/tests/init.pp --verbose

puppet module install zleslie/dhcp
puppet apply /etc/puppet/modules/dhcp/tests/init.pp --verbose

Running the dhcp tests init.pp file it complains that it could not find class concat::setup.

I think the forge module file needs to include a dependacy on concat::setup.

Peter

Documentation example uses Bind module with no reference (or suggestions)

Affected Puppet, Ruby, OS and module versions/distributions

  • Puppet: n/a
  • Ruby: n/a
  • Distribution: n/a
  • Module version: v1.0.0

What are you seeing

This issue is related to documentation.

In the examples it shows the module interfacing with BIND to do allow dynamic DNS entries, e.g. require => Bind::Key['rndc-key'],.

This example appears to reference a specific Bind module, but as there is no official module and quite a number of competing BIND Puppet modules in Forge, is there a specific version it's intended to work with and, if so, should this not be referenced somewhere?

in pool manifest, for options, an array is allowed but fails

Hi,

In the pool.pp manifest, the options is referred as:

# Optional String or Array of `option` to set in the pool

But, in the code, is reported as follows:

Optional[String[1]] $options = undef,

Given the YAML

    options:
      - 'netbios-name-servers 192.168.0.1'
      - 'netbios-dd-server 192.168.0.1'
      - 'netbios-node-type 8'
      - 'ubnt.unifi-address 192.168.0.2'

It is producing the following error:

Error: Could not retrieve catalog from remote server: Error 500 on SERVER: Server Error: Evaluation Error: Error while evaluating a Resource Statement, Dhcp::Pool[DOMAIN]: parameter 'options' expects a value of type Undef or String, got Tuple (file: /etc/puppetlabs/code/environments/development/modules/dhcp/manifests/init.pp, line: 311) on node FQDN

The following line restore the functionality:
Optional[Array[String]] $options = undef,
As well as
Optional[Variant[Array[String],String[1]]] $options = undef,

Mind that also "parameter" can be an Array, so i believe it's broken as well.

# Optional String or Array of manual parameters to set

Optional[String[1]] $parameters = undef,

Are possibly other portion of code with the same mistake?

Before pushing a PR, i would like to get a review...

Ubuntu 18.04 Interfaces not set

Affected Puppet, Ruby, OS and module versions/distributions

  • Puppet: puppetserver-5.3.5-1.el7.noarch
  • Ruby: 2.4.4 (puppet server), 2.5.1 (puppet client)
  • Distribution: Centos 7 (puppet server) / Ubuntu 18.04 (puppet agent)
  • Module version :3.3.0

How to reproduce (e.g Puppet code you use)

Setting up the dhcp class as follows:

Puppet file:

# Forge Modules
mod 'puppetlabs/ntp', '4.1.0'
mod 'puppetlabs/stdlib'
mod 'thias-bind', '0.5.3'
mod 'puppet-dhcp',           '3.3.0'  #https://forge.puppet.com/puppet/dhcp
mod 'puppetlabs-tftp',       '1.0.0'  #https://forge.puppet.com/puppetlabs/tftp
mod 'chocolatey-chocolatey', '1.2.6'  #https://forge.puppet.com/chocolatey/chocolatey
#mod 'puppet-nginx',          '0.14.0' #https://forge.puppet.com/puppet/nginx
mod 'puppetlabs-concat',     '5.1.0' #https://forge.puppet.com/puppetlabs/concat

dhcp class

class profile::dhcp(

  String $dns_server,
  String $gateway,
  String $pxe_server,
  Array $interfaces,

){
  
  include dhcp

  class { 'dhcp':
    service_ensure => running,
    dnsdomain      => [
      'network.local',
      '0.168.192.in-addr.arpa',
    ],
    nameservers  => [$dns_server],
    ntpservers   => ['192.168.0.1'],
    interfaces   =>  $interfaces,
    pxeserver    => '192.168.0.99',
    pxefilename  => 'pxelinux.0',
  }

   dhcp::pool {'sn_192.168.0.0' :
     network     => '192.168.0.0',
     mask        => '255.255.255.0',
     range       => '192.168.0.120 192.168.0.140',
     nameservers => [$dns_server],
     gateway     => $gateway,
     pxeserver   => $pxe_server,
     pxefilename => 'pxelinux.0',
   }
}

Node yaml has the following:

# dhcp settings for clients
profile::dhcp::dns_server: '192.168.0.99'
profile::dhcp::gateway: '192.168.0.1'
profile::dhcp::pxe_server: '192.168.0.99'
profile::dhcp::interfaces: 
  - 'bond-vms'

What are you seeing

The compilation error when running the class on the Ubuntu client (18.04)

Error: Could not retrieve catalog from remote server: Error 500 on SERVER: Server Error: Evaluation Error: Error while evaluating a Function Call, You need to set $interfaces in dhcp (file: /etc/puppetlabs/code/environments/master/modules/dhcp/manifests/init.pp, line: 104, column: 5) on node grace.network.local

It doesn't seem to matter if use the interface or interfaces I get the same error message.

Thanks
-Nigel

Add event handlers to main and pool config - Enhancement

  • Module version: 4.0.1

The event handlers are currently only supported for dhcp::host (see #216). These handlers can also exist globally in dhcpd.conf or in the pool definition dhcpd::pool and dhcpd::pool6.

I propose to replicate the PR and add 3 new optional parameters to the relevant classes:

on_commit
on_release
on_expiry

So two questions:

  • Is there any reason not to do this?
  • Is there a recommended pattern for including an ERB template fragment in multiple places, or should I just duplicate the 20 or so lines of template code (and associated test code) where needed?

dhcp6 support

It's currently not possible to use this module to set up a DHCPv6 service

Docs: mention the ripienaar-concat dependency

default behaviour when following the README:

# puppet apply /etc/puppet/manifests/razor.pp --verbose --noop
info: Loading facts in /etc/puppet/modules/stdlib/lib/facter/root_home.rb
info: Loading facts in /etc/puppet/modules/stdlib/lib/facter/facter_dot_d.rb
info: Loading facts in /etc/puppet/modules/stdlib/lib/facter/puppet_vardir.rb
Could not find class concat::setup for puppet-razor at /etc/puppet/modules/dhcp/manifests/init.pp:84 on node puppet-razor

After a 'puppet module install ripienaar-concat' the 'concat::setup' is correctly available.

Support hostnames for fixed-address parameter in dhcp::host

Currently the $ip parameter in dhcp::host is of type Stdlib::Compact::Ip_address and so it is not possible to pass a hostname to the fixed-address parameter. Since dhcpd also supports hostnames for the fixed-address parameter, please add support for this too.

All Numeric MAC causes Detail: undefined method `upcase'

Affected Puppet, Ruby, OS and module versions/distributions

  • Puppet: 3.8.7
  • Ruby: ruby 2.0.0p598 (2014-11-13) [x86_64-linux]
  • Distribution: Centos but can reproduce on Ubuntu, Debian, Oracle Linux
  • Module version: All

How to reproduce (e.g Puppet code you use)

When a host mac address contains only numeric values processing fails. For example:
mac: 00:07:43:14:16:70

What are you seeing

The following line in the template lcoated in puppetlabs-dhcp/templates/dhcpd.host.erb
causes the issue, because it can't do the operation when only numeric values exist.
hardware ethernet <%= @mac.upcase %>;

What behaviour did you expect instead

It should work on any valid mac address.

Output log

Debug: template[/etc/puppet/modules/dhcp/templates/dhcpd.host.erb]: Bound template variables for /etc/puppet/modules/dhcp/templates/dhcpd.host.erb in 0.00 seconds
Error: Failed to parse template dhcp/dhcpd.host.erb:
  Filepath: /etc/puppet/modules/dhcp/templates/dhcpd.host.erb
  Line: 2
  Detail: undefined method `upcase' for 6535303:Fixnum
 at /etc/puppet/modules/dhcp/manifests/host.pp:20 on node aa7edca96e89.c2r1.openstack.tld
/usr/share/ruby/vendor_ruby/puppet/parser/functions/template.rb:26:in `rescue in block (2 levels) in <top (required)>'
/usr/share/ruby/vendor_ruby/puppet/parser/functions/template.rb:22:in `block (2 levels) in <top (required)>'
/usr/share/ruby/vendor_ruby/puppet/parser/functions/template.rb:15:in `collect'
/usr/share/ruby/vendor_ruby/puppet/parser/functions/template.rb:15:in `block in <top (required)>'
/usr/share/ruby/vendor_ruby/puppet/parser/functions.rb:164:in `block (2 levels) in newfunction'
/usr/share/ruby/vendor_ruby/puppet/util/profiler/around_profiler.rb:58:in `profile'
/usr/share/ruby/vendor_ruby/puppet/util/profiler.rb:51:in `profile'
/usr/share/ruby/vendor_ruby/puppet/parser/functions.rb:157:in `block in newfunction'
/usr/share/ruby/vendor_ruby/puppet/parser/ast/function.rb:42:in `evaluate'
/usr/share/ruby/vendor_ruby/puppet/parser/ast.rb:61:in `safeevaluate'
/usr/share/ruby/vendor_ruby/puppet/parser/ast/resourceparam.rb:14:in `evaluate'
/usr/share/ruby/vendor_ruby/puppet/parser/ast.rb:61:in `safeevaluate'
/usr/share/ruby/vendor_ruby/puppet/parser/ast/resource.rb:29:in `block (2 levels) in evaluate'
/usr/share/ruby/vendor_ruby/puppet/parser/ast/branch.rb:12:in `block in each'
/usr/share/ruby/vendor_ruby/puppet/parser/ast/branch.rb:11:in `each'
/usr/share/ruby/vendor_ruby/puppet/parser/ast/branch.rb:11:in `each'
/usr/share/ruby/vendor_ruby/puppet/parser/ast/resource.rb:28:in `collect'
/usr/share/ruby/vendor_ruby/puppet/parser/ast/resource.rb:28:in `block in evaluate'
/usr/share/ruby/vendor_ruby/puppet/parser/ast/branch.rb:12:in `block in each'
/usr/share/ruby/vendor_ruby/puppet/parser/ast/branch.rb:11:in `each'
/usr/share/ruby/vendor_ruby/puppet/parser/ast/branch.rb:11:in `each'
/usr/share/ruby/vendor_ruby/puppet/parser/ast/resource.rb:25:in `collect'
/usr/share/ruby/vendor_ruby/puppet/parser/ast/resource.rb:25:in `evaluate'
/usr/share/ruby/vendor_ruby/puppet/parser/ast.rb:61:in `safeevaluate'
/usr/share/ruby/vendor_ruby/puppet/parser/ast/block_expression.rb:11:in `block in evaluate'
/usr/share/ruby/vendor_ruby/puppet/parser/ast/block_expression.rb:10:in `each'
/usr/share/ruby/vendor_ruby/puppet/parser/ast/block_expression.rb:10:in `evaluate'
/usr/share/ruby/vendor_ruby/puppet/parser/ast.rb:61:in `safeevaluate'
/usr/share/ruby/vendor_ruby/puppet/resource/type.rb:129:in `evaluate_code'
/usr/share/ruby/vendor_ruby/puppet/parser/resource.rb:81:in `block in evaluate'
/usr/share/ruby/vendor_ruby/puppet/util/profiler/around_profiler.rb:58:in `profile'
/usr/share/ruby/vendor_ruby/puppet/util/profiler.rb:51:in `profile'
/usr/share/ruby/vendor_ruby/puppet/parser/resource.rb:77:in `evaluate'
/usr/share/ruby/vendor_ruby/puppet/parser/compiler.rb:386:in `block (3 levels) in evaluate_definitions'
/usr/share/ruby/vendor_ruby/puppet/parser/compiler.rb:385:in `each'
/usr/share/ruby/vendor_ruby/puppet/parser/compiler.rb:385:in `block (2 levels) in evaluate_definitions'
/usr/share/ruby/vendor_ruby/puppet/util/profiler/around_profiler.rb:58:in `profile'
/usr/share/ruby/vendor_ruby/puppet/util/profiler.rb:51:in `profile'
/usr/share/ruby/vendor_ruby/puppet/parser/compiler.rb:384:in `block in evaluate_definitions'
/usr/share/ruby/vendor_ruby/puppet/util/errors.rb:64:in `exceptwrap'
/usr/share/ruby/vendor_ruby/puppet/parser/compiler.rb:383:in `evaluate_definitions'
/usr/share/ruby/vendor_ruby/puppet/parser/compiler.rb:404:in `block (2 levels) in evaluate_generators'
/usr/share/ruby/vendor_ruby/puppet/util/profiler/around_profiler.rb:58:in `profile'
/usr/share/ruby/vendor_ruby/puppet/util/profiler.rb:51:in `profile'
/usr/share/ruby/vendor_ruby/puppet/parser/compiler.rb:401:in `block in evaluate_generators'
/usr/share/ruby/vendor_ruby/puppet/parser/compiler.rb:398:in `loop'
/usr/share/ruby/vendor_ruby/puppet/parser/compiler.rb:398:in `evaluate_generators'
/usr/share/ruby/vendor_ruby/puppet/parser/compiler.rb:141:in `block (2 levels) in compile'
/usr/share/ruby/vendor_ruby/puppet/util/profiler/around_profiler.rb:58:in `profile'
/usr/share/ruby/vendor_ruby/puppet/util/profiler.rb:51:in `profile'
/usr/share/ruby/vendor_ruby/puppet/parser/compiler.rb:141:in `block in compile'
/usr/share/ruby/vendor_ruby/puppet/context.rb:64:in `override'
/usr/share/ruby/vendor_ruby/puppet.rb:246:in `override'
/usr/share/ruby/vendor_ruby/puppet/parser/compiler.rb:121:in `compile'
/usr/share/ruby/vendor_ruby/puppet/parser/compiler.rb:34:in `compile'
/usr/share/ruby/vendor_ruby/puppet/indirector/catalog/compiler.rb:95:in `block (2 levels) in compile'
/usr/share/ruby/vendor_ruby/puppet/util/profiler/around_profiler.rb:58:in `profile'
/usr/share/ruby/vendor_ruby/puppet/util/profiler.rb:51:in `profile'
/usr/share/ruby/vendor_ruby/puppet/indirector/catalog/compiler.rb:93:in `block in compile'
/usr/share/ruby/vendor_ruby/puppet/util.rb:161:in `block in benchmark'
/usr/share/ruby/benchmark.rb:296:in `realtime'
/usr/share/ruby/vendor_ruby/puppet/util.rb:160:in `benchmark'
/usr/share/ruby/vendor_ruby/puppet/indirector/catalog/compiler.rb:92:in `compile'
/usr/share/ruby/vendor_ruby/puppet/indirector/catalog/compiler.rb:52:in `find'
/usr/share/ruby/vendor_ruby/puppet/indirector/indirection.rb:201:in `find'
/usr/share/ruby/vendor_ruby/puppet/application/apply.rb:222:in `block in main'
/usr/share/ruby/vendor_ruby/puppet/context.rb:64:in `override'
/usr/share/ruby/vendor_ruby/puppet.rb:246:in `override'
/usr/share/ruby/vendor_ruby/puppet/application/apply.rb:198:in `main'
/usr/share/ruby/vendor_ruby/puppet/application/apply.rb:159:in `run_command'
/usr/share/ruby/vendor_ruby/puppet/application.rb:381:in `block (2 levels) in run'
/usr/share/ruby/vendor_ruby/puppet/application.rb:507:in `plugin_hook'
/usr/share/ruby/vendor_ruby/puppet/application.rb:381:in `block in run'
/usr/share/ruby/vendor_ruby/puppet/util.rb:496:in `exit_on_fail'
/usr/share/ruby/vendor_ruby/puppet/application.rb:381:in `run'
/usr/share/ruby/vendor_ruby/puppet/util/command_line.rb:146:in `run'
/usr/share/ruby/vendor_ruby/puppet/util/command_line.rb:92:in `execute'
/usr/bin/puppet:8:in `<main>'
Error: Failed to parse template dhcp/dhcpd.host.erb:
  Filepath: /etc/puppet/modules/dhcp/templates/dhcpd.host.erb
  Line: 2
  Detail: undefined method `upcase' for 6535303:Fixnum
 at /etc/puppet/modules/dhcp/manifests/host.pp:20 on node aa7edca96e89.c2r1.openstack.tld
/usr/share/ruby/vendor_ruby/puppet/parser/functions/template.rb:26:in `rescue in block (2 levels) in <top (required)>'
/usr/share/ruby/vendor_ruby/puppet/parser/functions/template.rb:22:in `block (2 levels) in <top (required)>'
/usr/share/ruby/vendor_ruby/puppet/parser/functions/template.rb:15:in `collect'
/usr/share/ruby/vendor_ruby/puppet/parser/functions/template.rb:15:in `block in <top (required)>'
/usr/share/ruby/vendor_ruby/puppet/parser/functions.rb:164:in `block (2 levels) in newfunction'
/usr/share/ruby/vendor_ruby/puppet/util/profiler/around_profiler.rb:58:in `profile'
/usr/share/ruby/vendor_ruby/puppet/util/profiler.rb:51:in `profile'
/usr/share/ruby/vendor_ruby/puppet/parser/functions.rb:157:in `block in newfunction'
/usr/share/ruby/vendor_ruby/puppet/parser/ast/function.rb:42:in `evaluate'
/usr/share/ruby/vendor_ruby/puppet/parser/ast.rb:61:in `safeevaluate'
/usr/share/ruby/vendor_ruby/puppet/parser/ast/resourceparam.rb:14:in `evaluate'
/usr/share/ruby/vendor_ruby/puppet/parser/ast.rb:61:in `safeevaluate'
/usr/share/ruby/vendor_ruby/puppet/parser/ast/resource.rb:29:in `block (2 levels) in evaluate'
/usr/share/ruby/vendor_ruby/puppet/parser/ast/branch.rb:12:in `block in each'
/usr/share/ruby/vendor_ruby/puppet/parser/ast/branch.rb:11:in `each'
/usr/share/ruby/vendor_ruby/puppet/parser/ast/branch.rb:11:in `each'
/usr/share/ruby/vendor_ruby/puppet/parser/ast/resource.rb:28:in `collect'
/usr/share/ruby/vendor_ruby/puppet/parser/ast/resource.rb:28:in `block in evaluate'
/usr/share/ruby/vendor_ruby/puppet/parser/ast/branch.rb:12:in `block in each'
/usr/share/ruby/vendor_ruby/puppet/parser/ast/branch.rb:11:in `each'
/usr/share/ruby/vendor_ruby/puppet/parser/ast/branch.rb:11:in `each'
/usr/share/ruby/vendor_ruby/puppet/parser/ast/resource.rb:25:in `collect'
/usr/share/ruby/vendor_ruby/puppet/parser/ast/resource.rb:25:in `evaluate'
/usr/share/ruby/vendor_ruby/puppet/parser/ast.rb:61:in `safeevaluate'
/usr/share/ruby/vendor_ruby/puppet/parser/ast/block_expression.rb:11:in `block in evaluate'
/usr/share/ruby/vendor_ruby/puppet/parser/ast/block_expression.rb:10:in `each'
/usr/share/ruby/vendor_ruby/puppet/parser/ast/block_expression.rb:10:in `evaluate'
/usr/share/ruby/vendor_ruby/puppet/parser/ast.rb:61:in `safeevaluate'
/usr/share/ruby/vendor_ruby/puppet/resource/type.rb:129:in `evaluate_code'
/usr/share/ruby/vendor_ruby/puppet/parser/resource.rb:81:in `block in evaluate'
/usr/share/ruby/vendor_ruby/puppet/util/profiler/around_profiler.rb:58:in `profile'
/usr/share/ruby/vendor_ruby/puppet/util/profiler.rb:51:in `profile'
/usr/share/ruby/vendor_ruby/puppet/parser/resource.rb:77:in `evaluate'
/usr/share/ruby/vendor_ruby/puppet/parser/compiler.rb:386:in `block (3 levels) in evaluate_definitions'
/usr/share/ruby/vendor_ruby/puppet/parser/compiler.rb:385:in `each'
/usr/share/ruby/vendor_ruby/puppet/parser/compiler.rb:385:in `block (2 levels) in evaluate_definitions'
/usr/share/ruby/vendor_ruby/puppet/util/profiler/around_profiler.rb:58:in `profile'
/usr/share/ruby/vendor_ruby/puppet/util/profiler.rb:51:in `profile'
/usr/share/ruby/vendor_ruby/puppet/parser/compiler.rb:384:in `block in evaluate_definitions'
/usr/share/ruby/vendor_ruby/puppet/util/errors.rb:64:in `exceptwrap'
/usr/share/ruby/vendor_ruby/puppet/parser/compiler.rb:383:in `evaluate_definitions'
/usr/share/ruby/vendor_ruby/puppet/parser/compiler.rb:404:in `block (2 levels) in evaluate_generators'
/usr/share/ruby/vendor_ruby/puppet/util/profiler/around_profiler.rb:58:in `profile'
/usr/share/ruby/vendor_ruby/puppet/util/profiler.rb:51:in `profile'
/usr/share/ruby/vendor_ruby/puppet/parser/compiler.rb:401:in `block in evaluate_generators'
/usr/share/ruby/vendor_ruby/puppet/parser/compiler.rb:398:in `loop'
/usr/share/ruby/vendor_ruby/puppet/parser/compiler.rb:398:in `evaluate_generators'
/usr/share/ruby/vendor_ruby/puppet/parser/compiler.rb:141:in `block (2 levels) in compile'
/usr/share/ruby/vendor_ruby/puppet/util/profiler/around_profiler.rb:58:in `profile'
/usr/share/ruby/vendor_ruby/puppet/util/profiler.rb:51:in `profile'
/usr/share/ruby/vendor_ruby/puppet/parser/compiler.rb:141:in `block in compile'
/usr/share/ruby/vendor_ruby/puppet/context.rb:64:in `override'
/usr/share/ruby/vendor_ruby/puppet.rb:246:in `override'
/usr/share/ruby/vendor_ruby/puppet/parser/compiler.rb:121:in `compile'
/usr/share/ruby/vendor_ruby/puppet/parser/compiler.rb:34:in `compile'
/usr/share/ruby/vendor_ruby/puppet/indirector/catalog/compiler.rb:95:in `block (2 levels) in compile'
/usr/share/ruby/vendor_ruby/puppet/util/profiler/around_profiler.rb:58:in `profile'
/usr/share/ruby/vendor_ruby/puppet/util/profiler.rb:51:in `profile'
/usr/share/ruby/vendor_ruby/puppet/indirector/catalog/compiler.rb:93:in `block in compile'
/usr/share/ruby/vendor_ruby/puppet/util.rb:161:in `block in benchmark'
/usr/share/ruby/benchmark.rb:296:in `realtime'
/usr/share/ruby/vendor_ruby/puppet/util.rb:160:in `benchmark'
/usr/share/ruby/vendor_ruby/puppet/indirector/catalog/compiler.rb:92:in `compile'
/usr/share/ruby/vendor_ruby/puppet/indirector/catalog/compiler.rb:52:in `find'
/usr/share/ruby/vendor_ruby/puppet/indirector/indirection.rb:201:in `find'
/usr/share/ruby/vendor_ruby/puppet/application/apply.rb:222:in `block in main'
/usr/share/ruby/vendor_ruby/puppet/context.rb:64:in `override'
/usr/share/ruby/vendor_ruby/puppet.rb:246:in `override'
/usr/share/ruby/vendor_ruby/puppet/application/apply.rb:198:in `main'
/usr/share/ruby/vendor_ruby/puppet/application/apply.rb:159:in `run_command'
/usr/share/ruby/vendor_ruby/puppet/application.rb:381:in `block (2 levels) in run'
/usr/share/ruby/vendor_ruby/puppet/application.rb:507:in `plugin_hook'
/usr/share/ruby/vendor_ruby/puppet/application.rb:381:in `block in run'
/usr/share/ruby/vendor_ruby/puppet/util.rb:496:in `exit_on_fail'
/usr/share/ruby/vendor_ruby/puppet/application.rb:381:in `run'
/usr/share/ruby/vendor_ruby/puppet/util/command_line.rb:146:in `run'
/usr/share/ruby/vendor_ruby/puppet/util/command_line.rb:92:in `execute'
/usr/bin/puppet:8:in `<main>'

Any additional information you'd like to impart

Tests - Pool has a string not an array

Hi,

When I installed the this module I ran the test script and got the below output:

root@creator ~# puppet apply /etc/puppet/modules/dhcp/tests/init.pp --verbose
Info: Loading facts in /etc/puppet/modules/stdlib/lib/facter/pe_version.rb
Info: Loading facts in /etc/puppet/modules/stdlib/lib/facter/root_home.rb
Info: Loading facts in /etc/puppet/modules/stdlib/lib/facter/puppet_vardir.rb
Info: Loading facts in /etc/puppet/modules/stdlib/lib/facter/facter_dot_d.rb
Info: Loading facts in /etc/puppet/modules/concat/lib/facter/concat_basedir.rb
Warning: Config file /etc/puppet/hiera.yaml not found, using Hiera defaults
Error: Failed to parse template dhcp/dhcpd.pool.erb:
Filepath: /etc/puppet/modules/dhcp/templates/dhcpd.pool.erb
Line: 7
Detail: undefined method each' for "10.1.1.100":String at /etc/puppet/modules/dhcp/manifests/pool.pp:15 on node creator.mgnt.local Error: Failed to parse template dhcp/dhcpd.pool.erb: Filepath: /etc/puppet/modules/dhcp/templates/dhcpd.pool.erb Line: 7 Detail: undefined methodeach' for "10.1.1.100":String
at /etc/puppet/modules/dhcp/manifests/pool.pp:15 on node creator.mgnt.local

While trying to work out what was wrong I realised that in the tests/init.pp file the test for the dhcpd.pool.erb file is passing a string and not an array:

dhcp::pool{ 'example.com':
network => '10.1.1.0',
mask => '255.255.255.0',
range => '10.1.1.100 10.1.1.200',
gateway => '10.1.1.1',
}

(Look at the range line) which means that in the erb template the string does not have an each method.

Also the DHCP module has a dependency on the Bind Module which means that the test fails because it cannot find the Bind module.

Centos 7 Failover fails

Affected Puppet, Ruby, OS and module versions/distributions

  • Puppet: 4.8.1
  • Ruby:
  • Distribution: CentOS Linux release 7.2.1511
  • Module version: 1.0.2-rc0+

How to reproduce (e.g Puppet code you use)

  class { 'dhcp':
    dnsdomain   => hiera('dhcp::dnsdomain'),
    nameservers => hiera('dhcp::nameservers'),
    ntpservers  => hiera('dhcp::ntpservers'),
    interfaces  => hiera('dhcp::interfaces'),
#   dnsupdatekey => "/etc/bind/bind.keys.d/${ddnskey}.key",
#   require      => Dns::Key[$ddnskey],
  }
  if ($ipam::dhcp_use_failover) {
    class {'dhcp::failover':
      role         => hiera('dhcp::failover::role'),
      peer_address => hiera('dhcp::failover::peer_address'),
    }

What are you seeing

Failover configuration fails do to "port" statement in template.

What behaviour did you expect instead

Failover configuration functioned properly when using centos 6. It appears changes between centos 6 and centos 7 regarding to dhcpd cause this module to when configuring failover on centos 7.
Commenting out the port statement in the templates/dhcpd.conf.failover.erb file resolves the issue.

Output log

Any additional information you'd like to impart

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.