If you need to install a few programs on around 40K linux machines, and would like to know what options you have to do it as efficiently as possible. Here I tried to show you installation of JDK (6/7/8) on multiple linux machines through automation script. You can install any other applications as well through these simple steps.
You can also use existing automation tool that allows you to centralize management of linux machines running on your network and manage every aspect of the configuration that you can, then you can look for puppet, chef, cfengine3 etc.
1. setup password-less ssh I have already discussed password-less ssh connect in one of my blog post which you can follow here. 2. disable host checking You need to disable host checking, otherwise it will ask for your confirmation (by manually type 'yes')
$ vi /etc/ssh/ssh_config find "StrictHostKeyChecking ask" and replace with "StrictHostKeyChecking no"
3. create "hostadd" file $ vi hostadd #here add all your host machines 52.25.19.233 52.25.69.166 52.25.12.243
4. create "comm.sh" file $ vi comm.sh #!/usr/bin/env bash sudo add-apt-repository -y ppa:webupd8team/java sudo apt-get update echo debconf shared/accepted-oracle-license-v1-1 select true | sudo debconf-set-selections echo debconf shared/accepted-oracle-license-v1-1 seen true | sudo debconf-set-selections #change version number 7/8 sudo apt-get -y install oracle-java7-installer 5. create "run.sh" file $ vi run.sh #!/usr/bin/env bash Servers_list=/home/ubuntu/hostadd for Host in $(< $Servers_list ) do echo "Installing package on $Host" echo "Copying file...." scp comm.sh ubuntu@"${Host}":/home/ubuntu ssh ubuntu@"${Host}" ./comm.sh done
6. give execute permission $ chmod 777 comm.sh $ chmod 777 run.sh 7. run "run.sh" $ ./run.sh
Note:
If you want to execute some commands in a single line then you can use &&
operator or ; (semicolons). && operator, if one of the commands fails, then all other commands following it won’t be executed. If you want to execute all commands regardless of whether the previous ones failed or not, separate them with semicolons.