Created
September 28, 2016 02:55
-
-
Save cotocisternas/9d9f5f908199610b5d5b73bb1a678f36 to your computer and use it in GitHub Desktop.
FIX? dns records for puppet autoconfig
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # = Class: profiles::dns::server | |
| # | |
| # Author: Coto Cisternas <cotocisternas@gmail.com> | |
| class profiles::dns::server ( | |
| $reverse = $profiles::params::primary_reverse, | |
| $primary_domain = $profiles::params::domain, | |
| $ns = $profiles::params::bind_nameservers, | |
| $admin_email = $profiles::params::bind_admin_email, | |
| $forwarders = $profiles::params::bind_forwarders, | |
| $allow_query = $profiles::params::bind_allow_query, | |
| $custom_domains = $profiles::params::bind_custom_domains, | |
| $external_records = $profiles::params::bind_external_records, | |
| $custom_forwards = $profiles::params::bind_custom_forwards, | |
| ) inherits profiles::params { | |
| include ::dns::server | |
| include ::profiles::firewall::dns::server | |
| include ::profiles::monitor::checks::dns::server | |
| sensu::subscription { 'dns': } | |
| ## TO HACKY!!! - WORKAROUND TODO FIX THIS SHIT! | |
| if $::company == 'tx' { | |
| Dns::Record::A <<||>> | |
| Dns::Record <<||>> | |
| } | |
| dns::server::options { '/etc/bind/named.conf.options': | |
| forwarders => $forwarders, | |
| allow_query => $allow_query, | |
| } | |
| dns::zone { $primary_domain: | |
| soa => "${::hostname}.${primary_domain}", | |
| soa_email => $admin_email, | |
| nameservers => $ns, | |
| } | |
| dns::zone { $reverse: | |
| soa => "${::hostname}.${primary_domain}", | |
| soa_email => $admin_email, | |
| nameservers => $ns, | |
| } | |
| if $external_records { | |
| create_resources(custom_record, $external_records) | |
| } | |
| define custom_record( | |
| $zone = $profiles::dns::client::primary_domain, | |
| $data = undef, | |
| $type = "A", | |
| $hostname = $title, | |
| $ttl = '' | |
| ) { | |
| $alias = "${hostname},${type},${zone}" | |
| dns::record { $alias: | |
| zone => $zone, | |
| host => $hostname, | |
| ttl => $ttl, | |
| record => $type, | |
| data => $data, | |
| } | |
| } | |
| if $custom_forwards { | |
| create_resources(custom_forward, $custom_forwards) | |
| } | |
| define custom_forward( | |
| $domain = $title, | |
| $forwarders = undef | |
| ) { | |
| dns::zone { $domain: | |
| zone_type => 'forward', | |
| forward_policy => 'only', | |
| allow_forwarder => $forwarders, | |
| } | |
| } | |
| if $custom_domains { | |
| $domain_hash = generate_resource_hash($custom_domains, 'domain') | |
| create_resources(custom_domain, $domain_hash) | |
| } | |
| define custom_domain($domain) { | |
| if !defined(Dns::Zone[$domain]) { | |
| dns::zone { $domain: | |
| soa => "${::hostname}.${profiles::dns::server::primary_domain}", | |
| soa_email => $profiles::dns::server::admin_email, | |
| nameservers => $profiles::dns::server::ns, | |
| } | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment