11#! /bin/bash -e
2+ # shellcheck disable=SC2086,2174
23
34#
45# Run a local containerized deployment of the Pbench Server, together with its
@@ -26,6 +27,10 @@ export PB_DASHBOARD_DIR="${PB_DASHBOARD_DIR:-${PWD}/dashboard/build/}"
2627export KEYCLOAK_REALM=${KEYCLOAK_REALM:- " pbench-server" }
2728export KEYCLOAK_CLIENT=${KEYCLOAK_CLIENT:- " pbench-client" }
2829
30+ host_name=${PB_HOST_NAME:- $(hostname --fqdn)}
31+ host_ip_list=${PB_HOST_IP:- $(hostname -I)}
32+ host_ip=${host_ip_list%% * }
33+
2934# Set up TMP_DIR, if it's not already defined, to point to WORKSPACE_TMP, if it
3035# is defined (e.g., by the CI), or to `/var/tmp/pbench` as a fallback.
3136#
@@ -45,7 +50,7 @@ export PB_DEPLOY_FILES=${PB_DEPLOY_FILES:-${TMP_DIR}/pbench_server_deployment}
4550
4651# Copy the deployment files to the deployment files directory
4752pbiac_etc=server/pbenchinacan/etc
48- rm -rf ${PB_DEPLOY_FILES} /etc ${PB_DEPLOY_FILES} /pbench-server.cfg
53+ rm -rf ${PB_DEPLOY_FILES:? } /etc ${PB_DEPLOY_FILES} /pbench-server.cfg
4954mkdir -p -m 755 ${PB_DEPLOY_FILES} /etc
5055cp -r ${pbiac_etc} /rsyslog.d ${pbiac_etc} /rsyslog.conf ${PB_DEPLOY_FILES} /etc/
5156cp ${pbiac_etc} /pbench-server/pbench-server.cfg ${PB_DEPLOY_FILES} /
@@ -91,6 +96,30 @@ podman run \
9196 ${PB_SERVER_IMAGE} \
9297 -c " chown -R pbench:pbench /srv/pbench/*"
9398
99+ # Create a private key and certificate, signed by our own, private CA, for the
100+ # Pbench Server to use to provide SSL connections. The certificate has to
101+ # match the host that the container is running on, so we generate it on the fly
102+ # and place it in the deployment files directory.
103+ #
104+ # We do this in the Pbench Server container so that we get a known version of
105+ # openssl (the native one on the Jenkins executors appears to be ancient).
106+ podman run \
107+ --rm \
108+ --volume ${PB_DEPLOY_FILES} :/data:Z \
109+ --volume ${PWD} /${pbiac_etc} /pki/tls:/pki_tls:Z \
110+ --entrypoint /usr/bin/openssl \
111+ ${PB_SERVER_IMAGE} \
112+ req -batch -new -noenc -sha256 -days 365 -newkey rsa:2048 \
113+ -out /data/pbench-server.crt \
114+ -keyout /data/pbench-server.key \
115+ -subj " /C=US/ST=Massachusetts/L=Westford/O=Red Hat/OU=Performance & Scale/CN=${host_name} " \
116+ -CA /pki_tls/certs/pbench_CA.crt \
117+ -CAkey /pki_tls/private/pbench_CA.key \
118+ -addext " authorityKeyIdentifier = keyid,issuer" \
119+ -addext " basicConstraints=CA:FALSE" \
120+ -addext " keyUsage = digitalSignature, nonRepudiation, keyEncipherment, dataEncipherment" \
121+ -addext " subjectAltName = IP.2:${host_ip} "
122+
94123# +
95124# Start the services which the Pbench Server depends upon and then start the
96125# Pbench Server itself.
0 commit comments