Hello,

I am trying to use with_items: from a file but I am getting the following 
error. I can't find any documentation to help me with this. I'm hoping 
someone can help me. The error message and my files are as follows:


Error:


TASK: [cloudwatch_alarms | include_vars ec2-alarms.yml] 
*********************** ok: [ec2-xx-xxx-xxx-xx.compute-1.amazonaws.com] 
TASK: [cloudwatch_alarms | debug var=ec2-alarms] 
****************************** ok: 
[ec2-xx-xxx-xxx-xx.compute-1.amazonaws.com] => { "ec2-alarms": 
"{{ec2-alarms}}" } TASK: [cloudwatch_alarms | ec2-alarms] 
**************************************** fatal: 
[ec2-xx-xxx-xxx-xx.compute-1.amazonaws.com -> 127.0.0.1] => One or more 
undefined variables: 'str object' has no attribute 'comparison' FATAL: all 
hosts have already failed -- aborting PLAY RECAP 
******************************************************************** to 
retry, use: --limit @/var/lib/awx/cloudwatch-alarms.retry 



Main Task:

---
# -----------------------------------------------------
# AWS CloudWatch Alarms
# -----------------------------------------------------
- include_vars: ec2-alarms.yml
- debug: var=ec2-alarms
- name: ec2-alarms
  local_action:
    module: ec2_metric_alarm
    state: present
    region: "{{ item.region }}"
    name: "{{ item.region }}-{{ item.name }}-{{ item.metric 
}}-instanceId-{{ item.instanceId }}"
    metric: "{{ item.metric }}"
    namespace: "AWS/EC2"
    statistic: Average
    comparison: "{{ item.comparison }}"
    threshold: "{{ item.threshold }}"
    period: 300
    evaluation_periods: 1
    unit: "{{ item.unit }}"
    description: ""
    dimensions: {"InstanceId":"{{ item.instanceId }}"}
    alarm_actions: ["{{ item.alarm }}"]
  with_items: ec2-alarms
  tags: alarm

- name: ec2-ebs-alarms
  local_action:
    module: ec2_metric_alarm
    state: present
    region: "{{ item.region }}"
    name: "{{ item.region }}-{{ item.name }}-{{ item.metric }}-volumeId-{{ 
item.volumeId }}"
    metric: "{{ item.metric }}"
    namespace: "AWS/EBS"
    statistic: Average
    comparison: "{{ item.comparison }}"
    threshold: "{{ item.threshold }}"
    period: "{{ item.period }}"
    evaluation_periods: 1
    unit: "{{ item.unit }}"
    description: ""
    dimensions: {"VolumeId":"{{ item.volumeId }}"}
    alarm_actions: ["{{ item.alarm }}"]
  with_items:
    - { name: 'chanakatest4', region: 'us-west-2', metric: 'VolumeReadOps', 
comparison: '>=', threshold: '1350', period: '3600', unit: 'None', 
volumeId: 'vol-69907266', alarm: 'arn:aws:sns:us-west-2:x:sysalerts' }
    - { name: 'chanakatest5', region: 'us-west-2', metric: 
'VolumeWriteOps', comparison: '>=', threshold: '1350', period: '3600', 
unit: 'None', volumeId: 'vol-69907266', alarm: 
'arn:aws:sns:us-west-2:x:sysalerts' }
  tags: alarm


EC2 Alarms Yml file:


---
ec2-alarms:
 - { name: 'chanakatest1', region: 'ap-southeast-1', metric: 
'CPUUtilization', comparison: '<=', threshold: '85.0', unit: 'Percent', 
instanceId: 'i-10ca18dd', alarm: 
'arn:aws:sns:ap-southeast-1:x:chanakaalerts' }
 - { name: 'chanakatest2', region: 'ap-southeast-1', metric: 'NetworkIn', 
comparison: '>=', threshold: '8000000000', unit: 'Bytes', instanceId: 
'i-10ca18dd', alarm: 'arn:aws:sns:ap-southeast-1:x:chanakaalerts' }
 - { name: 'chanakatest3', region: 'ap-southeast-1', metric: 'NetworkOut', 
comparison: '>=', threshold: '8000000000', unit: 'Bytes', instanceId: 
'i-10ca18dd', alarm: 'arn:aws:sns:ap-southeast-1:x:chanakaalerts' }


-- 
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-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/1741f28a-13a8-4364-b365-ce7fa538e90d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to