Created
March 22, 2018 09:37
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
- 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