Hello,
Can someone please let me know why I am getting this error message when using with_items? Error message my task are as follows.
ERROR: Syntax Error while loading YAML script, /var/lib/awx/projects/_11813__automated_aws_cloud_watch_alarms/roles/cloudwatch_alarms/tasks/main.yml
Note: The error may actually appear before this position: line 30, column 1
with_items:
- { name: 'test-alarm', metric: 'CPUUtilization' }
^
This one looks easy to fix. It seems that there is a value started
with a quote, and the YAML parser is expecting to see the line ended
with the same kind of quote. For instance:
when: "ok" in result.stdout
Could be written as:
when: '"ok" in result.stdout'
or equivalently:
when: "'ok' in result.stdout"
--------------------------------------------
- name: singapore-ec2-cpu-utilization
local_action:
module: ec2_metric_alarm
state: present
region: ap-southeast-1
metric: "{{ item.metric }}"
namespace: "AWS/EC2"
statistic: Average
comparison: ">="
threshold: 75.0
period: 60
evaluation_periods: 5
unit: "Percent"
description: "test"
dimensions: {'InstanceId':'i-08a707c4'}
alarm_actions: ["arn:aws:sns:ap-southeast-1:779200210943:chanakaalerts:35d082af-c259-4b8e-bc02-b2b516312afd"]
with_items:
- { name: 'test-alarm', metric: 'CPUUtilization' }