Thank you guys!!!

Peter

On Thursday, January 8, 2015 1:12:31 AM UTC-8, Tom Bamford wrote:
>
> Hi Peter
>
> As Fred says, the variables are not in scope for both plays. You will need 
> to declare your variables such that both plays can see them. You could put 
> them into a separate file and reference it with vars_files in both plays, 
> or you could pass them in as extra vars on the command line. You will not 
> be able to put them into group_vars/* or host_vars/*, as they are not 
> able to be resolved at the time the hosts are matched.
>
> Also, you can simplify your role call to
>
> roles:
>   - { role: webserver, port: port }
>
> (i.e. without interpolating the port var into a string)
>
> Although the port variable will be in scope within the role just by 
> declaring it in your play, so you can drop it altogether as a role parameter
>
> roles:
>   - webserver
>
> Regards
> Tom
>
>
> On 8 January 2015 at 09:05, Peter Mooshammer <[email protected] 
> <javascript:>> wrote:
>
> Hi there, 
>>
>> I am fairly new with ansible and I am having some with variables :-).
>>
>> Here is my 1st problem, I have a playbook I do have a variable:
>>
>> - name: Create instance(s)
>>   hosts: local
>>   gather_facts: no
>>   connection: local
>>   tags: provisioning
>>   vars:
>>     ....
>>     groupname: launched
>>     port: 8080
>>
>>
>> Later I use it in the add_host line:
>>
>>  
>>  - name: Add host to groupname
>>     add_host: hostname={{ item.public_ip }} 
>> ansible_ssh_private_key_file=PATH_TO_KEYFILE 
>> groupname={{ groupname }}
>>     with_items: gce.instance_data
>>
>>
>>
>> and then I use it again at:
>>
>> -
>>  name: Manage new instances
>>   hosts: "{{ groupname }}"
>>   connection: ssh
>>   sudo: True
>>   roles:
>>   - { role: webserver, port: "{{ port }}" }
>>
>>
>>
>> but I doesn't work - replacing it with:
>>  hosts: launched
>>
>> Second problem - maybe related I try to overwrite a variable in a role I 
>> include:
>>
>> roles:
>>   - { role: webserver, port: "{{ port }}" }
>>
>> this also doesn't work. Any hints?
>>
>> thanks
>>
>> Peter
>>
>>
>>
>>
>>
>>
>>
>>  -- 
>> 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/28fa7149-29e5-46f7-ac90-fb79e67ac422%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/ansible-project/28fa7149-29e5-46f7-ac90-fb79e67ac422%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/a9352e74-9223-4c92-a5e0-7dbcd2607e73%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to