Skip to content
This repository has been archived by the owner on May 28, 2024. It is now read-only.

Commit

Permalink
test: add gcp,aws,useradd-ssh layered images
Browse files Browse the repository at this point in the history
Signed-off-by: Wei Shi <[email protected]>
  • Loading branch information
shi2wei3 committed Mar 11, 2024
1 parent 1f8267f commit 2c3669d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
11 changes: 8 additions & 3 deletions os-replace.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ SSH_KEY=${TEMPDIR}/id_rsa
ssh-keygen -f "${SSH_KEY}" -N "" -q -t rsa-sha2-256 -b 2048
SSH_KEY_PUB="${SSH_KEY}.pub"

git submodule update
LAYERED_IMAGE="${LAYERED_IMAGE-cloud-init}"
LAYERED_DIR="examples/$LAYERED_IMAGE"
INSTALL_CONTAINERFILE="$LAYERED_DIR/Containerfile"
Expand Down Expand Up @@ -113,12 +112,14 @@ sed "s/REPLACE_ME/${QUAY_SECRET}/g" files/auth.template | tee "${LAYERED_DIR}"/a
greenprint "Create $TEST_OS installation Containerfile"
sed -i "s|^FROM.*|FROM $TIER1_IMAGE_URL\n$ADD_REPO|" "$INSTALL_CONTAINERFILE"
ROOT_SSH_KEY=""
if [[ "$PLATFORM" == "libvirt" ]] && [[ "$LAYERED_IMAGE" != "cloud-init" ]]; then
if [[ "$PLATFORM" == "libvirt" ]] && [[ "$LAYERED_IMAGE" != "cloud-init" ]] && [[ "$LAYERED_IMAGE" != "useradd-ssh" ]]; then
SSH_USER="root"
SSH_KEY_PUB_CONTENT=$(cat "${SSH_KEY_PUB}")
ROOT_SSH_KEY="RUN mkdir -p /usr/etc-system/ && echo 'AuthorizedKeysFile /usr/etc-system/%u.keys' >> /etc/ssh/sshd_config.d/30-auth-system.conf && \
echo \"$SSH_KEY_PUB_CONTENT\" > /usr/etc-system/root.keys && chmod 0600 /usr/etc-system/root.keys"
REPLACE_CLOUD_USER=""
elif [[ "$LAYERED_IMAGE" == "useradd-ssh" ]]; then
sed -i "s|exampleuser|$SSH_USER|g" "$INSTALL_CONTAINERFILE"
fi
tee -a "$INSTALL_CONTAINERFILE" > /dev/null << EOF
RUN dnf -y clean all
Expand All @@ -136,7 +137,11 @@ podman login -u "${QUAY_USERNAME}" -p "${QUAY_PASSWORD}" quay.io
retry podman pull "$TIER1_IMAGE_URL"

greenprint "Build $TEST_OS installation container image"
retry podman build -t "${TEST_IMAGE_NAME}:${QUAY_REPO_TAG}" "$LAYERED_DIR"
if [[ "$LAYERED_IMAGE" == "useradd-ssh" ]]; then
retry podman build --build-arg "sshpubkey=$(cat "${SSH_KEY_PUB}")" -t "${TEST_IMAGE_NAME}:${QUAY_REPO_TAG}" "$LAYERED_DIR"
else
retry podman build -t "${TEST_IMAGE_NAME}:${QUAY_REPO_TAG}" "$LAYERED_DIR"
fi

greenprint "Push $TEST_OS installation container image"
retry podman push "${TEST_IMAGE_NAME}:${QUAY_REPO_TAG}" "$TEST_IMAGE_URL"
Expand Down
4 changes: 4 additions & 0 deletions tmt/plans/os-replace.fmf
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ execute:
tag: openstack
environment+:
PLATFORM: openstack
LAYERED_IMAGE: useradd-ssh
adjust+:
- when: arch != x86_64
enabled: false
Expand All @@ -36,6 +37,7 @@ execute:
tag: gcp
environment+:
PLATFORM: gcp
LAYERED_IMAGE: gcp
prepare+:
- how: shell
script: cp tools/google-cloud-sdk.repo /etc/yum.repos.d/
Expand All @@ -51,6 +53,7 @@ execute:
tag: aws
environment+:
PLATFORM: aws
LAYERED_IMAGE: cloud-init
adjust+:
- when: arch != x86_64 and arch != aarch64
enabled: false
Expand All @@ -60,6 +63,7 @@ execute:
tag: [libvirt, stable]
environment+:
PLATFORM: libvirt
LAYERED_IMAGE: qemu-guest-agent
AIR_GAPPED: 1
prepare+:
- how: install
Expand Down

0 comments on commit 2c3669d

Please sign in to comment.