Skip to content

Commit 93de89d

Browse files
hjensasopenshift-merge-bot[bot]
authored andcommitted
Reprocuder: write ironic_nodes.yaml
In the reproducer role's `generate_bm_info.yaml` add another task to write the YAML required to enroll nodes in Openstack ironic. The ironic file is only written if `cifmw_reproducer_ironic_node_name_prefix` is set. The `cifmw_reproducer_ironic_node_name_prefix` is used to filter from libvirt_manager_bm_info_data so that only the nodes where the name startswith the value of this option is added to the ironic_nodes.yaml. Related: OSPRH-12093
1 parent eab8350 commit 93de89d

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

roles/reproducer/defaults/main.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,5 @@ cifmw_reproducer_controller_basedir: >-
5151
cifmw_reproducer_validate_network: true
5252
cifmw_reproducer_validate_network_host: "controller-0.utility"
5353
cifmw_reproducer_validate_ocp_layout: true
54+
55+
cifmw_reproducer_ironic_node_name_prefix:

roles/reproducer/tasks/generate_bm_info.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,3 +121,33 @@
121121
dest: "{{ cifmw_reproducer_controller_basedir }}/parameters/baremetal-info.yml"
122122
content: "{{ _content | to_nice_yaml }}"
123123
mode: "0644"
124+
125+
- name: Output ironic_nodes to file
126+
when: cifmw_reproducer_ironic_node_name_prefix
127+
ansible.builtin.copy:
128+
dest: "{{ cifmw_basedir }}/parameters/ironic_nodes.yaml"
129+
content: |
130+
{% set _ironic_nodes = [] %}
131+
{% for node in libvirt_manager_bm_info_data.keys() if node.startswith(cifmw_reproducer_ironic_node_name_prefix) %}
132+
{% set _node = libvirt_manager_bm_info_data[node] %}
133+
{% set _conn = _node.connection | urlsplit %}
134+
{% set _ironic_nodes = _ironic_nodes.append(
135+
{
136+
'name': node,
137+
'driver': 'redfish',
138+
'driver_info': {
139+
'redfish_address': (_conn.scheme | split('+') | last) + '://' + _conn.hostname + ':' + (_conn.port | string),
140+
'redfish_system_id': (_node.connection | urlsplit).path,
141+
'redfish_username': _node.username,
142+
'redfish_password': _node.password,
143+
},
144+
'ports': [
145+
{
146+
'address': (_node.nics | first).mac,
147+
'physical_network': (_node.nics | first).network,
148+
}
149+
]
150+
}
151+
) %}
152+
{% endfor %}
153+
{{ {'nodes': _ironic_nodes } | to_nice_yaml(indent=2) }}

0 commit comments

Comments
 (0)