-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from yetu/idempotency&enhancement
Supports supervisor "service resilience" and various enhancment
- Loading branch information
Showing
14 changed files
with
258 additions
and
125 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,54 @@ | ||
--- | ||
- name: "restartApp" | ||
service: | ||
|
||
- name: restart app | ||
debug: | ||
msg="Restart app" | ||
changed_when: true | ||
notify: | ||
- restart app initd | ||
- restart app supervisor | ||
|
||
- name: restart app initd | ||
service: | ||
name="{{ deployment_artifact_name }}" | ||
state="restarted" | ||
enabled="yes" | ||
notify: "wait for application to bootstrap" | ||
when: deployment_install_initd | ||
changed_when: true | ||
notify: wait 4 port | ||
when: deployment_install_daemon == "initd" | ||
|
||
- name: "wait for application to bootstrap" | ||
pause: seconds={{ deployment_bootstrap_wait_sec }} | ||
- name: restart app supervisor | ||
supervisorctl: | ||
name="{{ deployment_artifact_name }}" | ||
state="restarted" | ||
changed_when: true | ||
notify: "make http request to service" | ||
notify: wait 4 port | ||
when: deployment_install_daemon == "supervisor" | ||
|
||
- name: "make http request to service" | ||
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" | ||
- 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 | ||
|
||
- 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: check payload | ||
register: webpage | ||
tags: ["verify-working"] | ||
notify: "fail if http request does not contain expected content" | ||
when: deployment_http_check_url_suffix is defined | ||
tags: ["verify-working"] | ||
|
||
- name: "fail if http request does not contain expected content" | ||
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" | ||
- name: check 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 | ||
tags: ["verify-working"] | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
--- | ||
|
||
- include: init-script.yml | ||
when: deployment_install_daemon == "initd" | ||
tags: ["initd"] | ||
|
||
- include: supervisor.yml | ||
when: deployment_install_daemon == "supervisor" | ||
tags: ["supervisor"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
--- | ||
|
||
- name: daemon | supervisor | Create Service file | ||
template: | ||
src="../../templates/supervisor.j2" | ||
dest="/etc/supervisor/conf.d/{{ deployment_supervisor_name }}.ini.conf" | ||
owner=root | ||
mode=0640 | ||
notify: | ||
- restart app |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
--- | ||
|
||
- name: directory structure | Change file owner for all files | ||
file: | ||
path="{{ deployment_artifact_version_dir }}" | ||
owner="{{ deployment_user }}" | ||
group="{{ deployment_group }}" | ||
state="directory" | ||
recurse="yes" | ||
|
||
- name: directory structure | Change file owner for all files | ||
file: | ||
path="{{ deployment_artifact_version_dir }}" | ||
owner="{{ deployment_user }}" | ||
group="{{ deployment_group }}" | ||
state="directory" | ||
recurse="yes" | ||
|
||
- name: directory structure | Create latest symlink | ||
file: | ||
src="{{ deployment_artifact_version_dir }}" | ||
dest="{{ deployment_current_dir }}" | ||
owner="{{ deployment_user }}" | ||
group="{{ deployment_group }}" | ||
mode="0755" | ||
state="link" | ||
notify: | ||
- restart app | ||
|
||
- name: directory structure | Create deployment date file | ||
copy: | ||
content="" | ||
dest="{{ deployment_current_dir }}/{{ current_date.stdout }}.deployment.date" | ||
owner="{{ deployment_user }}" | ||
group="{{ deployment_group }}" | ||
when: download_artifact.changed |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
--- | ||
|
||
- name: download | Get current date | ||
shell: date +"%Y-%m-%d_%H_%M" | ||
changed_when: False | ||
register: current_date | ||
|
||
- name: download | set new version directory | ||
set_fact: | ||
deployment_artifact_version_dir : "{{ deployment_work_dir }}/{{ nexus_artifact_info.json.data.version }}" | ||
|
||
- name: download | Create application base directories | ||
file: | ||
path="{{ item }}" | ||
owner="{{ deployment_user }}" | ||
group="{{ deployment_group }}" | ||
mode="0755" | ||
state="directory" | ||
with_items: | ||
- "{{ deployment_work_dir }}" | ||
- "{{ deployment_artifact_version_dir }}" | ||
|
||
- name: download | nexus | download artifact | ||
get_url: | ||
url="{{ deployment_nexus_url_download }}" | ||
dest="{{ deployment_artifact_version_dir }}/{{ deployment_artifact_destination_name }}" | ||
register: download_artifact | ||
|
||
- name: download | Unzip application (if .tgz) | ||
command: "tar -xf {{deployment_artifact_version_dir}}/{{deployment_artifact_destination_name}} -C {{deployment_artifact_version_dir}} --strip-components 1" | ||
when: deployment_artifact_destination_name.find('.tgz') >= 1 and download_artifact.changed | ||
|
||
- name: download | Unzip application (if .zip) | ||
command: "unzip -o {{deployment_artifact_version_dir}}/{{deployment_artifact_destination_name}} -d {{deployment_artifact_version_dir}}" | ||
when: deployment_artifact_destination_name.find('.zip') >= 1 and download_artifact.changed | ||
|
||
- name: download | Unzip config files (if .jar) (Optional) | ||
command: "unzip {{deployment_artifact_version_dir}}/{{deployment_artifact_destination_name}} -d {{deployment_artifact_version_dir}} *.conf" | ||
when: deployment_artifact_destination_name.find('.jar') >= 1 and download_artifact.changed | ||
ignore_errors: yes |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
--- | ||
|
||
- include: nexus.yml | ||
when: deployment_artifact_resolver == "nexus" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
--- | ||
|
||
- name: resolve | nexus | Make the http request to find the latest version on nexus | ||
uri: | ||
url="{{ deployment_nexus_url_resolver }}" | ||
method=GET | ||
HEADER_Accept="application/json" | ||
HEADER_Authorization="{{ nexus_credentials | default(omit) }}" | ||
register: nexus_artifact_info | ||
tags: ["artifact-info"] | ||
|
||
- name: resolve | nexus | Show nexus url | ||
debug: | ||
var=deployment_nexus_url_resolver | ||
|
||
- name: resolve | nexus | Show nexus artifact information | ||
debug: | ||
var=nexus_artifact_info.json.data | ||
tags: ["artifact-info"] |
Oops, something went wrong.