Merge "Fix IPA client when doing brownfield deployment of internal TLS"

This commit is contained in:
Zuul 2019-05-23 17:23:39 +00:00 committed by Gerrit Code Review
commit c36eaa42d0

View File

@ -111,34 +111,32 @@ outputs:
fi fi
} }
if ! get_metadata_config_drive; then function get_fqdn {
if ! get_metadata_network; then # Get the instance hostname out of the metadata
echo "FATAL: No metadata available" fqdn=`echo $data | {{ python_interpreter }} -c 'import json,sys;obj=json.load(sys.stdin);print(obj.get("join", {}).get("hostname", ""))'`
if [ -z "$fqdn"]; then
echo "Unable to determine hostname"
return 1
fi
return 0
}
if ! get_metadata_config_drive || ! get_fqdn; then
if ! get_metadata_network || ! get_fqdn; then
echo "FATAL: No metadata available or could not read the hostname from the metadata"
exit 1 exit 1
fi fi
fi fi
# Get the instance hostname out of the metadata
fqdn=`echo $data | {{ python_interpreter }} -c 'import json,sys;obj=json.load(sys.stdin);print(obj.get("join", {}).get("hostname", ""))'`
if [ -z "$fqdn" ]; then
echo "Unable to determine hostname"
exit 1
fi
realm=`echo $data | {{ python_interpreter }} -c 'import json,sys;obj=json.load(sys.stdin);print(obj.get("join", {}).get("krb_realm", ""))'` realm=`echo $data | {{ python_interpreter }} -c 'import json,sys;obj=json.load(sys.stdin);print(obj.get("join", {}).get("krb_realm", ""))'`
otp=`echo $data | {{ python_interpreter }} -c 'import json,sys;obj=json.load(sys.stdin);print(obj.get("join", {}).get("ipaotp", ""))'` otp=`echo $data | {{ python_interpreter }} -c 'import json,sys;obj=json.load(sys.stdin);print(obj.get("join", {}).get("ipaotp", ""))'`
hostname=`/bin/hostname -f`
# Force hostname to use the FQDN # Force hostname to use the FQDN
hostnamectl set-hostname $fqdn hostnamectl set-hostname $fqdn
# run ipa-client-install # run ipa-client-install
OPTS="-U -w $otp" OPTS="-U -w $otp --hostname $fqdn"
if [ $hostname != $fqdn ]; then
OPTS="$OPTS --hostname $fqdn"
fi
if [ -n "$realm" ]; then if [ -n "$realm" ]; then
OPTS="$OPTS --realm=$realm" OPTS="$OPTS --realm=$realm"
fi fi