Skip to content

Commit

Permalink
Merge pull request #3 from yetu/feature/slack
Browse files Browse the repository at this point in the history
Notification support "slack"
  • Loading branch information
ahelal committed Jun 2, 2015
2 parents ff04bef + 05b5811 commit 60e6072
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 10 deletions.
10 changes: 9 additions & 1 deletion defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,12 @@ deployment_exec_arg : ""
# Used for getting PID ID, it should be a unique value
deployment_grep_name : "{{ deployment_exec_cmd }}"

deployment_timeout_start_sec : 5
deployment_timeout_start_sec : 5

# notification
deployment_notification_enabled : false
deployment_notification_slack_enabled : false
#deployment_notification_slack_token : "sometoken"
#deployment_notification_slack_domain : "domain"
deployment_status : "Failed"

37 changes: 33 additions & 4 deletions handlers/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,30 +25,59 @@
notify: wait 4 port
when: deployment_install_daemon == "supervisor"


- name: wait 4 port
wait_for:
port="{{ deployment_http_check_port }}"
host="{{ ansible_ssh_host | default(inventory_hostname) }}"
delay="{{ deployment_delay_sec }}"
timeout="{{ deployment_timeout_wait_sec }}"
changed_when: true
notify: HTTP request
notify:
- HTTP request
- deployment notification
register: wait_4_port

- name: HTTP request
uri:
url="{{ deployment_http_check_url }}"
return_content="yes"
HEADER_Accept="text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8"
changed_when: true
notify: fail on incorrect payload
notify:
- fail on incorrect payload
register: webpage
when: deployment_http_check_url_suffix is defined
tags: ["verify-working"]

- name: fail on incorrect payload
fail:
msg=" {{deployment_artifact_name}} is not happy, {{deployment_http_check_url}} does not return expected content [{{deployment_http_check_expected_content}}]"
when: deployment_http_check_expected_content not in webpage.content
msg="{{ deployment_artifact_name }} is not happy, {{deployment_http_check_url}} does not return expected content [{{deployment_http_check_expected_content}}]"
register: payload
when: deployment_http_check_expected_content is defined and deployment_http_check_expected_content not in webpage.content
tags: ["verify-working"]

- name: deployment notification
debug:
msg="Notify"
changed_when: True
notify:
- check if deployment succeeded
- notification slack
when: deployment_notification_enabled

- name: check if deployment succeeded
set_fact:
deployment_status: "Succeeded"
when: deployment_notification_slack_enabled and wait_4_port | success and webpage | success and payload | success and (deployment_http_check_url_suffix is defined) and (deployment_http_check_expected_content in webpage.content)

- name: notification slack
slack:
msg="Deployment of '{{ deployment_supervisor_name }}' verions '{{ deployment_artifact_version_hash }}' on '{{ inventory_hostname }}' [ {{ deployment_status }} ]"
domain="{{ deployment_notification_slack_token }}"
token="{{ deployment_notification_slack_domain }}"
validate_certs="no"
connection: local
delegate_to: localhost
sudo: false

1 change: 1 addition & 0 deletions tasks/download.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
- name: download | set new version directory
set_fact:
deployment_artifact_version_dir : "{{ deployment_work_dir }}/{{ nexus_artifact_info.json.data.version }}"
deployment_artifact_version_hash : "{{ nexus_artifact_info.json.data.version }}"

- name: download | Create application base directories
file:
Expand Down
5 changes: 0 additions & 5 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,3 @@
copy:
content=""
dest="{{ deployment_guard_file }}"





0 comments on commit 60e6072

Please sign in to comment.