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

Add parameters to configure dir and file modes #869

Merged
merged 1 commit into from
Jan 16, 2018
Merged
Show file tree
Hide file tree
Changes from all 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
26 changes: 20 additions & 6 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,12 @@
# @param sensu_group Name of the group Sensu is running as. Default is calculated
# according to the underlying OS
#
# @param config_dir_mode Directory mode for Sensu conf directory. Default is calculated
# according to the underlying OS
#
# @param config_file_mode File mode for config files under Sensu conf directory . Default is calculated
# according to the underlying OS
#
# @param rabbitmq_port Rabbitmq port to be used by sensu
#
# @param rabbitmq_host Host running rabbitmq for sensu
Expand Down Expand Up @@ -347,6 +353,14 @@
Boolean $manage_mutators_dir = true,
Optional[String] $sensu_user = undef,
Optional[String] $sensu_group = undef,
Optional[Stdlib::Filemode] $config_dir_mode = $::osfamily ? {
'windows' => undef,
default => '0555',
},
Optional[Stdlib::Filemode] $config_file_mode = $::osfamily ? {
'windows' => undef,
default => '0440',
},
Variant[Undef,Integer,Pattern[/^(\d+)$/]] $rabbitmq_port = undef,
Optional[String] $rabbitmq_host = undef,
Optional[String] $rabbitmq_user = undef,
Expand Down Expand Up @@ -459,8 +473,8 @@
$group = 'wheel'
$home_dir = '/opt/sensu'
$shell = '/bin/false'
$dir_mode = '0555'
$file_mode = '0440'
$dir_mode = $config_dir_mode
$file_mode = $config_file_mode
$service_name = 'org.sensuapp.sensu-client'
}
'Linux': {
Expand All @@ -477,8 +491,8 @@
}
$home_dir = '/opt/sensu'
$shell = '/bin/false'
$dir_mode = '0555'
$file_mode = '0440'
$dir_mode = $config_dir_mode
$file_mode = $config_file_mode
$service_name = 'sensu-client'
}
'windows': {
Expand All @@ -495,8 +509,8 @@
}
$home_dir = $etc_dir
$shell = undef
$dir_mode = undef
$file_mode = undef
$dir_mode = $config_dir_mode
$file_mode = $config_file_mode
$service_name = 'sensu-client'
}
default: {
Expand Down
28 changes: 28 additions & 0 deletions spec/classes/sensu_init_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,20 @@
let(:params) { {:sensu_etc_dir => '/opt/etc/sensu', :enterprise_dashboard => true, :enterprise_user => 'user', :enterprise_pass => 'pass' } }
it { should contain_file('/opt/etc/sensu/dashboard.json') }
end

context 'when config_dir_mode is set' do
let(:params) { {:config_dir_mode => '0755'} }
it { should contain_file('/etc/sensu/conf.d').with(
:mode => '0755',
) }
end

context 'when config_file_mode is set' do
let(:params) { {:config_file_mode => '0644'} }
it { should contain_file('/etc/sensu/conf.d/client.json').with(
:mode => '0644',
) }
end
end

describe 'osfamily windows defaults' do
Expand Down Expand Up @@ -254,6 +268,20 @@
let(:params) { {:sensu_etc_dir => 'C:/etc/sensu', :enterprise_dashboard => true, :enterprise_user => 'user', :enterprise_pass => 'pass' } }
it { should contain_file('C:/etc/sensu/dashboard.json') }
end

context 'when config_dir_mode is set' do
let(:params) { {:config_dir_mode => '0755'} }
it { should contain_file('C:/opt/sensu/conf.d').with(
:mode => '0755',
) }
end

context 'when config_file_mode is set' do
let(:params) { {:config_file_mode => '0644'} }
it { should contain_file('C:/opt/sensu/conf.d/client.json').with(
:mode => '0644',
) }
end
end

context 'with default setting' do
Expand Down