On 06/27/2014 11:27 AM, jepper wrote:
>
> I have the following defined in vars or defaults:
>
> fusemq_authentication:
>   - { 'username':'admin',     'password’:'blah',        
> 'groups':'admin' }
>   - { 'username':'LOGSTASH',  'password’:'bing',  'groups':'LOGSTASH' }
>
> I want to know the password for LOGSTASH in a template. Today I loop
> until I find it. Is there a simpler way?
>
> {% for value in fusemq_authentication %}
> {% if value.username=="LOGSTASH" %}
> fuseMQ_password={{ value.password }}
> {% endif %}
> {% endfor %}
>
> -- 
> 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]
> <mailto:[email protected]>.
> To post to this group, send email to [email protected]
> <mailto:[email protected]>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/72470009-3f65-4b70-85f1-e31c83b468bb%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/72470009-3f65-4b70-85f1-e31c83b468bb%40googlegroups.com?utm_medium=email&utm_source=footer>.
> For more options, visit https://groups.google.com/d/optout.

You could transform your data definition like this:

fusemq_users:
  admin:
    password: blah
    groups:
      - admin
  logstash:
    password: bing
    groups:
      - logstash

Then in a template you could access the password for 'logstash' user
like this:

{{ fusemq_users['logstash']['password'] }} or {{
fusemq_users.logstash.password }}

-- 
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/53AD35FF.4070003%40yahoo.gr.
For more options, visit https://groups.google.com/d/optout.

Reply via email to