Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow permissions change of puppet.conf #847

Merged
merged 3 commits into from
Jan 30, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -89,15 +89,15 @@
-> case $facts['os']['family'] {
'Windows': {
concat { "${puppet_dir}/puppet.conf":
mode => '0674',
mode => $puppet::puppetconf_mode,
}
}

default: {
concat { "${puppet_dir}/puppet.conf":
owner => 'root',
group => $puppet::params::root_group,
mode => '0644',
mode => $puppet::puppetconf_mode,
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,9 @@
# of the classes associated with the retrieved
# configuration.
#
# $puppetconf_mode:: The permissions for /etc/puppetlabs/puppet/puppet.conf
# default to '0644' and '0674' on windows
#
# == puppet::agent parameters
#
# $agent:: Should a puppet agent be installed
Expand Down Expand Up @@ -752,6 +755,7 @@
Optional[Stdlib::Absolutepath] $server_versioned_code_id = undef,
Optional[Stdlib::Absolutepath] $server_versioned_code_content = undef,
Array[String[1]] $server_jolokia_metrics_whitelist = [],
Pattern[/^[0-9]{3,4}$/] $puppetconf_mode = $puppet::params::puppetconf_mode,
teluq-pbrideau marked this conversation as resolved.
Show resolved Hide resolved
) inherits puppet::params {
contain puppet::config

Expand Down
4 changes: 4 additions & 0 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
$server_puppetserver_logdir = undef
$server_ruby_load_paths = []
$server_jruby_gem_home = undef
$puppetconf_mode = '0674'
}

/^(FreeBSD|DragonFly)$/ : {
Expand Down Expand Up @@ -96,6 +97,7 @@
# lint:endignore
}
$server_jruby_gem_home = '/var/puppet/server/data/puppetserver/jruby-gems'
$puppetconf_mode = '0644'
}

'Archlinux' : {
Expand All @@ -114,6 +116,7 @@
$server_puppetserver_logdir = undef
$server_ruby_load_paths = []
$server_jruby_gem_home = undef
$puppetconf_mode = '0644'
}

default : {
Expand Down Expand Up @@ -152,6 +155,7 @@
$server_jruby_gem_home = '/var/lib/puppet/jruby-gems'
}
$root_group = undef
$puppetconf_mode = '0644'
}
}

Expand Down
14 changes: 13 additions & 1 deletion spec/classes/puppet_init_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,22 @@
puppet_concat = '/usr/local/etc/puppet/puppet.conf'
puppet_directory = '/usr/local/etc/puppet'
puppet_package = "puppet#{puppet_major}"
puppetconf_mode = '0644'
when 'windows'
puppet_concat = 'C:/ProgramData/PuppetLabs/puppet/etc/puppet.conf'
puppet_directory = 'C:/ProgramData/PuppetLabs/puppet/etc'
puppet_package = 'puppet-agent'
puppetconf_mode = '0674'
when 'Archlinux'
puppet_concat = '/etc/puppetlabs/puppet/puppet.conf'
puppet_directory = '/etc/puppetlabs/puppet'
puppet_package = 'puppet'
puppetconf_mode = '0644'
else
puppet_concat = '/etc/puppetlabs/puppet/puppet.conf'
puppet_directory = '/etc/puppetlabs/puppet'
puppet_package = 'puppet-agent'
puppetconf_mode = '0644'
end

let :facts do
Expand All @@ -34,7 +38,7 @@
it { should contain_class('puppet::config') }
it { should_not contain_class('puppet::server') }
it { should contain_file(puppet_directory).with_ensure('directory') }
it { should contain_concat(puppet_concat) }
it { should contain_concat(puppet_concat).with_mode(puppetconf_mode) }
it { should contain_package(puppet_package)
.with_ensure('present')
.with_install_options(nil)
Expand Down Expand Up @@ -83,6 +87,14 @@
it { should contain_puppet__config__main('ca_port').with_value(8140) }
end

describe 'with puppetconf_mode' do
let :params do {
:puppetconf_mode => '0640',
} end

it { should contain_concat(puppet_concat).with_mode('0640') }
end

# compilation is broken due to paths
context 'on non-windows', unless: facts[:osfamily] == 'windows' do
describe 'with package_source => Httpurl' do
Expand Down