Blue-green deployment for web applications with Ansible.
See Martin Fowler's BlueGreenDeployment post for insights.
This role will check whether blue or green should be deployed next and
set the appropriate color in deploy_color
.
The role uses the last author commit date in blue and green directories, and sets the deploy color to the directory having the oldest checkout.
This role only solves part of the problem: guessing which one of blue/green needs to be deployed. The rest (deploying, swapping colors at the loadbalancer, ...) is left to you.
While there are no requirements for this role, your web application deployment role should be changed to use deploy in a directory specified by a variable (see Example below).
blue_green_directories
: dict containing blue and green application directories belowblue
andbreen
keys
verbose
: will display variables set in role; primarily for command line usage
blue_green_color
: which color has been selected for deployblue_green_color_directory
: in which directory the application can be deployedblue_green_color_parent_directory
: in which directory the application can be checked out by the git module
None
roles: - { role: ansible-blue-green, blue_green_directories: { blue: "/srv/www_blue/webapp", green: "/srv/www_green/webapp" } } - { role: my-webapp, my_webapp_home: "{{ blue_green_color_parent_directory }}", when: blue_green_color is defined }
The color is determined upon commiter date. This information might be erroneous !
BSD
@leucos