From 77530a935d6cd33d64bba3e5174f6652b5c0f9a5 Mon Sep 17 00:00:00 2001 From: Pat Riehecky Date: Tue, 14 Jun 2016 15:33:20 -0500 Subject: [PATCH] Allow defines to be created via ENC/Hiera Resolves #56 --- manifests/init.pp | 66 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) diff --git a/manifests/init.pp b/manifests/init.pp index 0ba1b99..446f8aa 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -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 @@ -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 @@ -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'],