Hello All,
I’m trying to re-use a task (by calling it for different purposes via include) so that I can substitute the values of one of module options.
So in one case I have dimension_name=“HealthyHostCount” and in another dimension_name=“BackendConnectionErrors” but it doesn’t work as I want.
It doesn’t throw error but “{{ dimension_name }}” is not substituted.
`
- name: Create alarm
ec2_metric_alarm:
region: “{{ aws_region }}”
…
dimensions:
“{{ dimension_name }}”: “{{ dimension_value }}”
…
state: “{{ state }}”
`
task 1:
`
- name: Create alarm
ec2_metric_alarm:
region: “{{ aws_region }}”
…
dimensions:
“HealthyHostCount”: “{{ dimension_value }}”
…
state: “{{ state }}”
`
task 2:
`
- name: Create alarm
ec2_metric_alarm:
region: “{{ aws_region }}”
…
dimensions:
“BackendConnectionErrors”: “{{ dimension_value }}”
…
state: “{{ state }}”
`
I want to avoid creation of 2 tasks like above with conditions rather use one tasks as I might have many possible values for “dimension_name” and the file become large and complex.
Is there any way to have a variable value substituted in left side?
Thanks,
Constantin