Skip to content

Commit 4cba10f

Browse files
committed
Adding support for a machine name suffix so that we can provide a nicer deployment scenario for a segregated farm
1 parent f02adcd commit 4cba10f

File tree

2 files changed

+19
-5
lines changed

2 files changed

+19
-5
lines changed

AzureWebFarm.OctopusDeploy/Infrastructure/ConfigSettings.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,25 @@ internal class ConfigSettings
1111
private const string TentacleRoleConfigName = "TentacleRole";
1212
private const string TentacleDeploymentsPathConfigName = "Deployments";
1313
private const string TentacleInstallPathConfigName = "Install";
14+
private const string TentacleMachineNameSuffixConfigName = "TentacleMachineNameSuffix";
1415

15-
private static readonly string[] ConfigSettingsNames = new[] { OctopusServerConfigName, OctopusApiKeyConfigName, TentacleEnvironmentConfigName, TentacleRoleConfigName };
16+
private static readonly string[] ConfigSettingsNames = new[] { OctopusServerConfigName, OctopusApiKeyConfigName, TentacleEnvironmentConfigName, TentacleRoleConfigName, TentacleMachineNameSuffixConfigName };
1617

1718
private static string _octopusServer;
1819
private static string _octopusApiKey;
1920
private static string _tentacleEnvironment;
2021
private static string _tentacleRole;
22+
private readonly string _tentacleMachineNameSuffix;
2123
private readonly string _tentacleDeploymentsPath;
2224
private readonly string _tentacleInstallPath;
23-
25+
2426
public ConfigSettings(Func<string, string> configSettingsGetter, Func<string, string> configPathGetter)
2527
{
2628
_octopusServer = configSettingsGetter(OctopusServerConfigName);
2729
_octopusApiKey = configSettingsGetter(OctopusApiKeyConfigName);
2830
_tentacleEnvironment = configSettingsGetter(TentacleEnvironmentConfigName);
2931
_tentacleRole = configSettingsGetter(TentacleRoleConfigName);
32+
_tentacleMachineNameSuffix = configSettingsGetter(TentacleMachineNameSuffixConfigName);
3033

3134
_tentacleDeploymentsPath = configPathGetter(TentacleDeploymentsPathConfigName);
3235
_tentacleInstallPath = configPathGetter(TentacleInstallPathConfigName);
@@ -36,6 +39,7 @@ public ConfigSettings(Func<string, string> configSettingsGetter, Func<string, st
3639
public string OctopusApiKey { get { return _octopusApiKey; } }
3740
public string TentacleEnvironment { get { return _tentacleEnvironment; } }
3841
public string TentacleRole { get { return _tentacleRole; } }
42+
public string TentacleMachineNameSuffix { get { return _tentacleMachineNameSuffix; } }
3943

4044
public string TentacleDeploymentsPath { get { return _tentacleDeploymentsPath; } }
4145
public string TentacleInstallPath { get { return _tentacleInstallPath; } }

AzureWebFarm.OctopusDeploy/WebFarmRole.cs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public WebFarmRole(string machineName = null)
2222
Log.Logger = AzureEnvironment.GetAzureLogger();
2323
var config = AzureEnvironment.GetConfigSettings();
2424

25-
machineName = machineName ?? AzureEnvironment.GetMachineName(config);
25+
machineName = machineName ?? GetMachineName(config);
2626
var octopusRepository = Infrastructure.OctopusDeploy.GetRepository(config);
2727
var processRunner = new ProcessRunner();
2828
var registryEditor = new RegistryEditor();
@@ -78,7 +78,17 @@ public void OnStop()
7878
_octopusDeploy.DeleteMachine();
7979
IisEnvironment.WaitForAllHttpRequestsToEnd();
8080
}
81-
}
8281

83-
82+
private static string GetMachineName(ConfigSettings config)
83+
{
84+
var machineName = AzureEnvironment.GetMachineName(config);
85+
86+
if (!string.IsNullOrEmpty(config.TentacleMachineNameSuffix))
87+
{
88+
machineName = machineName + "_" + config.TentacleMachineNameSuffix;
89+
}
90+
91+
return machineName;
92+
}
93+
}
8494
}

0 commit comments

Comments
 (0)