mirror of
https://github.com/freeipa/ansible-freeipa.git
synced 2026-05-14 21:42:17 +00:00
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
This commit is contained in:
10
infra/image/system-service/fixipaip.service
Normal file
10
infra/image/system-service/fixipaip.service
Normal file
@@ -0,0 +1,10 @@
|
||||
[Unit]
|
||||
Description=Fix IPA server IP in IPA Server
|
||||
After=multi-user.target
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=/root/fixipaip.sh
|
||||
|
||||
[Install]
|
||||
WantedBy=default.target
|
||||
26
infra/image/system-service/fixipaip.sh
Executable file
26
infra/image/system-service/fixipaip.sh
Executable file
@@ -0,0 +1,26 @@
|
||||
#!/bin/bash -eu
|
||||
|
||||
HOSTNAME=$(hostname)
|
||||
IP=$(hostname -I | cut -d " " -f 1)
|
||||
|
||||
if [ -z "${HOSTNAME}" ]; then
|
||||
echo "ERROR: Failed to retrieve hostname."
|
||||
exit 1
|
||||
fi
|
||||
if [ -z "${IP}" ]; then
|
||||
echo "ERROR: Failed to retrieve IP address."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! echo "SomeADMINpassword" | kinit -c ansible_freeipa_cache admin
|
||||
then
|
||||
echo "ERROR: Failed to obtain Kerberos ticket"
|
||||
exit 1
|
||||
fi
|
||||
KRB5CCNAME=ansible_freeipa_cache \
|
||||
ipa dnsrecord-mod test.local "${HOSTNAME%%.*}" --a-rec="$IP"
|
||||
KRB5CCNAME=ansible_freeipa_cache \
|
||||
ipa dnsrecord-mod test.local ipa-ca --a-rec="$IP"
|
||||
kdestroy -c ansible_freeipa_cache -A
|
||||
|
||||
exit 0
|
||||
12
infra/image/system-service/fixnet.service
Normal file
12
infra/image/system-service/fixnet.service
Normal file
@@ -0,0 +1,12 @@
|
||||
[Unit]
|
||||
Description=Fix server IP in IPA Server
|
||||
Wants=network.target
|
||||
After=network.target
|
||||
Before=ipa.service
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=/root/fixnet.sh
|
||||
|
||||
[Install]
|
||||
WantedBy=ipa.service
|
||||
24
infra/image/system-service/fixnet.sh
Executable file
24
infra/image/system-service/fixnet.sh
Executable file
@@ -0,0 +1,24 @@
|
||||
#!/bin/bash -eu
|
||||
|
||||
HOSTNAME=$(hostname)
|
||||
IP=$(hostname -I | cut -d " " -f 1)
|
||||
|
||||
if [ -z "${HOSTNAME}" ]; then
|
||||
echo "ERROR: Failed to retrieve hostname."
|
||||
exit 1
|
||||
fi
|
||||
if [ -z "${IP}" ]; then
|
||||
echo "ERROR: Failed to retrieve IP address."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# shellcheck disable=SC2143
|
||||
if [ -n "$(grep -P "[[:space:]]${HOSTNAME}" /etc/hosts)" ]; then
|
||||
sed -ie "s/.*${HOSTNAME}/${IP}\t${HOSTNAME}/" /etc/hosts
|
||||
else
|
||||
echo -e "$IP\t${HOSTNAME}" >> /etc/hosts
|
||||
fi
|
||||
|
||||
echo "nameserver 127.0.0.1" > /etc/resolv.conf
|
||||
|
||||
exit 0
|
||||
Reference in New Issue
Block a user