error in group vars that I can't solve

51 views
Skip to first unread message

Chanaka Samarajeewa

unread,
Apr 9, 2015, 8:50:02 AM4/9/15
to ansible...@googlegroups.com
Hello, 

I'm getting the following error when running my task. For some reason Ansible is complaining about >= characters, but it is ok with <= characters in the same file. I tried single quotes and double quotes around the characters but it causes other errors. Files and error message are as follows: Thank you for your help.

ERROR: Syntax Error while loading YAML script, /var/lib/awx/projects/_11813__automated_aws_cloud_watch_alarms/group_vars/ec2-alarms Note: The error may actually appear before this position: line 14, column 20 metric: NetworkIn comparison: >= ^

main.yml:
=======

---
# -----------------------------------------------------
# AWS CloudWatch Alarms
# -----------------------------------------------------
- include_vars: ec2-alarms.yml
- debug: var=ec2-alarms
- name: ec2-alarms
  with_items: 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 }}"]
  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:779200210943: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:779200210943:sysalerts' }
  tags: alarm



ec2-alarms yml
===========
---
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:779200210943:chanakaalerts
    - name: chanakatest2
      region: ap-southeast-1
      metric: NetworkIn
      comparison: >=
      threshold: 8000000000
      unit: Bytes
      instanceId: i-10ca18dd
      alarm: arn:aws:sns:ap-southeast-1:779200210943:chanakaalerts
    - name: chanakatest3
      region: ap-southeast-1
      metric: NetworkOut
      comparison: >=
      threshold: 8000000000
      unit: Bytes
      instanceId: i-10ca18dd
      alarm: arn:aws:sns:ap-southeast-1:779200210943:chanakaalerts

Brian Coca

unread,
Apr 9, 2015, 10:03:53 AM4/9/15
to ansible...@googlegroups.com
Have you tried quoting it? > is a reserved Yaml character (signifies
multiline input) so it requires quoting, < is not a reserved
character.

comparison: '>='


--
Brian Coca

Bhotu

unread,
Jan 28, 2016, 11:59:46 AM1/28/16
to Ansible Project
Does that "arn:aws:sns:ap-southeast-1:779200210943:chanakaalerts" works ?.. I am getting the unusual error saying 

"msg": "BotoServerError: 400 Bad Request\n<ErrorResponse xmlns=\"http://monitoring.amazonaws.com/doc/2010-08-01/\">\n  <Error>\n 


How to create the notification with ec2_metric_alarm module ?.. I created with "sns" module. But how can I use it in autoscaling group ?
Reply all
Reply to author
Forward
0 new messages