From 7fd715f1c91755f1e7e705bcc680ebae15e20407 Mon Sep 17 00:00:00 2001
From: Vadym Chepkov <vchepkov@gmail.com>
Date: Sun, 31 Mar 2024 08:12:42 -0400
Subject: [PATCH] support mono topology for standard installation

---
 plans/subplans/configure.pp  |  8 +++++++-
 tasks/provision_replica.json |  5 +++++
 tasks/provision_replica.sh   | 13 +++++++++----
 3 files changed, 21 insertions(+), 5 deletions(-)

diff --git a/plans/subplans/configure.pp b/plans/subplans/configure.pp
index bccc0503d..a6d32dfb4 100644
--- a/plans/subplans/configure.pp
+++ b/plans/subplans/configure.pp
@@ -2,7 +2,7 @@
 #
 # @summary Configure first-time classification and DR setup
 #
-# @param compiler_pool_address 
+# @param compiler_pool_address
 #   The service address used by agents to connect to compilers, or the Puppet
 #   service. Typically this is a load balancer.
 # @param internal_compiler_a_pool_address
@@ -107,6 +107,11 @@
   }
 
   if $arch['disaster-recovery'] {
+    $topology =  $arch['architecture']? {
+      'standard' => 'mono',
+      default    => 'mono-with-compile',
+    }
+
     # Run the PE Replica Provision
     run_task('peadm::provision_replica', $primary_target,
       replica    => $replica_target.peadm::certname(),
@@ -116,6 +121,7 @@
       # probably gets "starting", but fails out because that's not "running".
       # Can remove flag when that issue is fixed.
       legacy     => true,
+      topology   => $topology,
     )
   }
 
diff --git a/tasks/provision_replica.json b/tasks/provision_replica.json
index 8d1b44da2..e4e7f0de8 100644
--- a/tasks/provision_replica.json
+++ b/tasks/provision_replica.json
@@ -5,6 +5,11 @@
       "type": "String",
       "description": "The name of the replica to provision"
     },
+    "topology": {
+      "type": "String",
+      "description": "The topology of PE installation",
+      "default": "mono-with-compile"
+    },
     "token_file": {
       "type": "Optional[String]",
       "description": "The name of the token-file for auth"
diff --git a/tasks/provision_replica.sh b/tasks/provision_replica.sh
index 73161810f..8eadb2ec5 100755
--- a/tasks/provision_replica.sh
+++ b/tasks/provision_replica.sh
@@ -18,6 +18,11 @@ else
   export TOKEN_FILE="$PT_token_file"
 fi
 
+if [ "$PT_topology" = "mono" ] ; then
+  AGENT_CONFIG=""
+else
+  AGENT_CONFIG="--skip-agent-config"
+fi
 
 set -e
 
@@ -28,8 +33,8 @@ if [ "$PT_legacy" = "false" ]; then
   puppet infrastructure provision replica "$PT_replica" \
     --color false \
     --yes --token-file "$TOKEN_FILE" \
-    --skip-agent-config \
-    --topology mono-with-compile \
+    $AGENT_CONFIG \
+    --topology "$PT_topology" \
     --enable
 
 elif [ "$PT_legacy" = "true" ]; then
@@ -45,8 +50,8 @@ elif [ "$PT_legacy" = "true" ]; then
   puppet infrastructure enable replica "$PT_replica" \
     --color false \
     --yes --token-file "$TOKEN_FILE" \
-    --skip-agent-config \
-    --topology mono-with-compile
+    $AGENT_CONFIG \
+    --topology "$PT_topology"
 
 else
   exit 1