quickrun
quickrun is a module designed to make it easy to run commands and gather info from multiple servers.
Dependencies
- python3.8
- aws cli (v1)
Getting started
Setup
Install:
pip3 install quickrun
Use:
import quickrun
from quickrun.cli.aws import find_instances
# Define instance
qr = quickrun.QuickRun()
# Configure
qr.servers = [ quickrun.Server(host="my-ip-address-or-hostname", name="my-web-server", user="username") ]
# or from aws cli
qr.servers = quickrun.Servers.from_list(find_instances({ 'tag:environment': 'production', 'tag:name': '*web*' }, region='eu-west-1'))
qr.commands = [ quickrun.Command(name="Get openssl version", cmd="openssl version") ]
qr.formatter = quickrun.formatters.table
# Call
qr.main()
qr.display()
This will display something like:
Results
┏━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ server ┃ host ┃ command ┃ output ┃
┡━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│ my-instance-name-1 │ 192.168.0.1 │ openssl version │ OpenSSL 1.1.1 11 Sep 2018 │
│ my-instance-name-2 │ 192.168.0.1 │ openssl version │ OpenSSL 1.1.1 11 Sep 2018 │
│ my-instance-name-3 │ 192.168.0.1 │ openssl version │ OpenSSL 1.1.1 11 Sep 2018 │
│ my-instance-name-4 │ 192.168.0.1 │ openssl version │ OpenSSL 1.1.1 11 Sep 2018 │
└────────────────────┴─────────────┴─────────────────┴────────────────────────────┘
Making a script
Option 1: Basic script using some of the functions
You can just write a normal python script and use some of the functions from this module.
See examples/healthcheck.py as an example.
Option 2: Calling out to QuickRun
There is also the base QuickRun class which can be configured and called.
See examples/openssl-version.py and examples/list-logs.py as examples.
Option 3: Extending QuickRun
You could also create your own class extending from QuickRun.
This is handy since you can override the hook methods.
See examples/get-memory-settings.py as an example.
Helpers
There are a few core helpers built in to quickrun.
Formatters
There are a few formatters defined in quickrun.formatters
default: Just prints out the python objectnone: Does nothingfake_shell: Formats the run as if it was ran directlytable: Outputs the run as a table
cli.aws
There is also a helpful quickrun.cli.aws.find_instances() function that takes a dict of filters and returns matching instances.
Example:
find_instances({ 'tag:name': 'web', 'tag:environment': 'prod' }, region='eu-west-1')
cli.helpers
There is a collection of misc CLI helpers in quickrun.cli.helpers.
Currently there is only challenge(expect: str) -> bool which prompts the user to re-enter a value.
Hooks
TODO
Metadata
Release files for quickrun 0.0.8
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| quickrun-0.0.8.tar.gz | 7.4 kB | Without provenance | Details for quickrun-0.0.8.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| quickrun-0.0.8-py3-none-any.whl | Python 3 | none | any | Details for quickrun-0.0.8-py3-none-any.whl |
Total release size: 27.2 kB
Release files / quickrun-0.0.8.tar.gz
| Download URL | quickrun-0.0.8.tar.gz |
|---|---|
| Size | 7.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2922ae7336e1134e2c5112eb3951c2671d64b165ecab3467c2db3711043ecec1
|
|
BLAKE2b-256 checksum How to use checksums |
ad655c179f945cc956556076608b9f5743c0b46c5ba5b783652c57baeef2f5cc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.3.0 pkginfo/1.7.0 requests/2.25.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.5
|
Release files / quickrun-0.0.8-py3-none-any.whl
| Download URL | quickrun-0.0.8-py3-none-any.whl |
|---|---|
| Size | 19.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
10d2b4e835f6df2ae32ca2c907d5c62a7e632ec47ced4c468fa8df40fd241125
|
|
BLAKE2b-256 checksum How to use checksums |
42e04680637fa94ac3c634ca9b2a6164b6acefbf731b213f1c9a0382f79547e2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.3.0 pkginfo/1.7.0 requests/2.25.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.5
|
Security for quickrun 0.0.8
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.