🦊 is a mini automation framework; it runs commands on remote servers, kinda like Fabric.
- Python 100%
|
|
||
|---|---|---|
| .github/workflows | drop python 3.6 and update deps | |
| docs | return the correct value from run_concurrent | |
| fox | trim comment | |
| tests | switch to pytest-asyncio in tests | |
| .gitignore | gitignore and remove travis badge | |
| LICENSE | Create LICENSE | |
| mypy.ini | add more type annotations | |
| poetry.lock | update asyncssh, pytest and add pytest-asyncio | |
| pyproject.toml | update asyncssh, pytest and add pytest-asyncio | |
| README.md | add tests badge | |
| setup.py | drop python 3.6 and update deps | |
| tox.ini | drop python 3.6 and update deps | |
🦊 (Fox)
🦊 (Fox) is an experimental alternative implementation of some of the Fabric 1.14 APIs.
Check out the documentation on readthedocs.
NOTE: this project is under development.
Why?
I want to keep using the old Fabric 1.14 APIs with Python3:
- Fabric 2 changed the APIs
- Fabric3 (a fork of Fabric 1.14 for Python3) has some issues with Python3
- Maybe it's better to start from scratch with smaller project scope and focusing on Python3 only
Example usage
Adapting code that uses Fabric 1.x should be easy enough, but some features will be missing and some will behave differently.
from fox.conf import env
from fox.api import run, sudo
env.host_string = "server.example.com"
env.sudo_password = "very secret"
run("./configure --with-prefix=/90s", cd="/code/project")
sudo("make install", cd="/code/project")
# escaping should be handled correctly, for example:
run(
"""tail -n 1 < /etc/passwd | awk 'BEGIN { FS=":" } { print 1ドル " and " 3ドル }'"""
)
You can also use an explicit API:
from fox.connection import Connection
from fox.conf import env
env.sudo_password = "much more secret"
conn = Connection("app1.example.com")
conn.put("nginx.conf", "/tmp/nginx.conf")
# NOTE there is no "put() with sudo"
conn.sudo("mv /tmp/nginx.conf /etc/nginx/")
conn.sudo("systemctl restart nginx")
conn.disconnect()
You can also use Cluster mode when you want to run the same command on several hosts in parallel:
from fox.cluster import Cluster
cluster = Cluster("app1.example.com", "app2.example.com", "app3.example.com")
cluster.run("sleep $((1 + RANDOM % 5)) && hostname", limit=2)