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
while read f; do
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"
done < linux-list.txt
1) I would like the script to log into each node and run a bunch of commands to install Icinga - I kind of tried ading them all in one line.
2) I would like the script to log into the Icinga master and run a command:
ssh username@icingamaster
icinga2 pki ticket --cn '$f'
3) Then sends this generated code to the hostname ($f)
4) I would like the existing /etc/icinga2/zones.conf
file to get replaced with my own zones.conf
Can you please help me, I am not sure how to automate the log into each server and run commands should be automated.
Thanks
See Question&Answers more detail:os