If domain is set, you should redirect the IP of the current server to that domain via NGINX. Maybe you can get IP addresses via this? https://stackoverflow.com/questions/39819378/ansible-get-current-target-hosts-ip-address