Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for -e IPA_SERVER_IP=no-update. #640

Merged
merged 1 commit into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -292,11 +292,18 @@ and also use the `--add-host` option to the `docker run` / `podman run`
with the same IP address, especially when running the container
as read only.

Alternatively, the `IPA_SERVER_IP` environment variable via the
`-e` option to `docker run` / `podman run` can be used to
define what IP address should the FreeIPA server put to DNS as its
address. Using this mechanism will however not update the `ipa-ca`
record.
By default the container will attempt to update the FreeIPA
server's IPv4 address in the internal DNS server to its internal
address (as seen in the container) upon each startup, using the
systemd service `ipa-server-update-self-ip-address` in the container.
You can disable this mechanism by setting the `IPA_SERVER_IP`
environment variable to `no-update`, via the `-e` option to
`docker run` / `podman run`, or by exec-ing to the container and running
`systemctl disable ipa-server-update-self-ip-address.service`.

Alternatively, the `IPA_SERVER_IP` environment variable can be
used to force the IPv4 address DNS record to a specific value.
Using this mechanism will however not update the `ipa-ca` record.

## Debugging

Expand Down
10 changes: 8 additions & 2 deletions ipa-server-configure-first
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ set -e
test ! -f /run/ipa/debug-trace || set -x

HOSTNAME=$( cat /data/hostname )
IPA_SERVER_IP=
if [ -f /run/ipa/ipa-server-ip ] ; then
IPA_SERVER_IP=$( cat /run/ipa/ipa-server-ip )
fi

function update_server_ip_address () {
CURRENT_IP=$( dig +short -t A $HOSTNAME )
Expand Down Expand Up @@ -87,7 +91,9 @@ if [ "$1" == update-self-ip-address ] ; then
exec >> /var/log/ipa-server-run.log 2>&1
echo "$(date) $0 $@"

if systemctl is-active -q named named-pkcs11 || [ -f /run/ipa/ipa-server-ip ] ; then
if [ "$IPA_SERVER_IP" == no-update ] ; then
echo "FreeIPA server IP address update disabled, skipping update-self-ip-address."
elif systemctl is-active -q named named-pkcs11 || [ -n "$IPA_SERVER_IP" ] ; then
# Wait until DNS is up and running and resolving
if wait_for_dns 60; then
update_server_ip_address
Expand Down Expand Up @@ -224,7 +230,7 @@ else
exit
fi

if systemctl is-active -q named named-pkcs11 || [ -f /run/ipa/ipa-server-ip ] ; then
if [ "$IPA_SERVER_IP" != no-update ] && ( systemctl is-active -q named named-pkcs11 || [ -n "$IPA_SERVER_IP" ] ) ; then
cp -f /etc/resolv.conf /data/etc/resolv.conf.ipa
if wait_for_dns 180; then
update_server_ip_address
Expand Down
2 changes: 1 addition & 1 deletion tests/freeipa-k3s.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ spec:
- name: IPA_SERVER_INSTALL_OPTS
value: "-U -r CLUSTER.LOCAL --setup-dns --no-forwarders --no-ntp --ip-address=10.43.201.201"
- name: IPA_SERVER_IP
value: 10.43.201.201
value: no-update
readinessProbe:
exec:
command: [ "/usr/bin/systemctl", "status", "ipa" ]
Expand Down
2 changes: 1 addition & 1 deletion tests/freeipa-replica-k3s.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ spec:
name: freeipa-server-password
key: admin.password
- name: IPA_SERVER_IP
value: 10.43.202.202
value: no-update
readinessProbe:
exec:
command: [ "/usr/bin/systemctl", "status", "ipa" ]
Expand Down