Skip to content

Instantly share code, notes, and snippets.

@retr0h
Created September 22, 2015 23:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save retr0h/f25cf7f63dd4e812cd7c to your computer and use it in GitHub Desktop.
Save retr0h/f25cf7f63dd4e812cd7c to your computer and use it in GitHub Desktop.
rabbit_hosts: "{{ hostvars|fetch_list_from_dict(groups.aio)|map(attribute='ansible_internal_primary_interface.ipv4.address')|map('add_port', rabbitmq.port)|join(',') }}"
@paulczar
Copy link

my god have mercy on your soul.

@retr0h
Copy link
Author

retr0h commented Sep 22, 2015

Sure beats the shit out of something like.

-{% macro rabbitmq_hosts() -%}
-{% for host in groups[rabbitmq_group] -%}
-   {% if loop.last -%}
-'{{ rabbitmq_user }}@{{ hostvars[host]['ansible_hostname'] }}'
-   {%- else -%}
-'{{ rabbitmq_user }}@{{ hostvars[host]['ansible_hostname'] }}',
-   {%- endif -%}
-{% endfor -%}
-{% endmacro -%}

vs

+    {cluster_nodes, {[{{ hostvars|fetch_list_from_dict(groups[rabbitmq_group])|map(attribute='ansible_hostname')|map('add_at', rabbitmq_user)|map('to_quotes')|join(',') }}],disc} },

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment