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_firmware_compliance_info #766

Open
wants to merge 1 commit into
base: collections
Choose a base branch
from
Open
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,3 @@
---
testcase: '[^_].*'
test_items: []
Original file line number Diff line number Diff line change
@@ -0,0 +1,190 @@
- ' This module allows to fetch the firmware compliance report of'
- ' all the hosts of the cluster, or a specific host of the'
- ' cluster, or multiple clusters.'
- ''
- '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'
- ''
- '- clusters'
- ' The cluster details to retrieve the firmware compliance'
- ' report.'
- ' default: null'
- ' elements: dict'
- ' type: list'
- ''
- ' SUBOPTIONS:'
- ''
- ' = cluster_name'
- ' The cluster name of the hosts for which the firmware'
- ' compliance report needs to be fetched.'
- ' If `servicetags'' or `hosts'' is provided, then firmware'
- ' compliance report of only the specified hosts will be'
- ' fetched and shown.'
- ' type: str'
- ''
- ' - hosts'
- ' The IP address or hostname of the hosts.'
- ' The hosts for which the firmware compliance reports needs'
- ' to be fetched.'
- ' default: null'
- ' elements: str'
- ' type: list'
- ''
- ' - servicetags'
- ' The service tag of the hosts.'
- ' The hosts for which the firmware compliance reports needs'
- ' to be fetched.'
- ' default: null'
- ' elements: str'
- ' type: list'
- ''
- = hostname
- ' IP address or hostname of the OpenManage Enterprise Modular.'
- ' type: str'
- ''
- '- port'
- ' OpenManage Enterprise HTTPS port.'
- ' default: 443'
- ' type: int'
- ''
- '- 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: Abhishek Sinha(@ABHISHEK-SINHA10)'
- ''
- 'EXAMPLES:'
- ''
- '---'
- '- name: Fetch firmware compliance report of all the cluster'
- ' dellemc.openmanage.omevv_firmware_compliance_info:'
- ' hostname: "192.168.0.1"'
- ' vcenter_uuid: "xxxxx"'
- ' vcenter_username: "username"'
- ' vcenter_password: "password"'
- ' ca_path: "path/to/ca_file"'
- ''
- '- name: Fetch firmware compliance report of all the hosts in the specific cluster'
- ' dellemc.openmanage.omevv_firmware_compliance_info:'
- ' hostname: "192.168.0.1"'
- ' vcenter_uuid: "xxxxx"'
- ' vcenter_username: "username"'
- ' vcenter_password: "password"'
- ' ca_path: "path/to/ca_file"'
- ' clusters:'
- ' - cluster_name: cluster_a'
- ''
- '- name: Fetch firmware compliance report of a specific hosts in the cluster'
- ' dellemc.openmanage.omevv_firmware_compliance_info:'
- ' hostname: "192.168.0.1"'
- ' vcenter_uuid: "xxxxx"'
- ' vcenter_username: "username"'
- ' vcenter_password: "password"'
- ' ca_path: "path/to/ca_file"'
- ' clusters:'
- ' - cluster_name: cluster_a'
- ' servicetags:'
- ' - SVCTAG1'
- ' - SVCTAG2'
- ' hosts:'
- ' - host1'
- ' - xx.xx.xx.xx'
- ''
- '- name: Fetch firmware compliance report of multiple cluster'
- ' dellemc.openmanage.omevv_firmware_compliance_info:'
- ' hostname: "192.168.0.1"'
- ' vcenter_uuid: "xxxxx"'
- ' vcenter_username: "username"'
- ' vcenter_password: "password"'
- ' ca_path: "path/to/ca_file"'
- ' clusters:'
- ' - cluster_name: cluster_a'
- ' - cluster_name: cluster_b'
- ''
- ''
- 'RETURN VALUES:'
- '- firmware_compliance_info'
- ' Details of the compliance report.'
- ' elements: dict'
- ' returned: on HTTP error'
- ' sample: [{cluster: cluster_a, complianceStatus: NonCompliant, hostComplianceReports:
[{complianceStatus: WARNING,'
- ' componentCompliances: [{baselineValue: 4303A19, complianceStatus:
WARNING,'
- ' componentName: Enterprise UEFI Diagnostics, criticality: Optional,
currentValue: 4303A15,'
- ' driftStatus: NonCompliant, rebootRequired: false, sourceName:
''DCIM:INSTALLED#802__Diagnostics.Embedded.1:LC.Embedded.1'','
- ' updateAction: UPGRADE}], deviceModel: PowerEdge R660xs, hostAddress:
XX.XX.XX.XX,'
- ' hostId: 1002, serviceTag: SVCTAG}]}]'
- ' type: list'
- ''
- '- msg'
- ' Retrive the firmware compliance report.'
- ' returned: always'
- ' sample: Successfully fetched the firmware compliance report.'
- ' type: str'
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
dependencies:
- prepare_omevv_registration
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
- name: Post-requisite - Delete a baseline profile
dellemc.openmanage.omevv_baseline_profile:
hostname: "{{ hostname }}"
vcenter_uuid: "{{ uuid }}"
vcenter_username: "{{ vcenter_username }}"
vcenter_password: "{{ vcenter_password }}"
name: "AnsibleTest"
state: "absent"
validate_certs: false
register: delete_result
no_log: true
ignore_errors: true
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
- name: Pre-requisite - Create a baseline profile
dellemc.openmanage.omevv_baseline_profile:
hostname: "{{ hostname }}"
vcenter_uuid: "{{ uuid }}"
vcenter_username: "{{ vcenter_username }}"
vcenter_password: "{{ vcenter_password }}"
name: "AnsibleTest"
repository_profile: "Dell Default Catalog"
validate_certs: false
description: "Firmware repository profile created by Module"
cluster:
- "{{ cluster_name }}"
days:
- "sunday"
time: "03:59"
register: create_result
no_log: true
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
---
- name: Get all clusters by uri.
ansible.builtin.uri:
url: https://{{ hostname | ansible.utils.ipwrap }}:{{ port
}}/omevv/GatewayService/v1/Consoles/{{ uuid }}/Clusters
user: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
validate_certs: false
force_basic_auth: true
status_code: 200
headers:
x_omivv-api-vcenter-identifier: "{{ uuid }}"
register: all_clusters_resp

- name: Extract entityIds
ansible.builtin.set_fact:
entity_ids: "{{ entity_ids | default([]) + [item.entityId] }}"
loop: "{{ all_clusters_resp.json }}"

- name: Extract cluster names
ansible.builtin.set_fact:
cluster_names: "{{ cluster_names | default([]) + [item.name] }}"
loop: "{{ all_clusters_resp.json }}"

- name: Create payload
ansible.builtin.set_fact:
payload:
clustIds: "{{ entity_ids }}"

- name: Get list of groupIDs for given cluster IDs.
ansible.builtin.uri:
url: https://{{ hostname | ansible.utils.ipwrap }}:{{ port
}}/omevv/GatewayService/v1/Consoles/{{ uuid
}}/Groups/getGroupsForClusters
user: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
validate_certs: false
method: POST
body: "{{ payload | to_json }}"
body_format: json
force_basic_auth: true
status_code: 200
headers:
x_omivv-api-vcenter-identifier: "{{ uuid }}"
register: group_ids_resp

- name: Set fact for groupIds
ansible.builtin.set_fact:
group_ids: "{{ group_ids_resp.json | map(attribute='groupId') | list }}"

- name: Get cluster drift info.
ansible.builtin.uri:
url: https://{{ hostname | ansible.utils.ipwrap }}:{{ port
}}/omevv/GatewayService/v1/Consoles/{{ uuid
}}/Groups/{{ item }}/FirmwareDriftReport
user: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
validate_certs: false
method: GET
force_basic_auth: true
status_code: 200
headers:
x_omivv-api-vcenter-identifier: "{{ uuid }}"
loop: "{{ group_ids }}"
register: cluster_drift_info
ignore_errors: true

- name: Initialize all_cluster_drift_info
ansible.builtin.set_fact:
all_cluster_drift_info: []

- name: Set fact to store all drift info
ansible.builtin.set_fact:
all_cluster_drift_info: "{{ all_cluster_drift_info + [item.json] }}"
loop: "{{ cluster_drift_info.results }}"
when: item.json is defined

- name: Remove error and message from all_cluster_drift_info response
ansible.builtin.set_fact:
all_cluster_drift_info: "{{ all_cluster_drift_info | ansible.utils.
remove_keys(target=['errorCode', 'message'],
matching_parameter='regex') }}"

- name: Remove cluster key from module response
ansible.builtin.set_fact:
modified_response: "{{ info_result.firmware_compliance_info |
ansible.utils.remove_keys(target=['cluster', 'error_code', 'message'],
matching_parameter='regex') }}"
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
---
- name: Get group details
ansible.builtin.uri:
url: https://{{ hostname | ansible.utils.ipwrap }}:{{ port
}}/omevv/GatewayService/v1/Consoles/{{ uuid }}/Groups
user: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
validate_certs: false
force_basic_auth: true
status_code: 200
headers:
x_omivv-api-vcenter-identifier: "{{ uuid }}"
register: group_details

- name: Find the CLUSTER group
ansible.builtin.set_fact:
cluster_name: "{{ item.consoleEntityName }}"
group_id: "{{ item.groupId }}"
loop: "{{ group_details.json }}"
when: item.groupType == "CLUSTER"
register: cluster_result
until: cluster_result is defined
retries: 1
delay: 0

- name: Find hosts details
ansible.builtin.uri:
url: https://{{ hostname | ansible.utils.ipwrap }}:{{ port
}}/omevv/GatewayService/v1/Consoles/{{ uuid }}/ManagedHosts
user: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
validate_certs: false
force_basic_auth: true
status_code: 200
headers:
x_omivv-api-vcenter-identifier: "{{ uuid }}"
register: host_details

- name: Find the host and its servicetag
ansible.builtin.set_fact:
host: "{{ item.hostName }}"
servicetag: "{{ item.serviceTag }}"
loop: "{{ host_details.json }}"
when: item.omevvpGroupId|string == group_id
register: host_result
until: host_result is defined
retries: 1
delay: 0
Loading
Loading