summaryrefslogtreecommitdiff
path: root/src/BaseServerSetup.php
diff options
context:
space:
mode:
authorDaniel Weipert <code@drogueronin.de>2021-04-28 16:28:39 +0200
committerDaniel Weipert <code@drogueronin.de>2021-04-28 16:28:39 +0200
commit6f5455f6c525d5e5acedc8f5fcace1c2a9279423 (patch)
tree8a52aa12b8d4318033ca4a53c5fbd94db593b9ac /src/BaseServerSetup.php
parenta9a428462acb8aecc4c335027d552a30bb7c49b5 (diff)
Adds unattended upgrades as roleHEADmain
Diffstat (limited to 'src/BaseServerSetup.php')
-rw-r--r--src/BaseServerSetup.php30
1 files changed, 5 insertions, 25 deletions
diff --git a/src/BaseServerSetup.php b/src/BaseServerSetup.php
index 7ff1efb..206d773 100644
--- a/src/BaseServerSetup.php
+++ b/src/BaseServerSetup.php
@@ -2,11 +2,11 @@
namespace Dweipert\DevOps\BaseServerSetup;
+use Dweipert\DevOps\UnattendedUpgrades\UnattendedUpgrades;
use PHPIAC\Module\State;
use PHPIAC\Modules\AptModule;
use PHPIAC\Modules\CopyModule;
use PHPIAC\Modules\GitModule;
-use PHPIAC\Modules\TemplateModule;
use PHPIAC\Modules\UfwModule;
use PHPIAC\Modules\UserModule;
use PHPIAC\Role\RoleInterface;
@@ -17,8 +17,7 @@ class BaseServerSetup implements RoleInterface
public function __invoke(array $config = []): array
{
$config = array_replace_recursive(
- include __DIR__ . '/unattended-upgrades/unattended-upgrades.php',
- [
+ ['unattended_upgrades' => [
'unattended_origins_patterns' => [
'o=${distro_id},a=${distro_codename}',
'o=${distro_id},a=${distro_codename}-security',
@@ -26,32 +25,13 @@ class BaseServerSetup implements RoleInterface
'unattended_mail' => $config['mail'],
'unattended_automatic_reboot' => true,
'unattended_syslog_enable' => true,
- ],
+ ]],
$config
);
return [
# setup unattended upgrades
- (new Task())->setModule(new AptModule([
- 'package' => 'unattended-upgrades',
- 'updateCache' => true,
- ])),
- (new Task())->setModule(new TemplateModule([
- 'src' => __DIR__ . '/unattended-upgrades/auto-upgrades.twig',
- 'dest' => '/etc/apt/apt.conf.d/20auto-upgrades',
- 'vars' => $config,
- 'owner' => 'root',
- 'group' => 'root',
- 'mode' => 0644,
- ])),
- (new Task())->setModule(new TemplateModule([
- 'src' => __DIR__ . '/unattended-upgrades/unattended-upgrades.twig',
- 'dest' => '/etc/apt/apt.conf.d/50unattended-upgrades',
- 'vars' => $config,
- 'owner' => 'root',
- 'group' => 'root',
- 'mode' => 0644,
- ])),
+ ...(new UnattendedUpgrades())($config['unattended_upgrades']),
# setup user
(new Task())->setModule(new AptModule([
@@ -66,7 +46,7 @@ class BaseServerSetup implements RoleInterface
])),
(new Task())->setModule(new CopyModule([
'src' => '~/.ssh',
- 'dest' => '/home/' . $config['username'],
+ 'dest' => '/home/' . $config['username'] . '/.ssh',
'owner' => $config['username'],
'group' => $config['username'],
'remoteSrc' => true,