ps/Modules/Alkami.DevOps.TeamCity/Public/Get-TeamCityHostnames.ps1

53 lines
2.7 KiB
PowerShell
Raw Normal View History

2023-05-30 22:51:22 -07:00
function Get-TeamCityHostnames {
<#
.SYNOPSIS
Returns an array of hostnames of the TeamCity server and agent instances
.PARAMETER Type
Type of TeamCity host(s) to return: All, Server(s), or Agent(s)
#>
[CmdletBinding()]
[OutputType([string[]])]
param(
[Parameter(Mandatory = $false)]
[ValidateSet("All", "Server", "Agent")]
[string]$Type = "All",
[Parameter(Mandatory = $false)]
[string]$ProfileName
)
$logLead = Get-LogLeadName
# Because I don't feel like using SharedVariables (yet)
if (Test-StringIsNullOrWhitespace -Value $ProfileName) {
$TeamCityHosts = @{
All = @("team316179.fh.local", "tea316155.fh.local", "tea31697.fh.local", "tea316229.fh.local", "tea316208.fh.local", "tea46658.fh.local", "tea37021.fh.local", "tea370104.fh.local", "tea37168.fh.local", "tea37079.fh.local", "tea370181.fh.local", "tea370219.fh.local", "tea37020.fh.local", "tea370123.fh.local")
Server = @("team316179.fh.local", "tea37020.fh.local", "tea370123.fh.local")
Agent = @("tea316155.fh.local", "tea31697.fh.local", "tea316229.fh.local", "tea316208.fh.local", "tea46658.fh.local", "tea37021.fh.local", "tea370104.fh.local", "tea37168.fh.local", "tea37079.fh.local", "tea370181.fh.local", "tea370219.fh.local")
}
Write-Host "$logLead : Returning TeamCity Hosts of type - $Type - From all AWS Accounts"
} elseif ($ProfileName -eq "temp-prod") {
$TeamCityHosts = @{
All = @("team316179.fh.local", "tea316155.fh.local", "tea31697.fh.local", "tea316229.fh.local", "tea316208.fh.local", "tea46658.fh.local")
Server = @("team316179.fh.local")
Agent = @("tea316155.fh.local", "tea31697.fh.local", "tea316229.fh.local", "tea316208.fh.local", "tea46658.fh.local")
}
Write-Host "$logLead : Returning TeamCity Hosts of type - $Type - From the AWS Production Account"
} elseif ($ProfileName -eq "temp-mgmt") {
$TeamCityHosts = @{
All = @("tea37021.fh.local", "tea370104.fh.local", "tea37168.fh.local", "tea37079.fh.local", "tea370181.fh.local", "tea370219.fh.local", "tea37020.fh.local", "tea370123.fh.local")
Server = @("tea37020.fh.local", "tea370123.fh.local")
Agent = @("tea37021.fh.local", "tea370104.fh.local", "tea37168.fh.local", "tea37079.fh.local", "tea370181.fh.local", "tea370219.fh.local")
}
Write-Host "$logLead : Returning TeamCity Hosts of type - $Type - From the AWS Management Account"
} else {
Write-Warning "ProfileName does not fall under the criteria of temp-prod or temp-mgmt, exiting function..."
return
}
$hostnamesToReturn = $TeamCityHosts[$Type]
return $hostnamesToReturn
}