forked from ansible/ansible
-
Notifications
You must be signed in to change notification settings - Fork 0
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 ansible#41 from inventure/check_servers_state_1364…
…61073 Add ansible playbook for checking servers status
- Loading branch information
Showing
7 changed files
with
113 additions
and
1 deletion.
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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
- hosts: all | ||
become: yes | ||
become_user: root | ||
remote_user: vagrant | ||
roles: | ||
- { role: check-servers-state} |
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
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,2 +1,10 @@ | ||
--- | ||
country_code: tz | ||
|
||
# Server API urls | ||
dev_server_api_base_url: "tz-devserverapi.inventureaccess.com" | ||
demo_server_api_base_url: "tz-demoserverapi.inventureaccess.com" | ||
prod_server_api_base_url: "tz-api.inventureaccess.com" | ||
qa_server_api_base_url: "tz-qaserverapi.inventureaccess.com" | ||
qa2_server_api_base_url: "tz-qa2serverapi.inventureaccess.com" | ||
staging_server_api_base_url: "tz-stagingserverapi.inventureaccess.com" |
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,27 @@ | ||
--- | ||
# Role to ping servers to check their state | ||
|
||
- name: Set server api base url | ||
include: set-server-api-baseurl.yml | ||
tags: | ||
- check-servers-state | ||
|
||
- name: Check servers state | ||
uri: | ||
url: "{{ server_api_base_url }}/admin/serverstatus/check" | ||
return_content: yes | ||
status_code: 200 | ||
register: servers_state | ||
tags: | ||
- check-servers-state | ||
|
||
- name: Fail when one of the servers is down | ||
fail: | ||
msg: > | ||
"Server Name: {{ item.key }}" | ||
"Status Code: {{ item.value.status }}" | ||
"Error Details: {{ item.value.statusDetails }}" | ||
failed_when: item.value.status != 200 | ||
with_dict: "{{ servers_state.content|from_json }}" | ||
tags: | ||
- check-servers-state |
45 changes: 45 additions & 0 deletions
45
provisioning/roles/check-servers-state/tasks/set-server-api-baseurl.yml
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,45 @@ | ||
--- | ||
# Set server_api_base_url based on the environment | ||
|
||
- include_vars: group_vars/{{ country_code }}/vars.yml | ||
|
||
- name: Set server api base url - local | ||
set_fact: server_api_base_url="http://serverapi.lh" | ||
tags: | ||
- check-servers-state | ||
|
||
- name: Set server api base url - dev | ||
set_fact: server_api_base_url="http://{{ dev_server_api_base_url }}" | ||
when: env == "dev" | ||
tags: | ||
- check-servers-state | ||
|
||
- name: Set server api base url - demo | ||
set_fact: server_api_base_url="http://{{ demo_server_api_base_url }}" | ||
when: env == "demo" | ||
tags: | ||
- check-servers-state | ||
|
||
- name: Set server api base url - prod | ||
set_fact: server_api_base_url="http://{{ prod_server_api_base_url }}" | ||
when: env == "prod" | ||
tags: | ||
- check-servers-state | ||
|
||
- name: Set server api base url - qa | ||
set_fact: server_api_base_url="http://{{ qa_server_api_base_url }}" | ||
when: env == "qa" | ||
tags: | ||
- check-servers-state | ||
|
||
- name: Set server api base url - qa2 | ||
set_fact: server_api_base_url="http://{{ qa2_server_api_base_url }}" | ||
when: env == "qa2" | ||
tags: | ||
- check-servers-state | ||
|
||
- name: Set server api base url - staging | ||
set_fact: server_api_base_url="http://{{ staging_server_api_base_url }}" | ||
when: env == "staging" | ||
tags: | ||
- check-servers-state |