Skip to content

Instantly share code, notes, and snippets.

@jfryman
Created January 20, 2015 16:10
Show Gist options
  • Save jfryman/ee09e440e0e55593c290 to your computer and use it in GitHub Desktop.
Save jfryman/ee09e440e0e55593c290 to your computer and use it in GitHub Desktop.
---
chain:
-
name: get_canary_version
ref: consul.get
params:
key: "{{project}}::canary_version"
on-success: query_if_production_deploy
-
name: query_if_production_deploy
ref: core.local
params:
cmd: '"{{production}}" = "true"'
on-success: deploy_production
on-failure: deploy_canary
## Begin Production Workflow ##
-
name: deploy_production
ref: slack.post_message
params:
message: "Beginning deployment of {{project}} to production..."
channel: '#console'
on-success: get_production_version
-
name: get_production_version
ref: consul.get
params:
key: "{{project}}::version"
on-success: get_production_hosts
-
name: get_production_hosts
ref: consul.query_service
params:
service: "{{project}}"
tag: "{{app_role}}"
on-success: update_production_version
-
name: update_production_version
ref: consul.put
params:
key: "{{project}}::version"
value: "{{get_canary_version.result.Value}}"
on-success: update_application_on_production_hosts
-
name: update_application_on_production_hosts
ref: debian.apt_get_update_install
params:
package: "{{project}}"
version: "{{version}}"
hosts: "{{get_production_hosts.result}}"
on-success: notify_successful_production_deployment
on-failure: notify_unsuccessful_production_deployment
-
name: notify_unsuccessful_production_deployment
ref: slack.post_message
params:
message: "Something went wrong with the deployment of {{project}} to production nodes..."
channel: '#console'
-
name: notify_successful_production_deployment
ref: slack.post_message
params:
message: "SUCCESS!! {{project}} has been deployed to production! (`{{get_canary_version.result.Value}}`)"
channel: '#console'
## End Production Workflow ##
## Begin Canary Workflow ##
-
name: deploy_canary
ref: slack.post_message
params:
message: "Beginning deployment of {{project}} to canary hosts..."
channel: '#console'
on-success: get_canary_hosts
-
name: get_canary_hosts
ref: consul.query_service
params:
service: "{{project}}"
tag: "canary_{{app_role}}"
on-success: update_canary_version
-
name: update_canary_version
ref: consul.put
params:
key: "{{project}}::canary_version"
value: "{{version}}"
on-success: update_application_on_canary_hosts
-
name: update_application_on_canary_hosts
ref: debian.apt_get_update_install
params:
package: "{{project}}"
version: "{{version}}"
hosts: "{{get_canary_hosts.result}}"
on-success: notify_successful_canary_deployment
on-failure: notify_unsuccessful_canary_deployment
-
name: notify_unsuccessful_canary_deployment
ref: slack.post_message
params:
message: "Something went wrong with the deployment of {{project}} to canary nodes..."
channel: '#console'
-
name: notify_successful_canary_deployment
ref: slack.post_message
params:
message: "SUCCESS!! {{project}}-{{version}} has been deployed to canary nodes!"
channel: '#console'
default: get_canary_version
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment