summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDaniel Weipert <code@drogueronin.de>2021-04-28 14:49:16 +0200
committerDaniel Weipert <code@drogueronin.de>2021-04-28 14:49:16 +0200
commit50c2fbafe6bf15909b893ddf0c862af3f7e848cb (patch)
tree72bf5479a39faedde566bc6953c2c0845e986d8d /src
Initial commitv1.0.0
Diffstat (limited to 'src')
-rw-r--r--src/UnattendedUpgrades.php44
1 files changed, 44 insertions, 0 deletions
diff --git a/src/UnattendedUpgrades.php b/src/UnattendedUpgrades.php
new file mode 100644
index 0000000..2322cef
--- /dev/null
+++ b/src/UnattendedUpgrades.php
@@ -0,0 +1,44 @@
+<?php
+
+namespace Dweipert\DevOps\UnattendedUpgrades;
+
+use PHPIAC\Modules\AptModule;
+use PHPIAC\Modules\TemplateModule;
+use PHPIAC\Role\RoleInterface;
+use PHPIAC\Task;
+
+class UnattendedUpgrades implements RoleInterface
+{
+ public function __invoke(array $config = []): array
+ {
+ $config = array_replace_recursive(
+ include dirname(__DIR__) . '/files/config.php',
+ $config
+ );
+
+ return [
+ (new Task())->setModule(new AptModule([
+ 'package' => 'unattended-upgrades',
+ 'updateCache' => true,
+ ])),
+ (new Task())->setModule(new TemplateModule([
+ 'src' => dirname(__DIR__) . '/files/auto-upgrades.twig',
+ 'dest' => '/etc/apt/apt.conf.d/20auto-upgrades',
+ 'vars' => $config,
+ 'owner' => 'root',
+ 'group' => 'root',
+ 'mode' => 0644,
+ 'force' => true,
+ ])),
+ (new Task())->setModule(new TemplateModule([
+ 'src' => dirname(__DIR__) . '/files/unattended-upgrades.twig',
+ 'dest' => '/etc/apt/apt.conf.d/50unattended-upgrades',
+ 'vars' => $config,
+ 'owner' => 'root',
+ 'group' => 'root',
+ 'mode' => 0644,
+ 'force' => true,
+ ])),
+ ];
+ }
+}