Skip to content

Enhanced, drop-in Fabric Connection-object wrapper with features not yet implemented in the base.

License

Notifications You must be signed in to change notification settings

prokopto-dev/fabric-plus

Repository files navigation

PyPI - Version PyPI - Python Version PyPI - License GitHub Actions Workflow Status

FabricPlus

A drop-in expansion of features in the Fabric library.

As of version 0.1.0, those include:

  • Jumphost connectivity support
    • jump_run command to run commands from the intermediate jumphost
  • SCP Transfer support (including via a jumphost)
  • su command support

See the API documentation on the FabricPlus Website for more information, as well as "Getting Started" guide.

See fabric for more details on the base fabric library, if interested in the underlying behaviors. Some have been changed: see Important Changes and the documentation for more information.

Note On Changelogs

v1.0.1

  • Bugfix: su command had an invalid argument when processing subcommands. Fixed.

Installation

pip (via PyPI)

As of version 0.1.0, FabricPlus is available via pip and is on the Python Package Index.

To install, simply install fabricplus.

pip install fabricplus

Building From Source

You can also build fabricplus from source, especially if you want features or updates released outside of a tagged release on PyPI.

To do so, you'll need poetry, and an environment with a version of Python greater than or equal to 3.8.

Step 1: Install Poetry

To install poetry, simply run:

pip install poetry

For more information on poetry, see the Poetry Website.

Step 2: Clone Repo and Run poetry build

Once you have that installed, clone the repo, then run poetry build from the root directory:

# Clone
git clone https://github.com/prokopto-dev/fabric-plus
# Move into fabric-plus
cd fabric-plus
# Run poetry build
poetry build
# install with pip the newly build wheel file (file name may vary)
pip install dist/fabricplus-0.1.0-py3-none-any.whl

Quick-Start

The following is all the basic new features in one small block.

# importing as Connection
from fabricplus.connection import ConnectionPlus as Connection

# Creating a basic connection
conn_1: Connection = Connection("host1.example.com")

# Creating a jumphost connection, and then a host connection via that jumphost
jumphost_1: Connection = Connection("jumphost.example.com")
conn_via_jh: Connection = Connection("host2.example.com", jump_target=jumphost_1)

# Creating a host that uses SCP for transfers by default
conn_2: Connection("host3.example.com", scp=True)

# Running a get via SCP on the host1/conn_1, which doesn't use SCP by default
conn_1.get("/path/to/some/remote/file", scp=True)

# Running a command as some other user via su
conn_1.su("date", user="someotheruser", password="someuserspasswd")

License Addendum

  • scp.py is used by import under the LGPL v2.1 license, and this notice is in accordance with that license.
  • paramiko-jump used under Apache License 2.0, see fabricplus/paramiko_modifications/client.py for license details.
  • fabric is used, and falls under a BSD-2-Clause license, which doesn't restrict its use as an imported library, but is noted here anyways.