I have a script that reads a text file that has all the nodes listed in there:
node1
node2
node3
.
.
.
This is my script:
#!/bin/bash
while read f; do
ssh-copy-id myusername@"$f"
ssh username@master.icinga.test.com
icinga2 pki ticket --cn '$f'
done < linux-list.txt
while read f; do
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'
scp ./zones.conf myusername@"$f":/etc/icinga2/zones.conf
done < linux-list.txt
1) The script should log into the Icinga master and run a command icinga2 pki ticket --cn '$f' for each node found on that linux-list.txt file and generate a ticket for each host
2) Then sends this generated code to each node ($f)
After going through all the commands above, then the script needs to run a command icinga2 node wizard which will start a question/answer prompt and needs someone to type the answer as shown below.
Icinga master's FQDN is master.icinga.test.com and it's IP is 10.20.20.1. The PKI ticket is what we generated earlier on the Icinga master and it's different for each host.
Is there any way to automate this?
Y
Enter
master.icinga.test.com
Y
10.20.20.1
N
Y
[PKI Ticket created earlier on the Icinga master]
Enter
Enter
Y
Y
Enter
Enter
N
N
Thanks