Skip to content

Commit 2529d40

Browse files
committed
(tasks,gha) Implement version parameter for install task
Setting openvox_bootstrap::install version will install that version of the openvox-agent. Does not test for mismatch between collection and version major.
1 parent f4d9177 commit 2529d40

File tree

4 files changed

+55
-11
lines changed

4 files changed

+55
-11
lines changed

.github/workflows/pr_testing.yaml

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,4 +72,31 @@ jobs:
7272
PT_yum_source: "https://yum.overlookinfratech.com"
7373
run: ./openvox_bootstrap/tasks/install_linux.sh
7474
- name: Verify openvox-agent is installed
75-
run: /opt/puppetlabs/bin/puppet --version | grep -E '[0-9]+\.[0-9]+'
75+
run: /opt/puppetlabs/bin/puppet --version | grep -E '8\.[0-9]+'
76+
77+
test-install-version:
78+
strategy:
79+
matrix:
80+
image:
81+
- rockylinux:9
82+
- debian:12
83+
# Need to pull in the repo GPG keys for sles
84+
# - registry.suse.com/suse/sle15:15.6
85+
needs: shellcheck
86+
runs-on: ubuntu-latest
87+
container: ${{ matrix.image }}
88+
steps:
89+
- uses: actions/checkout@v4
90+
with:
91+
path: openvox_bootstrap
92+
- id: prep
93+
uses: ./openvox_bootstrap/.github/actions/container_task_prep
94+
- name: Run openvox-agent install task manually
95+
env:
96+
PT__installdir: ${{ github.workspace }}
97+
PT_version: "8.14.0"
98+
PT_apt_source: "https://apt.overlookinfratech.com"
99+
PT_yum_source: "https://yum.overlookinfratech.com"
100+
run: ./openvox_bootstrap/tasks/install_linux.sh
101+
- name: Verify openvox-agent is installed
102+
run: /opt/puppetlabs/bin/puppet --version | grep '8.14.0'

files/common.sh

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -166,21 +166,36 @@ install_package_file() {
166166
esac
167167
}
168168

169-
# TODO add support for the version parameter.
169+
# Install a package using the system package manager.
170170
install_package() {
171171
local _package="$1"
172-
173-
info "Installing ${_package}"
172+
local _version="$2"
173+
174+
info "Installing ${_package} ${_version}"
175+
176+
local _package_and_version
177+
if [[ -n "${_version}" ]]; then
178+
case $family in
179+
debian|ubuntu)
180+
_package_and_version="${_package}=${_version}"
181+
;;
182+
*)
183+
_package_and_version="${_package}-${_version}"
184+
;;
185+
esac
186+
else
187+
_package_and_version="${_package}"
188+
fi
174189
if exists 'dnf'; then
175-
exec_and_capture dnf install -y "$_package"
190+
exec_and_capture dnf install -y "$_package_and_version"
176191
elif exists 'yum'; then
177-
exec_and_capture yum install -y "$_package"
192+
exec_and_capture yum install -y "$_package_and_version"
178193
elif exists 'zypper'; then
179-
exec_and_capture zypper install -y "$_package"
194+
exec_and_capture zypper install -y "$_package_and_version"
180195
elif exists 'apt'; then
181-
exec_and_capture apt install -y "$_package"
196+
exec_and_capture apt install -y "$_package_and_version"
182197
elif exists 'apt-get'; then
183-
exec_and_capture apt-get install -y "$_package"
198+
exec_and_capture apt-get install -y "$_package_and_version"
184199
else
185200
fail "Unable to install ${_package}. Neither dnf, yum, zypper, apt nor apt-get are installed."
186201
fi

tasks/install.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"description": "Installs the openvox-agent package.",
33
"parameters": {
44
"version": {
5-
"description": "TODO The version of the openvox-agent package to install. Defaults to latest.",
5+
"description": "The version of the openvox-agent package to install. Defaults to latest.",
66
"type": "Optional[String]"
77
},
88
"collection": {

tasks/install_linux.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ set -e
66
# shellcheck disable=SC2154
77
installdir=$PT__installdir
88
# shellcheck disable=SC2154
9+
version=${PT_version:-'latest'}
10+
# shellcheck disable=SC2154
911
collection=${PT_collection:-'openvox8'}
1012
# shellcheck disable=SC2154
1113
yum_source=${PT_yum_source:-'https://yum.overlookinfratech.com'}
@@ -82,4 +84,4 @@ download "${package_url}" "${local_release_package}"
8284
# packages from the collection using the platform package manager.
8385
install_release_package "${local_release_package}" "${package_type}"
8486
# Use the platform package manager to install openvox-agent
85-
install_package 'openvox-agent'
87+
install_package 'openvox-agent' "${version}"

0 commit comments

Comments
 (0)