Merge branch 'develop' into neoloc/node_exporter

This commit is contained in:
Ben Vincent 2023-11-17 23:20:02 +11:00
commit 92269ae94b
9 changed files with 119 additions and 6 deletions

View File

@ -28,6 +28,7 @@ mod 'puppet-prometheus', '13.4.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',

View File

@ -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

View File

@ -29,11 +29,10 @@ class profiles::base (
include profiles::base::hosts
include profiles::accounts::sysadmin
include profiles::ntp::client
include profiles::dns::base
include profiles::cloudinit::init
include profiles::metrics::default
# configure dns records for client
profiles::dns::client {"${facts['networking']['fqdn']}-default":}
# include the python class
class { 'python':
manage_python_package => true,
@ -47,4 +46,8 @@ class profiles::base (
secure_path => '/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:/opt/puppetlabs/bin'
}
# manage virtualised guest agents
if $::facts['is_virtual'] and $::facts['dmi']['manufacturer'] == 'QEMU' {
include profiles::qemu::agent
}
}

View File

@ -0,0 +1,28 @@
# profiles::cloudinit::init
class profiles::cloudinit::init (
Boolean $enabled = false,
String $package = 'cloud-init',
String $service = 'cloud-init',
){
if $enabled {
package { $package:
ensure => installed,
}
service { $service:
ensure => running,
enable => true,
require => Package[$package],
}
} else {
service { $service:
ensure => stopped,
enable => false,
}
package { $package:
ensure => absent,
}
}
}

View 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":}
}

View File

@ -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']

View 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'),
}
}

View File

@ -0,0 +1,28 @@
# profiles::qemu::agent
class profiles::qemu::agent (
Boolean $enabled = true,
String $package = 'qemu-guest-agent',
String $service = 'qemu-guest-agent',
){
if $enabled {
package { $package:
ensure => installed,
}
service { $service:
ensure => running,
enable => true,
require => Package[$package],
}
} else {
service { $service:
ensure => stopped,
enable => false,
}
package { $package:
ensure => absent,
}
}
}

View File

@ -0,0 +1,7 @@
# Managed by Puppet
<% @nameservers.each do |ns| -%>
nameserver <%= ns %>
<% end -%>
<% unless @search_domains.empty? -%>
search <%= @search_domains.join(' ') %>
<% end -%>