Skip to content

Commit

Permalink
Merge pull request #146 from jcpunk/resource-args
Browse files Browse the repository at this point in the history
Added resource args for use with an ENC
  • Loading branch information
domcleal authored Apr 18, 2017
2 parents f05c108 + 9a3c5af commit 7fd17f5
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 0 deletions.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ class { 'dhcp':
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.

```puppet
dhcp::pool{ 'ops.dc1.example.net':
network => '10.0.1.0',
Expand All @@ -61,6 +63,7 @@ dhcp::pool{ 'ops.dc1.example.net':
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.
```puppet
dhcp::ignoredsubnet{ 'eth0':
network => '10.0.0.0',
Expand All @@ -72,6 +75,7 @@ dhcp::ignoredsubnet{ 'eth0':

Create host reservations.

May be passed as a hash into the DHCP class.
```puppet
dhcp::host { 'server1':
comment => 'Optional descriptive comment',
Expand Down Expand Up @@ -149,6 +153,11 @@ The following is the list of all parameters available for this class.
| `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

Expand Down
20 changes: 20 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@
Boolean $use_ldap = false,
String $option_code150_label = 'pxegrub',
String $option_code150_value = 'text',
Hash[String, Hash] $dhcp_classes = {},
Hash[String, Hash] $hosts = {},
Hash[String, Hash] $ignoredsubnets = {},
Hash[String, Hash] $pools = {},
Hash[String, Hash] $pools6 = {},
) inherits dhcp::params {
if $dnsdomain == undef {
Expand Down Expand Up @@ -242,6 +247,21 @@
order => '01',
}
# Create any DHCP classes requested
create_resources('dhcp::dhcp_class', $dhcp_classes)
# Create any DHCP hosts requested
create_resources('dhcp::host', $hosts)
# Ignore any DHCP subnets requested
create_resources('dhcp::ignoredsubnet', $ignoredsubnets)
# Setup any DHCP pools for IPv6
create_resources('dhcp::pool6', $pools6)
# Setup any DHCP pools for IPv4
create_resources('dhcp::pool', $pools)
# check if this is really a bool
if $use_ldap {
if ($ldap_password == '') {
Expand Down
27 changes: 27 additions & 0 deletions spec/classes/dhcp_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,33 @@
end
end

context 'resources' do
let :params do
default_params.merge('interfaces' => ['eth0'],
'pools' => { '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' } },
'pools6' => { 'ipv6.dc1.example.net' => { 'network' => '2001:db8::',
'prefix' => 64,
'range' => '2001:db8::100 2001:db8::110' } },
'ignoredsubnets' => { 'eth0' => { 'network' => '10.0.0.0',
'mask' => '255.255.255.0' } },
'hosts' => { 'server1' => { 'comment' => 'Optional descriptive comment',
'mac' => '00:50:56:00:00:01',
'ip' => '10.0.1.51' } },
'dhcp_classes' => { 'vendor-class-identifier' => { 'parameters' => ['match option vendor-class-identifier'] } })
end

it 'has resources' do
is_expected.to contain_concat__fragment('dhcp_pool_ops.dc1.example.net')
is_expected.to contain_concat__fragment('dhcp_pool_ipv6.dc1.example.net')
is_expected.to contain_concat__fragment('dhcp_ignoredsubnet_eth0')
is_expected.to contain_concat__fragment('dhcp_host_server1')
is_expected.to contain_concat__fragment('dhcp_class_vendor-class-identifier')
end
end

context 'ntp' do
let :params do
default_params.merge(interfaces: ['eth0'])
Expand Down

0 comments on commit 7fd17f5

Please sign in to comment.