Merge pull request 'feat: find resolvers by role' (#67) from neoloc/resolvconf into develop
Reviewed-on: unkinben/puppet-prod#67
This commit is contained in:
commit
38961848bb
@ -27,6 +27,7 @@ mod 'puppet-selinux', '4.1.0'
|
||||
# other
|
||||
mod 'ghoneycutt-puppet', '3.3.0'
|
||||
mod 'saz-sudo', '8.0.0'
|
||||
mod 'dalen-puppetdbquery', '3.0.1'
|
||||
|
||||
mod 'bind',
|
||||
:git => 'https://git.unkin.net/unkinben/puppet-bind.git',
|
||||
|
||||
@ -7,6 +7,7 @@ profiles::base::puppet_servers:
|
||||
- 'prodinf01n01.main.unkin.net'
|
||||
|
||||
profiles::dns::master::basedir: '/var/named/sources'
|
||||
profiles::dns::base::ns_role: 'roles::infra::dns::resolver'
|
||||
|
||||
profiles::packages::base:
|
||||
- bash-completion
|
||||
|
||||
@ -29,11 +29,9 @@ class profiles::base (
|
||||
include profiles::base::hosts
|
||||
include profiles::accounts::sysadmin
|
||||
include profiles::ntp::client
|
||||
include profiles::dns::base
|
||||
include profiles::cloudinit::init
|
||||
|
||||
# configure dns records for client
|
||||
profiles::dns::client {"${facts['networking']['fqdn']}-default":}
|
||||
|
||||
# include the python class
|
||||
class { 'python':
|
||||
manage_python_package => true,
|
||||
|
||||
31
site/profiles/manifests/dns/base.pp
Normal file
31
site/profiles/manifests/dns/base.pp
Normal file
@ -0,0 +1,31 @@
|
||||
# profiles::dns::base
|
||||
class profiles::dns::base (
|
||||
String $ns_role = undef,
|
||||
Array $search = [],
|
||||
Array $nameservers = ['8.8.8.8', '1.1.1.1'],
|
||||
){
|
||||
|
||||
# if ns_role is set, find all hosts matching that enc_role
|
||||
if $ns_role == undef {
|
||||
$nameserver_array = $nameservers
|
||||
}else{
|
||||
$nameserver_array = query_nodes("enc_role='${ns_role}'", 'networking.ip')
|
||||
}
|
||||
|
||||
# if search is undef, fallback to domainname from facts
|
||||
if $search == [] {
|
||||
$search_array = [$::facts['networking']['domain']]
|
||||
}else{
|
||||
$search_array = $search
|
||||
}
|
||||
|
||||
# include resolvconf class
|
||||
class { 'profiles::dns::resolvconf':
|
||||
nameservers => $nameserver_array,
|
||||
search_domains => $search_array,
|
||||
}
|
||||
|
||||
# export dns records for client
|
||||
profiles::dns::client {"${facts['networking']['fqdn']}-default":}
|
||||
|
||||
}
|
||||
@ -1,8 +1,8 @@
|
||||
# profiles::dns::client
|
||||
define profiles::dns::client (
|
||||
Boolean $forward = true,
|
||||
Boolean $reverse = true,
|
||||
Integer $order = 10,
|
||||
Boolean $forward = true,
|
||||
Boolean $reverse = true,
|
||||
Integer $order = 10,
|
||||
){
|
||||
|
||||
$intf = $facts['networking']['primary']
|
||||
|
||||
14
site/profiles/manifests/dns/resolvconf.pp
Normal file
14
site/profiles/manifests/dns/resolvconf.pp
Normal file
@ -0,0 +1,14 @@
|
||||
# profiles::dns::resolvconf
|
||||
class profiles::dns::resolvconf (
|
||||
Array[String] $nameservers,
|
||||
Array[String] $search_domains,
|
||||
) {
|
||||
|
||||
file { '/etc/resolv.conf':
|
||||
ensure => file,
|
||||
owner => 'root',
|
||||
group => 'root',
|
||||
mode => '0644',
|
||||
content => template('profiles/dns/resolvconf.erb'),
|
||||
}
|
||||
}
|
||||
7
site/profiles/templates/dns/resolvconf.erb
Normal file
7
site/profiles/templates/dns/resolvconf.erb
Normal file
@ -0,0 +1,7 @@
|
||||
# Managed by Puppet
|
||||
<% @nameservers.each do |ns| -%>
|
||||
nameserver <%= ns %>
|
||||
<% end -%>
|
||||
<% unless @search_domains.empty? -%>
|
||||
search <%= @search_domains.join(' ') %>
|
||||
<% end -%>
|
||||
Loading…
Reference in New Issue
Block a user