Skip to content
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

Adding EnableSecureBoot functionality #5899

Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
minor_changes:
- redfish_command - adding ``EnableSecureBoot`` functionality (https://github.com/ansible-collections/community.general/pull/5899).
19 changes: 19 additions & 0 deletions plugins/module_utils/redfish_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3198,3 +3198,22 @@ def verify_bios_attributes(self, bios_attributes):
"changed": False,
"msg": "BIOS verification completed"
}

def enable_secure_boot(self):
# This function enable Secure Boot on an OOB controller

response = self.get_request(self.root_uri + self.systems_uri)
if response["ret"] is False:
return response

server_details = response["data"]
secure_boot_url = server_details["SecureBoot"]["@odata.id"]

response = self.get_request(self.root_uri + secure_boot_url)
if response["ret"] is False:
return response

body = {}
body["SecureBootEnable"] = True

return self.patch_request(self.root_uri + secure_boot_url, body, check_pyld=True)
16 changes: 14 additions & 2 deletions plugins/modules/redfish_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,9 @@
default: {}
version_added: '5.7.0'

author: "Jose Delarosa (@jose-delarosa)"
felixfontein marked this conversation as resolved.
Show resolved Hide resolved
author:
- "Jose Delarosa (@jose-delarosa)"
- "T S Kushal (@TSKushal)"
'''

EXAMPLES = '''
Expand Down Expand Up @@ -255,6 +257,14 @@
baseuri: "{{ baseuri }}"
username: "{{ username }}"
password: "{{ password }}"

- name: Enable SecureBoot
community.general.redfish_config:
category: Systems
command: EnableSecureBoot
baseuri: "{{ baseuri }}"
username: "{{ username }}"
password: "{{ password }}"
'''

RETURN = '''
Expand All @@ -273,7 +283,7 @@
# More will be added as module features are expanded
CATEGORY_COMMANDS_ALL = {
"Systems": ["SetBiosDefaultSettings", "SetBiosAttributes", "SetBootOrder",
"SetDefaultBootOrder"],
"SetDefaultBootOrder", "EnableSecureBoot"],
"Manager": ["SetNetworkProtocols", "SetManagerNic", "SetHostInterface"],
"Sessions": ["SetSessionService"],
}
Expand Down Expand Up @@ -386,6 +396,8 @@ def main():
result = rf_utils.set_boot_order(boot_order)
elif command == "SetDefaultBootOrder":
result = rf_utils.set_default_boot_order()
elif command == "EnableSecureBoot":
result = rf_utils.enable_secure_boot()

elif category == "Manager":
# execute only if we find a Manager service resource
Expand Down