Thank you both for the suggestions. Much appreciated.

On Sun, Aug 18, 2024 at 12:05 PM Vladimir Botka <[email protected]> wrote:

> On Sun, 18 Aug 2024 15:11:11 +0100
> Will McDonald <[email protected]> wrote:
>
> > There may be more elegant ways to achieve this
>
> The below declaration should to the job
>
>     seeds: "{{ ansible_play_hosts |
>                difference([inventory_hostname]) |
>                map('extract', hostvars, 'ansible_host') |
>                product([':2113']) |
>                map('join') |
>                join(',') }}"
>
> > {%- set seeds = [] %}
> > {%- for host in ansible_play_hosts %}
> >   {%- if host != inventory_hostname %}
> >     {{ seeds.append(hostvars[host]['ansible_host'] ~ ':2113') }}
> >   {%- endif %}
> > {%- endfor %}
> >
> > GossipSeed: {{ seeds | join(',') }}
>
> For example, given the inventory
>
>
>   shell> cat hosts
>   host_A ansible_host=10.1.0.51
>   host_B ansible_host=10.1.0.52
>   host_C ansible_host=10.1.0.53
>
> the below play
>
>   - hosts: all
>     vars:
>       seeds: "{{ ansible_play_hosts |
>                  difference([inventory_hostname]) |
>                  map('extract', hostvars, 'ansible_host') |
>                  product([':2113']) |
>                  map('join') |
>                  join(',') }}"
>     tasks:
>       - debug:
>           var: seeds
>
> gives (abridged)
>
> ok: [host_A] =>
>   seeds: 10.1.0.53:2113,10.1.0.52:2113
> ok: [host_B] =>
>   seeds: 10.1.0.53:2113,10.1.0.51:2113
> ok: [host_C] =>
>   seeds: 10.1.0.51:2113,10.1.0.52:2113
>
> HTH,
>
> --
> Vladimir Botka
>
> --
> 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/20240818180500.6cbdd318%40gmail.com
> .
>

-- 
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/CAD8F6EmpSMCgxg3GfEuP-q2KR%2BX%2Bwtprs%3DiyNqid%2BdgQW7iiRg%40mail.gmail.com.

Reply via email to