nevermind i figured my ec2_elb problem was though . the instance_ids need 
to be passed in via complex args , since they are an array and the standard 
key=value argument method would not work here . To workaround this , I  
passed the ids through the jinja2 join filter 
 instance_id: '{{ new_instances.instance_ids|join(",") }}'  

 This will turn the argument into instance_ids=id1,id2,id3, and the 
parameter parsing in the module will know to turn it back into a list based 
on the fact that it is set to type='list'.

Eion : You should try and do this to fix your problem 



On Tuesday, March 10, 2015 at 6:39:29 PM UTC+5:30, Vishal Uderani wrote:
>
> Im facing a similar issue where my workflow is as follows 
>
> 1) deploy code to an instance 
> 2) create an ami from the said instance 
> 3) spawn x instances from the said AMI 
> 4) register all newly created instances to the elb using ec2_elb module 
>
>
> step 4) code looks like 
>
> - name: adding the new instances to the ELB
>
>   ec2_elb:
>
>     aws_access_key: "{{ ec2_access_key }}"
>
>     aws_secret_key: "{{ ec2_secret_key }}"
>
>     region: "{{ region }}"
>
>     instance_id: "{{ new_instance_ids.instance_ids }}"
>
>     ec2_elbs: ansible-test
>
>     state: present
>
>     wait: yes
>
> new_instance_ids is what i register after the instances are created and 
> query the instance_id field and get the below error 
>
> failed: [test-ami-2] => {"failed": true, "parsed": false}
>
> SUDO-SUCCESS-fscsgqdhhmhsmegnguzilbdrrlylbpbk
>
> Traceback (most recent call last):
>
>   File 
> "/home/ec2-user/.ansible/tmp/ansible-tmp-1425971748.07-61887153074694/ec2_elb",
>  
> line 2126, in <module>
>
>     main()
>
>   File 
> "/home/ec2-user/.ansible/tmp/ansible-tmp-1425971748.07-61887153074694/ec2_elb",
>  
> line 326, in main
>
>     elb_man.register(wait, enable_availability_zone, timeout)
>
>   File 
> "/home/ec2-user/.ansible/tmp/ansible-tmp-1425971748.07-61887153074694/ec2_elb",
>  
> line 154, in register
>
>     self._enable_availailability_zone(lb)
>
>   File 
> "/home/ec2-user/.ansible/tmp/ansible-tmp-1425971748.07-61887153074694/ec2_elb",
>  
> line 179, in _enable_availailability_zone
>
>     instance = self._get_instance()
>
>   File 
> "/home/ec2-user/.ansible/tmp/ansible-tmp-1425971748.07-61887153074694/ec2_elb",
>  
> line 283, in _get_instance
>
>     return ec2.get_only_instances(instance_ids=[self.instance_id])[0]
>
> AttributeError: 'EC2Connection' object has no attribute 
> 'get_only_instances'
>
>
>
> On Monday, March 9, 2015 at 7:06:39 PM UTC+5:30, Eoin Verling wrote:
>>
>> Hi,
>>
>> I'm trying to add instances to an ELB, I may be looking at this the wrong 
>> way.
>>
>> I have X number of instances, running ElasticSearch for example.
>> I want to create an ELB, and add (register) all the instance ids, with my 
>> "elasticsearch" tag, to that ELB.
>>
>> Is the "ec2_elb" module designed to "register a single instance id to a 
>> list of ELBs, at the instance creation time", as opposed to, "register a 
>> list of instance ids, to a single ELB, at any stage"? 
>>
>> So, what I am trying to to:-
>>
>> 1. create ec2 instances
>> 2. install elasticsearch on all "tag:Name=elasticsearch"
>> 3. create ELB
>> 4. get list of all instance ids with "tag:Name=elasticsearch"
>> 5. register this list with ELB
>>
>> - name: add instances to LB
>>   ec2_elb:
>>     instance_id: "{{ item }}"
>>     ec2_elbs: "{{ my_elb_name }}"
>>     state: present
>>   with_items: my_es_instances.stdout_lines
>>
>> TASK: [elb | debug var=my_es_instances] 
>> ***************************************
>> ok: [localhost] => {
>>     "my_es_instances": {
>>         "changed": true,
>>         "cmd": "ec2-describe-instances --hide-tags --region eu-west-1 -F 
>> 'tag:Name=elasticsearch' | grep INSTANCE | awk '{print $2}'",
>>         "delta": "0:00:01.477150",
>>         "end": "2015-03-06 17:27:25.737070",
>>         "invocation": {
>>             "module_args": "ec2-describe-instances --hide-tags --region 
>> eu-west-1 -F 'tag:Name=elasticsearch' | grep INSTANCE | awk '{print $2}'",
>>             "module_name": "shell"
>>         },
>>         "rc": 0,
>>         "start": "2015-03-06 17:27:24.259920",
>>         "stderr": "",
>>         "stdout": "i-123456\ni-abcdef",
>>         "stdout_lines": [
>>             "i-123456",
>>             "i-abcdef"
>>         ],
>>         "warnings": []
>>     }
>> }
>>
>> Step 5 is where I'm stuck. Am I loosing my mind?
>> thanks
>> e
>>
>

-- 
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 ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/44f805c0-5700-411c-bf2a-82b28fddad40%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to