From b7ce9f1a7504c83213df158cc8c07f63eecfd738 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Filip=20Str=C3=B6mb=C3=A4ck?= <filip.stromback@liu.se>
Date: Fri, 26 Feb 2021 11:17:29 +0100
Subject: [PATCH] Use 'devel' branch from COMM repo for the devel machine.

---
 manifests/auth.pp       |  4 +++-
 manifests/auth_keydb.pp | 11 ++++++++++-
 manifests/broker.pp     | 14 +++++++-------
 3 files changed, 20 insertions(+), 9 deletions(-)

diff --git a/manifests/auth.pp b/manifests/auth.pp
index a217dec..fae4da6 100644
--- a/manifests/auth.pp
+++ b/manifests/auth.pp
@@ -14,9 +14,11 @@ class aes::auth(
   if $facts[fqdn] == 'aes.edu.liu.se' {
     # The AD service account for this key is: ida_sys002_srv
     $auth_keytab_data = $keytab_production
+    $server_type = "production"
   } elsif $facts[fqdn] == 'aes-devel.edu.liu.se' {
     # The AD service account for this key is: ida_sys004_srv
     $auth_keytab_data = $keytab_devel
+    $server_type = "devel"
   } else {
     $auth_keytab_data = undef
   }
@@ -107,7 +109,7 @@ class aes::auth(
   }
 
   exec { 'update-auth-repo' :
-    command => "/opt/utils/update_repo.sh ${auth_home}/src https://oauth2:F-agHaRXCdyFy38q4c-N@gitlab.liu.se/upp-aes/communication.git production",
+    command => "/opt/utils/update_repo.sh ${auth_home}/src https://oauth2:F-agHaRXCdyFy38q4c-N@gitlab.liu.se/upp-aes/communication.git ${server_type}",
     environment => [ "REPO_USER=${auth_user}", "REPO_GROUP=${auth_group}", "REPO_ON_UPDATE=${auth_home}/on_update.sh" ],
     # This command will need to run "on_update" as root in order to restart the service.
     user => root,
diff --git a/manifests/auth_keydb.pp b/manifests/auth_keydb.pp
index 559a87b..d56a745 100644
--- a/manifests/auth_keydb.pp
+++ b/manifests/auth_keydb.pp
@@ -5,6 +5,15 @@ class aes::auth_keydb {
   $keydb_home = "/srv/${keydb_user}"
   $keydb_service = "aes_auth_keydb"
 
+  # Figure out which certificate to use based on the hostname.
+  if $facts[fqdn] == 'aes.edu.liu.se' {
+    $server_type = "production"
+  } elsif $facts[fqdn] == 'aes-devel.edu.liu.se' {
+    $server_type = "devel"
+  } else {
+    $server_type = undef
+  }
+
   user { "${keydb_user}" :
     ensure => present,
     home => "${keydb_home}",
@@ -40,7 +49,7 @@ class aes::auth_keydb {
   }
 
   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 production",
+    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,
diff --git a/manifests/broker.pp b/manifests/broker.pp
index 381fc4e..6853143 100644
--- a/manifests/broker.pp
+++ b/manifests/broker.pp
@@ -17,11 +17,11 @@ class aes::broker {
 
   # Figure out which certificate to use based on the hostname.
   if $facts[fqdn] == 'aes.edu.liu.se' {
-    $key_prefix = "production"
+    $server_type = "production"
   } elsif $facts[fqdn] == 'aes-devel.edu.liu.se' {
-    $key_prefix = "devel"
+    $server_type = "devel"
   } else {
-    $key_prefix = undef
+    $server_type = undef
   }
 
   user { "${broker_user}" :
@@ -69,7 +69,7 @@ class aes::broker {
     owner => "${broker_user}",
     group => "${broker_group}",
     mode => '0700',
-    source => "puppet:///modules/${module_name}/broker/cert/${key_prefix}_cert.pem"
+    source => "puppet:///modules/${module_name}/broker/cert/${server_type}_cert.pem"
   }
 
   file { "${broker_home}/ssl/key.pem" :
@@ -77,7 +77,7 @@ class aes::broker {
     owner => "${broker_user}",
     group => "${broker_group}",
     mode => '0700',
-    source => "puppet:///modules/${module_name}/broker/cert/${key_prefix}_key.pem"
+    source => "puppet:///modules/${module_name}/broker/cert/${server_type}_key.pem"
   }
 
   file { "${broker_home}/ssl/password" :
@@ -85,11 +85,11 @@ class aes::broker {
     owner => "${broker_user}",
     group => "${broker_group}",
     mode => '0700',
-    source => "puppet:///modules/${module_name}/broker/cert/${key_prefix}_password"
+    source => "puppet:///modules/${module_name}/broker/cert/${server_type}_password"
   }
 
   exec { 'update-broker-repo' :
-    command => "/opt/utils/update_repo.sh ${broker_home}/src https://oauth2:F-agHaRXCdyFy38q4c-N@gitlab.liu.se/upp-aes/communication.git production",
+    command => "/opt/utils/update_repo.sh ${broker_home}/src https://oauth2:F-agHaRXCdyFy38q4c-N@gitlab.liu.se/upp-aes/communication.git ${server_type}",
     environment => [ "REPO_USER=${broker_user}", "REPO_GROUP=${broker_group}", "REPO_ON_UPDATE=${broker_home}/on_update.sh" ],
     # This command will need to run "on_update" as root in order to restart the service.
     user => root,
-- 
GitLab