ec2_metric_alarm not working for Notification creation with "alarm_actions"

194 views
Skip to first unread message

Bhotu

unread,
Jan 28, 2016, 4:49:14 PM1/28/16
to Ansible Project
I have been using the following line in "alarm_actions" in "ec2_metric_alarm" module:

local_action:
  module: ec2_metric_alarm
.....
.....
.....
  alarm_actions: "arn:aws:sns:us-east-1:465404482164:Polnotify" 


I did created this with "sns_topic". But I am not able to link it with the ec2_metric_alarm module. How could I solve the issue ?


Stephen Granger

unread,
Jan 28, 2016, 7:12:29 PM1/28/16
to ansible...@googlegroups.com
Do you have an error message from the cli?

Does the action not get associated with the alarm? Is there an association in the AWS console?

Can you manually associate the action with the sns topic in the AWS console?

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/647db18b-4fb6-4542-806f-52f1439721ff%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Steve

Stephen Granger

unread,
Jan 28, 2016, 7:32:34 PM1/28/16
to ansible...@googlegroups.com
"Hi, I have not got the error message though. But when I tried once more, I am able to get the notification on my E-mail as I have set up the autoscaling policy such as CPUUtilization metric. But the thing is, I cannot create notification with ansible script on autoscaling group. I have to create it manually. That's not what I am looking for. "

You are able to create notifications/topcis with this module
http://docs.ansible.com/ansible/sns_topic_module.html

Keep things on the list, I'm sure everyone wants to know the solution to your problem.
--
Steve

Bhotu

unread,
Jan 29, 2016, 12:02:51 PM1/29/16
to Ansible Project
I am able to create SNS topic with sns_topic module. But How can I link it with the autoscaling group ?..Because in the auto scaling group we can clearly create the auto scaling policy and metric alarms and we can see on AWS console with ec2_metric_alarm or ec2_scaling_policy module..I have to create it manually on autoscaling group console for already available SNS ARN or is there any module in ansible which supports any parameter so that i can directly create SNS notifications in the autoscaling group ?

Bhotu

unread,
Jan 29, 2016, 2:58:33 PM1/29/16
to Ansible Project
Hi Stephen,

Here is the thing, I did the same..It can create the autoscaling group. But the "notification" tab in the autoscaling group remains empty. Although I can see it in the Cloudwatch. 

Why I cannot see it in the AWS autoscaling ?  Is it something to do with the ec2_asg ?

Here is my script,


---

- name: Start Autoscaling Configurations

  hosts: awsserver

  gather_facts: no

  tasks:

    - name: Autoscaling Starts Now...!!!!!

      local_action:

        module: ec2_scaling_policy

        region: us-east-1

        name: "{{ item.name }}"

        asg_name: "testing-ASG"

        state: present

        adjustment_type: "{{ item.adjustment_type }}"

        min_adjustment_step: "{{ item.min_adjustment_step }}"

        scaling_adjustment: "{{ item.scaling_adjustment }}"

        cooldown: "{{ item.cooldown }}"

      with_items:

        - name: "Increase Group Size"

          adjustment_type: "ChangeInCapacity"

          scaling_adjustment: +1

          min_adjustment_step: 1

          cooldown: 170

 

        - name: "Decrease Group Size"

          adjustment_type: "ChangeInCapacity"

          scaling_adjustment: -1

          min_adjustment_step: 1

          cooldown: 290

 

      register: autoscaling

 

    - name: Create or delete AWS metric alarms metrics you wish to alarm on must already exists

      local_action:

        module: ec2_metric_alarm

        region: us-east-1

        name: "{{ item.name }}"

        state: present

        metric: "CPUUtilization"

        namespace: "AWS/EC2"

        statistic: "Average"

        comparison: "{{ item.comparison }}"

        threshold: "{{ item.threshold }}"

        period: 60

        evaluation_periods: 3

        unit: "Percent"

        dimensions:

          AutoScalingGroupName: "testing-ASG"

        alarm_actions: "{{ item.alarm_actions }}"

  

      with_items:

        - name: "testing-SCALE-UP"

          comparison: ">="

          threshold: 70.0

          alarm_actions:

            - '{{ autoscaling.results[0].arn }}'

            - 'arn:aws:sns:us-east-1:465404420665:Polanotify'

 

        - name: "testing-SCALE-DOWN"

          comparison: "<="

          threshold: 20.0

          alarm_actions:

            - '{{ autoscaling.results[1].arn }}'

            - 'arn:aws:sns:us-east-1:465404420665:Polanotify'


So, I have done the above part.. What could be the possible problem ?.. I want to see the notification in "Notification" tab with this script. 


On Thursday, 28 January 2016 13:49:14 UTC-8, Bhotu wrote:
Reply all
Reply to author
Forward
0 new messages