Skip to content

Instantly share code, notes, and snippets.

@prandelicious
Created March 22, 2018 09:37
Show Gist options
  • Save prandelicious/74940025f179ca00f03959514f82b020 to your computer and use it in GitHub Desktop.
Save prandelicious/74940025f179ca00f03959514f82b020 to your computer and use it in GitHub Desktop.
[Ansible] Aggregate results from multiple hosts into a single var for later use
---
- hosts: all
vars:
uuids: |
{%- set o=[] %}
{%- for i in play_hosts %}
{%- if o.append(hostvars[i].uuid) %}
{%- endif %}
{%- endfor %}
{{ o }}
tasks:
- name: get uuids for existing cluster nodes
shell: mysql -N -B -u {{ db_user }} -p {{ db_user_password }} -e "SHOW GLOBAL STATUS LIKE 'wsrep_cluster_state_uuid';" | sed 's/\t/,/g' | cut -f2 -d','
register: maria_cluster_uuids
- set_fact:
uuid: "{{ maria_cluster_uuids.stdout }}"
- debug:
var: uuids
run_once: true
delegate_to: 127.0.0.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment