diff options
Diffstat (limited to 'src/UnattendedUpgrades.php')
-rw-r--r-- | src/UnattendedUpgrades.php | 44 |
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, + ])), + ]; + } +} |