diff --git a/tests/integration/targets/omevv_baseline_profile/defaults/main.yaml b/tests/integration/targets/omevv_baseline_profile/defaults/main.yaml new file mode 100644 index 000000000..852a6bee3 --- /dev/null +++ b/tests/integration/targets/omevv_baseline_profile/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: '[^_].*' +test_items: [] diff --git a/tests/integration/targets/omevv_baseline_profile/files/ansible_doc.txt b/tests/integration/targets/omevv_baseline_profile/files/ansible_doc.txt new file mode 100644 index 000000000..35d57dbe4 --- /dev/null +++ b/tests/integration/targets/omevv_baseline_profile/files/ansible_doc.txt @@ -0,0 +1,218 @@ +- ' This module allows you to create, modify, or delete an' +- ' OpenManage Enterprise Integration for VMware Center (OMEVV)' +- ' baseline profile.' +- '' +- 'ADDED IN: version 9.9.0 of dellemc.openmanage' +- '' +- 'OPTIONS (= is mandatory):' +- '' +- '- ca_path' +- ' The Privacy Enhanced Mail (PEM) file that contains a CA' +- ' certificate to be used for the validation.' +- ' default: null' +- ' type: path' +- '' +- '- cluster' +- ' List of cluster(s) for baseline profile creation.' +- ' This parameter is required when `state'' is `present'' and while' +- ' creating a new profile.' +- ' default: null' +- ' elements: str' +- ' type: list' +- '' +- '- days' +- ' Required days of a week on when the job must run.' +- ' This is required when `state'' is `present'' and while creating' +- ' a new profile.' +- ' choices: [sunday, monday, tuesday, wednesday, thursday, friday, saturday, + all]' +- ' default: null' +- ' elements: str' +- ' type: list' +- '' +- '- description' +- ' Description of OMEVV baseline profile.' +- ' default: null' +- ' type: str' +- '' +- = hostname +- ' IP address or hostname of the OpenManage Enterprise Modular.' +- ' type: str' +- '' +- '- job_wait' +- ' Whether to wait till completion of the job.' +- ' default: true' +- ' type: bool' +- '' +- '- job_wait_timeout' +- ' The maximum wait time of `job_wait'' in seconds. The job is' +- ' tracked only for this duration.' +- ' This is applicable when `job_wait'' is `true''.' +- ' default: 1200' +- ' type: int' +- '' +- = name +- ' Name of the OMEVV baseline profile.' +- ' This parameter is required for modification operation when' +- ' `state'' is `absent''.' +- ' type: str' +- '' +- '- port' +- ' OpenManage Enterprise HTTPS port.' +- ' default: 443' +- ' type: int' +- '' +- '- repository_profile' +- ' Repository profile for baseline creation.' +- ' This is required when `state'' is `present'' and while creating' +- ' a new profile.' +- ' default: null' +- ' type: str' +- '' +- '- state' +- ' `present'' creates an OMEVV baseline profile or modifies an' +- ' existing profile if the profile with the same name already' +- ' exists.' +- ' `absent'' deletes the OMEVV baseline profile.' +- ' `repository_profile'', `cluster'', `days'' and `time'' is required' +- ' when creating a new baseline profile.' +- ' Either `profile_name'' or `profile_id'' is required when `state''' +- ' is `absent''.' +- ' choices: [present, absent]' +- ' default: present' +- ' type: str' +- '' +- '- time' +- ' Time at when the job must run, and is 24 hours format.' +- ' The format must be HH:MM.' +- ' This is required when `state'' is `present'' and while creating' +- ' a new profile.' +- ' default: null' +- ' type: str' +- '' +- '- timeout' +- ' The socket level timeout in seconds.' +- ' default: 30' +- ' type: int' +- '' +- '- validate_certs' +- ' Whether to check SSL certificate. - If `true'', the SSL' +- ' certificates will be validated. - If `false'', the SSL' +- ' certificates will not be validated.' +- ' default: true' +- ' type: bool' +- '' +- '- vcenter_password' +- ' Password for OpenManage Enterprise Integration for VMware' +- ' vCenter (OMEVV).' +- ' If the password is not provided, then the environment variable' +- ' `OMEVV_VCENTER_PASSWORD'' is used.' +- ' Example: export OMEVV_VCENTER_PASSWORD=password' +- ' default: null' +- ' type: str' +- '' +- '- vcenter_username' +- ' Username for OpenManage Enterprise Integration for VMware' +- ' vCenter (OMEVV).' +- ' If the username is not provided, then the environment variable' +- ' `OMEVV_VCENTER_USERNAME'' is used.' +- ' Example: export OMEVV_VCENTER_USERNAME=username' +- ' default: null' +- ' type: str' +- '' +- '- vcenter_uuid' +- ' Universally Unique Identifier (UUID) of vCenter.' +- ' vCenter UUID details can be retrieved using' +- ' [dellemc.openmanage.omevv_vcenter_info] module.' +- ' If UUID is not provided, then the environment variable' +- ' `OMEVV_VCENTER_UUID'' is used.' +- ' Example: export OMEVV_VCENTER_UUID=uuid' +- ' default: null' +- ' type: str' +- '' +- '' +- 'ATTRIBUTES:' +- '' +- ' check_mode:' +- ' description: Runs task to validate without performing action on the target + machine.' +- ' support: full' +- ' diff_mode:' +- ' description: Runs the task to report the changes that are made or the + changes that' +- ' must be applied.' +- ' support: full' +- '' +- 'NOTES:' +- ' * Run this module from a system that has direct access to' +- ' Dell OpenManage Enterprise.' +- '' +- '' +- 'REQUIREMENTS: python >= 3.9.6' +- '' +- 'AUTHOR: Saksham Nautiyal (@Saksham-Nautiyal)' +- '' +- 'EXAMPLES:' +- '' +- '---' +- '- name: Create a baseline profile for multiple cluster' +- ' dellemc.openmanage.omevv_baseline_profile:' +- ' hostname: "192.168.0.1"' +- ' vcenter_uuid: "xxxxx"' +- ' vcenter_username: "username"' +- ' vcenter_password: "password"' +- ' ca_path: "path/to/ca_file"' +- ' state: "present"' +- ' name: "profile-1"' +- ' repository_profile: "repository-profile"' +- ' cluster:' +- ' - "cluster-1"' +- ' - "cluster-2"' +- ' days:' +- ' - "sunday"' +- ' - "wednesday"' +- ' time: "22:10"' +- '' +- '- name: Modify a baseline profile' +- ' dellemc.openmanage.omevv_baseline_profile:' +- ' hostname: "192.168.0.1"' +- ' vcenter_uuid: "xxxxx"' +- ' vcenter_username: "username"' +- ' vcenter_password: "password"' +- ' ca_path: "path/to/ca_file"' +- ' state: "present"' +- ' name: "profile-1"' +- ' new_name: "profile-newname"' +- ' repository_profile: "repository-profile"' +- ' cluster:' +- ' - "cluster-1"' +- ' - "cluster-2"' +- ' days:' +- ' - "sunday"' +- ' time: "05:00"' +- '' +- '- name: Delete a specific baseline profile' +- ' dellemc.openmanage.omevv_baseline_profile:' +- ' hostname: "192.168.0.1"' +- ' vcenter_uuid: "xxxxx"' +- ' vcenter_username: "username"' +- ' vcenter_password: "password"' +- ' ca_path: "path/to/ca_file"' +- ' state: "absent"' +- ' name: "profile-1"' +- '' +- '' +- 'RETURN VALUES:' +- '- error_info' +- ' Details of the HTTP Error.' +- ' returned: on HTTP error' +- ' sample:' +- ' errorCode: ''18001''' +- ' message: Baseline profile with name Test already exists.' +- ' type: dict' +- '' +- '- msg' +- ' Status of the profile operation.' +- ' returned: always' +- ' sample: Successfully created the OMEVV baseline profile.' +- ' type: str' diff --git a/tests/integration/targets/omevv_baseline_profile/meta/main.yaml b/tests/integration/targets/omevv_baseline_profile/meta/main.yaml new file mode 100644 index 000000000..f77b5cfb2 --- /dev/null +++ b/tests/integration/targets/omevv_baseline_profile/meta/main.yaml @@ -0,0 +1,3 @@ +--- +dependencies: + - prepare_omevv_registration diff --git a/tests/integration/targets/omevv_baseline_profile/tasks/main.yaml b/tests/integration/targets/omevv_baseline_profile/tasks/main.yaml new file mode 100644 index 000000000..49e57ca34 --- /dev/null +++ b/tests/integration/targets/omevv_baseline_profile/tasks/main.yaml @@ -0,0 +1,23 @@ +--- +- name: Collect all test cases + ansible.builtin.find: + paths: '{{ role_path }}/tests' + patterns: '{{ testcase }}.yaml' + use_regex: true + register: test_cases + delegate_to: localhost + +- name: Set test_items + ansible.builtin.set_fact: + test_items: "{{ test_cases.files | map(attribute='path') | list }}" + +- name: Fail if no test cases are found as per pattern. + ansible.builtin.fail: + msg: "Could not find test cases to run!!!" + when: not test_items|length > 0 + +- name: Run test case + ansible.builtin.include_tasks: '{{ test_case_to_run }}' + with_items: '{{ test_items }}' + loop_control: + loop_var: test_case_to_run diff --git a/tests/integration/targets/omevv_baseline_profile/tests/_cleanup.yml b/tests/integration/targets/omevv_baseline_profile/tests/_cleanup.yml new file mode 100644 index 000000000..7faefe3b0 --- /dev/null +++ b/tests/integration/targets/omevv_baseline_profile/tests/_cleanup.yml @@ -0,0 +1,61 @@ +--- +- block: + - name: Delete baseline profile + dellemc.openmanage.omevv_baseline_profile: + state: absent + name: OMAM_Baseline_Profile + register: delete_baseline_profile + when: delete_baseline_trigger is defined + + - name: Verify task status - Delete baseline profile + ansible.builtin.assert: + that: + - delete_baseline_profile.changed + - 'delete_baseline_profile.msg == "Successfully deleted the baseline + profile."' + when: delete_baseline_trigger is defined + + - name: Delete Repository profile - 1 + dellemc.openmanage.omevv_baseline_profile: + state: absent + name: OMAM_Firm_Repo + register: delete_firm_repo_profile + when: delete_repository_profile_1_trigger is defined + + - name: Verify task status - Delete baseline profile + ansible.builtin.assert: + that: + - delete_firm_repo_profile.changed + - 'delete_firm_repo_profile.msg == "Successfully deleted the OMEVV + firmware repository profile."' + when: delete_repository_profile_2_trigger is defined + + - name: Delete Repository profile - 2 + dellemc.openmanage.omevv_baseline_profile: + state: absent + name: OMAM_Firm_Repo + register: delete_firm_repo_profile + when: delete_repository_profile_1_trigger is defined + + - name: Verify task status - Delete baseline profile + ansible.builtin.assert: + that: + - delete_firm_repo_profile.changed + - 'delete_firm_repo_profile.msg == "Successfully deleted the OMEVV + firmware repository profile."' + when: delete_repository_profile_2_trigger is defined + + module_defaults: + dellemc.openmanage.omevv_baseline_profile: + validate_certs: "{{ validate_certs }}" + hostname: "{{ hostname | ansible.utils.ipwrap }}" + vcenter_username: "{{ vcenter_username }}" + vcenter_password: "{{ vcenter_password }}" + vcenter_uuid: "{{ uuid }}" + + 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 }}" diff --git a/tests/integration/targets/omevv_baseline_profile/tests/_helper.yml b/tests/integration/targets/omevv_baseline_profile/tests/_helper.yml new file mode 100644 index 000000000..5e02892cd --- /dev/null +++ b/tests/integration/targets/omevv_baseline_profile/tests/_helper.yml @@ -0,0 +1,77 @@ +# Create repository profile and baseline profile +--- +- block: + - name: Create firmware repository profile - 1 + dellemc.openmanage.omevv_firmware_repository_profile: + name: "OMAM_Firm_Repo" + description: "Firmware repository profile created by OMAM" + state: present + catalog_path: "{{ http_share_dir_path }}/ + omevv_baseline_profile_catalog.xml" + protocol_type: HTTP + register: firm_repo_1 + when: repository_profile_1_trigger is defined + + - name: Verify task status - Create firmware repository profile - 1 + ansible.builtin.assert: + that: + - firm_repo_1.changed is true + - 'firm_repo_1.msg == "Successfully created the OMEVV firmware + repository profile."' + - firm_repo_1.profile_info.status == "Success" + when: repository_profile_1_trigger is defined + + - name: Create firmware repository profile - 2 + dellemc.openmanage.omevv_firmware_repository_profile: + name: "OMAM_Modify_Firm_Repo" + description: "Firmware repository profile created by OMAM" + state: present + catalog_path: "{{ http_share_dir_path }}/ + omevv_baseline_profile_catalog.xml" + protocol_type: HTTP + register: firm_repo_2 + when: repository_profile_2_trigger is defined + + - name: Verify task status - Create firmware repository profile - 2 + ansible.builtin.assert: + that: + - firm_repo_2.changed is true + - 'firm_repo_2.msg == "Successfully created the OMEVV firmware + repository profile."' + - firm_repo_2.profile_info.status == "Success" + when: repository_profile_2_trigger is defined + + - name: Create a baseline profile with single cluster + dellemc.openmanage.omevv_baseline_profile: + state: present + name: OMAM_Baseline_Profile + repository_profile: OMAM_Firm_Repo + cluster: OMAM-Cluster-1 + days: + - all + time: "12:00" + register: result_baseline + when: baseline_trigger is defined + + - name: Verify task status - Create a baseline profile with single cluster + ansible.builtin.assert: + that: + - result_baseline.changed is true + - result_baseline.msg == "Successfully created the baseline profile." + - result_baseline.baseline_profile_info + when: baseline_trigger is defined + + 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 }}" + + dellemc.openmanage.omevv_baseline_profile: + validate_certs: "{{ validate_certs }}" + hostname: "{{ hostname | ansible.utils.ipwrap }}" + vcenter_username: "{{ vcenter_username }}" + vcenter_password: "{{ vcenter_password }}" + vcenter_uuid: "{{ uuid }}" diff --git a/tests/integration/targets/omevv_baseline_profile/tests/_verify_baseline.yml b/tests/integration/targets/omevv_baseline_profile/tests/_verify_baseline.yml new file mode 100644 index 000000000..7e42921ac --- /dev/null +++ b/tests/integration/targets/omevv_baseline_profile/tests/_verify_baseline.yml @@ -0,0 +1,21 @@ +# Retrieve baseline information from OMEVV and verify against module output +--- +- block: + - name: Retrieve Baseline information + dellemc.openmanage.omevv_baseline_profile_info: + name: OMAM_Baseline_Profile + register: baseline_info + + - name: Verify task status - Retrieve Baseline information + ansible.builtin.assert: + that: + - "baseline_info.baseline_profile_info == + normal_result_baseline.profile_info" + + module_defaults: + dellemc.openmanage.omevv_baseline_profile_info: + validate_certs: "{{ validate_certs }}" + hostname: "{{ hostname | ansible.utils.ipwrap }}" + vcenter_username: "{{ vcenter_username }}" + vcenter_password: "{{ vcenter_password }}" + vcenter_uuid: "{{ uuid }}" diff --git a/tests/integration/targets/omevv_baseline_profile/tests/ansible_doc.yaml b/tests/integration/targets/omevv_baseline_profile/tests/ansible_doc.yaml new file mode 100644 index 000000000..1c8e6baf8 --- /dev/null +++ b/tests/integration/targets/omevv_baseline_profile/tests/ansible_doc.yaml @@ -0,0 +1,22 @@ +# 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) +--- +- block: + - name: ansible-doc + command: ansible-doc dellemc.openmanage.omevv_baseline_profile + register: ansible_doc_hash + + - name: Get ansible-doc output + local_action: copy content={{ansible_doc_hash.stdout_lines[2:] | + to_nice_yaml }} dest={{ role_path }}/files/ansible_doc.txt + register: ansible_doc + check_mode: true + diff: true + + - name: Verify if doc changed + ansible.builtin.assert: + that: not ansible_doc.changed + run_once: true diff --git a/tests/integration/targets/omevv_baseline_profile/tests/create_bp_multiple_cluster.yaml b/tests/integration/targets/omevv_baseline_profile/tests/create_bp_multiple_cluster.yaml new file mode 100644 index 000000000..26b9fa56a --- /dev/null +++ b/tests/integration/targets/omevv_baseline_profile/tests/create_bp_multiple_cluster.yaml @@ -0,0 +1,129 @@ +# 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 OME host, OME username and OME password + ansible.builtin.fail: + msg: "Please define the following variables: hostname, vcenter_username + and vcenter_password." + when: + hostname is undefined or vcenter_username is undefined or vcenter_password + is undefined + +- name: Set prerequisite + ansible.builtin.include_tasks: _helper.yml + vars: + repository_profile_1_trigger: 1 + +- block: + - name: Create a baseline profile with multiple + cluster (Check mode - Changes expected) + dellemc.openmanage.omevv_baseline_profile: &bp_multiple_cluster + state: present + name: OMAM_Baseline_Profile + repository_profile: OMAM_Firm_Repo + cluster: + - OMAM-Cluster-1 + - OMAM-Cluster-2 + days: + - all + time: "00:00" + register: cm_result_baseline + check_mode: true + + - name: Verify task status - Create a baseline profile with multiple + cluster (Check mode - Changes expected) + ansible.builtin.assert: + that: + - cm_result_baseline.changed + - 'cm_result_baseline.msg == "Changes found to be applied."' + + - name: Create a baseline profile with multiple + cluster (Check and Diff mode) + dellemc.openmanage.omevv_baseline_profile: + <<: *bp_multiple_cluster + check_mode: true + diff: true + register: cm_dm_result_baseline + + - name: Verify task status - Create a baseline profile with multiple + cluster (Check and Diff mode - Changes expected) + ansible.builtin.assert: + that: + - cm_dm_result_baseline.changed + - 'cm_dm_result_baseline.msg == "Changes found to be applied."' + - cm_dm_result_baseline.diff.before | length == 0 + - cm_dm_result_baseline.diff.after | length > 1 + + - name: Create a baseline profile with multiple cluster (Normal mode) + dellemc.openmanage.omevv_baseline_profile: + <<: *bp_multiple_cluster + register: normal_result_baseline + + - name: Verify task status - Create a baseline profile with multiple + cluster (Normal mode) + ansible.builtin.assert: + that: + - normal_result_baseline.changed + - 'normal_result_baseline.msg == "Successfully created the baseline + profile."' + - normal_result_baseline.baseline_profile_info + + - name: Verify baseline details + ansible.builtin.include_tasks: _verify_baseline.yml + + - name: Create a baseline profile with multiple cluster (Idempotence) + dellemc.openmanage.omevv_baseline_profile: + <<: *bp_multiple_cluster + register: idempotence_result_baseline + + - name: Verify task status - Create a baseline profile with multiple + cluster (Idempotence) + ansible.builtin.assert: + that: + - not idempotence_result_baseline.changed + - 'idempotence_result_baseline.msg == "No changes found to be + applied."' + + - name: Delete baseline profile created in previous task + ansible.builtin.include_tasks: _cleanup.yml + vars: + delete_baseline_trigger: 1 + + - name: Create a baseline profile with multiple + cluster (Normal and Diff mode) + dellemc.openmanage.omevv_baseline_profile: + <<: *bp_multiple_cluster + diff: true + register: normal_diff_result_baseline + + - name: Verify task status - Create a baseline profile with multiple + cluster (Normal and Diff mode) + ansible.builtin.assert: + that: + - normal_diff_result_baseline.changed + - 'normal_diff_result_baseline.msg == "Successfully created the + baseline profile."' + - normal_diff_result_baseline.baseline_profile_info + - normal_diff_result_baseline.diff.before | length == 0 + - normal_diff_result_baseline.diff.after | length > 1 + + - name: Verify baseline details + ansible.builtin.include_tasks: _verify_baseline.yml + + always: + - name: Post clean up + ansible.builtin.include_tasks: _cleanup.yml + vars: + delete_baseline_trigger: 1 + delete_repository_profile_1_trigger: 1 + + module_defaults: + dellemc.openmanage.omevv_baseline_profile: + validate_certs: "{{ validate_certs }}" + hostname: "{{ hostname | ansible.utils.ipwrap }}" + vcenter_username: "{{ vcenter_username }}" + vcenter_password: "{{ vcenter_password }}" + vcenter_uuid: "{{ uuid }}" diff --git a/tests/integration/targets/omevv_baseline_profile/tests/create_bp_single_cluster.yaml b/tests/integration/targets/omevv_baseline_profile/tests/create_bp_single_cluster.yaml new file mode 100644 index 000000000..bb9660ec9 --- /dev/null +++ b/tests/integration/targets/omevv_baseline_profile/tests/create_bp_single_cluster.yaml @@ -0,0 +1,126 @@ +# 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 OME host, OME username and OME password + ansible.builtin.fail: + msg: "Please define the following variables: hostname, vcenter_username + and vcenter_password." + when: + hostname is undefined or vcenter_username is undefined or vcenter_password + is undefined + +- name: Set prerequisite + ansible.builtin.include_tasks: _helper.yml + vars: + repository_profile_1_trigger: 1 + +- block: + - name: Create a baseline profile with single + cluster (Check mode - Changes expected) + dellemc.openmanage.omevv_baseline_profile: &bp_single_cluster + state: present + name: OMAM_Baseline_Profile + repository_profile: OMAM_Firm_Repo + cluster: OMAM-Cluster-1 + days: + - sunday + - wednesday + time: "22:00" + register: cm_result_baseline + check_mode: true + + - name: Verify task status - Create a baseline profile with single + cluster (Check mode - Changes expected) + ansible.builtin.assert: + that: + - cm_result_baseline.changed + - 'cm_result_baseline.msg == "Changes found to be applied."' + + - name: Create a baseline profile with single cluster (Check and Diff mode) + dellemc.openmanage.omevv_baseline_profile: + <<: *bp_single_cluster + check_mode: true + diff: true + register: cm_dm_result_baseline + + - name: Verify task status - Create a baseline profile with single + cluster (Check and Diff mode - Changes expected) + ansible.builtin.assert: + that: + - cm_dm_result_baseline.changed + - 'cm_dm_result_baseline.msg == "Changes found to be applied."' + - cm_dm_result_baseline.diff.before | length == 0 + - cm_dm_result_baseline.diff.after | length > 1 + + - name: Create a baseline profile with single cluster (Normal mode) + dellemc.openmanage.omevv_baseline_profile: + <<: *bp_single_cluster + register: normal_result_baseline + + - name: Verify task status - Create a baseline profile with single + cluster (Normal mode) + ansible.builtin.assert: + that: + - normal_result_baseline.changed + - 'normal_result_baseline.msg == "Successfully created the baseline + profile."' + - normal_result_baseline.baseline_profile_info + + - name: Create a baseline profile with single cluster (Idempotence) + dellemc.openmanage.omevv_baseline_profile: + <<: *bp_single_cluster + register: idempotence_result_baseline + + - name: Verify task status - Create a baseline profile with single + cluster (Idempotence) + ansible.builtin.assert: + that: + - not idempotence_result_baseline.changed + - 'idempotence_result_baseline.msg == "No changes found to be + applied."' + + - name: Verify baseline details + ansible.builtin.include_tasks: _verify_baseline.yml + + - name: Delete baseline profile created in previous task + ansible.builtin.include_tasks: _cleanup.yml + vars: + delete_baseline_trigger: 1 + + - name: Create a baseline profile with single cluster (Normal and Diff mode) + dellemc.openmanage.omevv_baseline_profile: + <<: *bp_single_cluster + diff: true + register: normal_diff_result_baseline + + - name: Verify task status - Create a baseline profile with single + cluster (Normal and Diff mode) + ansible.builtin.assert: + that: + - normal_diff_result_baseline.changed + - 'normal_diff_result_baseline.msg == "Successfully created the + baseline profile."' + - normal_diff_result_baseline.baseline_profile_info + - normal_diff_result_baseline.diff.before | length == 0 + - normal_diff_result_baseline.diff.after | length > 1 + + - name: Verify baseline details + ansible.builtin.include_tasks: _verify_baseline.yml + + always: + - name: Post clean up + ansible.builtin.include_tasks: _cleanup.yml + vars: + delete_baseline_trigger: 1 + delete_repository_profile_1_trigger: 1 + + module_defaults: + dellemc.openmanage.omevv_baseline_profile: + validate_certs: "{{ validate_certs }}" + hostname: "{{ hostname | ansible.utils.ipwrap }}" + vcenter_username: "{{ vcenter_username }}" + vcenter_password: "{{ vcenter_password }}" + vcenter_uuid: "{{ uuid }}" diff --git a/tests/integration/targets/omevv_baseline_profile/tests/delete.yaml b/tests/integration/targets/omevv_baseline_profile/tests/delete.yaml new file mode 100644 index 000000000..7247e822f --- /dev/null +++ b/tests/integration/targets/omevv_baseline_profile/tests/delete.yaml @@ -0,0 +1,114 @@ +# 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 OME host, OME username and OME password + ansible.builtin.fail: + msg: "Please define the following variables: hostname, vcenter_username + and vcenter_password." + when: + hostname is undefined or vcenter_username is undefined or vcenter_password + is undefined + +- name: Set prerequisite + ansible.builtin.include_tasks: _helper.yml + vars: + repository_profile_1_trigger: 1 + baseline_trigger: 1 + +- block: + - name: Delete a baseline profile (Check mode - Changes expected) + dellemc.openmanage.omevv_baseline_profile: &bp_delete + state: absent + name: OMAM_Baseline_Profile + register: cm_result_baseline + check_mode: true + + - name: Verify task status - Delete a baseline + profile (Check mode - Changes expected) + ansible.builtin.assert: + that: + - cm_result_baseline.changed + - 'cm_result_baseline.msg == "Changes found to be applied."' + + - name: Delete a baseline profile (Check and Diff mode) + dellemc.openmanage.omevv_baseline_profile: + <<: *bp_delete + check_mode: true + diff: true + register: cm_dm_result_baseline + + - name: Verify task status - Delete a baseline profile (Check and Diff mode) + ansible.builtin.assert: + that: + - cm_dm_result_baseline.changed + - 'cm_dm_result_baseline.msg == "Changes found to be applied."' + - cm_dm_result_baseline.diff.before | length > 1 + - cm_dm_result_baseline.diff.after | length == 0 + + - name: Delete a baseline profile (Normal mode) + dellemc.openmanage.omevv_baseline_profile: + <<: *bp_delete + register: normal_result_baseline + + - name: Verify task status - Delete a baseline profile (Normal mode) + ansible.builtin.assert: + that: + - normal_result_baseline.changed + - 'normal_result_baseline.msg == "Successfully deleted the baseline + profile."' + + - name: Verify baseline details + ansible.builtin.include_tasks: _verify_baseline.yml + + - name: Delete a baseline profile (Idempotence) + dellemc.openmanage.omevv_baseline_profile: + <<: *bp_delete + register: idempotence_result_baseline + + - name: Verify task status - Delete a baseline profile (Idempotence) + ansible.builtin.assert: + that: + - not idempotence_result_baseline.changed + - 'idempotence_result_baseline.msg == "No changes found to be + applied."' + + - name: Prereq - Create a baseline profile + ansible.builtin.include_tasks: _helper.yml + vars: + baseline_trigger: 1 + + - name: Delete a baseline profile (Normal and Diff mode) + dellemc.openmanage.omevv_baseline_profile: + <<: *bp_delete + diff: true + register: normal_diff_result_baseline + + - name: Verify task status - Delete a baseline + profile (Normal and Diff mode) + ansible.builtin.assert: + that: + - normal_diff_result_baseline.changed + - 'normal_diff_result_baseline.msg == "Successfully deleted the + baseline profile."' + - normal_diff_result_baseline.diff.before | length > 1 + - normal_diff_result_baseline.diff.after | length == 0 + + - name: Verify baseline details + ansible.builtin.include_tasks: _verify_baseline.yml + + always: + - name: Post clean up + ansible.builtin.include_tasks: _cleanup.yml + vars: + delete_repository_profile_1_trigger: 1 + + module_defaults: + dellemc.openmanage.omevv_baseline_profile: + validate_certs: "{{ validate_certs }}" + hostname: "{{ hostname | ansible.utils.ipwrap }}" + vcenter_username: "{{ vcenter_username }}" + vcenter_password: "{{ vcenter_password }}" + vcenter_uuid: "{{ uuid }}" diff --git a/tests/integration/targets/omevv_baseline_profile/tests/invalid_common.yaml b/tests/integration/targets/omevv_baseline_profile/tests/invalid_common.yaml new file mode 100644 index 000000000..2e8914152 --- /dev/null +++ b/tests/integration/targets/omevv_baseline_profile/tests/invalid_common.yaml @@ -0,0 +1,208 @@ +# 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_baseline_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_baseline_profile) module: + unsupported_argument. Supported parameters include: ca_path, + cluster, days, description, hostname, job_wait, job_wait_timeout, + name, port, repository_profile, state, time, timeout, + validate_certs, vcenter_password, vcenter_username, vcenter_uuid."' + + - name: Negative - unreachable host + dellemc.openmanage.omevv_baseline_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 == "The URL with IP 999.999.999.999 and + port 443 cannot be reached."' + + - name: Negative - invalid port - 1 + dellemc.openmanage.omevv_baseline_profile: + port: 0 + state: absent + name: "Profile Name" + register: invalid_port_1 + ignore_errors: true + + - name: Verify task status - Negative - invalid port - 1 + ansible.builtin.assert: + that: + - invalid_port_1.failed + - not invalid_port_1.changed + - 'invalid_port_1.msg == "Invalid port number. Enter the valid port + number."' + - 'invalid_port_1.error_info.message == "Invalid port number. Enter + the valid port number."' + + - name: Negative - invalid port - 2 + dellemc.openmanage.omevv_baseline_profile: + port: -1 + state: absent + name: "Profile Name" + register: invalid_port_2 + ignore_errors: true + + - name: Verify task status - Negative - invalid port - 2 + ansible.builtin.assert: + that: + - invalid_port_2.failed + - not invalid_port_2.changed + - 'invalid_port_2.msg == "Invalid port number. Enter the valid port + number."' + - 'invalid_port_2.error_info.message == "Invalid port number. Enter + the valid port number."' + + - name: Negative - invalid username + dellemc.openmanage.omevv_baseline_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 == "The read operation timed out"' + + - name: Negative - invalid password + dellemc.openmanage.omevv_baseline_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 == "The read operation timed out"' + + - name: Negative - invalid validate_certs + dellemc.openmanage.omevv_baseline_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 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_baseline_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_baseline_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 + and we were unable to convert to + int: cannot be converted to an int"' + + - name: Negative - invalid timeout value + dellemc.openmanage.omevv_baseline_profile: + timeout: 0 + 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 == "The value for the + job_wait_timeout parameter cannot be negative or zero."' + + - name: Negative - invalid vcenter uuid + dellemc.openmanage.omevv_baseline_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_baseline_profile: + validate_certs: "{{ validate_certs }}" + hostname: "{{ hostname | ansible.utils.ipwrap }}" + vcenter_username: "{{ vcenter_username }}" + vcenter_password: "{{ vcenter_password }}" + vcenter_uuid: "{{ uuid }}" diff --git a/tests/integration/targets/omevv_baseline_profile/tests/invalid_specific.yaml b/tests/integration/targets/omevv_baseline_profile/tests/invalid_specific.yaml new file mode 100644 index 000000000..147611513 --- /dev/null +++ b/tests/integration/targets/omevv_baseline_profile/tests/invalid_specific.yaml @@ -0,0 +1,89 @@ +# 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' + +- name: Set prerequisite + ansible.builtin.include_tasks: _helper.yml + vars: + repository_profile_1_trigger: 1 + +- block: + - name: Negative - Invalid cluster name + dellemc.openmanage.omevv_baseline_profile: + state: present + name: "Profile Name" + cluster: "Invalid cluster" + repository_profile: "OMAM_Firm_Repo" + days: "sunday" + time: "23:00" + register: invalid_cluster + ignore_errors: true + + - name: Verify task status - Negative - Invalid cluster name + ansible.builtin.assert: + that: + - invalid_cluster.failed + - not invalid_cluster.changed + - 'invalid_cluster.msg == "Invalid cluster names: Invalid cluster. + Please provide valid cluster(s)."' + + - name: Negative - Invalid repository name + dellemc.openmanage.omevv_baseline_profile: + state: present + name: "Profile Name" + cluster: "OMAM-Cluster-1" + repository_profile: "Invalid repository" + days: "sunday" + time: "23:00" + register: invalid_repository + ignore_errors: true + + - name: Verify task status - Negative - Invalid cluster name + ansible.builtin.assert: + that: + - invalid_repository.failed + - not invalid_repository.changed + - 'invalid_repository.msg == "Invalid repository profile: Invalid + repository. Please provide a valid profile."' + + - name: Negative - Invalid time + dellemc.openmanage.omevv_baseline_profile: + state: present + name: "Profile Name" + cluster: "OMAM-Cluster-1" + repository_profile: "OMAM_Firm_Repo" + days: "sunday" + time: "25:00" + register: invalid_time + ignore_errors: true + + - name: Verify task status - Negative - Invalid time + ansible.builtin.assert: + that: + - invalid_time.failed + - not invalid_time.changed + - 'invalid_repository.msg == ""Invalid value for time. Enter the value + in positive integer."' + + always: + - name: Post clean up + ansible.builtin.include_tasks: _cleanup.yml + vars: + delete_repository_profile_1_trigger: 1 + + module_defaults: + dellemc.openmanage.omevv_baseline_profile: + validate_certs: "{{ validate_certs }}" + hostname: "{{ hostname | ansible.utils.ipwrap }}" + vcenter_username: "{{ vcenter_username }}" + vcenter_password: "{{ vcenter_password }}" + vcenter_uuid: "{{ uuid }}" diff --git a/tests/integration/targets/omevv_baseline_profile/tests/modify.yaml b/tests/integration/targets/omevv_baseline_profile/tests/modify.yaml new file mode 100644 index 000000000..165bff883 --- /dev/null +++ b/tests/integration/targets/omevv_baseline_profile/tests/modify.yaml @@ -0,0 +1,104 @@ +# 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 OME host, OME username and OME password + ansible.builtin.fail: + msg: "Please define the following variables: hostname, vcenter_username + and vcenter_password." + when: + hostname is undefined or vcenter_username is undefined or vcenter_password + is undefined + +- name: Set prerequisite + ansible.builtin.include_tasks: _helper.yml + vars: + repository_profile_1_trigger: 1 + repository_profile_2_trigger: 1 + baseline_trigger: 1 + +- block: + - name: Modify a baseline profile (Check mode - Changes expected) + dellemc.openmanage.omevv_baseline_profile: &bp_multiple_cluster + state: present + name: OMAM_Baseline_Profile + repository_profile: OMAM_Modify_Firm_Repo + cluster: + - OMAM-Cluster-1 + - OMAM-Cluster-2 + + days: + - sunday + - wednesday + - saturdayGi + time: "00:00" + register: cm_result_baseline + check_mode: true + + - name: Verify task status - Modify a baseline profile (Check mode - Changes + expected) + ansible.builtin.assert: + that: + - cm_result_baseline.changed + - 'cm_result_baseline.msg == "Changes found to be applied."' + + - name: Modify a baseline profile (Check and Diff mode) + dellemc.openmanage.omevv_baseline_profile: + <<: *bp_multiple_cluster + check_mode: true + diff: true + register: cm_dm_result_baseline + + - name: Verify task status - Modify a baseline profile (Check and Diff mode) + ansible.builtin.assert: + that: + - cm_dm_result_baseline.changed + - 'cm_dm_result_baseline.msg == "Changes found to be applied."' + - cm_dm_result_baseline.diff.before | length > 1 + - cm_dm_result_baseline.diff.after | length > 1 + + - name: Modify a baseline profile (Normal mode) + dellemc.openmanage.omevv_baseline_profile: + <<: *bp_multiple_cluster + register: normal_result_baseline + + - name: Verify task status - Modify a baseline profile (Normal mode) + ansible.builtin.assert: + that: + - normal_result_baseline.changed + - 'normal_result_baseline.msg == "Successfully modified the baseline + profile."' + - normal_result_baseline.baseline_profile_info + + - name: Modify a baseline profile (Idempotence) + dellemc.openmanage.omevv_baseline_profile: + <<: *bp_multiple_cluster + register: idempotence_result_baseline + + - name: Verify task status - Modify a baseline profile (Idempotence) + ansible.builtin.assert: + that: + - not idempotence_result_baseline.changed + - 'idempotence_result_baseline.msg == "No changes found to be + applied."' + + - name: Verify baseline details + ansible.builtin.include_tasks: _verify_baseline.yml + + always: + - name: Post clean up + ansible.builtin.include_tasks: _cleanup.yml + vars: + baseline_profile_trigger: 1 + delete_repository_profile_1_trigger: 1 + delete_repository_profile_2_trigger: 1 + + module_defaults: + dellemc.openmanage.omevv_baseline_profile: + validate_certs: "{{ validate_certs }}" + hostname: "{{ hostname | ansible.utils.ipwrap }}" + vcenter_username: "{{ vcenter_username }}" + vcenter_password: "{{ vcenter_password }}" + vcenter_uuid: "{{ uuid }}" diff --git a/tests/integration/targets/omevv_baseline_profile/vars/main.yaml b/tests/integration/targets/omevv_baseline_profile/vars/main.yaml new file mode 100644 index 000000000..ed97d539c --- /dev/null +++ b/tests/integration/targets/omevv_baseline_profile/vars/main.yaml @@ -0,0 +1 @@ +---