Hi Dick,
I have the same issue. Have you solved it?
On Saturday, April 26, 2014 at 7:18:59 PM UTC+2, Dick Davies wrote:
>
> Given the following inventory and variables:
>
> ansible-mesos:$ cat hosts
> ...
> [zookeepers]
> zk1.dom zk_id=1
> zk2.dom zk_id=2
> zk3.dom zk_id=3
> ....
>
> nsible-mesos:$ cat group_vars/all
> ...
> zk_client_port: 2181
> mesos_cluster: democluster
> .....
>
> I want to create a one-line file that looks like:
>
> zk://zk1.dom:2181,zk2.dom:2181,zk3.dom:2181/democluster
>
> groups['zookeepers'] holds the list of hostnames i want, so all i really
> need to do is map() each element to get a new list of
> 'fqdn:port' fragments and then join them with ','.
>
> But the best I could manage in an ansible template was:
>
> ansible-mesos:$ cat roles/mesos-common/templates/etc/mesos/zk.j2
> {# clanky hack ahoy! #}
> zk://{% for z in groups['zookeepers'] %}
> {{ hostvars[z][service_interface].ipv4.address }}:{{ zk_client_port
> }}{% if not loop.last %},{% endif %}
> {% endfor %}/{{ mesos_cluster }}
> ansible-mesos:$
>
> [ i can live with it in this case but annoyingly there are several other
> parts of the service configs that require the same hack and it's
> getting a bit ugly
> in there ]
>
> Is there something like pythons map() I can use in templates (ideally
> without requiring any Jinja add-ons)?
>
--
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/64ee97da-0776-4e18-b1e4-7d7afef3e0ff%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.