Skip to content

Commit

Permalink
Allow defines to be created via ENC/Hiera
Browse files Browse the repository at this point in the history
Resolves #56
  • Loading branch information
jcpunk committed Jun 14, 2016
1 parent b86659b commit 77530a9
Showing 1 changed file with 66 additions and 0 deletions.
66 changes: 66 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,21 @@
$service_ensure = 'running',
$strict_order = true,
$tftp_root = '/var/lib/tftpboot',
$addresses = {},
$cnames = {},
$dhcpboots = {},
$dhcpmatches = {},
$dhcpoptions = {},
$dhcps = {},
$dhcpstatics = {},
$dnsrrs = {},
$dnsservers = {},
$domains = {},
$hostrecords = {},
$mxs = {},
$ptrs = {},
$svrs = {},
$txts = {},
) inherits dnsmasq::params {

## VALIDATION
Expand Down Expand Up @@ -78,6 +93,11 @@
fail("Expect IP address for listen_address, got ${listen_address}")
}

## VALIDATE FOR DEFINES
validate_hash($addresses, $cnames, $dhcpboots, $dhcpmatches, $dhcpoptions,
$dhcps, $dhcpstatics, $dnsrrs, $dnsservers, $domains,
$hostrecords, $mxs, $ptrs, $svrs, $txts)

## CLASS VARIABLES

# Allow custom ::provider fact to override our provider, but only
Expand Down Expand Up @@ -164,6 +184,52 @@
}
}

if $addresses {
create_resources('dnsmasq::address', $addresses)
}
if $cnames {
create_resources('dnsmasq::cname', $cnames)
}
if $dhcpboots {
create_resources('dnsmasq::dhcpboot', $dhcpboots)
}
if $dhcpmatches {
create_resources('dnsmasq::dhcpmatch', $dhcpmatches)
}
if $dhcpoptions {
create_resources('dnsmasq::dhcpoption', $dhcpoptions)
}
if $dhcps {
create_resources('dnsmasq::dhcp', $dhcps)
}
if $dhcpstatics {
create_resources('dnsmasq::dhcpstatic', $dhcpstatics)
}
if $dnsrrs {
create_resources('dnsmasq::dnsrr', $dnsrrs)
}
if $dnsservers {
create_resources('dnsmasq::dnsserver', $dnsservers)
}
if $domains {
create_resources('dnsmasq::domain', $domains)
}
if $hostrecords {
create_resources('dnsmasq::hostrecord', $hostrecords)
}
if $mxs {
create_resources('dnsmasq::mx', $mxs)
}
if $ptrs {
create_resources('dnsmasq::ptr', $ptrs)
}
if $svrs {
create_resources('dnsmasq::svr', $svrs)
}
if $txts {
create_resources('dnsmasq::txt', $txts)
}

if ! $no_hosts {
Host <||> {
notify +> Service['dnsmasq'],
Expand Down

0 comments on commit 77530a9

Please sign in to comment.