diff --git a/CHANGELOG.md b/CHANGELOG.md index 296ce71..80c6f76 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,20 @@ All notable changes to this project will be documented in this file. Each new release typically also includes the latest modulesync defaults. These should not affect the functionality of the module. +## [v4.2.0](https://github.com/voxpupuli/puppet-cron/tree/v4.2.0) (2024-07-10) + +[Full Changelog](https://github.com/voxpupuli/puppet-cron/compare/v4.1.0...v4.2.0) + +**Implemented enhancements:** + +- Add support for FreeBSD 14 [\#136](https://github.com/voxpupuli/puppet-cron/pull/136) ([smortex](https://github.com/smortex)) +- Add parameters for file/directory modes [\#134](https://github.com/voxpupuli/puppet-cron/pull/134) ([ludovicus3](https://github.com/ludovicus3)) + +**Merged pull requests:** + +- refactor: define job template as epp instead of erb [\#138](https://github.com/voxpupuli/puppet-cron/pull/138) ([bastelfreak](https://github.com/bastelfreak)) +- Remove legacy top-scope syntax [\#125](https://github.com/voxpupuli/puppet-cron/pull/125) ([smortex](https://github.com/smortex)) + ## [v4.1.0](https://github.com/voxpupuli/puppet-cron/tree/v4.1.0) (2023-08-08) [Full Changelog](https://github.com/voxpupuli/puppet-cron/compare/v4.0.0...v4.1.0) diff --git a/REFERENCE.md b/REFERENCE.md index f34db25..5578aef 100644 --- a/REFERENCE.md +++ b/REFERENCE.md @@ -634,7 +634,6 @@ Array[Struct[{ Optional['month'] => Cron::Month, Optional['weekday'] => Cron::Weekday, Optional['special'] => Cron::Special, - Optional['environment'] => Cron::Environment, Optional['user'] => Cron::User, Optional['description'] => String, }]] diff --git a/manifests/job/multiple.pp b/manifests/job/multiple.pp index b17d4bc..d9a636e 100644 --- a/manifests/job/multiple.pp +++ b/manifests/job/multiple.pp @@ -35,7 +35,6 @@ Optional['month'] => Cron::Month, Optional['weekday'] => Cron::Weekday, Optional['special'] => Cron::Special, - Optional['environment'] => Cron::Environment, Optional['user'] => Cron::User, Optional['description'] => String, }]] $jobs, @@ -57,7 +56,11 @@ group => 'root', mode => $mode, path => "/etc/cron.d/${title}", - content => template('cron/multiple.erb'), + content => epp('cron/multiple.epp', { + name => $name, + environment => $environment, + jobs => $jobs, + }), } } } diff --git a/metadata.json b/metadata.json index f14d00c..f88807e 100644 --- a/metadata.json +++ b/metadata.json @@ -1,6 +1,6 @@ { "name": "puppet-cron", - "version": "4.1.1-rc0", + "version": "4.2.0", "author": "Vox Pupuli", "summary": "Module to manage cron jobs via /etc/cron.d/", "license": "Apache-2.0", diff --git a/templates/multiple.epp b/templates/multiple.epp new file mode 100644 index 0000000..d14527b --- /dev/null +++ b/templates/multiple.epp @@ -0,0 +1,31 @@ +################################################################################ +# This file is managed by Puppet, and is refreshed regularly. # +# Edit at your own peril! # +################################################################################ +## <%= $name %> Cron Job + +# Environment Settings +<% $environment.each |$env_var| { -%> +<%= $env_var %> +<% } -%> + +<%- $jobs.each |$job| { -%> + <%- if ! $job['command'] { -%> + <%- fail("Must pass command to Cron::Jobs") -%> + <%- } -%> + <%- $minute = $job['minute'] ? { undef => '*', default => $job['minute'] } -%> + <%- $hour = $job['hour'] ? { undef => '*', default => $job['hour'] } -%> + <%- $date = $job['date'] ? { undef => '*', default => $job['date'] } -%> + <%- $month = $job['month'] ? { undef => '*', default => $job['month'] } -%> + <%- $weekday = $job['weekday'] ? { undef => '*', default => $job['weekday'] } -%> + <%- $user = $job['user'] ? { undef => 'root', default => $job['user'] } -%> +<% if $job['description'] {-%> + +# <%= $job['description'] %> +<% } -%> +<%- if $job['special'] { -%> +@<%= $job['special'] %> <%= $user %> <%= $job['command'] %> +<% } else { -%> +<%= $minute %> <%= $hour %> <%= $date %> <%= $month %> <%= $weekday %> <%= $user %> <%= $job['command'] %> +<% } -%> +<% } -%> diff --git a/templates/multiple.erb b/templates/multiple.erb deleted file mode 100644 index d9be314..0000000 --- a/templates/multiple.erb +++ /dev/null @@ -1,47 +0,0 @@ -################################################################################ -# This file is managed by Puppet, and is refreshed regularly. # -# Edit at your own peril! # -################################################################################ -## <%= @name %> Cron Job - -# Environment Settings -<% Array(@environment).join("\n").split(%r{\n}).each do |env_var| - if env_var.match(%r{\S+=\S+}) -%> -<%= env_var %> -<% elsif env_var.match(%r{\S}) -%> -## Possible input error: <%= env_var %> -<% end - end -%> - -<%- Array(@jobs).each do | job | -%> - <%- if job['command'].nil? -%> - <%- scope.function_fail(["Must pass command to Cron::Jobs"]) -%> - <%- end -%> - <%- if job['minute'].nil? -%> - <%- job['minute'] = '*' -%> - <%- end -%> - <%- if job['hour'].nil? -%> - <%- job['hour'] = '*' -%> - <%- end -%> - <%- if job['date'].nil? -%> - <%- job['date'] = '*' -%> - <%- end -%> - <%- if job['month'].nil? -%> - <%- job['month'] = '*' -%> - <%- end -%> - <%- if job['weekday'].nil? -%> - <%- job['weekday'] = '*' -%> - <%- end -%> - <%- if job['user'].nil? -%> - <%- job['user'] = 'root' -%> - <%- end -%> -<% if job.has_key?('description') -%> - -# <%= job['description'] %> -<% end -%> -<%- if job['special'].nil? -%> -<%= job['minute'] %> <%= job['hour'] %> <%= job['date'] %> <%= job['month'] %> <%= job['weekday'] %> <%= job['user'] %> <%= job['command'] %> -<% else -%> -@<%= job['special'] %> <%= job['user'] %> <%= job['command'] %> -<% end -%> -<% end -%>