Skip to content

Commit

Permalink
feat(bmc_fw_update): validate only user/pass or token passed
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 8507941 commit d952c72
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
12 changes: 12 additions & 0 deletions roles/bmc_fw_update/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,18 @@
---
# tasks file for bmc_fw_update

- name: Validate server authentication input provided by user
ansible.builtin.fail:
msg: "{{ bmc_fw_update_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_fw_update_mutual_exclusive_msg }}"
when:
- ((dpu_bmc_username is defined or dpu_bmc_password is defined) and dpu_bmc_token is defined)

- name: Get Firmware Inventory
ansible.builtin.include_role:
name: get_bmc_facts
Expand Down
2 changes: 2 additions & 0 deletions roles/bmc_fw_update/vars/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@
bmc_fw_update_task_failure: "Task failed with status: %s"
bmc_fw_update_version_failure: "Version returned from BMC doesn't match version in the file name"
bmc_fw_update_delegate: "{{ lookup('ansible.builtin.env', 'RUNON', default='localhost') }}"
bmc_fw_update_mandatory_msg: "username/password or auth_token is mandatory"
bmc_fw_update_mutual_exclusive_msg: "Only one authentication method is allowed. Provide either username/password or auth_token."

0 comments on commit d952c72

Please sign in to comment.