I am having a strange issue
I have a role that looks like the following
roles/ec2_sg/tasks/main
- name: Create Security Group
ec2_group:
profile: “{{ profile }}”
name: “{{ type }}”
description: “ports required to communicate to {{ type }}”
vpc_id: “{{ aws_vpc_id }}”
region: “{{ aws_region }}”
rules: “{{ sg_rules }}”
When I have the following playbook it fails with the following error
-
hosts: localhost
connection: local
gather_facts: false
vars_files: -
group_vars/{{ env }}
tags: -
test
roles: -
role: ec2_sg
type: “test”
sg_rules: -
proto: tcp
from_port: 8081
to_port: 8082
cidr_ip: “{{ public_cidr }}”
TASK: [ec2_sg | Create Security Group] ****************************************
fatal: [localhost] => Failed to template {% if [{‘to_port’: 8082, ‘from_port’: 8081, ‘cidr_ip’: u’0.0.0.0/0’, ‘proto’: ‘tcp’}] %} True {% else %} False {% endif %}: template error while templating string: expected token ‘,’, got ‘string’
FATAL: all hosts have already failed – aborting
but if I do it works.
- hosts: localhost
connection: local
gather_facts: false
vars_files: - group_vars/{{ env }}
vars:
type: “test”
sg_rules: - proto: tcp
from_port: 8081
to_port: 8082
cidr_ip: “{{ public_cidr }}”
tags: - test
roles: - role: ec2_sg
type: “test”
It really makes no sense. Does anyone have any idea what is happening?
Appreciate the help in advance.
Cheers,
Edgardo