Bladerunner version 3.4. Released July 4, 2013. Written in Python 2.7.
Provides a method of pushing changes or running audits on groups of similar hosts over SSH using pexpect (http://pexpect.sourceforge.net). Can be extended to utilize an intermediary host in the event of networking restrictions.
Copyright (c) 2013, Activision Publishing, Inc. All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Main logic for the serial execution of commands on hosts.
Initialized by a dictionary with the following optional keys:
username: string username, or getpass will guess.
password: string plain text password, if required.
ssh_key: string non-default ssh key file location.
delay: integer in seconds to pause between servers.
extra_prompts: list of strings of additional expect prompts.
width: integer terminal width for output, or it uses all.
jump_host: string hostname of intermediary host.
jump_user: alternate username for jump_host.
jump_password: alternate password for jump_host.
second_password: an additional different password for commands.
password_safety: check if the first login succeeds first (False).
cmd_timeout: integer in seconds to wait for commands (20).
timeout: integer in seconds to wait to connect (20).
threads: integer number of parallel threads to run (100)
style: integer for outputting. Between 0-3 are pretty, or CSV.
csv_char: string character to use for CSV results.
progressbar: boolean to declare if we want a progress display.
Closes a connection object.
Args:
sshc: the pexpect object to close
terminate: a boolean value to terminate all connections or not
Connects to a server, maybe from another server.
Args:
target: the hostname, as a string
username: the user we are connecting as
password: plain text password to pass
Internal method for logging in, used by connect.
Args:
sshc: the pexpect object
password: plain text password to send
login_response: the pexpect return status integer
Executes commands on servers.
Args:
commands: a list of strings of commands to run
servers: a list of strings of hostnames
Makes a list of servers and replies, consolidates dupes.
Prints the results consolidated and in a CSV-ish fashion.
Args:
results: the results dictionary from Bladerunner.run
options: dictionary with optional keys:
csv_char: a character or string to separate with
Formatting function to strip colours, remove tabs, etc.
Args:
output: the pexpect object's before method after issuing the command
command: the command last issued
A buffer for selecting the correct output function and exiting.
Args:
results: the results dictionary from Bladerunner.run
options: the options dictionary, uses 'style' key only
Searches through a list and tosses empty elements.
Internal function for printing the header of pretty_results.
Args:
options: a dictionary with the following keys:
width: terminal width, already determined in pretty_results
chars: the character dictionary map, defined in pretty_results
left_len: the left side length, defined in pretty_results
jump_host: a string hostname of the jumpbox (if any)
Prints the results in a relatively pretty way.
Args:
results: the results dictionary from Bladerunner.run
options: a dictionary with optional keys.
style: integer style, from 0-3
jump_host: the string jumpbox hostname
width: integer fixed width for output