Skip to content

Commit e37d393

Browse files
authored
Merge pull request #2088 from craigcomstock/ent-13483-centos-6
ENT-13483: Fix centos-6, ubuntu-20 and debian-9 bootstrap build host setup after removal of quick install script use
2 parents f15eedd + 66a8757 commit e37d393

File tree

2 files changed

+69
-27
lines changed

2 files changed

+69
-27
lines changed

ci/cfengine-build-host-setup.cf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,10 @@ bundle agent cfengine_build_host_setup
4545
"python3-psycopg2";
4646
"rsync" comment => "added for debian-10";
4747
"systemd-coredump" comment => "added step to jenkins testing-pr job to query for coredumps on failures";
48+
4849
# core/ci/dependencies.sh is run on some systems where quickinstall and cf-remote cannot install an agent to run this policy so we must remove some system packages that we also build since both install to /usr as a prefix.
50+
# we do need these still installed on bootstrap-pr hosts though, so guard against that class
51+
debian.!bootstrap_pr_host::
4952
"libattr1-dev" package_policy => "delete";
5053
"libssl-dev" package_policy => "delete";
5154
"libpcre2-dev" package_policy => "delete";
@@ -69,6 +72,7 @@ bundle agent cfengine_build_host_setup
6972
(debian_10|debian_11).systemssl_build_host::
7073
"libssl-dev";
7174
debian.bootstrap_pr_host::
75+
"libssl-dev"; # bootstrap_pr host needs this to configure before we build openssl ourselves
7276
"librsync-dev"; # bootstrap_pr host needs this to run configure and make dist
7377
"autoconf-archive" comment => "Required to resolve the AX_PTHREAD macro";
7478

ci/setup-cfengine-build-host.sh

Lines changed: 65 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ fi
1616
mkdir -p /home/jenkins
1717
chown -R jenkins /home/jenkins
1818

19+
# cleanup any previous runs cfengine-masterfiles tar balls
20+
rm -rf cfengine-masterfiles*
21+
1922
function cleanup()
2023
{
2124
set -ex
@@ -83,6 +86,9 @@ if [ -f /etc/os-release ]; then
8386
elif grep debian /etc/os-release; then
8487
DEBIAN_FRONTEND=noninteractive apt upgrade --yes && DEBIAN_FRONTEND=noninteractive apt autoremove --yes
8588
alias software='DEBIAN_FRONTEND=noninteractive apt install --yes'
89+
if grep stretch /etc/os-release; then
90+
DEBIAN_STRETCH=1 # special case, cf-remote install needs to NOT use master as there are no packages there
91+
fi
8692
elif grep suse /etc/os-release; then
8793
zypper -n update
8894
alias software='zypper install -y'
@@ -107,34 +113,65 @@ else
107113
exit 1
108114
fi
109115

110-
echo "Installing cf-remote for possible package install and masterfiles download"
111-
# try pipx first for debian as pip won't work.
112-
# If that fails to install CFEngine then try python3-pip for redhats.
113-
if software pipx; then
114-
pipx install cf-remote
115-
export PATH=$HOME/.local/bin:$PATH
116-
elif software python3-pip; then
117-
if command -v pip; then
118-
pip install cf-remote
119-
elif command -v pip3; then
120-
pip3 install cf-remote
121-
else
122-
echo "failure: neither pip nor pip3 seem to be available."
123-
exit 42
116+
if grep 6.10 /etc/issue; then
117+
# special case of centos-6, cf-remote depends on urllib3 which depends on openssl 1.1.1+ that is not available
118+
# generally we rely on cf-remote to install cfengine-nova and download masterfiles so here we must provide for both of those
119+
echo "Found CentOS 6.10 so installing via hard-coded package URL..."
120+
121+
if [ ! -x /var/cfengine/bin/cf-agent ]; then
122+
rm -rf cfengine-nova*rpm
123+
urlget https://cfengine-package-repos.s3.amazonaws.com/enterprise/Enterprise-3.24.3/agent/agent_rhel6_x86_64/cfengine-nova-3.24.3-1.el6.x86_64.rpm
124+
rpm -i cfengine-nova-3.24.3-1.el6.x86_64.rpm
124125
fi
126+
urlget https://cfengine-package-repos.s3.amazonaws.com/enterprise/Enterprise-3.24.3/misc/cfengine-masterfiles-3.24.3-1.pkg.tar.gz
125127
fi
126-
export PATH=/usr/local/bin:$PATH # add /usr/local/bin for pip/pipx installed cf-remote
127128

128-
if ! command -v cf-remote; then
129-
echo "cf-remote was not installed, it is required so exiting now"
130-
exit 42
131-
fi
129+
if [ -x /var/cfengine/bin/cf-agent ]; then
130+
echo "Case of pre-installed CFEngine so skipping cf-remote install and assuming download of masterfiles earlier in the script."
131+
else
132+
echo "Installing cf-remote for possible package install and masterfiles download"
133+
# try pipx first for debian as pip won't work.
134+
# If that fails to install CFEngine then try python3-pip for redhats.
135+
PIP=""
136+
software python3-venv || true # on ubuntu-20 this is needed, debian-12 it is not but won't hurt
137+
if software pipx; then
138+
PIP=pipx
139+
export PATH=$HOME/.local/bin:$PATH
140+
elif software python3-pip; then
141+
if command -v pip; then
142+
PIP=pip
143+
elif command -v pip3; then
144+
PIP=pip3
145+
fi
146+
elif software python-pip; then
147+
if command -v pip; then
148+
PIP=pip
149+
fi
150+
else
151+
echo "Tried installing pipx, python3-pip and python-pip, none of which resulted in pipx, pip3 or pip being available. Exiting."
152+
exit 23
153+
fi
154+
export PATH=/usr/local/bin:$PATH # some pip/pipx use /usr/local/bin
155+
156+
$PIP uninstall cf-remote || true # just in case a previous is there and would cause the install to fail
157+
$PIP install cf-remote
158+
159+
if ! command -v cf-remote; then
160+
echo "cf-remote was not installed, it is required so exiting now"
161+
exit 42
162+
fi
132163

133-
echo "Checking for pre-installed CFEngine (chicken/egg problem)"
134-
# We need a cf-agent to run build host setup policy and redhat-10-arm did not have a previous package to install.
135-
if ! /var/cfengine/bin/cf-agent -V; then
136-
echo "No existing CFEngine install found, try cf-remote..."
137-
cf-remote --log-level info --version master install --clients localhost || true
164+
echo "Checking for pre-installed CFEngine (chicken/egg problem)"
165+
# We need a cf-agent to run build host setup policy and redhat-10-arm did not have a previous package to install.
166+
if ! /var/cfengine/bin/cf-agent -V; then
167+
echo "No existing CFEngine install found, try cf-remote..."
168+
if [ -n "$DEBIAN_STRETCH" ]; then
169+
_VERSION="--version 3.21.8"
170+
else
171+
_VERSION="--version master"
172+
fi
173+
cf-remote --log-level info $_VERSION install --clients localhost || true
174+
fi
138175
fi
139176

140177
if [ ! -x /var/cfengine/bin/cf-agent ]; then
@@ -149,9 +186,10 @@ if [ ! -x /var/cfengine/bin/cf-agent ]; then
149186
)
150187
fi
151188

152-
# get masterfiles
153-
rm -rf cfengine-masterfiles*tar.gz
154-
cf-remote download masterfiles --output-dir .
189+
# download masterfiles if not already present (such as in case of centos-6 above, hard-coded 3.24.3 download)
190+
if ! ls cfengine-masterfiles*gz; then
191+
cf-remote download masterfiles --output-dir .
192+
fi
155193
tar xf cfengine-masterfiles-*tar.gz
156194
cp -a masterfiles/* /var/cfengine/inputs/
157195

0 commit comments

Comments
 (0)