Created
February 13, 2015 18:45
-
-
Save smashwilson/870815a1a10d56b4e4a5 to your computer and use it in GitHub Desktop.
Sample playbook for Rackspace Cloud Monitoring modules.
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
--- | |
- name: Rackspace Cloud Monitoring test playbook | |
hosts: all | |
connection: local | |
gather_facts: false | |
tasks: | |
- name: Entity | |
rax_mon_entity: | |
credentials: .credentials | |
state: present | |
label: the_entity | |
metadata: | |
hurf: durf | |
register: the_entity | |
- name: Port 80 should redirect to 443. | |
rax_mon_check: | |
credentials: .credentials | |
state: present | |
entity_id: "{{ the_entity.entity.id }}" | |
label: the_check_redirect | |
check_type: remote.http | |
details: | |
url: http://somehost.net/ | |
method: GET | |
follow_redirects: false | |
monitoring_zones_poll: ["mzdfw", "mziad", "mzord"] | |
target_hostname: somehost.net | |
register: the_check_redirect | |
- name: Port 443 should render the page. | |
rax_mon_check: | |
credentials: .credentials | |
state: present | |
entity_id: "{{ the_entity.entity.id }}" | |
label: the_check_content | |
check_type: remote.http | |
details: | |
url: https://somehost.net/ | |
body: hello | |
method: GET | |
follow_redirects: true | |
monitoring_zones_poll: ["mzdfw", "mziad", "mzord"] | |
target_hostname: somehost.net | |
register: the_check_content | |
- name: Email notification | |
rax_mon_notification: | |
credentials: .credentials | |
state: present | |
label: the_notification | |
notification_type: email | |
details: | |
address: address@gmail.com | |
register: the_notification | |
- name: The plan | |
rax_mon_notification_plan: | |
credentials: .credentials | |
state: present | |
label: the_notification_plan | |
ok_state: | |
- "{{ the_notification.notification.id }}" | |
warning_state: | |
- "{{ the_notification.notification.id }}" | |
critical_state: | |
- "{{ the_notification.notification.id }}" | |
register: the_notification_plan | |
- name: Trigger an alarm when the redirect doesn't happen. | |
rax_mon_alarm: | |
credentials: .credentials | |
state: present | |
label: the_alarm_redirection | |
entity_id: "{{ the_entity.entity.id }}" | |
check_id: "{{ the_check_redirect.check.id }}" | |
notification_plan_id: "{{ the_notification_plan.notification_plan.id }}" | |
criteria: > | |
if (metric['code'] != "301") { | |
return new AlarmStatus(CRITICAL, "Non-301 status code #{code} returned."); | |
} | |
return new AlarmStatus(OK); | |
- name: Trigger an alarm when the page has incorrect content. | |
rax_mon_alarm: | |
credentials: .credentials | |
state: present | |
label: the_alarm_content | |
entity_id: "{{ the_entity.entity.id }}" | |
check_id: "{{ the_check_content.check.id }}" | |
notification_plan_id: "{{ the_notification_plan.notification_plan.id }}" | |
criteria: > | |
if (metric['code'] != "200") { | |
return new AlarmStatus(CRITICAL, "Non-200 status code #{code} returned."); | |
} | |
if (metric['body_match'] == "") { | |
return new AlarmStatus(CRITICAL, "Expected page content not found."); | |
} | |
if (metric['cert_end_in'] < 1209600) { | |
return new AlarmStatus(WARNING, "SSL certificate will expire in less than 14 days."); | |
} | |
return new AlarmStatus(OK); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment