Register overcloud hosts in Bifrost
This patch adds functionality to enroll baremetal nodes in Bifrost using the Kayobe CLI `kayobe overcloud hardware register` similar to the registration workflow available in Overcloud Ironic using 'kayobe baremetal compute register'. Co-Authored-By: Matt Anson <matta@stackhpc.com> Change-Id: I412cf9ccf4c41c89405c904b41b04e64f234e7de Signed-off-by: Hollie Hutchinson <hollie@stackhpc.com>
This commit is contained in:
1 parent
3af169b943
commit
bc795c1884
6 files changed
+149
No files matched your search
@@ -0,0 +1,61 @@
|
||||
---
|
||||
- name: Ensure overcloud hosts are registered in Bifrost
|
||||
hosts: overcloud
|
||||
gather_facts: false
|
||||
vars:
|
||||
seed_host: "{{ groups['seed'][0] }}"
|
||||
# Try to reduce contention on Bifrost and resolve db lock errors
|
||||
serial: 10
|
||||
tasks:
|
||||
- name: Fail when no supported drivers are available
|
||||
ansible.builtin.fail:
|
||||
msg: This node uses an unsupported or undefined driver, only Redfish is supported.
|
||||
when:
|
||||
- ironic_driver | default ('') not in ['redfish']
|
||||
|
||||
- name: List baremetal nodes
|
||||
command: >
|
||||
{{ container_engine }} exec bifrost_deploy
|
||||
bash -c '
|
||||
export OS_CLOUD=bifrost &&
|
||||
openstack baremetal node show {{ inventory_hostname }}'
|
||||
register: node_show
|
||||
failed_when: false
|
||||
changed_when: false
|
||||
delegate_to: "{{ seed_host }}"
|
||||
vars:
|
||||
ansible_host: "{{ hostvars[seed_host].ansible_host | default(seed_host) }}"
|
||||
|
||||
- name: Create baremetal nodes
|
||||
command: >
|
||||
{{ container_engine }} exec bifrost_deploy
|
||||
bash -c '
|
||||
export OS_CLOUD=bifrost &&
|
||||
openstack baremetal node create
|
||||
--driver {{ ironic_driver }}
|
||||
{% for key, value in ironic_driver_info.items() %}
|
||||
--driver-info {{ key }}={{ value }}
|
||||
{% endfor %}
|
||||
{% for key, value in ironic_properties.items() %}
|
||||
--property {{ key }}={{ value }}
|
||||
{% endfor %}
|
||||
--name {{ inventory_hostname }}'
|
||||
delegate_to: "{{ seed_host }}"
|
||||
vars:
|
||||
ansible_host: "{{ hostvars[seed_host].ansible_host | default(seed_host) }}"
|
||||
when:
|
||||
- node_show.rc != 0
|
||||
|
||||
- name: Manage baremetal nodes
|
||||
command: >
|
||||
{{ container_engine }} exec bifrost_deploy
|
||||
bash -c '
|
||||
export OS_CLOUD=bifrost &&
|
||||
openstack baremetal node manage
|
||||
{{ inventory_hostname }}
|
||||
--wait'
|
||||
delegate_to: "{{ seed_host }}"
|
||||
vars:
|
||||
ansible_host: "{{ hostvars[seed_host].ansible_host | default(seed_host) }}"
|
||||
when:
|
||||
- node_show.rc != 0
|
||||
@@ -468,6 +468,52 @@ to add them to the Kayobe and Kolla-Ansible inventories::
|
||||
naming Ironic nodes via switch port descriptions, Ironic Inspector and
|
||||
LLDP.
|
||||
|
||||
Registration
|
||||
------------
|
||||
|
||||
This workflow acts as an alternative to enrolling nodes through discovery where
|
||||
nodes can be registered in Bifrost via Kayobe given these nodes are defined in
|
||||
the Kayobe inventory.
|
||||
|
||||
A group_vars file for the `overcloud` group should be created which contains the Ironic
|
||||
variables, this should be in ``etc/kayobe/inventory/group_vars/overcloud/ironic_vars`` or
|
||||
in the environment you are using.
|
||||
|
||||
.. code-block:: yaml
|
||||
|
||||
ironic_driver: redfish
|
||||
|
||||
ironic_driver_info:
|
||||
redfish_system_id: "{{ ironic_redfish_system_id }}"
|
||||
redfish_address: "{{ ironic_redfish_address }}"
|
||||
redfish_username: "{{ ironic_redfish_username }}"
|
||||
redfish_password: "{{ ironic_redfish_password }}"
|
||||
redfish_verify_ca: "{{ ironic_redfish_verify_ca }}"
|
||||
ipmi_address: "{{ ipmi_address }}"
|
||||
|
||||
ironic_properties:
|
||||
capabilities: "{{ ironic_capabilities }}"
|
||||
|
||||
ironic_resource_class: "example_resouce_class"
|
||||
ironic_redfish_system_id: "/redfish/v1/Systems/System.Embedded.1"
|
||||
ironic_redfish_verify_ca: "{{ inspector_rule_var_redfish_verify_ca }}"
|
||||
ironic_redfish_address: "{{ ipmi_address }}"
|
||||
ironic_redfish_username: "{{ inspector_redfish_username }}"
|
||||
ironic_redfish_password: "{{ inspector_redfish_password }}"
|
||||
ironic_capabilities: "boot_option:local,boot_mode:uefi"
|
||||
|
||||
It's essential that the Ironic username and password match the BMC username
|
||||
and password for your nodes, if the username and password combination is
|
||||
not the same for the entire group you will need to adjust your configuration
|
||||
accordingly. The IPMI address should also match the BMC address for your node.
|
||||
Once this has been completed you can begin enrolling the Ironic nodes::
|
||||
|
||||
(kayobe) $ kayobe overcloud hardware register
|
||||
|
||||
Inspector is not used to discover nodes and no node inspection will take place on
|
||||
enrollment, nodes will automatically be placed into ``manageable`` state. To inspect,
|
||||
you should use ``kayobe overcloud hardware inspect`` following enrollment.
|
||||
|
||||
Saving Hardware Introspection Data
|
||||
----------------------------------
|
||||
|
||||
|
||||
@@ -1303,6 +1303,16 @@ class OvercloudBIOSRAIDConfigure(KayobeAnsibleMixin, VaultMixin, Command):
|
||||
self.run_kayobe_playbooks(parsed_args, playbooks)
|
||||
|
||||
|
||||
class OvercloudHardwareRegister(KayobeAnsibleMixin, VaultMixin, Command):
|
||||
"""Register overcloud hosts in Bifrost"""
|
||||
|
||||
def take_action(self, parsed_args):
|
||||
self.app.LOG.debug("Registering overcloud hosts in Bifrost")
|
||||
playbooks = _build_playbook_list("kolla-bifrost-hostvars",
|
||||
"overcloud-hardware-register")
|
||||
self.run_kayobe_playbooks(parsed_args, playbooks)
|
||||
|
||||
|
||||
class OvercloudHardwareInspect(KayobeAnsibleMixin, VaultMixin, Command):
|
||||
"""Inspect the overcloud hardware using ironic inspector.
|
||||
|
||||
|
||||
@@ -1244,6 +1244,29 @@ class TestCase(unittest.TestCase):
|
||||
]
|
||||
self.assertListEqual(expected_calls, mock_run.call_args_list)
|
||||
|
||||
@mock.patch.object(commands.KayobeAnsibleMixin,
|
||||
"run_kayobe_playbooks")
|
||||
def test_overcloud_hardware_register(self, mock_run):
|
||||
command = commands.OvercloudHardwareRegister(TestApp(), [])
|
||||
parser = command.get_parser("test")
|
||||
parsed_args = parser.parse_args([])
|
||||
|
||||
result = command.run(parsed_args)
|
||||
self.assertEqual(0, result)
|
||||
|
||||
expected_calls = [
|
||||
mock.call(
|
||||
mock.ANY,
|
||||
[
|
||||
utils.get_data_files_path(
|
||||
"ansible", "kolla-bifrost-hostvars.yml"),
|
||||
utils.get_data_files_path(
|
||||
"ansible", "overcloud-hardware-register.yml"),
|
||||
],
|
||||
),
|
||||
]
|
||||
self.assertListEqual(expected_calls, mock_run.call_args_list)
|
||||
|
||||
@mock.patch.object(commands.KayobeAnsibleMixin,
|
||||
"run_kayobe_playbooks")
|
||||
def test_overcloud_hardware_inspect(self, mock_run):
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
---
|
||||
features:
|
||||
- |
|
||||
Adds a new ``kayobe overcloud hardware register`` command to enroll
|
||||
overcloud hosts in Bifrost based on nodes defined in the Kayobe
|
||||
inventory.
|
||||
@@ -67,6 +67,7 @@ kayobe.cli=
|
||||
overcloud_deprovision = kayobe.cli.commands:OvercloudDeprovision
|
||||
overcloud_facts_gather = kayobe.cli.commands:OvercloudFactsGather
|
||||
overcloud_hardware_inspect = kayobe.cli.commands:OvercloudHardwareInspect
|
||||
overcloud_hardware_register = kayobe.cli.commands:OvercloudHardwareRegister
|
||||
overcloud_host_configure = kayobe.cli.commands:OvercloudHostConfigure
|
||||
overcloud_host_image_build = kayobe.cli.commands:OvercloudHostImageBuild
|
||||
overcloud_host_package_update = kayobe.cli.commands:OvercloudHostPackageUpdate
|
||||
@@ -172,6 +173,8 @@ kayobe.cli.overcloud_facts_gather =
|
||||
hooks = kayobe.cli.commands:HookDispatcher
|
||||
kayobe.cli.overcloud_hardware_inspect =
|
||||
hooks = kayobe.cli.commands:HookDispatcher
|
||||
kayobe.cli.overcloud_hardware_register =
|
||||
hooks = kayobe.cli.commands:HookDispatcher
|
||||
kayobe.cli.overcloud_host_configure =
|
||||
hooks = kayobe.cli.commands:HookDispatcher
|
||||
kayobe.cli.overcloud_host_image_build =
|
||||
|
||||
Reference in new issue
Block a user