I had this in another post, but I think it is worth its own.
sudo hostnamectl set-hostname --static undercloud.ayoung-dell-t1700.test
export address=`ip -4 addr show eth0 primary | awk '/inet/ {sub ("/24" ,"" , $2) ; print $2}'`
echo $address `hostname` | sudo tee -a /etc/hosts
sudo yum -y install ipa-server-dns
export P=FreIPA4All
ipa-server-install -U -r `hostname -d|tr "[a-z]" "[A-Z]"` -p $P -a $P --setup-dns `awk '/^name/ {print "--forwarder",$2}' /etc/resolv.conf`
`rolectl deploy –name=$(hostname -d) domaincontroller`
That does everything you just typed (and could set the machine domain name instead of reading it from hostname.
Sorry, I left out the JSON for explicitly setting the password; this one generates random admin and DM passwords that can be retrieved and then cleared. See the man page.