We have a workflow that deploy Ubuntu 20.04.5 LTS in vSphere VM with automatic AD integration using the following commands:
#!/bin/bash
if [ x$1 == x"precustomization" ]; then
rm -v /home/sysadmin/.bash_history /root/.bash_history
rm -v /etc/ssh/ssh_host_*
dpkg-reconfigure openssh-server
elif [ x$1 == x"postcustomization" ]; then
echo "P@ssw0rd" | realm join --user "svc.vm.enroll" --computer-ou "OU=UNIX,OU=Managed Servers,DC=corp,DC=example,DC=com" --os-name "Ubuntu Server" corp.example.com
cat <<'EOF' > /tmp/sssd.awk
/^\[sssd\]$/ {
print
print "default_domain_suffix = corp.example.com"
next
}
/^\[domain\/corp.example.com\]$/ {
print
print "ldap_user_ssh_public_key = altSecurityIdentities"
next
}
1
EOF
awk -f /tmp/sssd.awk -i inplace /etc/sssd/sssd.conf
service sssd restart
realm permit --groups "adm-unix@corp.example.com"
landscape-config --computer-title "$(hostname)" --account-name standalone --url https://landscape.corp.example.com/message-system --ping-url http://landscape.corp.example.com/ping --script-users=ALL --registration-key="key"
fi
Manually running the commands works well, but when executed in vSphere, it works too but the PRT record in the DNS is set to anhost.
instead of anhost.corp.example.com
In /etc/hosts
I have
127.0.0.1 localhost
127.0.1.1 template-ubuntu-server
# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
10.0.0.123 anhost.corp.example.com anhost
And in /etc/resolv.conf
the search domain is also the correct one
Manually fixing the PRT record in AD does not solve the issue, at each reboot or after a certain time, it got reverted to the wrong value
How can I fix that?