Skip to content

Commit

Permalink
Fix Issue voxpupuli#70 Add file mode parameters default to RPM permis…
Browse files Browse the repository at this point in the history
…sions
  • Loading branch information
TJM committed Apr 3, 2018
1 parent 352a383 commit 1a029ee
Show file tree
Hide file tree
Showing 12 changed files with 42 additions and 32 deletions.
2 changes: 1 addition & 1 deletion manifests/conf.pp
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@
ensure => $ensure,
owner => $logrotate::root_user,
group => $logrotate::root_group,
mode => '0444',
mode => $logrotate::logrotate_conf_mode,
content => template('logrotate/etc/logrotate.conf.erb'),
}

Expand Down
2 changes: 1 addition & 1 deletion manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
group => $logrotate::root_group,
purge => $::logrotate::purge_configdir,
recurse => $::logrotate::purge_configdir,
mode => '0755',
mode => $logrotate::rules_configdir_mode,
}

if $manage_cron_daily {
Expand Down
2 changes: 1 addition & 1 deletion manifests/cron.pp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
ensure => $ensure,
owner => $logrotate::root_user,
group => $logrotate::root_group,
mode => '0555',
mode => $logrotate::cron_file_mode,
content => template('logrotate/etc/cron/logrotate.erb'),
}
}
4 changes: 2 additions & 2 deletions manifests/hourly.pp
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@
ensure => $dir_ensure,
owner => 'root',
group => 'root',
mode => '0755',
mode => $logrotate::rules_configdir_mode,
}
file { $logrotate::cron_hourly_file:
ensure => $ensure,
owner => 'root',
group => 'root',
mode => '0555',
mode => $logrotate::cron_file_mode,
source => 'puppet:///modules/logrotate/etc/cron.hourly/logrotate',
require => [File["${logrotate::rules_configdir}/hourly"],Package['logrotate']],
}
Expand Down
41 changes: 22 additions & 19 deletions manifests/init.pp
Original file line number Diff line number Diff line change
@@ -1,24 +1,27 @@
#
class logrotate (
String $ensure = present,
Boolean $hieramerge = false,
Boolean $manage_cron_daily = true,
Boolean $create_base_rules = true,
Boolean $purge_configdir = false,
String $package = 'logrotate',
Hash $rules = {},
Optional[Hash] $config = undef,
Integer[0,23] $cron_daily_hour = $logrotate::params::cron_daily_hour,
Integer[0,59] $cron_daily_minute = $logrotate::params::cron_daily_minute,
Integer[0,59] $cron_hourly_minute = $logrotate::params::cron_hourly_minute,
String $cron_hourly_file = $logrotate::params::cron_hourly_file,
String $configdir = $logrotate::params::configdir,
String $logrotate_bin = $logrotate::params::logrotate_bin,
String $logrotate_conf = $logrotate::params::logrotate_conf,
Boolean $manage_package = $logrotate::params::manage_package,
String $rules_configdir = $logrotate::params::rules_configdir,
String $root_user = $logrotate::params::root_user,
String $root_group = $logrotate::params::root_group,
String $ensure = present,
Boolean $hieramerge = false,
Boolean $manage_cron_daily = true,
Boolean $create_base_rules = true,
Boolean $purge_configdir = false,
String $package = 'logrotate',
Hash $rules = {},
Optional[Hash] $config = undef,
Integer[0,23] $cron_daily_hour = $logrotate::params::cron_daily_hour,
Integer[0,59] $cron_daily_minute = $logrotate::params::cron_daily_minute,
Integer[0,59] $cron_hourly_minute = $logrotate::params::cron_hourly_minute,
String $cron_hourly_file = $logrotate::params::cron_hourly_file,
Stdlib::Filemode $cron_file_mode = $logrotate::params::cron_file_mode,
String $configdir = $logrotate::params::configdir,
String $logrotate_bin = $logrotate::params::logrotate_bin,
String $logrotate_conf = $logrotate::params::logrotate_conf,
Stdlib::Filemode $logrotate_conf_mode = $logrotate::params::logrotate_conf_mode,
Boolean $manage_package = $logrotate::params::manage_package,
String $rules_configdir = $logrotate::params::rules_configdir,
Stdlib::Filemode $rules_configdir_mode = $logrotate::params::rules_configdir_mode,
String $root_user = $logrotate::params::root_user,
String $root_group = $logrotate::params::root_group,
) inherits logrotate::params {

contain ::logrotate::install
Expand Down
7 changes: 7 additions & 0 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -188,4 +188,11 @@
$manage_package = true
$root_user = 'root'
$rules_configdir = "${configdir}/logrotate.d"

# File modes (permissions)
# - These may need to be moved to the osfamily case statement
# - These are currently matching the RedHat RPM permissions
$cron_file_mode = '0700'
$logrotate_conf_mode = '0644'
$rules_configdir_mode = '0755'
}
2 changes: 1 addition & 1 deletion manifests/rule.pp
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@
ensure => $ensure,
owner => $logrotate::root_user,
group => $logrotate::root_group,
mode => '0444',
mode => $logrotate::logrotate_conf_mode,
content => template('logrotate/etc/logrotate.d/rule.erb'),
require => Class['::logrotate::config'],
}
Expand Down
2 changes: 1 addition & 1 deletion metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"dependencies": [
{
"name": "puppetlabs/stdlib",
"version_requirement": ">= 4.13.1 <5.0.0"
"version_requirement": ">= 4.22.0 < 5.0.0"
}
],
"requirements": [
Expand Down
2 changes: 1 addition & 1 deletion spec/classes/hourly_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
'ensure' => 'present',
'owner' => 'root',
'group' => 'root',
'mode' => '0555'
'mode' => '0700'
)
end
end
Expand Down
4 changes: 2 additions & 2 deletions spec/classes/init_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
# 'ensure' => 'file',
# 'owner' => 'root',
# 'group' => 'root',
# 'mode' => '0444',
# 'mode' => '0644',
# 'content' => 'template(\'logrotate/etc/logrotate.conf.erb\')',
# 'source' => 'puppet:///modules/logrotate/etc/logrotate.conf',
# 'require' => 'Package[logrotate]',
Expand All @@ -36,7 +36,7 @@
is_expected.to contain_file('/etc/cron.daily/logrotate').with('ensure' => 'present',
'owner' => 'root',
'group' => 'root',
'mode' => '0555')
'mode' => '0700')

is_expected.to contain_class('logrotate::defaults')
end
Expand Down
4 changes: 2 additions & 2 deletions spec/defines/conf_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@
'owner' => 'root',
'group' => 'root',
'ensure' => 'present',
'mode' => '0444'
'mode' => '0644'
).with_content(%r{\ninclude \/etc\/logrotate.d\n})
}

Expand Down Expand Up @@ -380,7 +380,7 @@
'owner' => 'root',
'group' => 'root',
'ensure' => 'present',
'mode' => '0444'
'mode' => '0644'
).with_content(%r{\ninclude \/etc\/logrotate.d\n})
}
end
Expand Down
2 changes: 1 addition & 1 deletion spec/defines/rule_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
'owner' => 'root',
'group' => 'root',
'ensure' => 'present',
'mode' => '0444'
'mode' => '0644'
).with_content(%r{^/var/log/foo\.log \{\n\}\n})
end
end
Expand Down

0 comments on commit 1a029ee

Please sign in to comment.