Created
June 22, 2018 01:43
-
-
Save naavveenn/ca855e247e620cf866f59d5b289421cb to your computer and use it in GitHub Desktop.
This file contains hidden or 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
--- | |
- hosts: local | |
connection: local | |
vars_files: | |
- /home/ansible/tbb_awscreds.yml | |
tasks: | |
- name: Check for the ECS services | |
shell: aws ecs list-services --cluster "{{ cluster }}" --region ap-south-1 --profile tbb | awk -F ":" '{print $6}' | tr -d '"',"," | awk -F "/" '{print $2}' | sed '/^\s*$/d' > /root/ecs_service.txt | |
- name: Create a Basic CPU Alarm | |
ec2_metric_alarm: | |
aws_access_key: "{{ aws_id }}" | |
aws_secret_key: "{{ aws_key }}" | |
region: "{{ aws_region }}" | |
state: present | |
name: "msp-ecs-{{ item }}-CPUUtilization-Critical (MSP)" | |
metric: "CPUUtilization" | |
namespace: "AWS/ECS" | |
statistic: Average | |
comparison: ">=" | |
threshold: 90.0 | |
period: 300 | |
evaluation_periods: 1 | |
unit: "Percent" | |
description: "This alarm triggers when CPU is greater than 90% for 5 minutes" | |
dimensions: {'ClusterName': "{{ cluster }}",'ServiceName': "{{ item }}"} | |
alarm_actions: ['arn:aws:sns:ap-south-1:652024084351:TataSkyBB-MSP-Alerts'] | |
with_lines: | |
- "cat /root/ecs_service.txt" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ansible-playbook ecs.yml --extra-vars "cluster=prod-cluster"