Skip to content
This repository was archived by the owner on Apr 16, 2018. It is now read-only.

Commit c7baa60

Browse files
Add a fact that resolves correctly to puppet's ssldir and use it.
1 parent dce0308 commit c7baa60

File tree

4 files changed

+36
-4
lines changed

4 files changed

+36
-4
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
require 'facter'
2+
3+
# Based on the facter from https://github.com/jhg03a/puppet-agentfacts
4+
5+
# Set the preferred run mode. This dictates what config sections get loaded.
6+
# This fixes the issue where you are getting agentfacts from a manual facter -p run
7+
# and the environment setting is wrong.
8+
Puppet.settings.preferred_run_mode= :agent
9+
10+
# Pull in puppet settings from global variable
11+
settings = Puppet.settings.to_h
12+
13+
# Resolve setting values to their bare value instead of the puppet setting class
14+
pretty_settings = {}
15+
settings.each do |key, value|
16+
if key.to_s == "ssldir"
17+
Facter.add("icinga2_puppet_ssldir") do
18+
setcode do
19+
result = value.value
20+
end
21+
end
22+
end
23+
end

manifests/init.pp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
$sbin_dir = $::icinga2::params::sbin_dir,
4343
$share_dir = $::icinga2::params::share_dir,
4444
$var_dir = $::icinga2::params::var_dir,
45+
$puppet_ssldir = $::icinga2::params::puppet_ssldir,
4546
) inherits ::icinga2::params {
4647
# TODO: temporary parameter until we provide some default templates
4748
validate_bool($purge_confd)

manifests/params.pp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,14 @@
132132
$var_dir = '/var'
133133
}
134134

135+
# Use the fact for the local agents ssldir, if it is not found it will use the masters.
136+
if $::icinga2_puppet_ssldir {
137+
$puppet_ssldir = $::icinga2_puppet_ssldir
138+
}
139+
else {
140+
$puppet_ssldir = $::settings::ssldir
141+
}
142+
135143
# the schema is now using a set parameter for the os or the default.
136144
$db_schema_mysql = "${share_dir}/icinga2-ido-mysql/schema/mysql.sql"
137145
$db_schema_pgsql = "${share_dir}/icinga2-ido-pgsql/schema/pgsql.sql"

manifests/pki/puppet.pp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
#
55
class icinga2::pki::puppet(
66
$ca_path = "${::icinga2::config_dir}/pki/ca.crt",
7-
$ca_source = "${::settings::ssldir}/certs/ca.pem",
7+
$ca_source = "${::icinga2::puppet_ssldir}/certs/ca.pem",
88
$cert_path = "${::icinga2::config_dir}/pki/${::fqdn}.crt",
9-
$cert_source = "${::settings::ssldir}/certs/${::fqdn}.pem",
9+
$cert_source = "${::icinga2::puppet_ssldir}/certs/${::fqdn}.pem",
1010
$key_path = "${::icinga2::config_dir}/pki/${::fqdn}.key",
11-
$key_source = "${::settings::ssldir}/private_keys/${::fqdn}.pem",
11+
$key_source = "${::icinga2::puppet_ssldir}/private_keys/${::fqdn}.pem",
1212
$crl_path = "${::icinga2::config_dir}/pki/crl.pem",
13-
$crl_source = "${::settings::ssldir}/crl.pem",
13+
$crl_source = "${::icinga2::puppet_ssldir}/crl.pem",
1414
) {
1515

1616
File {

0 commit comments

Comments
 (0)