text: ---
  - set_fact: outer_loop="{{ item }}"
  
  - name: Add nodes to hadoop-cluster and {{ outer_loop.host_group }} groups
    add_host:
      name: "{{ hostvars[local_loop].openstack.name }}"
      ansible_host: "{{ (outer_loop.public_ip|default(false)== true) | ternary(hostvars[local_loop].openstack.public_v4,hostvars[local_loop].openstack.private_v4) }}"
      ansible_user: "{{ cloud_config.admin_username|default('root') }}"
      ansible_ssh_private_key_file: "{{ cloud_config.ssh.privatekey }}"
      ansible_become_user: root
      groups: hadoop-cluster, {{ outer_loop.host_group }}
    loop_control:
      loop_var: local_loop
    when: outer_loop.count > 0
    with_items: "{{ groups['meta-Group_'~cluster_name~'-'~outer_loop.host_group] }}"
  