I want to extend Fabric with some functionality and would like to call Fabric programmatically.
What I figured out is to call the main()
method in https://github.com/fabric/fabric/blob/master/fabric/main.py, but I can't pass any parameters directly to the function, because it reads it's parameters within the function.
Any idea to set the command line parameters programmatically and the calling main()
?
Fabric is a Python library (i.e. a tool to build on) used for interacting with SSH and computer systems [easily] to automate a wide range of tasks, varying from application deployment to general system administration.
The Fabfile This is the file that Fabric uses to execute tasks. Each task is a simple function. The fabfile should be in the same directory where you run the Fabric tool. The fabfile is where all of your functions, roles, configurations, etc. will be defined.
fab uses Python's optparse library, meaning that it honors typical Linux or GNU style short and long options, as well as freely mixing options and arguments. E.g. fab task1 -H hostname task2 -i path/to/keyfile is just as valid as the more straightforward fab -H hostname -i path/to/keyfile task1 task2 .
You can use the execute
method in the Fabric
library to call tasks.
http://docs.fabfile.org/en/1.8/api/core/tasks.html?highlight=execute#fabric.tasks.execute
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With