Fabalicious - How to setup Fabalicious for your project
Setting up fabalicious for Drupal projects
Before we start discussing about the actual setup, hope you are acquainted with the following.
- Drupal - A free and open source content managment system written in PHP
- Git - A free and open source distributed version control system
- Fabric - A Python (2.5-2.7) library and command-line tool for streamlining the use of SSH for application deployment or systems administration tasks
- Fabalicious - A specially crafted deployment script based on fabric to help deploy drupal installations across different servers
Adding fabalicious to your project
STEP 1: Install fabric
Skip this step if fabric is already installed in your system.
You can install fabric using pip by running following command.
pip install fabric
For more detailed explanation on how to install fabric, visit this link.
STEP 2: Add fabalicious to your project
If your project is composer based you can install fabalicious via
composer require factorial-io/fabalicious
Optionally add fabalicious as submodule if you are already using git to manage your project. To add fabalicious as submodule, do the following,
- Create a folder named _tools in your project root.
- Add fabalicious as a git submodule under this folder.
- Create a symbolic link to _tools/fabalicious/fabfile.py in the project root.
1 2 3 4 5
mkdir _tools git submodule add https://github.com/factorial-io/fabalicious.git _tools/fabalicious ln -s _tools/fabalicious/fabfile.py fabfile.py git add fabfile.py git commit -m "Add fabalicious as submodule"
STEP 3: Create project specific fabfile.yaml
Create fabfile.yaml under project folder and populate it with server details.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
name: My awesome project requires: 2.0 needs: - ssh - git # if you are using drupal 8 use drush8 instead - drush7 # Our list of host-configurations hosts: dev: type: dev host: example.com user: root port: 22 rootFolder: /var/www filesFolder: /sites/default/files siteFolder: /sites/default backupFolder: /var/backups
Fabalicious command structure is of format
fab config:<host> <task>.
If drush is installed on your dev server then you can try clearing cache by running
fab config:dev drush:'u'
1 2 3 4 5 6 7 8
$ fab config:dev drush:'cc all' Fabalicious deployment scripts [104.131.xxx.xxx] Executing task 'drush' [notice] 'all' cache was cleared. Done. Disconnecting from 104.131.xxx.xxx... done.
TIP: If you include your public key to authorized keys on the remote server then it wont prompt for your password
To see a full list of supported task, please checkout the tasks documentation in fabalicious project.
Using Gitflow with fabalicious
Gitflow is a successful Git branching model by Vincent Driessen.
- A simple and elegant git branching workflow easy to understand and follow.
- Has a git extention which provides high level repository actions to make it developer life easier.
- Has become popular and comes integrated with some git client ui.
fabfile.yaml, you can specifiy the branch that needs to be checked out and pulled while deploying. Thus you continue with your gitflow workflow where development will checkout develop branch, production will checkout master branch and so on.
1 2 3 4 5
hosts: dev: branch: develop type: dev host: example.com
See our other fabalicious-based posts: