Skip to content

Latest commit

 

History

History
53 lines (26 loc) · 2.59 KB

File metadata and controls

53 lines (26 loc) · 2.59 KB

Cluster Package Management Script

Script Breakdown

  1. Display Usage Information

image

  This function provides the user with information on how to use the script correctly. It is called when the script is run without arguments or  with invalid options.

  1. Parse Command-Line Options

image

 This snippet processes the command-line options passed to the script, determining whether the user wishes to install or uninstall a package. It  calls the usage function if an invalid option is provided.

  1. Check for Package Name Argument

image

  After option parsing, the script checks if the package name has been specified. If not, it displays the usage information.

  1. Perform Action on the Host

image

perform_action_local function defines and calls a function to install or uninstall the package on the host system, based on the previously set ACTION variable.

  1. Scan for Active Hosts

image

The above code utilizes nmap to scan for active hosts within the subnet 192.168.0.1/24. The output is processed to extract IP addresses and hostnames.

  1. Identify Client Hosts and Users

image

This part parses the output from the previous step, filtering out the head node and preparing a list of client hosts and corresponding user names for SSH access.

  1. Perform Action on Client Nodes

image

perform_action_client function performs the specified action (install/uninstall) on each client node via SSH, then iterates over the list of client hosts and users to apply these actions concurrently.

  1. Finalize Operations

image

Finally, waits for all background operations (SSH commands) to complete, then prints a message indicating that the script has finished executing (Full Script can be found here)