From ad96de011269558b0bd32c39d710d2b6bcfaa42f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Filip=20Str=C3=B6mb=C3=A4ck?= <filip.stromback@liu.se>
Date: Mon, 21 Aug 2023 14:24:50 +0200
Subject: [PATCH] Updated the keydb to use vcsrepo as well.

---
 files/auth/on_update_keydb.sh |  4 ----
 manifests/auth_keydb.pp       | 29 +++++++++++------------------
 2 files changed, 11 insertions(+), 22 deletions(-)
 delete mode 100644 files/auth/on_update_keydb.sh

diff --git a/files/auth/on_update_keydb.sh b/files/auth/on_update_keydb.sh
deleted file mode 100644
index 3ed0354..0000000
--- a/files/auth/on_update_keydb.sh
+++ /dev/null
@@ -1,4 +0,0 @@
-#!/bin/bash
-
-systemctl restart aes_auth_keydb.service
-systemctl restart aes_temp_userdb.service
diff --git a/manifests/auth_keydb.pp b/manifests/auth_keydb.pp
index 5bde484..238a7b3 100644
--- a/manifests/auth_keydb.pp
+++ b/manifests/auth_keydb.pp
@@ -1,7 +1,8 @@
 # @summary
-#   Describe what this class do!
+#   Key database for the communication module.
 #
-#   Detailed summary info if suitable
+#   Stores authentication keys (=SSH keys) for cases where Kerberos
+#   is not a suitable authentication method.
 #
 #
 class aes::auth_keydb {
@@ -45,22 +46,14 @@ class aes::auth_keydb {
     source => "puppet:///modules/${module_name}/auth/keydb.service",
   }
 
-  file { "${keydb_home}/on_update.sh" :
-    ensure => file,
-    owner  => root,
-    group  => root,
-    mode   => '0700',
-    source => "puppet:///modules/${module_name}/auth/on_update_keydb.sh",
-  }
-
-  exec { 'update-keydb-repo' :
-    command     => "/opt/utils/update_repo.sh ${keydb_home}/src https://oauth2:F-agHaRXCdyFy38q4c-N@gitlab.liu.se/upp-aes/communication.git ${server_type}",
-    environment => ["REPO_USER=${keydb_user}", "REPO_GROUP=${keydb_group}", "REPO_ON_UPDATE=${keydb_home}/on_update.sh"],
-    # This command will need to run "on_update" as root in order to restart the service.
-    user        => root,
-    group       => root,
-    cwd         => $keydb_home,
-    require     => File["${keydb_home}/on_update.sh"],
+  vcsrepo { "${keydb_home}/src":
+    ensure   => latest,
+    provider => git,
+    source   => 'https://oauth2:F-agHaRXCdyFy38q4c-N@gitlab.liu.se/upp-aes/communication.git',
+    revision => $server_type,
+    owner    => $keydb_user,
+    group    => $keydb_group,
+    notify   => [Service[$keydb_service], Service['aes_temp_userdb']],
   }
 
   service { $keydb_service :
-- 
GitLab