From addd443cd15ce0a432bc23eade40c122a2926175 Mon Sep 17 00:00:00 2001 From: Ewoud Kohl van Wijngaarden Date: Wed, 22 Jun 2022 13:56:22 +0200 Subject: [PATCH] Use $facts and fact() where applicable --- manifests/config.pp | 2 +- manifests/params.pp | 21 ++++++--------------- manifests/server/config.pp | 6 +++--- 3 files changed, 10 insertions(+), 19 deletions(-) diff --git a/manifests/config.pp b/manifests/config.pp index b17751ba..3f4083d3 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -45,7 +45,7 @@ } if $use_srv_records { unless $srv_domain { - fail('$::domain fact found to be undefined and $srv_domain is undefined') + fail('domain fact found to be undefined and $srv_domain is undefined') } puppet::config::main { 'use_srv_records': value => true; diff --git a/manifests/params.pp b/manifests/params.pp index ad50a29d..93cac3d1 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -33,11 +33,7 @@ $dns_alt_names = [] $use_srv_records = false - if defined('$::domain') { - $srv_domain = $facts['networking']['domain'] - } else { - $srv_domain = undef - } + $srv_domain = fact('networking.domain') # lint:ignore:puppet_url_without_modules $pluginsource = 'puppet:///plugins' @@ -45,7 +41,7 @@ # lint:endignore $classfile = '$statedir/classes.txt' $syslogfacility = undef - $environment = $::environment + $environment = $server_facts['environment'] # aio_agent_version is a core fact that's empty on non-AIO $aio_package = fact('aio_agent_version') =~ String[1] @@ -198,13 +194,8 @@ # Will this host be a puppet agent ? $agent = true - $client_certname = $::clientcert - - if defined('$::puppetmaster') { - $puppetmaster = $::puppetmaster - } else { - $puppetmaster = undef - } + $client_certname = $trusted['certname'] + $puppetmaster = $server_facts['servername'] # Hashes containing additional settings $additional_settings = {} @@ -219,7 +210,7 @@ $server_external_nodes = "${dir}/node.rb" $server_trusted_external_command = undef $server_request_timeout = 60 - $server_certname = $::clientcert + $server_certname = trusted['certname'] $server_strict_variables = false $server_http = false $server_http_port = 8139 @@ -261,7 +252,7 @@ $server_storeconfigs = false - $puppet_major = regsubst($::puppetversion, '^(\d+)\..*$', '\1') + $puppet_major = regsubst($facts['puppetversion'], '^(\d+)\..*$', '\1') if ($facts['os']['family'] =~ /(FreeBSD|DragonFly)/) { $server_package = "puppetserver${puppet_major}" diff --git a/manifests/server/config.pp b/manifests/server/config.pp index 50d6cb52..320ea4f6 100644 --- a/manifests/server/config.pp +++ b/manifests/server/config.pp @@ -173,19 +173,19 @@ command => "${puppet::puppetserver_cmd} ca migrate", creates => $puppet::server::cadir, onlyif => "test -d '${puppet::server::ssl_dir}/ca' && ! test -L '${puppet::server::ssl_dir}'", - path => $::path, + path => $facts['path'], before => Exec['puppet_server_config-generate_ca_cert'], } } } elsif $puppet::server::ca_crl_sync { # If not a ca AND sync the crl from the ca master - if defined('$::servername') { + if $server_facts['servername'] { file { $puppet::server::ssl_ca_crl: ensure => file, owner => $puppet::server::user, group => $puppet::server::group, mode => '0644', - content => file($::settings::cacrl, $::settings::hostcrl, '/dev/null'), + content => file($settings::cacrl, $settings::hostcrl, '/dev/null'), } } }