Package: ploy-fabric
OverviewThe ploy_fabric plugin provides integration ofFabricwithploy.Installationploy_fabric is best installed with easy_install, pip or with zc.recipe.egg in a buildout.Once installed, it’s functionality is immediately usable with ploy.CommandsThe plugin adds the following commands to ploy.doRuns a Fabric task with simplified syntax for arguments.
You can just put positional arguments on the command line behind the task name.
For keyword arguments user thename=valuesyntax.
For example:ploy do something arg key=valuefabRuns a Fabric task and passes on command line options to Fabric.
This basically reflects thefabscript of Fabric.OptionsInstances only get the newfabfileoption to specify which file to look in for tasks.
The location is relative toploy.conf.Instance methodsFor the Python side, each instance gains thedo(task, *args, **kwargs)method.
Thetaskargument is the name of a task from the Fabric script which should be run. The remaining arguments are passed on to that task.Another helper added to each instance is a context manager accessible via thefabricattribute on instances.
With that you can switch to a new ssh connection with a different user in your Fabric tasks:fromfabric.apiimportenv,rundefsometask():run("whoami")# prints the default user (root)withenv.instance.fabric(user='foo'):run("whoami")# prints 'foo' if the connection workedrun("whoami")# prints the default user (root)All changes to the Fabric environment are reverted when the context manager exits.Fabric task decoratorWithploy_fabric.contextyou can decorate a task to use a specific user with a separate connection.
All changes to the Fabric environment are reverted when the context manager exits.
This is useful if you want to run a task from inside another task.fromfabric.apiimportenv,runfromploy_fabricimportcontext@context# always run with the default userdefsometask():run("whoami")# prints the default user (root)@context(user=None)# always run with the default user (alternate syntax)defsomeothertask():env.forward_agent=Truerun("whoami")# prints the default user (root)@context(user='foo')# always run as foo userdefanothertask():env.forward_agent=Falserun("whoami")# prints the default user (user)someothertask()assertenv.forward_agent==FalseFabric environmentThe Fabric environment has the following settings by default.reject_unknown_hostsAlways set toTrue, ssh connections are handled by this plugin and ploy.disable_known_hostsAlways set toTrue, handled by ploy.host_stringTheunique idof the current instance, only manipulate if you know what you do!known_hostsPath to theknown_hostsfile managed by ploy.instancesDictionary allowing access to the other instances to get variables or call methods on.instanceThe current instance to access variables from theconfigattribute or other things and methods.config_baseThe directory ofploy.conf.Any option of the instance starting withfabric-is stripped of thefabric-prefix and overwrites settings in the environment with that name.Changelog2.0.0 - 2022-08-17Dropped support for Python < 3.7.
[fschulze]Added support up to Python 3.10.
[fschulze]2.0.0b2 - 2019-06-09Pin to Fabric < 2dev.
[fschulze]Drop Python 3.4 support.
[fschulze]2.0.0b1 - 2018-02-07Support Python 3.x via Fabric3.
[fschulze]Support for ploy 2.0.0.
[fschulze]1.1.1 - 2018-06-07Update requirements to block Fabric >= 2 as it isn’t compatible.
[fschulze]1.1.0 - 2014-10-27Require Fabric >= 1.4.0 and vastly simplify the necessary patching.
[fschulze]Close all newly opened connections after a Fabric call.
[fschulze]Add context manager and decorator to easily switch fabric connections.
[fschulze]1.0.0 - 2014-07-19Added documentation.
[fschulze]1.0b6 - 2014-07-15Allow overwriting of fabric env from config with options prefixed byfabric-, i.e.fabric-shell= /bin/sh-c.
[fschulze]1.0b5 - 2014-07-08Packaging and test fixes.
[fschulze]Fix task listing fordocommand.
[fschulze]1.0b4 - 2014-07-04Use unique id for host string to avoid issues.
[fschulze]Addedfabcommand which is just a wrapper for Fabric with all it’s options
and reworkeddocommand into a simple version to just run a task.
[fschulze]Renamed mr.awsome to ploy and mr.awsome.fabric to ploy_fabric.
[fschulze]1.0b3 - 2014-06-09When depending on Fabric, skip 1.8.3 which added a version pin on paramiko.
[fschulze]Only add Fabric to install_requires if it can’t be imported. That way we
don’t get problems if it’s already installed as a system packages or in a
virtualenv.
[fschulze]1.0b2 - 2014-05-15Registerfabfilemassager for all instances.
[fschulze]Use context manager for output filtering and filter indohelper.
[fschulze]Moved setuptools-git from setup.py to .travis.yml, it’s only needed for
releases and testing.
[fschulze]1.0b1 - 2014-03-24Initial release
[fschulze]