Skip to content

Commit ccda2cb

Browse files
committed
(CAT-2413) Defaults puppetcore agent version to newest if none given
When puppetcore is selected without a specified version, this change defaults to the latest 8.x version available. This prevents errors caused by the download site requiring a version parameter. Relates to CAT-2413
1 parent 46101ee commit ccda2cb

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

tasks/install_powershell.ps1

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,16 @@ if (($collection -like '*nightly*') -And -Not ($PSBoundParameters.ContainsKey('w
120120
$windows_source = 'https://nightlies.puppet.com/downloads'
121121
} elseif (($collection -like '*puppetcore*') -And -Not ($PSBoundParameters.ContainsKey('windows_source'))) {
122122
$windows_source = 'https://artifacts-puppetcore.puppet.com/v1/download'
123+
124+
# Puppetcore requires a version to be specified, so we will use the latest version if not specified.
125+
# Or if the version is set to "latest".
126+
if ($version -eq "" || !$version || $version -eq "latest") {
127+
$response = Invoke-WebRequest -Uri "https://forgeapi.puppet.com/private/versions/puppet-agent" -UseBasicParsing
128+
$jsonData = $response.Content | ConvertFrom-Json
129+
$allVersions = $jsonData.PSObject.Properties.Name
130+
$version8x = $allVersions | Where-Object { $_ -like "8.*" }
131+
$version = $version8x | Sort-Object { [Version]$_ } | Select-Object -Last 1
132+
}
123133
}
124134

125135
if ($absolute_source) {
@@ -131,6 +141,7 @@ if ($absolute_source) {
131141
} else {
132142
$dev = ''
133143
}
144+
134145
$msi_source = "${windows_source}?type=native&version=${version}&os_name=windows&os_version=${major_os_version}&os_arch=${arch}&fips=${fips}${dev}"
135146
} else {
136147
$msi_source = "$windows_source/windows/${collection}/${msi_name}"

tasks/install_shell.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,14 @@ if [ -n "$PT_mac_source" ]; then
152152
mac_source=$PT_mac_source
153153
elif [[ "$collection" == "puppetcore"* ]]; then
154154
mac_source='https://artifacts-puppetcore.puppet.com/v1/download'
155+
# Puppetcore requires a version to be specified, so we will use the latest version if not specified.
156+
# Or if the version is set to "latest".
157+
if [[ -z "$version" || "$version" == "latest" ]]; then
158+
version=$(curl -sL https://forgeapi.puppet.com/private/versions/puppet-agent | \
159+
jq -r 'keys_unsorted |
160+
map(select(startswith("8."))) |
161+
max_by(split(".") | map(tonumber))')
162+
fi
155163
elif [ "$nightly" = true ]; then
156164
mac_source='http://nightlies.puppet.com/downloads'
157165
else

0 commit comments

Comments
 (0)