hey, thanks, thats a good idea. Here is my output. Instances is clearly
empty... I am using private vpc subnet instances.... Do you think that may
be why they aren't loading?
my debug output is:
ok: [localhost] => {
"ec2": {
"changed": false,
"msg": "All items completed",
"results": [
{
"_ansible_no_log": false,
"changed": false,
"instance_ids": null,
"instances": [],
"invocation": {
"module_args": {
"assign_public_ip": false,
"aws_access_key": null,
"aws_secret_key": null,
"count": 1,
"count_tag": {
"Name": "s-test"
},
"ebs_optimized": false,
"ec2_url": null,
"exact_count": 1,
"group": null,
"group_id": [
"sg-81398ee4",
"sg-a6398ec3"
],
"id": null,
"image": "ami-06116566",
"instance_ids": null,
"instance_profile_name": null,
"instance_tags": {
"Name": "s-test",
"Type": "staging"
},
"instance_type": "t2.medium",
"kernel": null,
"key_name": "ansible_provisioning",
"monitoring": false,
"network_interfaces": null,
"placement_group": null,
"private_ip": "10.101.1.33",
"profile": null,
"ramdisk": null,
"region": "us-east-1",
"security_token": null,
"source_dest_check": true,
"spot_launch_group": null,
"spot_price": null,
"spot_type": "one-time",
"spot_wait_timeout": 600,
"state": "present",
"tenancy": "default",
"termination_protection": false,
"user_data": null,
"validate_certs": true,
"volumes": null,
"vpc_subnet_id": "subnet-819f45cd8",
"wait": true,
"wait_timeout": 300,
"zone": null
},
"module_name": "ec2"
},
"item": [
{
"environment": "staging"
},
{
"name": "s-test",
"private_ip": "10.101.1.33",
"type": "app"
}
],
"tagged_instances": [
{
"ami_launch_index": "0",
"architecture": "x86_64",
"block_device_mapping": {
"/dev/sda1": {
"delete_on_termination": true,
"status": "attached",
"volume_id": "vol-c14a1569"
}
},
"dns_name": "",
"ebs_optimized": false,
"groups": {
"sg-81398ee4": "ssh",
"sg-a6398ec3": "default"
},
"hypervisor": "xen",
"id": "i-11eeg8a3",
"image_id": "ami-06116566",
"instance_type": "t2.medium",
"kernel": null,
"key_name": "ansible_provisioning",
"launch_time": "2016-02-03T22:47:37.000Z",
"placement": "us-west-1a",
"private_dns_name":
"ip-10-101-1-33.us-west-1.compute.internal",
"private_ip": "10.101.1.33",
"public_dns_name": "",
"public_ip": null,
"ramdisk": null,
"region": "us-west-1",
"root_device_name": "/dev/sda1",
"root_device_type": "ebs",
"state": "running",
"state_code": 16,
"tags": {
"Name": "s-colin",
"Type": "integ"
},
"tenancy": "default",
"virtualization_type": "hvm"
}
]
}
]
}
}
On Friday, February 19, 2016 at 1:04:41 AM UTC-8, Alexey Vazhnov wrote:
>
> 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/4ef15365-33b0-4799-bd4f-69e1536e54c1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.