0

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.

  • 1
    Possibly using expect to script the dialog inside the ssh connection will help. – dirkt Jul 26 '18 at 5:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.