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.

Can you please help me, I am not sure how to automate the log into each server and run commands should be automated.

Thanks

Irina I
  • 31
  • 1
  • 5
  • Your script has many unrelated errors, many of which were already resolved in your previous question. A variable name cannot contain a dash; perhaps use an array, or simply use the same variable name for each iteration, or perhaps don't put the ticket in a variable at all. – tripleee Jul 26 '18 at 13:24
  • As already suggested, `ssh -o StrictHostKeyChecking=no myusername@icingamaster icinga2 pki ticket --cn "$f" | ssh myusername@"$f" "cat > output.txt"` – tripleee Jul 26 '18 at 13:35
  • Thanks, for some reason the other question got stuck while I was trying to post it, so I added this one. I'll go back to the previous ticket. – Irina I Jul 26 '18 at 15:57

0 Answers0