On Wed, Nov 05, 2014 at 08:06:41AM -0800, James Morgan wrote:
> Hi,
> 
> I'd like to be able to build a variable name programatically in a similar 
> fashion to
> 
> http://docs.ansible.com/faq.html#how-do-i-access-a-variable-name-programmatically
> 
> Instead of accessing a dict I would like to build up the variable name. For 
> example
> 
> - hosts: localhost
>   connection: local
>   vars:
>     test_app: admin
>     admin_port: 1234
>   tasks:
>     - debug:
>         msg: "Admin port = {{ test_app + '_port' }}"
> 
> This outputs
> 
> TASK: [debug ] 
> **************************************************************** 
> ok: [localhost] => {
>     "msg": "Admin port = admin_port"
> }
> 
> I would like to get the value of *admin_port*. So would need to do some 
> kind of double substitution. 

{{ hostvars[inventory_hostname][test_app + '_port'] }} i think

-- 
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/20141105163148.GK17066%40voodoowarez.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to