Skip to content
Open
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
20 changes: 20 additions & 0 deletions manifests/allow_deny_fragment.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
define cron::allow_deny_fragment (
$users,
$type,
) {
include cron

validate_re($type, ['^allow$','^deny$'])
validate_array($users)

$target = $type ? {
'allow' => $cron::cron_allow_path,
'deny' => $cron::cron_deny_path,
}

concat::fragment { $name:
target => $target,
order => '02',
content => template('cron/_cron_allow_deny_fragment.erb'),
}
}
32 changes: 24 additions & 8 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,17 @@
}
if $cron_allow_users != undef {
validate_array($cron_allow_users)
cron::allow_deny_fragment { 'Initial cron.allow users':
type => 'allow',
users => $cron_allow_users,
}
}
if $cron_deny_users != undef {
validate_array($cron_deny_users)
cron::allow_deny_fragment { 'Initial cron.deny users':
type => 'deny',
users => $cron_deny_users,
}
}

if $crontab_tasks != undef {
Expand Down Expand Up @@ -219,29 +227,37 @@
"cron::cron_deny_mode is <${cron_deny_mode}> and must be a valid four digit mode in octal notation.")
# End of validation

file { 'cron_allow':
# Initialize cron.allow
concat { $cron_allow_path:
ensure => $cron_allow,
path => $cron_allow_path,
owner => $cron_allow_owner,
group => $cron_allow_group,
mode => $cron_allow_mode,
content => template('cron/cron_allow.erb'),
}
concat::fragment { "${cron_allow_path} header":
target => $cron_allow_path,
order => '01',
content => template('cron/_cron_allow_deny_header.erb'),
}

file { 'cron_deny':
# Initialize cron.deny
concat { $cron_deny_path:
ensure => $cron_deny,
path => $cron_deny_path,
owner => $cron_deny_owner,
group => $cron_deny_group,
mode => $cron_deny_mode,
content => template('cron/cron_deny.erb'),
}
concat::fragment { "${cron_deny_path} header":
target => $cron_deny_path,
order => '01',
content => template('cron/_cron_allow_deny_header.erb'),
}

package { $package_name_array:
ensure => $package_ensure,
before => [
File[cron_allow],
File[cron_deny],
Concat[$cron_allow_path],
Concat[$cron_deny_path],
File[crontab],
File[cron_d],
File[cron_hourly],
Expand Down
5 changes: 5 additions & 0 deletions templates/_cron_allow_deny_fragment.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

# <%= @name %>
<% [@users].flatten.each do |user| -%>
<%= user %>
<% end -%>
2 changes: 2 additions & 0 deletions templates/_cron_allow_deny_header.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# This file is being maintained by Puppet.
# DO NOT EDIT