Giter Site home page Giter Site logo

puppet-dhcp's Introduction

DHCP module for Puppet

DHCP module for theforeman. Based on original DHCP module by ZLeslie, thanks to him for the original work.

Installs and manages a DHCP server.

Dependencies

Features

  • Multiple subnet support
  • Support for multiple pools within a subnet
  • Host reservations
  • Secure dynamic DNS updates when combined with Bind
  • Failover support

Usage

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

class { 'dhcp':
  dnsdomain    => [
    'dc1.example.net',
    '1.0.10.in-addr.arpa',
    ],
  nameservers  => ['10.0.1.20'],
  interfaces   => ['eth0'],
  dnsupdatekey => "/etc/bind/keys.d/$ddnskeyname",
  require      => Bind::Key[ $ddnskeyname ],
  pxeserver    => '10.0.1.50',
  pxefilename  => 'pxelinux.0',
}

dhcp::pool

To create a subnet with a single pool, use dhcp::pool.

Define the pool attributes

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

Override global attributes with pool specific

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

For the support of static routes (RFC3442):

dhcp::pool{ 'ops.dc1.example.net':
  network => '10.0.1.0',
  mask    => '255.255.255.0',
  range   => '10.0.1.100 10.0.1.200',
  gateway => $gw,
  static_routes =>  [ { 'mask' => '32', 'network' => '169.254.169.254', 'gateway' => $ip },
                      { 'mask' => '0',                                  'gateway' => $gw } ],
}

dhcp::subnet

To create a subnet with multiple pools, use dhcp::subnet.

dhcp::subnet{ 'ops.dc1.example.net':
  network => '10.0.1.0',
  mask    => '255.255.255.0',
  pools   => [
    {
      range      => '10.0.1.101 10.0.1.110',
      parameters => [
        'allow members of "group1"',
        'next-server 10.1.1.1',
      ],
    },
    {
      range      => '10.0.1.111 10.0.1.120',
      parameters => [
        'allow members of "group2"',
        'next-server 10.1.1.2',
      ],
    },
  ],
  gateway => '10.0.1.1',
}

dhcp::host

Create host reservations.

dhcp::host {
  'server1': mac => "00:50:56:00:00:01", ip => "10.0.1.51";
  'server2': mac => "00:50:56:00:00:02", ip => "10.0.1.52";
  'server3': mac => "00:50:56:00:00:03", ip => "10.0.1.53";
}

Contributors

Original authors:

Copyright (c) 2010-2016 Zach Leslie, Ben Hughes, Greg Sutcliffe, Foreman developers

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

puppet-dhcp's People

Contributors

alexjfisher avatar alvin-huang avatar archanaserver avatar bastelfreak avatar brandonweeks avatar cwood avatar davidblaisonneau-orange avatar dizz avatar dlobatog avatar dmitri-d avatar domcleal avatar ehelms avatar ekohl avatar evgeni avatar ezr-ondrej avatar gregsutcliffe avatar inecas avatar izzette avatar jhoblitt avatar jklare avatar lzap avatar manfredp avatar mmoll avatar oneingan avatar russellshackleford avatar sathieu avatar uip9av6y avatar wbclark avatar wnkz avatar xcompass avatar

Stargazers

 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

puppet-dhcp's Issues

Failed to convert '/var/lib/puppet/concat/output/["dhcp.conf"].out' to URI

I get the following error with the dhcp module:

Error: Failed to apply catalog: Parameter source failed on File[/etc/dhcp/dhcpd.conf]: Failed to convert '/var/lib/puppet/concat/output/["dhcp.conf"].out' to URI: bad component(expected absolute path component): /var/lib/puppet/concat/output/[%22dhcp.conf%22].out at /var/lib/puppet/environments/production/modules/dhcp/manifests/init.pp:83
Wrapped exception:
Failed to convert '/var/lib/puppet/concat/output/["dhcp.conf"].out' to URI: bad component(expected absolute path component): /var/lib/puppet/concat/output/[%22dhcp.conf%22].out

Any hints what I can do to fix it?

dhcp domain-search

It seems the syntax for the domain-search option is wrong. Current syntax:

option domain-search "domain.com, domain.org";

That didn't work for me and I tried:

option domain-search "domain.com", "domain.org";

and it worked! I'm not exactly sure if this is a version conflict because I can't find any documentation in the man pages of dhcpd.conf.

Add support for options in dhcp pool

Support for an option-array of options to be added in the dhcp-pool:

Example:

dhcp::pool { "name":
  ....
  options => [
    'domain-search       "pro.localdomain", "ont.localdomain"',
    'broadcast-address   192.168.0.254',
    'domain-name-servers 192.168.0.10, 192.168.0.11',
  ]
}

The puppetlabs/dhcp is almost the same as theforeman/puppet-dhcp and puppetlabs support this but that module isn't supported by theforeman puppet modules.

Compatible with Puppet 4?

The changelog for version 2.0.0 states the following:

Test with future parser and Puppet 4

However, the Puppet Forge compatibility states this:

Puppet Enterprise 3.8.x, 3.7.x, 3.3.x, 3.2.x, 3.1.x
Puppet >= 3.0.0 < 4.0.0

This leaves me a bit confused...

Issue disabling the pool

Our foreman deployment model is to put a dhcp/tftp server on each subnet. Now we are being requested to deploy to subnets where we can not control the IPs with dhcp.

My thought is to build a dhcp/tftp server that only serves static reservations. The <% if @range -%> in templates/dhcpd.pool.erb the check is always returning true because foreman is passing the value as a string, so not disabling the pool definition.

My quick hack was to change the line to:
<% if (@range and (@range =~ /\d/)) -%>

This was sufficient for my testing, but is probably not ideal to be published. Better suggestions are welcome.

Pool Description

Hello,
is there a specific reason for defining the pool description within templates/dhcpd.pool.erb like this?

#################################
# <%= @name %>
#################################

Some tools like Webmin rely on the first comment to name the pools within the webinterface. In the above mentioned case it will be displayed as ################################# which is kind of useless.

Would you mind if we adjust this to the following?

# <%= @name %>
  • mat1010

Allow multiple pools per subnet

Hello,

I have modified the dhcp module to allow multiple pools per subnet and I'd like to propose it for inclusion in your module.

I'd be glad if you could have a look at the fork geof77/puppet-dhcp and give me feedback on the modifications. The README has also been modified to reflect the improvements and give usage examples.

I hope you find this useful, at least it is very useful for me :-)

Use case:

I want to change the pxefilename for clients matching a filter, e.g. the hostname (dhcp::host definition) begins with "ppc".

  1. create dhcp::host definitions
  2. create "ppc64" dhcp::class, match if hostname begins with 'ppc'
  3. create subnet with common attributes (network, mask, gateway, pxeserver,...)
  4. create two pools with different ranges within this subnet (previously not possible)
  5. through the "(pool_)parameters" attribute, pass
    'allow members of "ppc64"' and 'filename "ppcxyz"' to the first pool
    'deny members of "ppc64"' to the second pool

Implementation:

Note: I did not care about backward compatibility yet.

Split dhcp::pool in two:

  • A 'dhcp::subnet' definition containing only network-related attributes
  • A 'dhcp::subnet::pool' definition containing the range (and pxefilename overrides)
    Split templates in two:
  • A 'dhcpd.subnet.erb' template
  • A 'dhcpd.pool.erb' template
    Replace pool.pp manifest with subnet.pp containing "dhcp::subnet" and "dhcp::subnet::pool"
    Modify init.pp to create subnet and pool resources.

Other improvements in my fork:

  • Allow pxefilename and pxeserver overrides in the subnet and/or pool instances
  • Add allow_class and deny_class parameters to the pools to avoid using plain text "parameters" (i.e. "allow members of ...")

Best regards,
Geof

please provide a new release

Hi,
could you please publish a new version of the module? The 8.0.0 release on the forge doesn't allow puppetlabs/stdlib 8.1.0. The metadata.json in master already allows it. I've the same request for:

  • theforeman/dns
  • theforeman/puppet
  • theforeman/puppetserver_foreman
  • theforeman/tftp
    I didn't raise separate issues for them. Please let me know if I should do that.

Use of notify_service requires systemd dependency version bump

#199 makes use of systemd::dropin_file notify_service parameter, however the module currently depends on camptocamp/systemd which tops out at version 3.0, however notify_service has only been implemented from puppet/systemd version 3.1. This causes the nightly versions of foreman installer to fail with the below error:

2021-09-19 20:45:26 [NOTICE] [root] Loading installer configuration. This will take some time.
2021-09-19 20:45:34 [NOTICE] [root] Running installer with log based terminal output at level NOTICE.
2021-09-19 20:45:34 [NOTICE] [root] Use -l to set the terminal output log level to ERROR, WARN, NOTICE, INFO, or DEBUG. See --full-help for definitions.
2021-09-19 20:45:54 [NOTICE] [configure] Starting system configuration.
2021-09-19 20:46:05 [ERROR ] [configure] Evaluation Error: Error while evaluating a Resource Statement, Systemd::Dropin_file[interfaces.conf]: has no parameter named 'notify_service' (file: /usr/share/foreman-installer/modules/dhcp/manifests/init.pp, line: 102) on node whitefall.jellybean.sihnon.net
2021-09-19 20:46:05 [NOTICE] [configure] System configuration has finished.

  There were errors detected during install.
  Please address the errors and re-run the installer to ensure the system is properly configured.
  Failing to do so is likely to result in broken functionality.

  The full log is at /var/log/foreman-installer/katello.log

Dropping in puppet/systemd 3.4.0 appears to work fine as a drop-in replacement:

puppet module install puppet/systemd --target-dir /usr/share/foreman-installer/modules/ --ignore-dependencies --force

This module's dependency list should be updated to at least puppet/systemd >= 3.1.0, else #199 should be reworked to only use functionality available in the older camptocamp module versions.

Foreman doesn't import this class, no errors.

I have added this class to my puppet modules folder but foreman doesn't recognize the class and doesn't import it.

I don't see any faults that fast in the module, I tested also some simple other manifest in my env and that one gets detected well.

Any idea ?

shared_network support

Hi, I'm need to configure dhcp shared network to use different subnet on the same server with one interface.

I need to change configuration from

subnet 172.17.0.0 netmask 255.255.255.0 {
  option subnet-mask 255.255.255.0;
  option routers 172.17.0.1;
}

to

shared-network provisioning {
  subnet 172.17.0.0 netmask 255.255.255.0 {
    option subnet-mask 255.255.255.0;
    option routers 172.17.0.1;
  }

  subnet 172.17.1.0 netmask 255.255.255.0 {
    option subnet-mask 255.255.255.0;
    option routers 172.17.1.1;
  }
}

Is it supported or scheduled?

Cannot set service status

Service is set to
service { $servicename:
ensure => running,
enable => true,
}

Need to add the ensure as a variable.

Why is it impossible to properly include a bind key stanza without Bind::Key dependency?

If this module is actually dependent on a Bind::Key resource from another module that dependency should be clearly stated. If it isn't dependent the correct method needs to be in the README.md. Both theforeman/dhcp and the foreman/dns need their READMEs updated badly. Telling everyone to join the IRC channel for the Foreman is counterproductive.

The sections enable DDNS:
ddns_updates => true,
ddns_domainname => $my_domain,
ddns_rev_domainname => $my_domain,

But it can't properly function without additional steps because the dhcpd.conf.erb will never include the definition of the key.

Setting the option:
dnsupdatekey => '/etc/dhcp/dynamic',
Tells the config where to look for a separate stanza in a file that could have just been in dhcpd.conf

The contents of the file have to be in a format similar to this (where you set a secret appropriate for the algorithm of your choice and note that several algorithms available don't actually work):
key dynamic { algorithm hmac-md5; secret "abcdefghijklmnopqrstuvwxyz"; }

And setting the option:
dnskeyname => 'dynamic',
Add key dynamic to every pool so that it knows to refer to a key named 'dynamic' that you had created.

The actual key that DNS would use is a separate piece you would need setting up bind9 and using dnssec-keygen but which should have the same name when you cat the public key generated by dnssec-keygen.

I hope this helps save someone the awesome headache of trying to use this module.

capability to add custom fragments

currently, module doesn't support ability to add custom configuration, akin apache::custom_config
There are too many options available in dhcpd to support them all and it would be beneficial to add custom code fragments in dhcpd.conf

For example, in a pool section, I can't support both BIOS and UEFI

  if option architecture-type = 00:07 {
    filename "shimx64.efi";
  } else {
    filename "pxelinux.0";
  }

Can't specify these either, for example:

ddns-ttl 600;
ddns-hostname = pick-first-value (option host-name, option fqdn.hostname);

Documentation missing for 'parameters' within pool

Am I blind and not seeing it somewhere, or is there no documentation for "parameters" and "pool_parameters"?

I just found both of these and were exactly what I needed after digging through the source a bit.

I'd be happy to do a quick write up and submit a PR for this if it doesn't already exist somewhere I'm not seeing.

@interfaces should be @dhcp_interfaces in templates/redhat/systemd-dropin.conf.erb

With the puppet code:

include dhcp

and the hieradata:

dhcp::interface "${facts.networking.primary}"

The catalog compilation fails with the following error:

Error while evaluating a Function Call, Failed to parse template dhcp/redhat/systemd-dropin.conf.erb:
  Filepath: /etc/puppetlabs/code/environments/dhcpd/modules/dhcp/templates/redhat/systemd-dropin.conf.erb
  Line: 3
  Detail: undefined method `join' for nil:NilClass
 (file: /etc/puppetlabs/code/environments/dhcpd/modules/dhcp/manifests/init.pp, line: 88, column: 22)

The problem is that the template is attempting to use the parameter @interfaces instead of @dhcp_interfaces which is set

# In case people set interface instead of interfaces work around
# that. If they set both, use interfaces and the user is a unwise
# and deserves what they get.
if $interface != 'NOTSET' and $interfaces == undef {
$dhcp_interfaces = [ $interface ]
} elsif $interface == 'NOTSET' and $interfaces == undef {
fail ("You need to set \$interfaces in ${module_name}")
} else {
$dhcp_interfaces = $interfaces
}

I would honestly recommend, while you are looking at that to just set the default interface using the fact like we did above in hieradata.

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.