🔧 Pitcrew
AsyncIO-powered python DSL for running commands locally, on docker, or over ssh.
What does Pitcrew do?
| Pitcrew can run commands |
$ crew sh date
|
| ...or over ssh |
$ crew sh -p providers.ssh -P '{"hosts": ["192.168.0.1"]}' date
|
| on hundreds of hosts! |
$ crew sh -p providers.ssh -P '{"hosts": ["192.168.0.1-100"]}' date
|
| Crew can also run tasks |
$ crew run install.homebrew
|
| Tasks are either other shell commands, or other tasks, for example, this provisions Cloudfront, SSL and S3 and builds and deploys docs to pitcrew.io |
$ crew run examples.deploy_pitcrew
|
| You can list available tasks |
$ crew list
|
| ...edit an existing task |
$ crew edit examples.deploy_pitcrew
# opens in $EDITOR
|
| or create a new task! |
$ crew new some.new.task
|
Installation
From binary
To install pitcrew in your home directory, run the following:
curl -fsSL "https://github.com/joshbuddy/pitcrew/releases/latest/download/crew-$(uname)" > crew
chmod u+x crew
./crew run crew.install --dest="$HOME/crew"
From PyPi
To install from the Python Package Index, run the following:
pip install pitcrew
crew run crew.install --dest="$HOME/crew"
From source
git clone https://github.com/joshbuddy/pitcrew
cd pitcrew
python3.6 -m venv env
source env/bin/activate
pip install -e .
Concepts
A command or set of commands is called a task. A context runs tasks either locally, on docker or over ssh. A provider generates contexts.
Tasks
Tasks are either composed from other tasks or invoking a command on a shell.
An example of a task might be reading a file. fs.read(path) reads a file as bytes and returns it:
pitcrew/tasks/fs/read.py
import base64
from pitcrew import task
@task.arg("path", desc="The file to read", type=str)
@task.returns("The bytes of the file")
class FsRead(task.BaseTask):
"""Read value of path into bytes"""
async def run(self) -> bytes:
code, out, err = await self.sh_with_code(f"cat {self.params.esc_path}")
assert code == 0, "exitcode was not zero"
return out
Other tasks might include writing a file, installing xcode or cloning a git repository. All the currently available tasks are listed at docs/tasks.md. The api available in a task is available at docs/api.md#crewtask.
Contexts
An example of a context might be over ssh, or even locally. Learn more about contexts at docs/api.md#crewcontext.
Providers
A provider is a task with a specific return type. The return type is an async iterator which returns contexts.
Usage
For detailed usage, see docs/cli.md for more details.
Run a command
Pitcrew allows running a command using bin/crew sh -- [shell command].
For example crew sh ls / will list the "/" directory locally.
You can run this across three hosts via ssh using crew sh -p providers.ssh -P '{"hosts": ["192.168.0.1", "192.168.0.2", "192.168.0.3"]}' ls /.
Run a task
Pitcrew allows running a task using crew run [task name] <task args>. This will normally target your local machine unless you use the -p flag to select a different provider.
See available tasks
To see all the available tasks run crew list. This will show all available tasks which are stored in crew/tasks.
Make a new task
To see all the available tasks run crew new [task_name]. This will create a template of a new task.
Run tests
To run an ad-hoc command use . For tasks use crew run [task-name] <args>.
Get CLI help
To see the whole list of commands available from the command-line, run crew help.
Metadata
Release files for pitcrew 0.0.3
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 |
|---|---|---|---|---|
| pitcrew-0.0.3.tar.gz | 18.3 kB | Without provenance | Details for pitcrew-0.0.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pitcrew-0.0.3-py2.py3-none-any.whl | Python 3, Python 2 | none | any | Details for pitcrew-0.0.3-py2.py3-none-any.whl |
Total release size: 45.2 kB
Release files / pitcrew-0.0.3.tar.gz
| Download URL | pitcrew-0.0.3.tar.gz |
|---|---|
| Size | 18.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5dbeb2a6c609bd3ebc80e2c1cc781327d90040e77a9f13004438df2d81afa082
|
|
BLAKE2b-256 checksum How to use checksums |
5e5e02b53ad83abc9160a8e1d3e41b92a107059726267322afdb617a70c9144f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.3
|
Release files / pitcrew-0.0.3-py2.py3-none-any.whl
| Download URL | pitcrew-0.0.3-py2.py3-none-any.whl |
|---|---|
| Size | 26.9 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
258a379fb87d1bbecedb4ed6a26a65bd07ec33ff45fcf315358cd69f78420091
|
|
BLAKE2b-256 checksum How to use checksums |
04304875e0853ad392654390863b75d5e3c9e3801f7580371bcd966d89c55faa
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.3
|
Security for pitcrew 0.0.3
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.