Ok - It appears to be an issue with the indentation level of with_items -
I've dropped if back a level but an now receiving:
TASK: [Create ASG for each zone]
**********************************************
fatal: [127.0.0.1] => with_items expects a list or a set
FATAL: all hosts have already failed -- aborting
On Monday, 30 March 2015 12:58:52 UTC+1, Neil Saunders wrote:
>
> 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/cf098009-50db-44e5-ab24-7d2c536431a4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.