Click here to Skip to main content
15,884,388 members
Articles / Programming Languages / C#
Tip/Trick

Push2Linux - A Mass Unix Deploy Tool

Rate me:
Please Sign up or sign in to vote.
5.00/5 (1 vote)
11 Dec 2012CPOL3 min read 10.8K   175   3   1
An Understanding of what it does and how it can help.....

Introduction   

Push2Linux is a deploy tool or rather a mass deploy tool. Consider attempting to deploy a piece of software across 500 Unix/Linux devices and the possible time involved doing it manually. This is where Push2Linux comes in – it tries to simplify the process by managing the deploy of the code for you. This is also a very handy tool for a developer especially in testing.

Features 

  1. Deploy software across a single or a large subset of hosts
  2. Execute commands remotely across multiple unixes devices from one location
  3. Execute a script remotely across multiple unix devices
  4. Customize installation to fit your needs with a bash shell script
  5. Restart Services of multiple hosts
<o:p>

How it works? 

Let’s try understand how we can leverage Push2Linux by looking at various scenarios:<o:p>

Scenario 1: Execute Command Across A Host<o:p>

Assume we have Web Server  and we need to restart the ‘Apache Web Service’ on it. In Diagram A below, you can just add in the host name, username and password and then the exact command you would like to execute. In this case we will issue a service restart for Apache.

 Image 1 

[Diagram A]  

Scenario 2: Execute Command Across Multiple Hosts 

Firstly you going to need to create a CSV file to be used as the configuration file (input). The format is displayed below, <o:p>

<ip/hostname>, <username>, <password>

 Image 2

 [Diagram B] 

Let’s say I wanted to get the log file for multiple devices and have the log emailed to my address, using this handy one-liner and Push2Linux, this is no problem.

echo "This is the message body" | mutt -a file.to.attach -s "subject of message" recipient@domain.com 

 Image 3

 [Diagram C]  

Just click - Deploy and you done! 

Scenario 3: Install and setup Software on Multiple Hosts 

In the third scenario, let us assume we have some custom software we have written in Java or Ruby and we would like to deploy it across a mass of hosts. We obviously create our CSV file, adding in the devices and their authentication details. <o:p>

Following along with Diagram D, we tick the ‘Use Zipped Archive’ checkbox. That will provide you with the following options:

  1. Archive: a zip compressed file (no spaces in name) containing the files or software you would like to deploy. PS. This needs to include the setup script for your planned installation, in this case it’s called setup.sh.
  2. Copy to Archive: is the remote location to which the files will be copied on the remote host and from where you will commence to execute your setup script.
  3. Checkbox Unzip: This is used if the file you are attaching is Zip compressed
  4. Checkbox Script: This is important to take note off. If this is unticked that means the file attached is just a script (a bash script) which Push2Linux will SCP across, and then execute using the Command Option with full path. 
<o:p>

Image 4

[Diagram D] 

Lastly the Command Option below is the full path the script file you would like to execute. 

Points of Interest  

This is the basics of Push2Linux, a mass deploy tool. I’ve also built in asynchronous call back to kill connections when they are taking too long. I noticed on some larger deployments that SCP/SSH on certain machines hang or never return. Though rare, the Push2Linux should take care of this. 

Attached is full source code with Project File, including Installer.  

Requirements for Remote Hosts:

  1. Dos2Unix  - used to convert scripts to unix format unless control characters from windows will break script execution
  2. Unzip/Zip 

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior) Senwes
South Africa South Africa
Hacking at code.....

Comments and Discussions

 
QuestionSSH keys? Pin
CherryDT3-Nov-15 4:25
CherryDT3-Nov-15 4:25 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.