Skip to main content

space-control

space-control, or sctl, 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'

sctl by 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 / --configuration option. This will be expanded on in the future to allow for multiple "profiles" in a single config.

The keys for each entry of nodes are the parameters specified by fabric.connection.Connection (of the wonderful fabric) 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) fabric is an awesome wrapper around paramiko and 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.

Install

Install via pip:

pip install sctl

Or for latest and greatest, clone this repository and then run:

python setup.py install

or install directly from GitHub with pip:

python -m pip install git+https://github.com/Lnk2past/space-control.git

Sample Usage

Run ls on each node and print the output (the default action is exec and may be omitted):

sctl ls
sctl exec ls

Download the .bashrc from each node:

sctl download .bashrc

Upload a new .bashrc to each node:

sctl upload .bashrc

Notes

You may omit specifying a directory in your configuration; in these cases the default directory is usually the home directory of the user you are logging in as.

Configurable Actions

space-control refers to executing commands and transferring files as actions. 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: 'docker exec postgres pg_dump -f pg_data.txt -t my_table my_db'
    - action: 'exec'
      command: 'docker cp postgres:pg_data.txt pg_data.txt'
    - action: 'download'
      remote: 'pg_data.txt'

The custom action pgdump here will execute pg_dump within the postgres container, copy the file from the postgres container, and then download it locally.

Filtering Nodes

Sometimes you may want to run an action on specific nodes in your configuration. This can be done using the -n / --nodes input 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 the foo and foobar nodes only using:

sctl -n foo ls

Here the pattern foo will be partial matches for both foo and foobar and will both be included in the set of nodes to run against.

Metadata

Release files for sctl 2020.0.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sctl 2020.0.4
File Size Uploaded Provenance
sctl-2020.0.4.tar.gz 5.8 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for sctl 2020.0.4
File Interpreter ABI Platform
sctl-2020.0.4-py3-none-any.whl Python 3 none any Details

Total release size: 13.6 kB

Release files / sctl-2020.0.4.tar.gz

Download URL sctl-2020.0.4.tar.gz
Size 5.8 kB
Tags Source
SHA-256 checksum
How to use checksums
49376a696e696e8d9a373af846a63bcaa02983d42db4150aeeff262d2c0967ae
BLAKE2b-256 checksum
How to use checksums
edeab7a6e6d8662d6fe924588d84f9a6dec14eff2e5519ad3475bb80c8ab3058
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.8.4

Release files / sctl-2020.0.4-py3-none-any.whl

Download URL sctl-2020.0.4-py3-none-any.whl
Size 7.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b80ec44795eeb15a741ef5b85f0aa9fdb738e5a2a5fc2dfb07da125a6a9425e8
BLAKE2b-256 checksum
How to use checksums
144a7592d4bb80905ce7f162e7a0d2c4ae60fa98a00fcf11f752b4d3a57a21f1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.8.4

Security for sctl 2020.0.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page