On 28.09.2016 03:07, Chris Stobie wrote:
<snip>
- name: Create EC2 instance for zone A
ec2:
key_name: "{{ keypair }}"
group: "{{ security_groups }}"
image: "{{ ami }}"
instance_type: "{{ instance_type }}"
wait: true
region: "{{ ec2_region }}"
vpc_subnet_id: "{{ subneta }}"
assign_public_ip: "{{ public_choice }}"
zone: "{{ zonea }}"
count: 1
instance_tags:
Name: "db{{ item }}a.{{ env }}"
envtype: "{{ envtype }}"
register: ec2
with_sequence: "start=1 end={{ num }}"
Remember that all the with_ is a loop, and the register is a little
different as described here
https://docs.ansible.com/ansible/playbooks_loops.html#using-register-with-a-loop
The result is stored in a list ec2.results
<snip>
ok: [localhost] => {
"msg": {
"changed": true,
"msg": "All items completed",
"results": [
Here you can see the results list.
<snip>
So I can see that the variable that should exist does in the output of
the
full ec2 variable. But when trying to use the key specific variable of
ec2.instance_ids it fails...
The correct entry would be ec2.results[0].instance_ids for the first
iteration of the loop and for the second iteration
ec2.results[1].instance_ids and so on.
--
Kai Stian Olstad
--
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/869c4cc59eac8af3ba98fd957eedafea%40olstad.com.
For more options, visit https://groups.google.com/d/optout.