Skip to content

Commit

Permalink
Stop using absolute names
Browse files Browse the repository at this point in the history
Since Puppet 4 this is no longer needed.
  • Loading branch information
ekohl authored and mmoll committed Nov 19, 2018
1 parent 3cd2f39 commit 631e0e6
Show file tree
Hide file tree
Showing 11 changed files with 27 additions and 28 deletions.
1 change: 0 additions & 1 deletion Gemfile
Expand Up @@ -12,7 +12,6 @@ gem 'rspec-puppet', '~> 2.3'
gem 'rspec-puppet-facts', '>= 1.7'
gem 'puppetlabs_spec_helper', '>= 2.1.1'
gem 'puppet-lint', '>= 2'
gem 'puppet-lint-absolute_classname-check'
gem 'puppet-lint-classes_and_types_beginning_with_digits-check'
gem 'puppet-lint-empty_string-check'
gem 'puppet-lint-file_ensure-check'
Expand Down
8 changes: 4 additions & 4 deletions examples/init.pp
@@ -1,19 +1,19 @@
$ddnskeyname = 'dhcp_updater'

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

class { '::dhcp::failover':
class { 'dhcp::failover':
role => 'primary',
peer_address => '10.1.1.20',
}
Expand Down
2 changes: 1 addition & 1 deletion manifests/dhcp_class.pp
Expand Up @@ -2,7 +2,7 @@
Variant[Array[String], String] $parameters,
) {
concat::fragment { "dhcp.conf+50_${name}.dhcp":
target => "${::dhcp::dhcp_dir}/dhcpd.conf",
target => "${dhcp::dhcp_dir}/dhcpd.conf",
content => template('dhcp/dhcpd.class.erb'),
order => "50-${name}",
}
Expand Down
6 changes: 3 additions & 3 deletions manifests/disable.pp
Expand Up @@ -2,10 +2,10 @@
# Remove and Disable the DHCP server
# ----------
class dhcp::disable {
include ::dhcp::params
include dhcp::params

$packagename = $::dhcp::params::packagename
$servicename = $::dhcp::params::servicename
$packagename = $dhcp::params::packagename
$servicename = $dhcp::params::servicename

package { $packagename:
ensure => absent,
Expand Down
6 changes: 3 additions & 3 deletions manifests/failover.pp
@@ -1,7 +1,7 @@
class dhcp::failover (
String $peer_address,
Enum['primary', 'secondary'] $role = 'primary',
String $address = $::ipaddress,
String $address = $facts['ipaddress'],
Variant[Integer[0, 65535], String] $port = 519,
Variant[Integer[0], String] $max_response_delay = 30,
Variant[Integer[0], String] $max_unacked_updates = 10,
Expand All @@ -11,10 +11,10 @@
Optional[String] $omapi_key = undef,
) {

include ::dhcp
include dhcp

concat::fragment { 'dhcp.conf+10_failover.dhcp':
target => "${::dhcp::dhcp_dir}/dhcpd.conf",
target => "${dhcp::dhcp_dir}/dhcpd.conf",
content => template('dhcp/dhcpd.conf.failover.erb'),
order => '10',
}
Expand Down
2 changes: 1 addition & 1 deletion manifests/host.pp
Expand Up @@ -7,7 +7,7 @@
$host = $name

concat::fragment { "dhcp.hosts+10_${name}.hosts":
target => "${::dhcp::dhcp_dir}/dhcpd.hosts",
target => "${dhcp::dhcp_dir}/dhcpd.hosts",
content => template('dhcp/dhcpd.host.erb'),
order => "10-${name}",
}
Expand Down
6 changes: 3 additions & 3 deletions manifests/init.pp
Expand Up @@ -69,7 +69,7 @@
}

# Only debian and ubuntu have this style of defaults for startup.
case $::osfamily {
case $facts['osfamily'] {
'Debian': {
file{ '/etc/default/isc-dhcp-server':
ensure => file,
Expand All @@ -82,8 +82,8 @@
}
}
'RedHat': {
if versioncmp($::operatingsystemmajrelease, '7') >= 0 {
include ::systemd
if versioncmp($facts['operatingsystemmajrelease'], '7') >= 0 {
include systemd
systemd::dropin_file { 'interfaces.conf':
unit => 'dhcpd.service',
content => template('dhcp/redhat/systemd-dropin.conf.erb'),
Expand Down
8 changes: 4 additions & 4 deletions manifests/params.pp
@@ -1,9 +1,9 @@
class dhcp::params {

$dnsdomain = [$::domain]
$dnsdomain = [$facts['domain']]
$pxefilename = 'pxelinux.0'

case $::osfamily {
case $facts['osfamily'] {
'Debian': {
$dhcp_dir = '/etc/dhcp'
$packagename = 'isc-dhcp-server'
Expand Down Expand Up @@ -37,7 +37,7 @@
$packagename = 'dhcp'
$servicename = 'dhcpd'
$root_group = 'root'
if $::operatingsystemrelease =~ /^[0-6]\./ {
if $facts['operatingsystemrelease'] =~ /^[0-6]\./ {
$bootfiles = {
'00:07' => 'grub/grubx64.efi',
'00:09' => 'grub/grubx64.efi',
Expand All @@ -52,7 +52,7 @@
}

default: {
fail("${::hostname}: This module does not support osfamily ${::osfamily}")
fail("${facts['hostname']}: This module does not support osfamily ${facts['osfamily']}")
}
}
}
2 changes: 1 addition & 1 deletion manifests/pool.pp
Expand Up @@ -19,7 +19,7 @@
) {

concat::fragment { "dhcp.conf+70_${name}.dhcp":
target => "${::dhcp::dhcp_dir}/dhcpd.conf",
target => "${dhcp::dhcp_dir}/dhcpd.conf",
content => template('dhcp/dhcpd.pool.erb'),
order => "70-${name}",
}
Expand Down
8 changes: 4 additions & 4 deletions spec/acceptance/basic_spec.rb
Expand Up @@ -18,18 +18,18 @@

let(:pp) do
<<-EOS
$interface = $::facts['networking']['interfaces'][#{interface}]
$interface = $facts['networking']['interfaces'][#{interface}]
class { '::dhcp':
class { 'dhcp':
interfaces => ['#{interface}'],
}
::dhcp::pool { "default subnet":
dhcp::pool { "default subnet":
network => $interface['network'],
mask => $interface['netmask'],
}
::dhcp::host { $::fqdn:
dhcp::host { $facts['fqdn']:
ip => $interface['ip'],
mac => $interface['mac'],
}
Expand Down
6 changes: 3 additions & 3 deletions spec/acceptance/include_spec.rb
Expand Up @@ -18,18 +18,18 @@

let(:pp) do
<<-EOS
$interface = $::facts['networking']['interfaces'][#{interface}]
$interface = $facts['networking']['interfaces'][#{interface}]
file { '/etc/dhcp.include':
ensure => file,
}
class { '::dhcp':
class { 'dhcp':
interfaces => ['#{interface}'],
includes => '/etc/dhcp.include',
}
::dhcp::pool { "default subnet":
dhcp::pool { "default subnet":
network => $interface['network'],
mask => $interface['netmask'],
}
Expand Down

0 comments on commit 631e0e6

Please sign in to comment.