% {{ ansible_managed }}

[{rabbit, [
  {log_levels, [{connection, info}]},
{% if RABBITMQ_CLUSTERED -%}
  {%- set hosts= [] -%}

  {%- for host in hostvars.keys() -%}
    {% do hosts.append("rabbit@ip-" + host.replace('.','-')) %}
  {%- endfor %}

  {cluster_nodes, {['{{ hosts|join("\',\'") }}'], disc}}

{%- else -%}
{# If rabbitmq_clustered_hosts is set, use that instead assuming an aws stack.
   Note: That these names should include the node name prefix. eg. 'rabbit@hostname'
#}
  {cluster_nodes, {['{{ rabbitmq_clustered_hosts|join("\',\'") }}'], disc}}
{%- endif %}
]}].
