Imagine I have multiple hadoop clusters, each with a master node and a 
varying amount of slave nodes connected to it.
I want to dynamically discover the slaves from the master, and then perform 
actions on them in serial mode (only impact one node at a time to minimize 
downtime).

What's the right way to do this?

An almost-working approach is below, but I have a problem at "xxxxx". If I 
hardcode a master node name there, everything works. But I don't want to 
since that's silly and
there are lots of clusters. But I don't know how I can pass the master node 
name across the plays?

- hosts : hadoop_master_nodes   # run this on all master nodes
  tasks:
    - name: find targets
      shell: list_all_my_hadoop_nodes.sh   # show list of nodes connected 
to this master
      register: target_nodes
    - set_fact:
        target_nodes: "{{ target_nodes.stdout_lines }}"  # set a fact so we 
can call it from the next step

- hosts:  "{{ hostvars['xxxxxxxx']['target_nodes'] }}"  # call the list of 
target_nodes discovered above
  serial: 1
  tasks:
    - name: do whatever   # "do whatever" one at a time across all the 
target nodes
      .....

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/5a6caa7c-84bb-46ec-9740-2dd79c450620%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to