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

[Integration][OMEVV][omevv_firmware_repository_profile] - Added automation for delete operation. #745

Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
- name: Pre-requisite - Create a profile to be deleted
dellemc.openmanage.omevv_firmware_repository_profile:
hostname: "{{ hostname }}"
vcenter_uuid: "{{ uuid }}"
vcenter_username: "{{ vcenter_username }}"
vcenter_password: "{{ vcenter_password }}"
state: "present"
protocol_type: "{{ protocol }}"
share_username: "{{ share__username | default(omit) }}"
share_password: "{{ share__password | default(omit) }}"
catalog_path: "{{ path }}"
name: "{{ profile_name }}"
validate_certs: false
description: "Firmware repository profile created by Module"
register: create_result
no_log: true
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
# Dell OpenManage Ansible modules
# Copyright (C) 2024 Dell Inc. or its subsidiaries. All Rights Reserved.

# GNU General Public License v3.0+ (see COPYING or
# https://www.gnu.org/licenses/gpl-3.0.txt)
---
- name: Test that we have an OMEVV host, OMEVV username and OMEVV password
ansible.builtin.fail:
msg: 'Please define the following variables: hostname,
vcenter_username and vcenter_password.'
when: 'hostname is not defined or vcenter_username is not defined or
vcenter_password is not defined'

- block:
- name: Including helper file for creating firmware repo profile
ansible.builtin.include_tasks: ../__pre_req_create.yml
vars:
profile_name: "temp_profile"
protocol: "HTTP"
share__username: "{{ http_share_user }}"
share__password: "{{ http_share_password }}"
path: "{{ http_share }}{{ http_share_dir_path }}"

- name: Delete the profile (Check mode - Changes expected)
dellemc.openmanage.omevv_firmware_repository_profile: &delete_profile
hostname: "{{ hostname }}"
vcenter_uuid: "{{ uuid }}"
vcenter_username: "{{ vcenter_username }}"
vcenter_password: "{{ vcenter_password }}"
state: "absent"
name: "temp_profile"
register: cm_delete_result
check_mode: true

- name: Verify task status - Delete profile (Check mode)
ansible.builtin.assert:
that:
- cm_delete_result.changed
- cm_delete_result.msg == "Changes found to be applied."

- name: Delete the profile (Diff and check modes - Changes expected)
dellemc.openmanage.omevv_firmware_repository_profile:
<<: *delete_profile
register: cm_diff_delete_result
check_mode: true
diff: true

- name: Verify task status - Delete profile (Check and Diff modes)
ansible.builtin.assert:
that:
- cm_diff_delete_result.changed
- cm_diff_delete_result.msg == "Changes found to be applied."
- cm_diff_delete_result.diff.after | length == 0
- cm_diff_delete_result.diff.before | length > 0

- name: Delete the profile (Normal and Diff Mode)
dellemc.openmanage.omevv_firmware_repository_profile:
<<: *delete_profile
register: delete_result
diff: true

- name: Verify task status - Delete profile (Normal and Diff Mode)
ansible.builtin.assert:
that:
- delete_result.changed
- delete_result.msg == "Successfully deleted the OMEVV firmware
repository profile."
- delete_result.diff.after | length == 0
- delete_result.diff.before | length > 0

- name: Delete a profile (Idempotence)
dellemc.openmanage.omevv_firmware_repository_profile:
<<: *delete_profile
register: idempotence_result_delete
ignore_errors: true

- name: Set expected message for assertion
ansible.builtin.set_fact:
expected_msg: "Unable to delete the profile temp_profile because the
profile name is invalid. Enter a valid profile name and
retry the operation."

- name: Verify task status - Delete a profile (Idempotence)
ansible.builtin.assert:
that:
- not idempotence_result_delete.changed
- idempotence_result_delete.msg == expected_msg

always:
- name: Cleanup
dellemc.openmanage.omevv_firmware_repository_profile:
name: "temp_profile"
state: absent
ignore_errors: true
no_log: true

module_defaults:
dellemc.openmanage.omevv_firmware_repository_profile:
validate_certs: "{{ validate_certs }}"
hostname: "{{ hostname | ansible.utils.ipwrap }}"
vcenter_username: "{{ vcenter_username }}"
vcenter_password: "{{ vcenter_password }}"
vcenter_uuid: "{{ uuid }}"
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Dell OpenManage Ansible modules
# Copyright (C) 2024 Dell Inc. or its subsidiaries. All Rights Reserved.

# GNU General Public License v3.0+ (see COPYING or
# https://www.gnu.org/licenses/gpl-3.0.txt)
---
- name: Test that we have an OMEVV host, OMEVV username and OMEVV password
ansible.builtin.fail:
msg: 'Please define the following variables: hostname,
vcenter_username and vcenter_password.'
when: 'hostname is not defined or vcenter_username is not defined or
vcenter_password is not defined'

- block:
- name: Negative - invalid profile name
dellemc.openmanage.omevv_firmware_repository_profile:
name: "Invalid"
state: absent
register: invalid_profile_name
ignore_errors: true

- name: Verify task status - Negative - invalid profile name
ansible.builtin.assert:
that:
- invalid_profile_name.failed
- not invalid_profile_name.changed
- 'invalid_profile_name.msg == "Unable to delete the profile Invalid
because the profile name is invalid. Enter a valid profile name
and retry the operation."'

module_defaults:
dellemc.openmanage.omevv_firmware_repository_profile:
validate_certs: "{{ validate_certs }}"
hostname: "{{ hostname | ansible.utils.ipwrap }}"
vcenter_username: "{{ vcenter_username }}"
vcenter_password: "{{ vcenter_password }}"
vcenter_uuid: "{{ uuid }}"
Original file line number Diff line number Diff line change
@@ -0,0 +1,193 @@
# Dell OpenManage Ansible modules
# Copyright (C) 2024 Dell Inc. or its subsidiaries. All Rights Reserved.

# GNU General Public License v3.0+ (see COPYING or
# https://www.gnu.org/licenses/gpl-3.0.txt)
---
- name: Test that we have an OMEVV host, OMEVV username and OMEVV password
ansible.builtin.fail:
msg: 'Please define the following variables: hostname,
vcenter_username and vcenter_password.'
when: 'hostname is not defined or vcenter_username is not defined or
vcenter_password is not defined'

- block:
- name: Negative - unsupported argument
dellemc.openmanage.omevv_firmware_repository_profile:
unsupported_argument: unsupported
state: absent
name: "Profile Name"
register: invalid_unsupported_argument
ignore_errors: true

- name: Verify task status - Negative - unsupported argument
ansible.builtin.assert:
that:
- invalid_unsupported_argument.failed
- not invalid_unsupported_argument.changed
- 'invalid_unsupported_argument.msg == "Unsupported parameters for
(dellemc.openmanage.omevv_firmware_repository_profile) module:
unsupported_argument. Supported parameters include: ca_path,
catalog_path, description, hostname, name, new_name, port,
protocol_type, share_domain, share_password, share_username, state,
timeout, validate_certs, vcenter_password, vcenter_username,
vcenter_uuid."'

- name: Negative - unreachable host
dellemc.openmanage.omevv_firmware_repository_profile:
hostname: 999.999.999.999
state: absent
name: "Profile Name"
register: invalid_unreachable
ignore_unreachable: true

- name: Verify task status - Negative - unreachable host
ansible.builtin.assert:
that:
- invalid_unreachable.unreachable
- not invalid_unreachable.changed
- 'invalid_unreachable.msg == "<urlopen error Unable to resolve
hostname or IP 999.999.999.999.>" or invalid_unreachable.msg ==
"<urlopen error [Errno -2] Name or service not known>"'

- name: Negative - invalid port
dellemc.openmanage.omevv_firmware_repository_profile:
port: -1
state: absent
name: "Profile Name"
register: invalid_port
ignore_unreachable: true

- name: Verify task status - Negative - invalid port
ansible.builtin.assert:
that:
- invalid_port.unreachable
- not invalid_port.changed
- ('invalid_port.msg == "<urlopen error [Errno 111] Connection
refused>"') or ('invalid_port.msg == "<urlopen error timed out>"')

- name: Negative - invalid username
dellemc.openmanage.omevv_firmware_repository_profile:
vcenter_username: invalid
state: absent
name: "Profile Name"
register: invalid_username
ignore_errors: true

- name: Verify task status - Negative - invalid username
ansible.builtin.assert:
that:
- invalid_username.failed
- not invalid_username.changed
- 'invalid_username.msg.message == "Invalid Credentials." or
invalid_username.msg.message == "<urlopen error timed out>"'
- 'invalid_username.msg.errorCode == "12017"'

- name: Negative - invalid password
dellemc.openmanage.omevv_firmware_repository_profile:
vcenter_password: invalid
state: absent
name: "Profile Name"
register: invalid_password
ignore_errors: true

- name: Verify task status - Negative - invalid password
ansible.builtin.assert:
that:
- invalid_password.failed
- not invalid_password.changed
- 'invalid_password.msg.message == "Invalid Credentials." or
invalid_password.msg.message == "<urlopen error timed out>"'
- 'invalid_username.msg.errorCode == "12017"'

- name: Negative - invalid validate_certs
dellemc.openmanage.omevv_firmware_repository_profile:
validate_certs: invalid
state: absent
name: "Profile Name"
register: invalid_validate_certs
ignore_errors: true

- ansible.builtin.set_fact:
invalid_validate_certs_expected_msg: "argument 'validate_certs' is of
type <class 'str'> and we were unable to convert to bool: The value
'invalid' is not a valid boolean. Valid booleans include: "

- name: Verify task status - Negative - invalid validate_certs
ansible.builtin.assert:
that:
- invalid_validate_certs.failed
- not invalid_validate_certs.changed
- invalid_validate_certs_expected_msg in invalid_validate_certs.msg

- name: Negative - invalid ca_path path
dellemc.openmanage.omevv_firmware_repository_profile:
ca_path: /invalid/path
state: absent
name: "Profile Name"
register: invalid_ca_path
ignore_errors: true

- name: Verify task status - Negative - invalid ca_path path
ansible.builtin.assert:
that:
- invalid_ca_path.failed
- not invalid_ca_path.changed
- 'invalid_ca_path.msg == "[Errno 2] No such file or
directory: b''/invalid/path''"'

- name: Negative - invalid timeout type
dellemc.openmanage.omevv_firmware_repository_profile:
timeout: invalid
state: absent
name: "Profile Name"
register: invalid_timeout_type
ignore_errors: true

- name: Verify task status - Negative - invalid timeout type
ansible.builtin.assert:
that:
- invalid_timeout_type.failed
- not invalid_timeout_type.changed
- 'invalid_timeout_type.msg == "argument ''timeout'' is of type
<class ''str''> and we were unable to convert to
int: <class ''str''> cannot be converted to an int"'

- name: Negative - invalid timeout value
dellemc.openmanage.omevv_firmware_repository_profile:
timeout: -1
state: absent
name: "Profile Name"
register: invalid_timeout_value
ignore_errors: true

- name: Verify task status - Negative - invalid timeout value
ansible.builtin.assert:
that:
- invalid_timeout_value.failed
- not invalid_timeout_value.changed
- 'invalid_timeout_value.msg == "Timeout value out of range"'

- name: Negative - invalid vcenter uuid
dellemc.openmanage.omevv_firmware_repository_profile:
vcenter_uuid: invalid
state: absent
name: "Profile Name"
register: invalid_uuid
ignore_errors: true

- name: Verify task status - Negative - invalid vcenter uuid
ansible.builtin.assert:
that:
- invalid_uuid.failed
- not invalid_uuid.changed
- 'invalid_uuid.msg == "vCenter with UUID invalid is not
registered."'

module_defaults:
dellemc.openmanage.omevv_firmware_repository_profile:
validate_certs: "{{ validate_certs }}"
hostname: "{{ hostname | ansible.utils.ipwrap }}"
vcenter_username: "{{ vcenter_username }}"
vcenter_password: "{{ vcenter_password }}"
vcenter_uuid: "{{ uuid }}"
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
---
Loading