It is strange, look like all must to work. I don't understand why you
received "undefined attribute".
Try to add after first task:
- debug: var=ec2
On Friday, February 19, 2016 at 5:05:24 AM UTC+5, Colin Byrne wrote:
>
> Hey, so I feel like I am following all the tutorials.... but I can't seem
> to get the instance id after I create and instance with the ec2 module, to
> use for other modules, like the ec2_vol module, which depends on the ec2
> instance id to attach it to the correct instance. I am not sure if I am
> missing some underlying concept, or missing a variable or missing something
> else. Here are my ec2 and ec2_vol modules:
>
> ---
> - name: Launch instances based on server list
> ec2:
> key_name: "{{ environment_settings[item.0.environment].key_name }}"
> group_id: "{{
> environment_settings[item.0.environment].security_groups[item.1.type] }}"
> instance_type: "{{
> environment_settings[item.0.environment].instance_type[item.1.type] }}"
> image: "{{ environment_settings[item.0.environment].image }}"
> termination_protection: "{{
> environment_settings[item.0.environment].termination_protection }}"
> wait: true
> region: "{{ environment_settings[item.0.environment].region }}"
> instance_tags:
> Type: "{{ item.0.environment }}"
> Name: "{{ item.1.name }}"
> exact_count: 1
> count_tag:
> Name: "{{ item.1.name }}"
> vpc_subnet_id: "{{ environment_settings[item.0.environment].subnet_id
> }}"
> assign_public_ip: "{{
> environment_settings[item.0.environment].assign_public_ip[item.1.type] }}"
> private_ip: "{{ item.1.private_ip }}"
> register: ec2
> with_subelements:
> - server_environments
> - servers
>
> - name: Attach volumes to created instances
> ec2_vol:
> instance: "{{ item.id }}"
> device_name: /dev/xvdb
> volume_size: 200
> volume_type: gp2
> iops: 600
> with_items: ec2.instances
> register: ec2_vol
>
> The output I get from the second task is :
>
> [DEPRECATION WARNING]: Skipping task due to undefined attribute, in the
> future this will be a fatal error.. This feature will be removed in a
> future release. Deprecation warnings can
>
> be disabled by setting deprecation_warnings=False in ansible.cfg.
>
> I know this error is thrown by the 'ec2.instances' not being properly
> defined. I am using ansible 2.1.0.
>
> As a secondary issue, is there a way to define a variable for reuse so I
> can clean up my super-messy traversing of the nested dictionary?
>
> Thanks for any help, C
>
--
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/f19bce5b-c1fc-4a12-ba99-c796482845ff%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.