Configuring AWS metric alarm using newly created scaling policy ARN

300 views
Skip to first unread message

Claire Lee

unread,
Jul 14, 2014, 2:42:20 PM7/14/14
to ansible...@googlegroups.com
Hi guys, I'm still pretty new to Ansible and was wondering if you could answer a question I have. 

I'm trying to create an AWS scaling policy and attach a metric alarm to it. From what I understand, the ec2_metric_alarm module needs the ARN of the scaling policy so that it can associate itself with it. However, I can't seem to get the ARN after creating a new scaling policy from the ec2_scaling_policy module's output. Currently I'm trying to register the result of the ec2_scaling policy module. For example, my playbook looks something like this:

- name: Create scaling policy and associate it with autoscaling group
  ec2_scaling_policy:
    state: present
    region: us-east-1
    name: "test-scaleup-policy"
    adjustment_type: "ChangeInCapacity"
    asg_name: "test-asg"
    scaling_adjustment: 1
    min_adjustment_step: 1
    cooldown: 300
  register: sp_result

- name: Debug result of scaling policy creation
  debug: var=sp_result

- name: Create metric alarm and associate it with autoscaling policy
  action:
    module: ec2_metric_alarm
    state: present
    alarm_actions: ["{{ sp_result.arn }}"]
    etc...

The debug module prints this:

TASK: [Debug] ***************************************************************** 
ok: [localhost] => {
   "sg_result": {
      "changed": false, 
      "invocation": {
      "module_args": "", 
      "module_name": "ec2_scaling_policy"
}}}

According to this merged pull request, the ARN should be included in the data the module returns. Am I trying to capturing this information in the wrong way, e.g. using register when I should be using something else? Otherwise, is there something else I should be doing?

James Cammarata

unread,
Jul 14, 2014, 3:10:35 PM7/14/14
to ansible...@googlegroups.com
What version of Ansible are you running? The above PR was merged into devel and will be included in 1.7, however it is not yet available in 1.6.x.


--
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/f3ca0fa1-2b9b-4de1-a0a4-61f2c58e27a3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Claire Lee

unread,
Jul 14, 2014, 4:47:37 PM7/14/14
to ansible...@googlegroups.com
D'oh, looks like I was still on 1.6.6. Using the devel branch now and it works, thanks!
Reply all
Reply to author
Forward
0 new messages