Skip to content

Commit

Permalink
feat: implement ResetToDefaults phase1
Browse files Browse the repository at this point in the history
Signed-off-by: Boris Glimcher <[email protected]>
  • Loading branch information
glimchb committed Apr 10, 2024
1 parent 9f9a492 commit 8507941
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
38 changes: 38 additions & 0 deletions roles/bmc_factory_reset/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,40 @@
# SPDX-License-Identifier: Apache-2.0
# Copyright (c) 2022-2024 Dell Inc, or its subsidiaries.

---
# tasks file for bmc_factory_reset

- name: Validate server authentication input provided by user
ansible.builtin.fail:
msg: "{{ bmc_factory_reset_mandatory_msg }}"
when:
- (dpu_bmc_username is not defined or dpu_bmc_password is not defined) and (dpu_bmc_token is not defined)

- name: Fail when more than one valid authentication method is provided
ansible.builtin.fail:
msg: "{{ bmc_factory_reset_mutual_exclusive_msg }}"
when:
- ((dpu_bmc_username is defined or dpu_bmc_password is defined) and dpu_bmc_token is defined)

- name: Factory reset BMC when username and password are defined
when: dpu_bmc_username is defined and dpu_bmc_password is defined
block:
- name: Reset DPU BMC to default factory settings
community.general.redfish_command:
category: Manager
command: GracefulRestart
baseuri: "{{ inventory_hostname }}"
username: "{{ dpu_bmc_username }}"
password: "{{ dpu_bmc_password }}"
delegate_to: "{{ bmc_factory_reset_delegate }}"

- name: Factory reset BMC when auth_token is defined
when: dpu_bmc_token is defined
block:
- name: Reset DPU BMC to default factory settings
community.general.redfish_command:
category: Manager
command: GracefulRestart
baseuri: "{{ inventory_hostname }}"
auth_token: "{{ dpu_bmc_token }}"
delegate_to: "{{ bmc_factory_reset_delegate }}"
2 changes: 2 additions & 0 deletions roles/bmc_factory_reset/vars/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@
# vars file for bmc_factory_reset

bmc_factory_reset_delegate: "{{ lookup('ansible.builtin.env', 'RUNON', default='localhost') }}"
bmc_factory_reset_mandatory_msg: "username/password or auth_token is mandatory"
bmc_factory_reset_mutual_exclusive_msg: "Only one authentication method is allowed. Provide either username/password or auth_token."

0 comments on commit 8507941

Please sign in to comment.