Ansible - Configuring Supermicro servers via Redfish API
-
I plan to configure Supermicro servers via the Redfish API. Ansible provides the following modules for the Redfish API:
- https://docs.ansible.com/ansible/latest/collections/community/general/redfish_command_module.html
- https://docs.ansible.com/ansible/latest/collections/community/general/redfish_config_module.html
Supermicro offers https://www.supermicro.com/manuals/other/RedfishRefGuide.pdf Redfish Reference Guide, which describes its Redfish REST API in detail. However, the Ansible modules use some sort of commands to do the configurations, instead of URIs.
Can someone explain how to map the API options to the Ansible modules? E. g., how can I use the Ansible modules to set the hostname or to provide NTP settings?
-
Supermicro offers this Redfish Reference Guide, which describes its Redfish REST API in detail.
Right. According the documentation you've referenced, Ch. 4 "Using RESTful APIs" p. 13 ff., the structure of the REST API call seems to be
https://${URL}/redfish/v1/${CATEGORY} ...
followed by further actions, commands, tasks or payloads.
Can someone explain how to map the API options to the Ansible modules?
After looking up the module documentation examples and the source code
- https://github.com/ansible-collections/community.general/blob/main/plugins/modules/redfish_config.py
- https://github.com/ansible-collections/community.general/blob/main/plugins/modules/redfish_command.py
it turns out that the modules using
- https://github.com/ansible-collections/community.general/blob/main/plugins/module_utils/redfish_utils.py
as a wrapper the utilize the REST API. It maps the REST API structure to the parameter structure of the modules (
category
,command
,payload
). For a better understanding you may have a look into the mentioned source.How can I use the Ansible modules to set the hostname or to provide NTP settings?
https://github.com/ansible-collections/community.general/blob/main/plugins/module_utils/redfish_utils.py#L2729 it seems to be the
manager_services
for NTP. Because of the lack of the specific environment I'm not able to investigate this further and to do tests, therefore for how to use it you may also have a look into the source.To get familar with the Redfish RESTful API you may also have a look into https://github.com/DMTF/Redfishtool it
was originally written during the development of the Redfish specification to help find ambiguities in the spec.
Further Examples
There are some explanations and a general programming example from a bigger production environment available
- Krenn Wiki https://www-thomas--krenn-com.translate.goog/de/wiki/Redfish?_x_tr_sl=de&_x_tr_tl=en&_x_tr_hl=de&_x_tr_pto=wapp
Documentation
- https://www.dmtf.org/sites/default/files/standards/documents/DSP2060_1.0.0.pdf