0

I try to fill the ansible (jinja) template with a comma-separated list of all hosts in the group 'lan-msqservers'.

<add key="MessageBus:LanConnectionString" value="host=host1.fqdn,host2.fqdn,host3.fqdn;virtualHost=/;username=user;password=passwd;timeout=60" />

I tried:

host='{{ groups[lan-msqservers][0] }}','{{ groups[lan-msqservers][1]}}';

host=groups['lan-msqservers'][0]],groups['lan-msqservers'][1]];

Without success.

can anyone help?

Niko E.
  • 1
  • 1
  • i don't need a list like that. even not if it's joined by comma. i want to read all hostsnames from ansible inventory and put it info this template. – Niko E. Feb 27 '18 at 13:58
  • the solution is: host={% for host in groups['lan-msqservers'] %}{{ host }}{% if not loop.last %},{% endif %}{% endfor %} – Niko E. Feb 27 '18 at 14:27

0 Answers0