1 {% set control_dict = {} %}
2 {% set compute_dict = {} %}
3 {% for host in groups['ostack'] %}
4 {% if hostvars[host].node_type is defined and hostvars[host].node_type == 'controller' %}
5 {% set control_dict = control_dict.update({hostvars[host].ansible_host: hostvars[host].ansible_default_ipv4.interface}) %}
8 {% for host in groups['ostack'] %}
9 {% if hostvars[host].node_type is defined and hostvars[host].node_type == 'compute' %}
10 {% for iface in hostvars[host].ansible_interfaces %}
11 {%- if ((hostvars[host]['ansible_' + iface.replace('-', '_')].ipv4 is defined) and
12 (hostvars[host]['ansible_' + iface.replace('-', '_')].ipv4.address is defined) and
13 (hostvars[host]['ansible_' + iface.replace('-', '_')].ipv4.address == hostvars[host].secondary_ip)) -%}
14 {% set compute_dict = compute_dict.update({hostvars[host].ansible_host: iface}) %}
19 {% macro print_node(in_dict, iface_str='', cnt=1) %}
20 {%- for host, iface in in_dict | dictsort -%}
21 {% if loop.index <= cnt %}
23 {{ host }} ansible_ssh_user={{ hostvars[host].ansible_user }} ansible_private_key_file=/root/.ssh/id_rsa ansible_become=True {{ iface_str }}={{ iface }}
25 {{ host }} ansible_ssh_user={{ hostvars[host].ansible_user }} ansible_private_key_file=/root/.ssh/id_rsa ansible_become=True
31 {{ print_node(control_dict, iface_str='network_interface', cnt=control_dict | length) }}
33 {{ print_node(compute_dict, iface_str='network_interface', cnt=compute_dict | length) }}
35 {{ print_node(control_dict, iface_str='', cnt=control_dict | length) }}
37 {{ print_node(control_dict) }}
39 {{ print_node(control_dict, iface_str='', cnt=control_dict | length) }}