I have a script that reads a text file that has all the nodes listed in there:
node1
node2
node3
.
.
.
This is part my script:
#!/bin/bash
ssh-copy-id myusername@icingamaster
while read f; do
ssh-copy-id myusername@"$f"
ssh -o StrictHostKeyChecking=no myusername@icingamaster "ticket-\"f\"=echo $(icinga2 pki ticket --cn \"$f\")"
echo "ticket-\"f\" | ssh myusername@$f "cat > output.txt"
ssh-copy-id 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 https://packages.icinga.org/epel/7/release/noarch/icinga-rpm-release-7-1.el7.centos.noarch.rpm; yum install -y icinga2; yum install -y nagios-plugins-all; chown -R icinga:icinga /etc/icinga2 ; chown -R icinga:icinga /var/lib/icinga2 ; chown -R icinga:icinga /var/log/icinga2 ;icinga2 node wizard"
done < linux-list.txt
icinga2 node wizard
will ask a bunch of question which the answers will be a bunch of Yes and No and at one point it will ask for that ticket I got above for that host which I am not sure how to pass that ticket to the prompt.
Can you please help me, I am not sure how to automate the log into each server and run commands should be automated.
Thanks