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

Fix Issue 70 add file mode parameters #109

Merged
merged 1 commit into from
Apr 4, 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
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,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You probably knew this already but be aware that Stdlib::Filemode does not support all of the variants of File mode =>. For instance, a+rwx

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct, it currently looks like: Pattern[/^[0124]{1}[0-7]{3}$/] ... which matches the permissions that are set in params.

I think the right thing to do would be to improve Stdlib::Filemode, if someone wants to use symbolic file modes. If the folks here feel strongly that we need to support it before that time, we could just make the type String[3] or whatever. I don't feel like we should make our own FileMode to support it.

Boolean $manage_package = $logrotate::params::manage_package,
String $rules_configdir = $logrotate::params::rules_configdir,
Stdlib::Filemode $rules_configdir_mode = $logrotate::params::rules_configdir_mode,
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is why I dislike lining up equals (and why I jokingly asked if we could just change to module level hieradata :)

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"
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This appears to be the version of stdlib where they added Stdlib::Filemode

}
],
"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