开发者

Sharing a fabfile across multiple projects

开发者 https://www.devze.com 2022-12-25 01:17 出处:网络
Fabric has become my deployment tool of choice both for deploying Django projects and for initially configuring Ubuntu slices. However, my current workflow with Fabric isn\'t very DRY,开发者_StackOver

Fabric has become my deployment tool of choice both for deploying Django projects and for initially configuring Ubuntu slices. However, my current workflow with Fabric isn't very DRY,开发者_StackOverflow社区 as I find myself:

  1. copying the fabfile.py from one Django project to another and
  2. modifying the fabfile.py as needed for each project (e.g., changing the webserver_restart task from Apache to Nginx, configuring the host and SSH port, etc.).

One advantage of this workflow is that the fabfile.py becomes part of my Git repository, so between the fabfile.py and the pip requirements.txt, I have a recreateable virtualenv and deployment process. I want to keep this advantage, while becoming more DRY. It seems that I could improve my workflow by:

  1. being able to pip install the common tasks defined in the fabfile.py and
  2. having a fab_config file containing the host configuration information for each project and overriding any tasks as needed

Any recommendations on how to increase the DRYness of my Fabric workflow?


I've done some work in this direction with class-based "server definitions" that include connection info and can override methods to do specific tasks in a different way. Then my stock fabfile.py (which never changes) just calls the right method on the server definition object.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号