There may be more elegant ways to achieve this, but I had a similar
requirement from some Eventstore config a while back and ended up with a
construct like:

# Construct each GossipSeed from ansible_play_hosts minus the inventory_host
{%- set seeds = [] %}
{%- for host in ansible_play_hosts %}
  {%- if host != inventory_hostname %}
    {{ seeds.append(hostvars[host]['ansible_host'] ~ ':2113') }}
  {%- endif %}
{%- endfor %}

GossipSeed: {{ seeds | join(',') }}

In your case you could maybe do something like (untested):

# Construct list of LDAP server URIs
{%- set ldap_sever_list = [] %}
{%- for server in ldapservers %}
    {{ ldap_sever_list.append('ldap://' ~ server ~ '/') }}
{%- endfor %}

URI: {{ ldap_server_list | join(',') }}


On Sun, 18 Aug 2024 at 14:45, Michael Starling <[email protected]>
wrote:

> Hello.
>
> Consider I have this variable list that can contain as little as 1 and up
> to 4 items.
>
> ldapservers:
>     - server1
>     - server2
>
>
> Consider this line in my ldap.conf template.
>
> URI ldap://{{ ldapservers(' ') }}/
>
>
> I would like the resulting file to look like this:
>
> URI ldap://server1/ ldap://server2/
>
> I know I can use "join" with something like this, but how do I keep the
> "URI" the " ldap://"; and the trailing "/" consistent without adding them to
> the variable.
>
> URI ldap://{{ ldap_srv_fqdn|join(' ') }}/
>
> Thanks in advance.
>
> Mike
>
> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/CAD8F6EndrOwpvRuOYWXauBQQ4xUs7-piNzwzNT1867AtaZLXmg%40mail.gmail.com
> <https://groups.google.com/d/msgid/ansible-project/CAD8F6EndrOwpvRuOYWXauBQQ4xUs7-piNzwzNT1867AtaZLXmg%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAKtKohRtu2ODVg%3DzPrRQC-L%2BbGA5eBm9juapG732GtrkdoL-_Q%40mail.gmail.com.

Reply via email to