That was exactly my issue.  Thank you very much for your help!

On Saturday, August 16, 2014 4:21:14 AM UTC-3, Tomasz Kontusz wrote:
>
>  On 16.08.2014 04:37, Matthew Morgan wrote:
>  
>  Okay, I understand that it only adds to the in-memory inventory, but 
> that's not really the problem I'm having.
>
>  The problem I'm having is I can't get the IP.  What I plan to do with 
> the IP after I get it involves provisioning those hosts.  I can't provision 
> those hosts unless I get the IP from the current run which creates the host.
>
>  The step where I should be able to get the IP to add it to a group (in 
> memory or otherwise) is failing.
>
>    TASK: [Add new instance to host group] 
> **************************************** 
> fatal: [localhost -> 127.0.0.1] => One or more undefined variables: 'str 
> object' has no attribute 'tagged_instances'
>
>  FATAL: all hosts have already failed -- aborting
>    
> Sorry, I only skimmed that paste and missed the actual problem.
> For the record: it's easier if you paste examples in your mail, and it's 
> better for archiving too :-)
>
>    
>  
>  ---
> - name: Create EC2 Instances in VPC
>   gather_facts: False
>   hosts: local
>   vars:
>     security_group: my-sg
>     instance_type: t2.medium
>     image: ami-000111222
>     region: us-east-1
>     key_name: my-key
>     attr:
>       - { zone: us-east-1a, az: a, subnet: subnet-12345678 }
>       - { zone: us-east-1b, az: b, subnet: subnet-23456789 }
>       - { zone: us-east-1d, az: d, subnet: subnet-34567890 }
>   tasks:
>     - name: Create Nodes in VPC
>       local_action: 
>         module: ec2 
>         group: "{{ security_group }}" 
>         instance_type: "{{ instance_type }}" 
>         image: "{{ image }}" 
>         wait: "yes"
>         vpc_subnet_id: "{{ item.subnet }}"
>         region: "{{ region }}" 
>         zone: "{{ item.zone }}" 
>         key_name: "{{ key_name }}"
>         instance_tags: 
>           Name: my-cool-tag-{{item.az}}-vpc
>         exact_count: 1
>         count_tag:
>           Name: my-cool-tag-{{item.az}}-vpc
>       with_items: attr
>       register: ec2
>
>      - name: dump output of ec2.results
>       debug: var=ec2.results
>
>      - name: Add new instance to host group
>       local_action: add_host hostname={{item.tagged_instances.private_ip}} 
> groupname=launched
>       with_items: 
>         - ec2.results
>    
> I think what you meant is "run this task for all of ec2.results", but 
> what you wrote is "run this task for all of ['ec2.results']" (that's why 
> it's complaining about a string).
> You want:
>       with_items: ec2.results
>
> Dash at the beginning of a line creates a list element in YAML (that's why 
> all tasks start with it :-))
>
>     
>      - name: Wait for SSH to come up
>       local_action: wait_for host={{item.instances.private_ip}} port=22 
> delay=60 timeout=320 state=started
>       with_items: 
>         - ec2.results
>
>  - name: Configure instances
>   hosts: launched
>   gather_facts: True
>   sudo: True
>   roles:
>     - my-role
>
>    
>
>
> On Friday, August 15, 2014 7:56:39 PM UTC-3, Tomasz Kontusz wrote: 
>>
>>  On 16.08.2014 00:35, Matthew Morgan wrote:
>>  
>> So, I'm super stuck on this problem.  I created a pastie of all the info. 
>>
>>  http://pastie.org/private/po3yakcngchu8wzjiwhsa
>>  
>>  What am I doing wrong in the playbook that I can't get those IPs into 
>> my hosts file?  
>>
>>  Any help would be greatly appreciated!
>>  
>> add_host is for adding a host to current run's in-memory inventory, not 
>> the one on disk. It's used to provision a newly-created VMs.
>>
>> You want to either use dynamic inventory and pull data from EC2, or 
>> somehow add the host to static inventory (with lineinfile maybe?)
>>
>>  
>>  
>>  -- 
>> 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/8d21cfef-aa4f-4009-abc4-f9e2c235b8be%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/ansible-project/8d21cfef-aa4f-4009-abc4-f9e2c235b8be%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>>
>>   -- 
> 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] <javascript:>.
> To post to this group, send email to [email protected] 
> <javascript:>.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/ansible-project/e272d073-10a1-4895-a55d-cd69c7444268%40googlegroups.com
>  
> <https://groups.google.com/d/msgid/ansible-project/e272d073-10a1-4895-a55d-cd69c7444268%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>
>
>  

-- 
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/70e19ba0-1dd0-4bd4-bd67-e2e2587dced4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to