Skip to content

idrac_gather_facts 17G support #844

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

Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions roles/idrac_gather_facts/tasks/__capture_error.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
- name: Capture error (if any)
ansible.builtin.set_fact:
error_msg_list: "{{ error_msg_list | default([]) + [error_msg] }}"
when:
- register_vars is defined
- "'json' in item"
- "'error' in item.json"
- "'@Message.ExtendedInfo' in item.json.error"
- "'Message' in item.json.error['@Message.ExtendedInfo'][0]"
vars:
error_msg: "{{ item.json.error['@Message.ExtendedInfo'][0]['Message'] }}"
loop: "{{ register_vars }}"
no_log: true

- name: Updating error (if any)
ansible.builtin.set_fact:
idrac_gather_facts_error: "{{ idrac_gather_facts_error |
combine({component: error_msg_list}) }}"
when:
- component is defined
- error_msg_list is defined
- error_msg_list != []

- name: Emptying error_msg_list
ansible.builtin.set_fact:
error_msg_list: []
Original file line number Diff line number Diff line change
Expand Up @@ -4,57 +4,78 @@
url: https://{{ hostname }}:{{ https_port }}/redfish/v1/Systems
register: system_api_result
delegate_to: "{{ idrac_gather_facts_delegate }}"

- name: Get first System Id from the system response
ansible.builtin.set_fact:
api_system: "{{ system_api_result.json.Members[0]['@odata.id'] |
default('') }}"
computer_system_id: "{{ system_api_result.json.Members[0]['@odata.id'] |
split('/') | last | default('System.Embedded.1') }}"
when: computer_system_id == ''

- name: Get system detail
ansible.builtin.uri:
url: https://{{ hostname }}:{{ https_port }}{{ api_system }}
register: sys_detail
delegate_to: "{{ idrac_gather_facts_delegate }}"

- name: Extracting iDRAC generation
ansible.builtin.set_fact:
idrac_gen: "{{ sys_detail.json.Oem.Dell.DellSystem.SystemGeneration }}"

- name: Get all system Ids
ansible.builtin.set_fact:
system_ids_list: "{{ system_api_result.json.Members | map('dict2items') |
flatten | map(attribute='value') }}"
when: computer_system_id != ''

- name: Split system ids from the string
ansible.builtin.set_fact:
system_ids: '{{ (system_ids | default([])) + ([item | split("/") | last]) }}'
with_list: "{{ system_ids_list }}"
when: computer_system_id != ''

- name: Fail when system id is incorrect
ansible.builtin.fail:
msg: "{{ idrac_gather_facts_invalid_sys_id_message |
format(computer_system_id, (system_ids | join(','))) }}"
when: computer_system_id != "" and not computer_system_id in system_ids

- name: Get manager resource api id
ansible.builtin.uri:
url: https://{{ hostname }}:{{ https_port }}/redfish/v1/Managers
register: manager_api_result
delegate_to: "{{ idrac_gather_facts_delegate }}"

- name: Get first manager resource id from manager response.
ansible.builtin.set_fact:
api_manager: "{{ manager_api_result.json.Members[0]['@odata.id'] | default('') }}"
when: manager_id == ''

- name: Get all manager resource ids.
ansible.builtin.set_fact:
manager_ids_list: "{{ manager_api_result.json.Members | map('dict2items') |
flatten | map(attribute='value') }}"
when: manager_id != ''

- name: Split manager ids from the string
ansible.builtin.set_fact:
manager_ids: '{{ (manager_ids | default([])) + ([item | split("/") | last]) }}'
with_list: "{{ manager_ids_list }}"
when: manager_id != ''

- name: Fail when manager id is incorrect
ansible.builtin.fail:
msg: "{{ idrac_gather_facts_invalid_manager_id_message | format(manager_id,
(manager_ids | join(','))) }}"
when: manager_id != "" and not manager_id in manager_ids

- name: Get chassis resource api id
ansible.builtin.uri:
url: https://{{ hostname }}:{{ https_port }}/redfish/v1/Chassis
register: chassis_api_result
delegate_to: "{{ idrac_gather_facts_delegate }}"

- name: Get first chassis resource id from manager response.
ansible.builtin.set_fact:
api_chassis: "{{ chassis_api_result.json.Members[0]['@odata.id'] | default('') }}"
10 changes: 10 additions & 0 deletions roles/idrac_gather_facts/tasks/get_attributes_info.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,13 @@
lifecycle_controller_attributes: "{{ lc_attr.json.Attributes }}"
when: sys_attr.status == 200 and mgr_attr.status == 200 and
lc_attr.status == 200

- name: Error capture
ansible.builtin.include_tasks:
file: ./__capture_error.yml
vars:
register_vars:
- "{{ sys_attr }}"
- "{{ mgr_attr }}"
- "{{ lc_attr }}"
component: 'idrac'
20 changes: 18 additions & 2 deletions roles/idrac_gather_facts/tasks/get_backplane_info.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,28 @@
---
- name: API based on iDRAC generation
ansible.builtin.set_fact:
backplane_uri: "{{ idrac10 if '17G' in idrac_gen else idrac9 }}"
vars:
idrac9: "/redfish/v1/Chassis/Oem/Dell/DellPCIeSSDBackPlanes"
idrac10: "{{ api_chassis }}/Oem/Dell/DellPCIeSSDBackPlanes"

- name: Get PCIeSSDBackPlane information.
ansible.builtin.uri:
url: "https://{{ hostname }}:{{ https_port }}/redfish/v1/Chassis/Oem/Dell/DellPCIeSSDBackPlanes"
url: "https://{{ hostname }}:{{ https_port }}{{ backplane_uri }}"
register: pcie_result
delegate_to: "{{ idrac_gather_facts_delegate }}"

- name: Set PCIeSSDBackPlane facts
ansible.builtin.set_fact:
backplane: "{{ pcie_result.json.Members | ansible.utils.remove_keys(target=['@odata.context', '@odata.id', '@odata.type']) }}"
backplane: "{{ pcie_result.json.Members | ansible.utils.remove_keys(target=[

Check warning on line 17 in roles/idrac_gather_facts/tasks/get_backplane_info.yml

View workflow job for this annotation

GitHub Actions / ansible-lint / Ansible Lint

jinja[spacing]

Jinja2 spacing could be improved: {{ pcie_result.json.Members | ansible.utils.remove_keys(target=[ '@odata.context', '@odata.id', '@odata.etag', '@odata.type']) }} -> {{ pcie_result.json.Members | ansible.utils.remove_keys(target=['@odata.context', '@odata.id', '@odata.etag', '@odata.type']) }}
'@odata.context', '@odata.id', '@odata.etag', '@odata.type']) }}"
when: pcie_result.status == 200
register: pcie_result_register

- name: Error capture
ansible.builtin.include_tasks:
file: ./__capture_error.yml
vars:
register_vars:
- "{{ pcie_result }}"
component: 'backplane'
10 changes: 9 additions & 1 deletion roles/idrac_gather_facts/tasks/get_battery_info.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@
ansible.builtin.set_fact:
"sensor_battery":
"{{ battery_result.json | ansible.utils.remove_keys(target=['@odata.context',
'@odata.id', '@odata.type']) }}"
'@odata.id', '@odata.etag', '@odata.type']) }}"
when: battery_result.status == 200
register: battery_result_register

- name: Error capture
ansible.builtin.include_tasks:
file: ./__capture_error.yml
vars:
register_vars:
- "{{ battery_result }}"
component: 'sensors_battery'
11 changes: 10 additions & 1 deletion roles/idrac_gather_facts/tasks/get_bios_info.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,14 @@
ansible.builtin.set_fact:
bios:
"{{ bios_result.json | ansible.utils.remove_keys(target=['@odata.context',
'@odata.type', '@odata.id', 'SettingsObject', 'Actions', 'AttributeRegistry', 'Description',
'@odata.type', '@odata.id', '@odata.etag', 'SettingsObject', 'Actions',
'AttributeRegistry', 'Description',
'Id', 'Links', 'Name']) }}"

- name: Error capture
ansible.builtin.include_tasks:
file: ./__capture_error.yml
vars:
register_vars:
- "{{ bios_result }}"
component: 'bios'
9 changes: 9 additions & 0 deletions roles/idrac_gather_facts/tasks/get_controller_info.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,12 @@
ansible.utils.remove_keys(target=['^.*@odata.*$'],
matching_parameter='regex') }}"
when: controller_list_temp is defined

- name: Error capture
ansible.builtin.include_tasks:
file: ./__capture_error.yml
vars:
register_vars:
- "{{ disk_result }}"
- "{{ result }}"
component: 'controller'
12 changes: 11 additions & 1 deletion roles/idrac_gather_facts/tasks/get_cpu_info.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,14 @@

- name: Set CPU facts
ansible.builtin.set_fact:
cpu: "{{ cpu_result.json.Members | ansible.utils.remove_keys(target=['@odata.context', '@odata.id', '@odata.type', 'Assembly', 'Links']) }}"
cpu: "{{ cpu_result.json.Members | ansible.utils.remove_keys(target=[

Check warning on line 10 in roles/idrac_gather_facts/tasks/get_cpu_info.yml

View workflow job for this annotation

GitHub Actions / ansible-lint / Ansible Lint

jinja[spacing]

Jinja2 spacing could be improved: {{ cpu_result.json.Members | ansible.utils.remove_keys(target=[ '@odata.context', '@odata.id', '@odata.etag', '@odata.type', 'Assembly', 'Links']) }} -> {{ cpu_result.json.Members | ansible.utils.remove_keys(target=['@odata.context', '@odata.id', '@odata.etag', '@odata.type', 'Assembly', 'Links']) }}
'@odata.context', '@odata.id', '@odata.etag', '@odata.type', 'Assembly',
'Links']) }}"

- name: Error capture
ansible.builtin.include_tasks:
file: ./__capture_error.yml
vars:
register_vars:
- "{{ cpu_result }}"
component: 'cpu'
21 changes: 19 additions & 2 deletions roles/idrac_gather_facts/tasks/get_enclosure_emm_info.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,29 @@
---
- name: API based on iDRAC generation
ansible.builtin.set_fact:
enclosure_emm_uri: "{{ idrac10 if '17G' in idrac_gen else idrac9 }}"
vars:
idrac9: "/redfish/v1/Chassis/Oem/Dell/DellEnclosureEMM"
idrac10: "{{ api_chassis }}/Oem/Dell/DellEnclosureEMM/"

- name: Get enclosure EMM information.
ansible.builtin.uri:
url: "https://{{ hostname }}:{{ https_port }}/redfish/v1/Chassis/Oem/Dell/DellEnclosureEMM"
url: "https://{{ hostname }}:{{ https_port }}{{ enclosure_emm_uri }}"
register: emm_result
delegate_to: "{{ idrac_gather_facts_delegate }}"

- name: Set enclosure EMM facts
ansible.builtin.set_fact:
enclosure_emm: "{{ emm_result.json.Members | ansible.utils.remove_keys(target=['@odata.context', '@odata.id', '@odata.type', 'Description', 'Links']) }}"
enclosure_emm: "{{ emm_result.json.Members | ansible.utils.remove_keys(

Check warning on line 17 in roles/idrac_gather_facts/tasks/get_enclosure_emm_info.yml

View workflow job for this annotation

GitHub Actions / ansible-lint / Ansible Lint

jinja[spacing]

Jinja2 spacing could be improved: {{ emm_result.json.Members | ansible.utils.remove_keys( target=['@odata.context', '@odata.id', '@odata.type', 'Description', 'Links']) }} -> {{ emm_result.json.Members | ansible.utils.remove_keys(target=['@odata.context', '@odata.id', '@odata.type', 'Description', 'Links']) }}
target=['@odata.context', '@odata.id', '@odata.type', 'Description',
'Links']) }}"
when: emm_result.status == 200
register: emm_result_register

- name: Error capture
ansible.builtin.include_tasks:
file: ./__capture_error.yml
vars:
register_vars:
- "{{ emm_result }}"
component: 'enclosure_emm'
21 changes: 19 additions & 2 deletions roles/idrac_gather_facts/tasks/get_enclosure_info.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,29 @@
---
- name: API based on iDRAC generation
ansible.builtin.set_fact:
enclosure_uri: "{{ idrac10 if '17G' in idrac_gen else idrac9 }}"
vars:
idrac9: "/redfish/v1/Chassis/Oem/Dell/DellEnclosures"
idrac10: "{{ api_chassis }}/Oem/Dell/DellEnclosures"

- name: Get enclosure information.
ansible.builtin.uri:
url: "https://{{ hostname }}:{{ https_port }}/redfish/v1/Chassis/Oem/Dell/DellEnclosures"
url: "https://{{ hostname }}:{{ https_port }}{{ enclosure_uri }}"
register: enclosure_result
delegate_to: "{{ idrac_gather_facts_delegate }}"

- name: Set enclosure facts
ansible.builtin.set_fact:
enclosure: "{{ enclosure_result.json.Members | ansible.utils.remove_keys(target=['@odata.context', '@odata.id', '@odata.type', 'Links', 'Description']) }}"
enclosure: "{{ enclosure_result.json.Members | ansible.utils.remove_keys(

Check warning on line 17 in roles/idrac_gather_facts/tasks/get_enclosure_info.yml

View workflow job for this annotation

GitHub Actions / ansible-lint / Ansible Lint

jinja[spacing]

Jinja2 spacing could be improved: {{ enclosure_result.json.Members | ansible.utils.remove_keys( target=['@odata.context', '@odata.id', '@odata.type', 'Links', 'Description']) }} -> {{ enclosure_result.json.Members | ansible.utils.remove_keys(target=['@odata.context', '@odata.id', '@odata.type', 'Links', 'Description']) }}
target=['@odata.context', '@odata.id', '@odata.type', 'Links',
'Description']) }}"
when: enclosure_result.status == 200
register: enclosure_result_register

- name: Error capture
ansible.builtin.include_tasks:
file: ./__capture_error.yml
vars:
register_vars:
- "{{ enclosure_result }}"
component: 'enclosure'
11 changes: 10 additions & 1 deletion roles/idrac_gather_facts/tasks/get_fan_info.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,15 @@

- name: Set Fan facts
ansible.builtin.set_fact:
fan: "{{ fan_result.json.Members | ansible.utils.remove_keys(target=['@odata.context', '@odata.id', '@odata.type']) }}"
fan: "{{ fan_result.json.Members | ansible.utils.remove_keys(target=[

Check warning on line 11 in roles/idrac_gather_facts/tasks/get_fan_info.yml

View workflow job for this annotation

GitHub Actions / ansible-lint / Ansible Lint

jinja[spacing]

Jinja2 spacing could be improved: {{ fan_result.json.Members | ansible.utils.remove_keys(target=[ '@odata.context', '@odata.id', '@odata.etag', '@odata.type']) }} -> {{ fan_result.json.Members | ansible.utils.remove_keys(target=['@odata.context', '@odata.id', '@odata.etag', '@odata.type']) }}
'@odata.context', '@odata.id', '@odata.etag', '@odata.type']) }}"
when: fan_result.status == 200
register: fan_result_register

- name: Error capture
ansible.builtin.include_tasks:
file: ./__capture_error.yml
vars:
register_vars:
- "{{ fan_result }}"
component: 'fan'
14 changes: 12 additions & 2 deletions roles/idrac_gather_facts/tasks/get_firmware_info.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@

- name: Set Firmware facts
ansible.builtin.set_fact:
firmware:

Check warning on line 10 in roles/idrac_gather_facts/tasks/get_firmware_info.yml

View workflow job for this annotation

GitHub Actions / ansible-lint / Ansible Lint

jinja[spacing]

Jinja2 spacing could be improved: {{ firmware_result.json.Members | ansible.utils.remove_keys(target=[ '@odata.context', '@odata.id', '@odata.etag', '@odata.type', '[email protected]', '[email protected]', '[email protected]']) }} -> {{ firmware_result.json.Members | ansible.utils.remove_keys(target=['@odata.context', '@odata.id', '@odata.etag', '@odata.type', '[email protected]', '[email protected]', '[email protected]']) }}
"{{ firmware_result.json.Members | ansible.utils.remove_keys(target=['@odata.context', '@odata.id', '@odata.type',
'[email protected]', '[email protected]', '[email protected]']) }}"
"{{ firmware_result.json.Members | ansible.utils.remove_keys(target=[
'@odata.context', '@odata.id', '@odata.etag', '@odata.type',
'[email protected]', '[email protected]',
'[email protected]']) }}"

- name: Error capture
ansible.builtin.include_tasks:
file: ./__capture_error.yml
vars:
register_vars:
- "{{ firmware_result }}"
component: 'firmware'
13 changes: 11 additions & 2 deletions roles/idrac_gather_facts/tasks/get_host_nic_info.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,15 @@

- name: Set HostNIC facts
ansible.builtin.set_fact:
hostnic:

Check warning on line 10 in roles/idrac_gather_facts/tasks/get_host_nic_info.yml

View workflow job for this annotation

GitHub Actions / ansible-lint / Ansible Lint

jinja[spacing]

Jinja2 spacing could be improved: {{ nic_result.json.Members | ansible.utils.remove_keys(target=[ '@odata.context', '@odata.id', '@odata.etag', '@odata.type', 'HostEthernetInterfaces', 'ManagerEthernetInterface']) }} -> {{ nic_result.json.Members | ansible.utils.remove_keys(target=['@odata.context', '@odata.id', '@odata.etag', '@odata.type', 'HostEthernetInterfaces', 'ManagerEthernetInterface']) }}
"{{ nic_result.json.Members | ansible.utils.remove_keys(target=['@odata.context', '@odata.id', '@odata.type',
'HostEthernetInterfaces', 'ManagerEthernetInterface']) }}"
"{{ nic_result.json.Members | ansible.utils.remove_keys(target=[
'@odata.context', '@odata.id', '@odata.etag', '@odata.type',
'HostEthernetInterfaces', 'ManagerEthernetInterface']) }}"

- name: Error capture
ansible.builtin.include_tasks:
file: ./__capture_error.yml
vars:
register_vars:
- "{{ nic_result }}"
component: 'hostnic'
11 changes: 10 additions & 1 deletion roles/idrac_gather_facts/tasks/get_intrusion_info.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,15 @@

- name: Set Sensor Battery facts
ansible.builtin.set_fact:
"intrusion_sensor": "{{ intrusion_result.json | ansible.utils.remove_keys(target=['@odata.context', '@odata.id', '@odata.type']) }}"
"intrusion_sensor": "{{ intrusion_result.json | ansible.utils.remove_keys(

Check warning on line 10 in roles/idrac_gather_facts/tasks/get_intrusion_info.yml

View workflow job for this annotation

GitHub Actions / ansible-lint / Ansible Lint

jinja[spacing]

Jinja2 spacing could be improved: {{ intrusion_result.json | ansible.utils.remove_keys( target=['@odata.context', '@odata.id', '@odata.etag', '@odata.type']) }} -> {{ intrusion_result.json | ansible.utils.remove_keys(target=['@odata.context', '@odata.id', '@odata.etag', '@odata.type']) }}
target=['@odata.context', '@odata.id', '@odata.etag', '@odata.type']) }}"
when: intrusion_result.status == 200
register: intrusion_result_register

- name: Error capture
ansible.builtin.include_tasks:
file: ./__capture_error.yml
vars:
register_vars:
- "{{ intrusion_result }}"
component: 'intrusion_sensor'
11 changes: 10 additions & 1 deletion roles/idrac_gather_facts/tasks/get_license_info.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,14 @@

- name: Set License facts
ansible.builtin.set_fact:
license: "{{ license_result.json.Members | ansible.utils.remove_keys(target=['@odata.context', '@odata.id', '@odata.type']) }}"
license: "{{ license_result.json.Members | ansible.utils.remove_keys(

Check warning on line 11 in roles/idrac_gather_facts/tasks/get_license_info.yml

View workflow job for this annotation

GitHub Actions / ansible-lint / Ansible Lint

jinja[spacing]

Jinja2 spacing could be improved: {{ license_result.json.Members | ansible.utils.remove_keys( target=['@odata.context', '@odata.id', '@odata.etag', '@odata.type']) }} -> {{ license_result.json.Members | ansible.utils.remove_keys(target=['@odata.context', '@odata.id', '@odata.etag', '@odata.type']) }}
target=['@odata.context', '@odata.id', '@odata.etag', '@odata.type']) }}"
when: license_result.status == 200

- name: Error capture
ansible.builtin.include_tasks:
file: ./__capture_error.yml
vars:
register_vars:
- "{{ license_result }}"
component: 'license'
16 changes: 13 additions & 3 deletions roles/idrac_gather_facts/tasks/get_memory_info.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,17 @@

- name: Set Memory facts
ansible.builtin.set_fact:
memory:

Check warning on line 10 in roles/idrac_gather_facts/tasks/get_memory_info.yml

View workflow job for this annotation

GitHub Actions / ansible-lint / Ansible Lint

jinja[spacing]

Jinja2 spacing could be improved: {{ memory_result.json.Members | ansible.utils.remove_keys(target=[ '@odata.context', '@odata.id', '@odata.etag', '@odata.type', '[email protected]', '[email protected]', '[email protected]', '[email protected]', '[email protected]']) }} -> {{ memory_result.json.Members | ansible.utils.remove_keys(target=['@odata.context', '@odata.id', '@odata.etag', '@odata.type', '[email protected]', '[email protected]', '[email protected]', '[email protected]', '[email protected]']) }}
"{{ memory_result.json.Members | ansible.utils.remove_keys(target=['@odata.context', '@odata.id', '@odata.type',
'[email protected]', '[email protected]', '[email protected]', '[email protected]',
'[email protected]']) }}"
"{{ memory_result.json.Members | ansible.utils.remove_keys(target=[
'@odata.context', '@odata.id', '@odata.etag', '@odata.type',
'[email protected]', '[email protected]',
'[email protected]', '[email protected]',
'[email protected]']) }}"

- name: Error capture
ansible.builtin.include_tasks:
file: ./__capture_error.yml
vars:
register_vars:
- "{{ memory_result }}"
component: 'memory'
Loading
Loading