Package: sctl
space-controlspace-control, orsctl, is a simple CLI tool for working within a distributed environment. The goal is to allow batch operations to be easily executed on any number of hosts, whether that means executing commands, downloading or uploading files, or whatever else is needed.Sample configuration file:directory:/nodes:-host:'some_host'user:'root'connect_kwargs:{password:password}-host:'mypi'user:'pi'sctlby default will look for a configuration file relative to your current location:.sctl/config.yml. If a file cannot be found, it will look in~/.sctl/config.yml. Alternatively you can specify a path to a configuration using the-c / --configurationoption. This will be expanded on in the future to allow for multiple "profiles" in a single config.The keys for each entry ofnodesare the parameters specified byfabric.connection.Connection(of the wonderfulfabric) library. Any configuration you want to do locally with SSH keys, authorized_keys, etc. is up to you. If you are not familiar (as I was merely 10 hours ago)fabricis an awesome wrapper aroundparamikoand some other tools, and it is so easy and clean to use. Check out both of those libraries.This tool is not complete and is far from it.InstallInstall via pip:pipinstallsctlOr for latest and greatest, clone this repository and then run:pythonsetup.pyinstallor install directly from GitHub with pip:python-mpipinstallgit+https://github.com/Lnk2past/space-control.gitSample UsageRunlson each node and print the output (the default action isexecand may be omitted):sctllssctlexeclsDownload the.bashrcfrom each node:sctldownload.bashrcUpload a new.bashrcto each node:sctlupload.bashrcNotesYou may omit specifying adirectoryin your configuration; in these cases the default directory is usually the home directory of the user you are logging in as.Configurable Actionsspace-controlrefers to executing commands and transferring files asactions. While you can certainly specify actions directly on the CLI (as shown above), you can also provide custom sets of actions in your configuration file. The added benefit here is that configurable actions are designed to allow you to chain multiple actions together (something you cannot do directly with the CLI). So for example, you can upload a file, run a command to produce a new file, and download that new file all by configuring a single set of actions.nodes:-host:'somehost'user:'root'actions:pgdump:-action:'exec'command:'dockerexecpostgrespg_dump-fpg_data.txt-tmy_tablemy_db'-action:'exec'command:'dockercppostgres:pg_data.txtpg_data.txt'-action:'download'remote:'pg_data.txt'The custom actionpgdumphere will executepg_dumpwithin thepostgrescontainer, copy the file from thepostgrescontainer, and then download it locally.Filtering NodesSometimes you may want to run an action on specific nodes in your configuration. This can be done using the-n/--nodesinput options. This option takes a regex pattern and will filter nodes on that pattern. For example, given the following config:nodes:-host:'foo'user:'root'-host:'bar'user:'root'-host:'foobar'user:'root'We can run an action against thefooandfoobarnodes only using:sctl-nfoolsHere the patternfoowill be partial matches for bothfooandfoobarand will both be included in the set of nodes to run against.