Skip to content

Commit

Permalink
Merge pull request #113 from Phil-Friderici/ssldir_param_rebased2
Browse files Browse the repository at this point in the history
parameterize ssldir in puppet agent's config
  • Loading branch information
ghoneycutt committed Nov 25, 2015
2 parents 63ee097 + dd22f5a commit f8799ff
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 1 deletion.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,12 @@ The name the puppet agent daemon should run as.

- *Default*: puppet

ssldir
------
String with absolute path for ssldir in puppet agent's config. Using the default will set it to: '$vardir/ssl'

- *Default*: 'USE_DEFAULTS'

stringify_facts
---------------
Boolean to set the value of stringify_facts main section of the puppet agent's config. This must be set to true to use structured facts.
Expand Down
8 changes: 8 additions & 0 deletions manifests/agent.pp
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
$agent_sysconfig = 'USE_DEFAULTS',
$agent_sysconfig_ensure = 'USE_DEFAULTS',
$daemon_name = 'puppet',
$ssldir = 'USE_DEFAULTS',
$stringify_facts = true,
$etckeeper_hooks = false,
) {
Expand Down Expand Up @@ -63,6 +64,13 @@
fail("puppet::agent::puppet_masterport is set to <${puppet_masterport}>. It should be an integer.")
}

if $ssldir == 'USE_DEFAULTS' {
$ssldir_real = '$vardir/ssl'
} else {
validate_absolute_path($ssldir)
$ssldir_real = $ssldir
}

if is_string($stringify_facts) {
$stringify_facts_bool = str2bool($stringify_facts)
} else {
Expand Down
33 changes: 33 additions & 0 deletions spec/classes/agent_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,39 @@
end
end

let(:facts) { { :osfamily => 'RedHat' } }
describe 'with ssldir' do
['/var/lib/puppet/ssl-test','/srv/puppet/ssl'].each do |value|
context "set to valid #{value} (as #{value.class})" do
let(:params) do
{
:ssldir => value,
:env => 'production',
}
end

it { should contain_file('puppet_config').with_content(/^\s*ssldir = #{Regexp.escape(value)}$/) }
end
end

['../../relative/path','',242,2.42,['array'],a={'ha'=>'sh'},true,nil].each do |value|
context "set to invalid #{value} (as #{value.class})" do
let(:params) do
{
:ssldir => value,
:env => 'production',
}
end

it 'should fail' do
expect {
should contain_class('puppet::agent')
}.to raise_error(Puppet::Error,/is not an absolute path/)
end
end
end
end

describe 'with stringify_facts' do
['true',true].each do |value|
context "set to #{value}" do
Expand Down
2 changes: 1 addition & 1 deletion templates/puppetagent.conf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

# Where SSL certificates are kept.
# The default value is '$confdir/ssl'.
ssldir = $vardir/ssl
ssldir = <%= @ssldir_real %>

archive_files = true
archive_file_server = <%= @puppet_server %>
Expand Down

0 comments on commit f8799ff

Please sign in to comment.