Hi All -
I'm trying iterate over a list of dicts stored in an external file.
My variables file (vpc.yml) is as follows:
---
eu-west-1:
stage:
- { name: eu-west-1a, subnet: subnet-832023ea }
- { name: eu-west-1b, subnet: subnet-10272479 }
- { name: eu-west-1c, subnet: subnet-8e2724e7 }
live:
- { name: eu-west-1a, subnet: subnet-cd340ea4 }
- { name: eu-west-1b, subnet: subnet-18272471 }
- { name: eu-west-1c, subnet: subnet-37af955e }
<snip>
And my task definition is:
---
- hosts: 127.0.0.1
connection: local
vars_files:
- vpc.yml
tasks:
- name: Create ASG for each zone
ec2_asg:
name: "{{ component_name }}-{{ environment }}-{{ item.name }}"
availability_zones: [ "{{ item.name }}" ]
launch_config_name: 'lc-1'
min_size: 1
max_size: 10
desired_capacity: 1
vpc_zone_identifier: [ "{{ item.subnet }}" ]
tags:
- Component: "{{ component_name }}"
- ComponentVersion: "{{ component_name }}"
- EnvLevel: "{{ environment }}"
- ClusterName: "{{ cluster_name }}"
- Country: "{{ country }}"
propagate_at_launch: yes
with_items: {{ region[environment] }}
Which I then invoke with:
ansible-playbook create-clustered-persistance-infra.yml --check -i inventory
.ini --extra-vars="component_name=elasticsearch environment=stage
clustername=eventsearch instance_type=m1.medium country=us region=us-east-1
component_version=9 component_ami=ami-293872"
But receive the error:
TASK: [Create ASG for each zone]
**********************************************
fatal: [127.0.0.1] => One or more undefined variables: 'item' is undefined
FATAL: all hosts have already failed -- aborting
I've tried what feels like every combination of brackets and quotes, but
I'm clearly missing something.
Any assistance gratefully received.
Ta,
Neil
--
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/57113fe3-a8f6-4447-b0ab-fed3c3224c5e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.