Create overcloud_baremetal_deploy.yaml file properly

Currently the overcloud_baremetal_deploy does not match the
VMs with the flavor/role properly. The way that
currently creates the file may deploy the compute on
a ceph or a controller vm.

This way the vms will be used for the role that
they were created

Closes-Bug: #1949070
Change-Id: I4de262fc049b74482ff7220a11ec864133f1cb75
This commit is contained in:
Juan Badia Payno 2021-06-22 15:40:57 +02:00
parent da0cdfc957
commit d8622a2e52
2 changed files with 40 additions and 3 deletions

View File

@ -60,9 +60,19 @@
when: topology_map is defined
- name: Create overcloud baremetal deploy yaml
template:
src: "overcloud_baremetal_deploy.yaml.j2"
dest: "{{ working_dir }}/overcloud_baremetal_deploy.yaml"
block:
- name: Read instackenv.json file
command: cat "{{ working_dir }}/instackenv.json"
register: instackenv_json
- name: Set the baremetal nodes into a json var
set_fact:
baremetal_instackenv: "{{ instackenv_json.stdout | from_json }}"
- name: Create overcloud baremetal deploy yaml file
template:
src: "overcloud_baremetal_deploy.yaml.j2"
dest: "{{ working_dir }}/overcloud_baremetal_deploy.yaml"
when: baremetal_provision|bool and topology_map is defined
- name: Cloud names heat environment

View File

@ -7,6 +7,33 @@
{% if role_count %}
- name: {{ role }}
count: {{ role_count }}
{% if 'Controller' in role %}
{# (jbadiapa) The to_json | from_json is due to the ansible issue at #}
{# https://github.com/ansible/ansible/issues/27299 #}
{% if ( baremetal_instackenv | to_json | from_json | json_query("nodes[?contains(capabilities, 'profile:control')].name")| length > 0 ) %}
instances:
{% for instance in range (role_count): %}
- hostname: {{stack_name}}-{{role|lower}}-{{instance}}
name: {{ (baremetal_instackenv | to_json | from_json | json_query("nodes[?contains(capabilities, 'profile:control')].name"))[instance] }}
{% endfor %}
{% endif %}
{% elif 'Compute' in role %}
{% if (baremetal_instackenv | to_json | from_json | json_query("nodes[?contains(capabilities, 'profile:compute')].name")| length > 0 ) %}
instances:
{% for instance in range (role_count): %}
- hostname: {{stack_name}}-{{role|lower}}-{{instance}}
name: {{ (baremetal_instackenv | to_json | from_json | json_query("nodes[?contains(capabilities, 'profile:compute')].name"))[instance] }}
{% endfor %}
{% endif %}
{% elif 'Ceph' in role %}
{% if ( baremetal_instackenv | to_json | from_json | json_query("nodes[?contains(capabilities, 'profile:ceph')].name")| length > 0 ) %}
instances:
{% for instance in range (role_count): %}
- hostname: {{stack_name}}-{{role|lower}}-{{instance}}
name: {{ (baremetal_instackenv | to_json | from_json | json_query("nodes[?contains(capabilities, 'profile:ceph')].name"))[instance] }}
{% endfor %}
{% endif %}
{% endif %}
{% if role_profile or (network_config and network_provision|bool) or (role_networks and network_isolation and network_provision|bool) %}
defaults:
{% endif %}