-
Notifications
You must be signed in to change notification settings - Fork 114
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for Sushy Emulator backed virtual baremetal
This patch enables Redfish BMC control of VMs deployed via the reproducer layout. Sushy Emulator is deployed onto the Ansible controller as a Podman Pod and access' the hypervisor's libvirt socket via SSH. - `cifmw_use_sushy_emulator` parameter is added to control the deployment of Sushy Emulator in the reproducer and set to true. - `cifmw_use_vbmc` parameter is added to control the deployment of Virtual BMC in the reproducer and behavoir changed to default to false. - sushy_emulator role now creates and uses it's own ssh keypair to to communicate with the hypervisor - `baremetal-info.yml` creation has now been extracted into it's own task file and enhanced to support adding new baremetal hosts entries resulting from scaling or additional hosts for baremetal instances. - Sushy Emulator verification has now moved to it's own task file and tests both Sushy Emulator connection and connection to each host. - sushy_emulator role now uses the `cifmw_libvirt_manager_uuids` fact to filter vms rather than using an additional `virsh` call. This means `libvirt-client` can be removed from the packages list to install. - Add `cifmw_sushy_redfish_bmc_protocol` param to control the bmc protocol Sushy Emulator uses. Jira: OSPRH-6497
- Loading branch information
1 parent
1f4d358
commit 2331546
Showing
18 changed files
with
422 additions
and
161 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
- name: Extract IP address from network bridges | ||
community.general.xml: | ||
xmlstring: "{{ item.xml }}" | ||
xpath: /network/ip | ||
content: attribute | ||
register: networkxml | ||
|
||
- name: Set network_bridge_info fact with network and address | ||
ansible.builtin.set_fact: | ||
network_bridge_info: "{{ network_bridge_info | default({}) | combine( {item.name: networkxml.matches[0].ip.address} ) }}" |
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
--- | ||
- name: Ensure directories exist | ||
ansible.builtin.file: | ||
path: "{{ cifmw_reproducer_controller_basedir }}/{{ item }}" | ||
state: directory | ||
mode: "0755" | ||
loop: | ||
- parameters | ||
- artifacts | ||
|
||
- name: Convert VBMC list into a dict for better usage | ||
when: | ||
- cifmw_use_vbmc | default(false) | bool | ||
- cifmw_virtualbmc_known_hosts is defined | ||
vars: | ||
keys: "{{ item.keys() | difference(['Domain name']) }}" | ||
vals: "{{ keys | map('extract', item) | list }}" | ||
value: "{{ dict(keys | map('lower') | zip(vals)) }}" | ||
_host: "{{ item['Domain name'] | regex_replace('^cifmw-', '') }}" | ||
ansible.builtin.set_fact: | ||
_vbmc_info_dict: >- | ||
{{ | ||
_vbmc_info_dict | default({}) | | ||
combine({_host: value}, recursive=true) | ||
}} | ||
cacheable: false | ||
loop: "{{ cifmw_virtualbmc_known_hosts }}" | ||
|
||
- name: Check if baremetal-info.yml exists | ||
register: _stat_baremetal_info_file | ||
ansible.builtin.stat: | ||
path: "{{ cifmw_reproducer_controller_basedir }}/parameters/baremetal-info.yml" | ||
|
||
- name: Slurp current baremetal-info file into _oringal_cifmw_baremetal_hosts var | ||
when: _stat_baremetal_info_file.stat.exists | ||
block: | ||
- name: Get content of baremetal-info file | ||
ansible.builtin.slurp: | ||
src: "{{ cifmw_reproducer_controller_basedir }}/parameters/baremetal-info.yml" | ||
register: _baremetal_info_file | ||
|
||
- name: Interpret remote file content as yaml | ||
vars: | ||
_yaml: "{{ _baremetal_info_file.content | b64decode | from_yaml }}" | ||
ansible.builtin.set_fact: | ||
_oringal_cifmw_baremetal_hosts: "{{ _yaml.cifmw_baremetal_hosts }}" | ||
|
||
- name: Load cifmw_libvirt_manager_mac_map fact from file | ||
vars: | ||
_file: "{{ cifmw_reproducer_controller_basedir }}/artifacts/interfaces-info.yml" | ||
when: | ||
- cifmw_libvirt_manager_mac_map is not defined | ||
block: | ||
- name: "Slurp content of: {{ _file }}" | ||
ansible.builtin.slurp: | ||
src: "{{ _file }}" | ||
register: _slurped_file | ||
|
||
- name: "Set cifmw_libvirt_manager_mac_map fact from {{ _file }}" | ||
vars: | ||
_yaml: "{{ _slurped_file.content | b64decode | from_yaml }}" | ||
ansible.builtin.set_fact: | ||
cifmw_libvirt_manager_mac_map: "{{ _yaml }}" | ||
|
||
|
||
# In this task we combine information from _layout, cifmw_libvirt_manager_mac_map | ||
# and cifmw_libvirt_manager_uuids to create the libvirt_manager_bm_info_data fact. | ||
# to create the `baremetal-info.yml` file which is used as a source of truth for | ||
# for baremetal nodes. If `baremetal-info.yml` already exists we combine | ||
# `_oringal_cifmw_baremetal_hosts` with the updated hosts and override | ||
# `baremetal-info.yml` | ||
- name: Generate libvirt_manager_bm_info_data fact | ||
when: item.key is match('cifmw-') | ||
vars: | ||
_host: "{{ item.key | replace('cifmw-', '') }}" | ||
_uefi: >- | ||
{% set _type = _host | regex_replace('-[0-9]+$', '') -%} | ||
{{ _layout.vms[_type].uefi | default(false) | bool }} | ||
_data: | | ||
"{{ _host }}": | ||
boot_mode: "{{ _uefi | ternary('UEFI', 'legacy') }}" | ||
uuid: "{{ item.value }}" | ||
{% if cifmw_use_vbmc | default(false) | bool %} | ||
address: "{{ _vbmc_info_dict[_host].address }}" | ||
connection: "ipmi://{{ _vbmc_info_dict[_host].address }}:{{ _vbmc_info_dict[_host].port }}" | ||
password: "{{ _vbmc_info_dict[_host].password }}" | ||
port: {{ _vbmc_info_dict[_host].port | int }} | ||
username: "{{ _vbmc_info_dict[_host].username }}" | ||
{% elif cifmw_use_sushy_emulator | default(true) | bool %} | ||
{% if item.value in _cifmw_sushy_emulator_instances | default([]) %} | ||
connection: "{{ cifmw_sushy_redfish_bmc_protocol | default('redfish-virtualmedia') ~ '+' ~ _sushy_url }}/redfish/v1/Systems/{{ item.value }}" | ||
username: "{{ cifmw_redfish_username | default('admin') }}" | ||
password: "{{ cifmw_redfish_password | default('password') }}" | ||
{% endif %} | ||
{% endif %} | ||
_with_nics: >- | ||
{{ | ||
_data | from_yaml | | ||
combine({_host: {'nics': cifmw_libvirt_manager_mac_map[_host]}}, | ||
recursive=true) | ||
}} | ||
ansible.builtin.set_fact: | ||
libvirt_manager_bm_info_data: >- | ||
{{ | ||
libvirt_manager_bm_info_data | default({}) | | ||
combine((_with_nics | from_yaml), recursive=true) | | ||
combine((_oringal_cifmw_baremetal_hosts | default({}) | from_yaml), recursive=true) | ||
}} | ||
loop: "{{ cifmw_libvirt_manager_uuids | dict2items }}" | ||
|
||
- name: Output baremetal info file | ||
vars: | ||
_content: | ||
cifmw_baremetal_hosts: "{{ libvirt_manager_bm_info_data }}" | ||
ansible.builtin.copy: | ||
dest: "{{ cifmw_reproducer_controller_basedir }}/parameters/baremetal-info.yml" | ||
content: "{{ _content | to_nice_yaml }}" | ||
mode: "0644" |
This file contains 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
This file contains 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
Oops, something went wrong.