-
Notifications
You must be signed in to change notification settings - Fork 23
Skc baremetal environment #2017
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
3eeadec
f190830
4725d97
6f7e510
ea55fc3
a7df156
02e6321
cb543de
bb16a3e
7b62965
d89cc63
8071839
9ced382
0e41ba3
b0bc901
f83cfa4
6b51b00
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| #todo |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| --- | ||
|
|
||
| - name: Register baremetal compute nodes | ||
| hosts: "{{ groups['controllers'][0] }}" | ||
| vars: | ||
| venv: "{{ virtualenv_path }}/openstack-cli" | ||
| tasks: | ||
| - name: Set up openstack cli virtualenv | ||
| pip: | ||
| virtualenv: "{{ venv }}" | ||
| name: | ||
| - python-openstackclient | ||
| - python-ironicclient | ||
| state: latest | ||
| virtualenv_command: "python3.{{ ansible_facts.python.version.minor }} -m venv" | ||
| extra_args: "{% if pip_upper_constraints_file %}-c {{ pip_upper_constraints_file }}{% endif %}" | ||
|
|
||
| - name: Ensure overcloud baremetal nodes are registered in ironic | ||
| hosts: baremetal-overcloud | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Its probably worth a quick comment here to note that this is because "kayobe baremetal compute register" doesn't currently touch the overcloud nodes, but we want them here.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. change host to baremetal |
||
| gather_facts: false | ||
| max_fail_percentage: >- | ||
| {{ baremetal_compute_register_max_fail_percentage | | ||
| default(baremetal_compute_max_fail_percentage) | | ||
| default(kayobe_max_fail_percentage) | | ||
| default(100) }} | ||
| tags: | ||
| - baremetal | ||
| vars: | ||
| venv: "{{ virtualenv_path }}/openstack-cli" | ||
| #todo: extract this as a variable | ||
| controller_host: "{{ groups['controllers'][0] }}" | ||
| tasks: | ||
| - name: Check Ironic variables are defined | ||
| ansible.builtin.assert: | ||
| that: | ||
| - ironic_driver is defined | ||
| - ironic_driver_info is defined | ||
| - ironic_properties is defined | ||
| - ironic_resource_class is defined | ||
| fail_msg: One or more Ironic variables are undefined. | ||
|
|
||
| - block: | ||
| - name: Show baremetal node | ||
| ansible.builtin.command: | ||
| cmd: "{{ venv }}/bin/openstack baremetal node show {{ inventory_hostname }}" | ||
| register: node_show | ||
| failed_when: | ||
| - '"HTTP 404" not in node_show.stderr' | ||
| - node_show.rc != 0 | ||
| changed_when: false | ||
|
|
||
| # NOTE: The openstack.cloud.baremetal_node module cannot be used in this | ||
| # script due to requiring a MAC address pre-defined, instead, this should | ||
| # be discovered by inpsection following this script. | ||
| # | ||
| # NOTE: IPMI address must be passed with Redfish address to ensure existing | ||
| # Ironic nodes match with new nodes during inspection. | ||
| - name: Create baremetal nodes | ||
| ansible.builtin.shell: | ||
| cmd: | | ||
| {{ venv }}/bin/openstack baremetal node create \ | ||
| --name {{ inventory_hostname }} \ | ||
| --driver {{ ironic_driver }} \ | ||
| {% for key, value in ironic_driver_info.items() %} | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. actually maybe don't do this as a dictionary, so fix the omit. |
||
| --driver-info {{ key }}={{ value }} \ | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. --driver-info refish_username = {{ ironic_redfish_username }} |
||
| {% endfor %} | ||
| {% for key, value in ironic_properties.items() %} | ||
| --property {{ key }}={{ value }} \ | ||
| {% endfor %} | ||
| --resource-class {{ ironic_resource_class }} | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we need to extend this to allow us to specify all the interfaces that match the driver e.g. boot-interface, inspect-interface, etc. Annoyingly this means we should change this playbook to run over both compute nodes and baremetal nodes for now.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. add for other variable {% if ironic_management_interface %} and then ironic_management_interface defined in group_vars/baremetal-redfish/ironic |
||
| when: | ||
| - node_show.rc != 0 | ||
|
|
||
| - name: Manage baremetal nodes | ||
| ansible.builtin.command: | ||
| cmd: "{{ venv }}/bin/openstack baremetal node manage {{ inventory_hostname }} --wait" | ||
| when: | ||
| - node_show.rc != 0 | ||
| delegate_to: "{{ controller_host }}" | ||
| vars: | ||
| # NOTE: Without this, the controller's ansible_host variable will not | ||
| # be respected when using delegate_to. | ||
| ansible_host: "{{ hostvars[controller_host].ansible_host | default(controller_host) }}" | ||
| environment: "{{ openstack_auth_env }}" | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,129 @@ | ||
| --- | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we should maybe rename these steps as 10,20,30,40... to allow people to add things in the middle. |
||
| - name: Check baremetal compute node bmc is up | ||
| hosts: baremetal | ||
| gather_facts: false | ||
| max_fail_percentage: >- | ||
| {{ baremetal_compute_register_max_fail_percentage | | ||
| default(baremetal_compute_max_fail_percentage) | | ||
| default(kayobe_max_fail_percentage) | | ||
| default(100) }} | ||
| tags: | ||
| - baremetal | ||
| vars: | ||
| venv: "{{ virtualenv_path }}/openstack-cli" | ||
| controller_host: "{{ groups['controllers'][0] }}" | ||
|
|
||
| tasks: | ||
| - name: Check Ironic variables are defined | ||
| ansible.builtin.assert: | ||
| that: | ||
| - ironic_driver is defined | ||
| - ironic_driver_info is defined | ||
| - ironic_properties is defined | ||
| - ironic_resource_class is defined | ||
| fail_msg: One or more Ironic variables are undefined. | ||
|
|
||
| - name: Show and check baremetal node | ||
| delegate_to: "{{ controller_host }}" | ||
| vars: | ||
| # NOTE: Without this, the controller's ansible_host variable will not | ||
| # be respected when using delegate_to. | ||
| ansible_host: "{{ hostvars[controller_host].ansible_host | default(controller_host) }}" | ||
| environment: "{{ openstack_auth_env }}" | ||
| block: | ||
|
|
||
| - name: Show baremetal node | ||
| ansible.builtin.command: | ||
| cmd: "{{ venv }}/bin/openstack baremetal node show {{ inventory_hostname }} -f json" | ||
| register: node_show | ||
| failed_when: | ||
| - node_show.rc != 0 | ||
| changed_when: false | ||
|
|
||
| - name: Check if bmc is up | ||
| ansible.builtin.set_fact: | ||
| kayobe_bmc_up: "{{ (node_show.stdout | from_json)['extra'].get('kayobe_bmc_up') }}" | ||
| provision_state: "{{ (node_show.stdout | from_json)['provision_state'] }}" | ||
|
|
||
| - name: Output when bmc last up run | ||
| ansible.builtin.debug: | ||
| msg: "BMC for node {{ inventory_hostname }} was up at {{ kayobe_bmc_up }}." | ||
| when: kayobe_bmc_up != "" | ||
|
|
||
| - name: Check BMC is up | ||
| ansible.builtin.uri: | ||
| url: "{{ ironic_driver_info['redfish_address'] + '/redfish/v1' }}" | ||
| method: GET | ||
| status_code: 200 | ||
| validate_certs: false | ||
| timeout: 10 | ||
|
|
||
| - name: Get firmware inventory (to check redfish auth) | ||
claudia-lola marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| community.general.redfish_info: | ||
| category: Update | ||
| command: GetFirmwareInventory | ||
| baseuri: "{{ ironic_redfish_address }}" | ||
| username: "{{ ironic_redfish_username }}" | ||
| password: "{{ ironic_redfish_password }}" | ||
| when: ironic_redfish_username is defined | ||
| register: firmware_inventory | ||
| failed_when: not firmware_inventory.redfish_facts.firmware.ret | ||
|
|
||
| # - name: Print fetched information | ||
| # ansible.builtin.debug: | ||
| # msg: "{{ firmware_inventory.redfish_facts.firmware | to_nice_json }}" | ||
|
|
||
| - name: Reboot BMC | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. as above, I think we need to remove this for now, until we have a generic version. Its possible we could add this as an extra step.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe we should add something here, like a TODO, saying lets add an optional BMC reboot into the flow here. |
||
| community.general.redfish_command: | ||
| category: Manager | ||
| command: PowerReboot | ||
| resource_id: 1 | ||
claudia-lola marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| baseuri: "{{ ironic_redfish_address }}" | ||
| username: "{{ ironic_redfish_username }}" | ||
| password: "{{ ironic_redfish_password }}" | ||
| when: | ||
| - kayobe_bmc_up == "" | ||
| - ironic_redfish_username is defined | ||
|
|
||
| # - name: Wait 300 seconds for port 443 to become open | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we don't need these we should remove them I think.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. +1 lets remove it. |
||
| # ansible.builtin.wait_for: | ||
| # port: 443 | ||
| # host: "{{ ironic_redfish_address }}" | ||
| # delay: 20 | ||
| # timeout: 300 | ||
| # when: | ||
| # - kayobe_bmc_up == "" | ||
| # - ironic_redfish_username is defined | ||
|
|
||
| - name: Check BMC back up again | ||
| ansible.builtin.uri: | ||
| url: "{{ ironic_driver_info['redfish_address'] }}/redfish/v1" | ||
| method: GET | ||
| status_code: 200 | ||
| validate_certs: false | ||
| timeout: 10 | ||
| register: uri_output | ||
| until: uri_output.status == 200 | ||
| delay: 5 | ||
claudia-lola marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| retries: 24 # Retries for 24 * 5 seconds = 120 seconds = 2 minutes | ||
|
|
||
| - name: Note when we are able to reach the bmc, the first time | ||
| ansible.builtin.command: | ||
| cmd: | | ||
| {{ venv }}/bin/openstack baremetal node set {{ inventory_hostname }} --extra kayobe_bmc_up={{ now(utc=true, fmt='%Y-%m-%dT%H:%M:%SZ') }} | ||
| register: node_set | ||
| failed_when: | ||
| - node_set.rc != 0 | ||
| changed_when: true | ||
| when: kayobe_bmc_up == "" | ||
|
|
||
| - name: Try move from enroll to manageable | ||
| ansible.builtin.command: | ||
| cmd: | | ||
| {{ venv }}/bin/openstack baremetal node manage {{ inventory_hostname }} --wait 300 | ||
| register: node_set | ||
| failed_when: | ||
| - node_set.rc != 0 | ||
| changed_when: true | ||
| when: | ||
| - provision_state == "enroll" | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,86 @@ | ||
| --- | ||
| - name: Check baremetal compute node bmc is up | ||
| hosts: baremetal | ||
| gather_facts: false | ||
| max_fail_percentage: >- | ||
| {{ baremetal_compute_register_max_fail_percentage | | ||
| default(baremetal_compute_max_fail_percentage) | | ||
| default(kayobe_max_fail_percentage) | | ||
| default(100) }} | ||
| tags: | ||
| - baremetal | ||
| vars: | ||
| venv: "{{ virtualenv_path }}/openstack-cli" | ||
| controller_host: "{{ groups['controllers'][0] }}" | ||
|
|
||
| tasks: | ||
| - name: Show and check baremetal node | ||
| delegate_to: "{{ controller_host }}" | ||
| vars: | ||
| # NOTE: Without this, the controller's ansible_host variable will not | ||
| # be respected when using delegate_to. | ||
| ansible_host: "{{ hostvars[controller_host].ansible_host | default(controller_host) }}" | ||
| redfish_inspect_timeout: 120 | ||
| environment: "{{ openstack_auth_env }}" | ||
| block: | ||
|
|
||
| - name: Show baremetal node | ||
| ansible.builtin.command: | ||
| cmd: "{{ venv }}/bin/openstack baremetal node show {{ inventory_hostname }} -f json" | ||
| register: node_show | ||
| failed_when: | ||
| - node_show.rc != 0 | ||
| changed_when: false | ||
|
|
||
| - name: Check BMC is up | ||
| ansible.builtin.uri: | ||
| url: "{{ ironic_driver_info['redfish_address'] }}/redfish/v1" | ||
| method: GET | ||
| status_code: 200 | ||
| validate_certs: false | ||
| timeout: 10 | ||
|
|
||
| - name: Check for redfish inspection details | ||
| ansible.builtin.set_fact: | ||
| kayobe_redfish_inspect_done: "{{ (node_show.stdout | from_json)['extra'].get('kayobe_redfish_inspect_done') }}" | ||
| inspect_interface: "{{ (node_show.stdout | from_json)['inspect_interface'] }}" | ||
| provision_state: "{{ (node_show.stdout | from_json)['provision_state'] }}" | ||
|
|
||
| - name: Output when redfish inspection was done | ||
| ansible.builtin.debug: | ||
| msg: "{{ inventory_hostname }} inspected at {{ kayobe_redfish_inspect_done }}." | ||
| when: kayobe_redfish_inspect_done != "" | ||
|
|
||
| - name: Fail if not redfish inspection | ||
| ansible.builtin.fail: | ||
| msg: "{{ inventory_hostname }} has the wrong inspect_interface: {{ inspect_interface }}" | ||
| when: | ||
| - inspect_interface != "redfish" | ||
| - kayobe_redfish_inspect_done == "" | ||
|
|
||
| - name: Fail if not in manageable state | ||
| ansible.builtin.fail: | ||
| msg: "{{ inventory_hostname }} has the wrong provision_state: {{ provision_state }}" | ||
| when: | ||
| - provision_state != "manageable" | ||
| - kayobe_redfish_inspect_done == "" | ||
|
|
||
| - name: Wait for inspection | ||
| ansible.builtin.command: | ||
| cmd: | | ||
| {{ venv }}/bin/openstack baremetal node inspect {{ inventory_hostname }} --wait {{ redfish_inspect_timeout }} | ||
| register: node_inspect | ||
| failed_when: | ||
| - node_inspect.rc != 0 | ||
| changed_when: true | ||
| when: kayobe_redfish_inspect_done == "" | ||
|
|
||
| - name: Note when redfish inspection is done | ||
| ansible.builtin.command: | ||
| cmd: | | ||
| {{ venv }}/bin/openstack baremetal node set {{ inventory_hostname }} --extra kayobe_redfish_inspect_done={{ now(utc=true, fmt='%Y-%m-%dT%H:%M:%SZ') }} | ||
| register: node_set | ||
| failed_when: | ||
| - node_set.rc != 0 | ||
| changed_when: true | ||
| when: kayobe_redfish_inspect_done == "" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if this should be a separate script that we add into baremetal-all? like baremetal-env.yml or similar? With a clear error message if the venv is missing.