I am trying to automate the installation of Icinga2 on many remote clients. The PKI token will get generated on the Icinga server and it's different for each client - Then it should be sent to each client. As part of the client installation, icinga2 node wizard would run and I would like to pipe a series of inputs to a prompt as below. Can you please check to see if I use the heredoc correctly?
#!/bin/bash
while read f; do
ssh-copy-id myusername"$f"
ssh myusername@"$f" '
yum install -y epel-release
wget --no-check-certificate https://packages.icinga.org/epel/7/release/noarch/icinga-rpm-release-7-1.el7.centos.noarch.rpm
yum install icinga-rpm-release-7-1.el7.centos.noarch.rpm
yum install -y icinga2 nagios-plugins-all
chown -R icinga:icinga /etc/icinga2 /var/lib/icinga2 /var/log/icinga2' </dev/null
ssh myusername@master.icinga.test.com icinga2 pki ticket --cn "$f" |
ssh myusername@"$f" 'cat >/tmp/pkicode'
PKI= echo $/tmp/pkicode
icinga2 node wizard << EOF
Y
Enter
master.icinga.test.com
Y
10.20.20.1
N
Y
$PKI
Enter
Enter
Y
Y
Enter
Enter
N
N
EOF
scp ./zones.conf myusername@"$f":/etc/icinga2/zones.conf
done < linux-list.txt
Thank you