From 451fb8b1bf2f7feedac7379e0ccedabfdad64ab4 Mon Sep 17 00:00:00 2001 From: jszwedko Date: Fri, 3 Oct 2014 16:17:47 -0400 Subject: [PATCH] Optionally notify NewRelic during deployments Requires new_relic_api_token. Default to off. --- README.md | 20 ++++++++++++++++++++ defaults/main.yml | 9 +++++++++ tasks/main.yml | 10 ++++++++++ 3 files changed, 39 insertions(+) diff --git a/README.md b/README.md index 22bb66c..efaa115 100644 --- a/README.md +++ b/README.md @@ -77,8 +77,28 @@ modcloth_app_cron_logrotate_template: cron-logrotate.j2 # additional conditions on the upstart service modcloth_app_upstart_start_condition: "" +# Name of the application in NewRelic (for deployment notifications) +modcloth_app_new_relic_app_name: "[{{env}}] {{modcloth_app_name}}" + # Template used for the file written to /etc/init/{{ modcloth_app_name }}.conf modcloth_app_upstart_conf_template: upstart.conf.j2 + +# Whether to notify NewRelic of app deployments +modcloth_app_notify_new_relic: false + +# External dependency variables + +# Github API token +github_token: "{{ github_api_token | default('') }}" + +# HipChat API token +hipchat_token: "{{ hipchat_api_token | default('') }}" + +# HipChat room id +hipchat_room: "{{ hipchat_team_room | default('') }}" + +# NewRelic API token (for deployment notifications) +new_relic_api_token: "{{ new_relic_api_token | default('') }}" ``` ## License diff --git a/defaults/main.yml b/defaults/main.yml index 9064d46..27b4ae2 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -71,6 +71,12 @@ modcloth_app_upstart_conf_template: upstart.conf.j2 # Name of the organism running the playbook modcloth_app_deployer: "" +# Name of the application in NewRelic (for deployment notifications) +modcloth_app_new_relic_app_name: "[{{env}}] {{modcloth_app_name}}" + +# Whether to notify NewRelic of app deployments +modcloth_app_notify_new_relic: false + # External dependency variables # Github API token @@ -81,3 +87,6 @@ hipchat_token: "{{ hipchat_api_token | default('') }}" # HipChat room id hipchat_room: "{{ hipchat_team_room | default('') }}" + +# NewRelic API token (for deployment notifications) +new_relic_api_token: "{{ new_relic_api_token | default('') }}" diff --git a/tasks/main.yml b/tasks/main.yml index 2372b93..f0a7c66 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -64,3 +64,13 @@ color: purple changed_when: False when: hipchat_token != "" and hipchat_room != "" + +- name: notify new relic deploy complete + sudo: false + newrelic_deployment: + token="{{new_relic_api_token}}" + app_name="{{modcloth_app_new_relic_app_name}}" + revision="{{modcloth_app_docker_tag}}" + user="{{modcloth_app_deployer}}" + when: modcloth_app_notify_new_relic|bool + ignore_errors: yes