Skip to content

Commit fc5889d

Browse files
Use Puppet version to determine collection in install_shell.sh
When a collection is not explicitly specified, determine the appropriate collection based on the installed Puppet version rather than defaulting to the generic 'puppet' collection. This ensures platforms like Ubuntu 24 use the correct version-specific package (e.g., puppet8-release) instead of the generic package (puppet-release) which can cause failures. Signed-off-by: Gavin Didrichsen <[email protected]>
1 parent 22e07b9 commit fc5889d

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

tasks/install_shell.sh

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,24 @@ if [ -n "$PT_collection" ]; then
120120

121121
collection=$PT_collection
122122
else
123-
collection='puppet'
123+
# Try to determine the appropriate collection based on puppet version
124+
# This helps ensure we use version-specific packages (e.g., puppet8-release)
125+
# rather than generic packages (puppet-release) which can fail on some platforms like Ubuntu 24
126+
if [ -f /opt/puppetlabs/puppet/VERSION ]; then
127+
puppet_version=`cat /opt/puppetlabs/puppet/VERSION`
128+
major_version=`echo $puppet_version | cut -d. -f1`
129+
collection="puppet${major_version}"
130+
info "Setting collection to ${collection} based on installed Puppet version ${puppet_version}"
131+
elif type -p puppet >/dev/null; then
132+
puppet_version=`puppet --version`
133+
major_version=`echo $puppet_version | cut -d. -f1`
134+
collection="puppet${major_version}"
135+
info "Setting collection to ${collection} based on puppet command version ${puppet_version}"
136+
else
137+
# Default to generic collection as a last resort
138+
collection='puppet'
139+
info "No puppet version detected, using default collection: ${collection}"
140+
fi
124141
fi
125142

126143
if [ -n "$PT_yum_source" ]; then

0 commit comments

Comments
 (0)