ansible / autoscaling-blog

Companion playbooks to an article at http://www.ansible.com/blog/autoscaling-infrastructures
55 stars 46 forks source link

Incorrect casting of "threshold" variable in infra role scale down alarm #2

Closed n473- closed 8 years ago

n473- commented 9 years ago

roles/infra/tasks/main.yml

- name: create scale down alarm
  ec2_metric_alarm:
    state: present
    region: "{{ region }}"
    name: "cpu-low"
    metric: CPUUtilization
    namespace: "AWS/EC2"
    statistic: Average
    comparison: "<="
    threshold: 5.0
    period: 300
    evaluation_periods: 3
    unit: "Percent"
    description: "This will alarm when cpu usage average is lower than 5% for 15 minutes "
    dimensions:
      AutoScalingGroupName: "{{ app_name }}"
    alarm_actions:
    - "{{ scale_down_policy.arn }}"
  tags: alarm

Attempting to run this playbook as-is results in the following error:

argument threshold is of invalid type: <type 'int'>, required: float

This is due to the threshold variable in the "create scale down alarm" play being cast automatically as "int" instead of float. This can be resolved by ensuring the value of threshold is in decimal form, i.e. "5.0"

einarc commented 8 years ago

I had to fork this and change it, I agree. I have other issues, like the callback not working and Debian not getting permissions to install a package.

DerekTBrown commented 8 years ago

+1