Files
ansible-freeipa/infra/image/build.sh
Thomas Woerner 8153239ef7 New image builder without molecule using podman
The new image builder is not using molecule and uses podman directly for
the generation of the ansible-test images.

Two additional services are installed to simplify the use of the
container in the test:

- fixnet.service uses /root/fixnet.sh to fix IP address of the server in
  /etc/hosts and to set localhost as the nameserver.
  This service is executed before IPA is started. This eliminates the
  need to restart the IPA server after the container has been started
  and the IPs have been fixed.
- fixipaip.service uses /root/fixipaip.sh to fix the IP address of the
  IPA dnsrecords of server and ipa-ca.

With these services it is now only needed to wait till all services in
the container are started. There is no need to restart the IPA server
anymore. Simply use something like this before starting the tests:

    while [ -n "$(podman exec ansible-test systemctl list-jobs | grep -vi 'no jobs running')" ]; do echo "waiting.."; sleep 5; done

New files
- infra/image/build.sh
- infra/image/dockerfile/c8s
- infra/image/dockerfile/c9s
- infra/image/dockerfile/c10s
- infra/image/dockerfile/fedora-latest
- infra/image/dockerfile/fedora-rawhide
- infra/image/inventory
- infra/image/system-service/fixipaip.service
- infra/image/system-service/fixipaip.sh
- infra/image/system-service/fixnet.service
- infra/image/system-service/fixnet.sh
2024-07-31 16:09:29 +02:00

67 lines
1.6 KiB
Bash
Executable File

#!/bin/bash -eu
BASEDIR="$(readlink -f "$(dirname "$0")")"
TOPDIR="$(readlink -f "${BASEDIR}/../..")"
scenario=${1:-}
name="ansible-test"
hostname="ipaserver.test.local"
cpus="2"
memory="4g"
quayname="quay.io/ansible-freeipa/upstream-tests"
if [ -z "${scenario}" ]; then
echo "ERROR: Image needs to be given"
exit 1
fi
if [ ! -f "${BASEDIR}/dockerfile/${scenario}" ]; then
echo "ERROR: ${scenario} is not a valid image"
exit 1
fi
echo "= Cleanup existing ${scenario} ="
podman image rm "${scenario}" --force
echo
echo "= Building ${scenario} ="
podman build -t "${scenario}" -f "${BASEDIR}/dockerfile/${scenario}" \
"${BASEDIR}"
echo
echo "= Creating ${name} ="
podman create --privileged --name "${name}" --hostname "${hostname}" \
--network bridge:interface_name=eth0 --systemd true \
--cpus "${cpus}" --memory "${memory}" --memory-swap -1 --no-hosts \
--replace "${scenario}"
echo
echo "= Starting ${name} ="
podman start "${name}"
echo
echo "= Installing IPA ="
ansible-playbook -i "${BASEDIR}/inventory" \
"${TOPDIR}/playbooks/install-server.yml"
echo
echo "= Enabling additional services ="
podman exec "${name}" systemctl enable fixnet
podman exec "${name}" systemctl enable fixipaip
echo
echo "= Stopping ${name} ="
podman stop "${name}"
echo
echo "= Committing \"${quayname}:${scenario}\" ="
podman commit "${name}" "${quayname}:${scenario}"
echo
echo "= DONE ="
# For tests:
# podman start "${name}"
# while [ -n "$(podman exec ansible-test systemctl list-jobs | grep -vi "no jobs running")" ]; do echo "waiting.."; sleep 5; done
# # Run tests
# podman stop "${name}"