Files
kayobe/ansible/overcloud-introspection-data-save.yml
Will Szumski 75d93c8da0 Support built-in inspector
Switches to using the builtin inspector rather than the standalone
ironic-inspector service since this has now been dropped from
kolla-ansible. Where possible, the new service has been configured to
maintain the same behaviour of the old standalone service.

When using the standalone inspector, Kayobe has a few opinionated
defaults for the set of processing hooks.  These defaults have been
translated over to the built-in inspector equivalents for a more
consistent experience.

Inspection rules have rewritten to use the new format.

CLI invocations have been updated to use the commands for the new
inspection service.

Change-Id: I09bd59d085c7ec3fa0ccd6abb84bd2d0c8b9825d
Depends-On:  https://review.opendev.org/c/openstack/kolla-ansible/+/961266
Signed-off-by: Will Szumski <will@stackhpc.com>
2025-11-14 10:37:20 +00:00

68 lines
2.7 KiB
YAML

---
- name: Ensure the overcloud nodes' hardware introspection data is saved
hosts: overcloud
max_fail_percentage: >-
{{ overcloud_introspection_data_save_max_fail_percentage |
default(kayobe_max_fail_percentage) |
default(100) }}
vars:
seed_host: "{{ groups['seed'][0] }}"
# Override this to save results to another location.
output_dir: "{{ lookup('env', 'PWD') }}/overcloud-introspection-data"
# Override this to set the output data format. One of json, yaml.
output_format: json
gather_facts: no
tasks:
- name: Query overcloud nodes' hardware introspection data
command: >
{{ container_engine }} exec bifrost_deploy
bash -c '
env BIFROST_INVENTORY_SOURCE=ironic BIFROST_NODE_NAMES="{{ inventory_hostname }}" OS_CLOUD=bifrost
ansible baremetal
--connection local
--inventory /etc/bifrost/inventory/
-e @/etc/bifrost/bifrost.yml
-e @/etc/bifrost/dib.yml
--limit {{ inventory_hostname }}
-m shell
-a "env OS_CLOUD=bifrost baremetal node inventory save {% raw %}{{ inventory_hostname }}{% endraw %}"'
register: save_result
changed_when: False
# Ignore errors, log a message later.
failed_when: False
delegate_to: "{{ seed_host }}"
vars:
# NOTE: Without this, the seed's ansible_host variable will not be
# respected when using delegate_to.
ansible_host: "{{ hostvars[seed_host].ansible_host | default(seed_host) }}"
become: "{{ container_engine == 'podman' }}"
- name: Ensure introspection data output directory exists
delegate_to: localhost
file:
path: "{{ output_dir }}"
state: directory
- name: Ensure introspection data is saved locally
delegate_to: localhost
copy:
content: "{{ introspection_data_map[output_format | lower] }}"
dest: "{{ output_dir }}/{{ inventory_hostname }}.{{ output_format | lower }}"
when: save_result.rc == 0
vars:
introspection_data: "{{ save_result.stdout_lines[1:] | join('\n') | from_json }}"
introspection_data_json: "{{ introspection_data | to_nice_json(indent=4) }}"
introspection_data_yaml: "{{ introspection_data | to_nice_yaml }}"
introspection_data_map:
json: "{{ introspection_data_json }}"
yaml: "{{ introspection_data_yaml }}"
- name: Log when introspection data could not be queried
debug:
msg: >
Could not query hardware introspection data for
{{ inventory_hostname }}.
Stdout: {{ save_result.stdout }}.
Stderr: {{ save_result.stderr }}.
when: save_result.rc != 0