summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Pigulla <mp@webfactory.de>2016-03-20 22:54:51 +0100
committerMatthias Pigulla <mp@webfactory.de>2016-03-21 08:39:56 +0100
commit5847fd26445ea45abcf5fca7044b2ee1a0888191 (patch)
tree4ea1ac7a6e11a74e049823897801b056d9c03786
parent767b3fb53e1502b2bcf6333af112b31eaa46fb52 (diff)
Add parameter to control reboot time
-rw-r--r--README.md1
-rw-r--r--manifests/params.pp2
-rw-r--r--spec/classes/unattended_upgrades_spec.rb5
-rw-r--r--templates/unattended-upgrades.erb5
4 files changed, 12 insertions, 1 deletions
diff --git a/README.md b/README.md
index 3b818ee..aa1bf32 100644
--- a/README.md
+++ b/README.md
@@ -54,6 +54,7 @@ Using unattended\_upgrades simply consists of including the module and if needed
* `clean`(`0`): Remove packages that can no longer be downloaded from cache every X days (`0` = disabled).
* `fix_interrupted_dpkg`(`true`): Try to fix package installation state.
* `reboot`(`false`): Reboot system after package update installation.
+ * `reboot_time`(`now`): If automatic reboot is enabled and needed, reboot at the specific time (instead of immediately).
* `remove`(`true`): Remove unneeded dependencies after update installation.
Any of these keys can be specified and will be merged into the defaults:
diff --git a/manifests/params.pp b/manifests/params.pp
index fceec73..e9a7605 100644
--- a/manifests/params.pp
+++ b/manifests/params.pp
@@ -5,7 +5,7 @@ class unattended_upgrades::params {
fail('This module only works on Debian or derivatives like Ubuntu')
}
- $default_auto = { 'fix_interrupted_dpkg' => true, 'remove' => true, 'reboot' => false, 'clean' => 0, }
+ $default_auto = { 'fix_interrupted_dpkg' => true, 'remove' => true, 'reboot' => false, 'clean' => 0, 'reboot_time' => 'now', }
$default_mail = { 'only_on_error' => true, }
$default_backup = { 'archive_interval' => 0, 'level' => 3, }
$default_age = { 'min' => 2, 'max' => 0, }
diff --git a/spec/classes/unattended_upgrades_spec.rb b/spec/classes/unattended_upgrades_spec.rb
index dc2137f..d951a87 100644
--- a/spec/classes/unattended_upgrades_spec.rb
+++ b/spec/classes/unattended_upgrades_spec.rb
@@ -49,6 +49,8 @@ describe 'unattended_upgrades' do
/Unattended-Upgrade::Remove-Unused-Dependencies "true";/
).with_content(
/Unattended-Upgrade::Automatic-Reboot "false";/
+ ).with_content(
+ /Unattended-Upgrade::Automatic-Reboot-Time "now";/
).without_content(
/Unattended-Upgrade::Mail/
).without_content(
@@ -278,6 +280,7 @@ describe 'unattended_upgrades' do
'fix_interrupted_dpkg' => false,
'remove' => false,
'reboot' => true,
+ 'reboot_time' => '03:00',
},
verbose: 1,
legacy_origin: true,
@@ -328,6 +331,8 @@ describe 'unattended_upgrades' do
).with_content(
/Unattended-Upgrade::Automatic-Reboot "true";/
).with_content(
+ /Unattended-Upgrade::Automatic-Reboot-Time "03:00";/
+ ).with_content(
/Unattended-Upgrade::Mail "root@localhost";/
).with_content(
/Unattended-Upgrade::MailOnlyOnError "true";/
diff --git a/templates/unattended-upgrades.erb b/templates/unattended-upgrades.erb
index c73d58c..a87ff31 100644
--- a/templates/unattended-upgrades.erb
+++ b/templates/unattended-upgrades.erb
@@ -55,6 +55,11 @@ Unattended-Upgrade::Remove-Unused-Dependencies "<%= @_auto['remove'].to_s %>";
// if the file /var/run/reboot-required is found after the upgrade
Unattended-Upgrade::Automatic-Reboot "<%= @_auto['reboot'].to_s %>";
+// If automatic reboot is enabled and needed, reboot at the specific
+// time instead of immediately
+// Default: "now"
+Unattended-Upgrade::Automatic-Reboot-Time "<%= @_auto['reboot_time'].to_s %>";
+
<%- unless @dl_limit.nil? -%>
// Use apt bandwidth limit feature, this example limits the download
// speed to 70kb/sec