Skip to content

Commit

Permalink
Updated README and improved share handling in idrac_network.py
Browse files Browse the repository at this point in the history
README.md:
- Added TOC
- Based on user feedback took @anupamaloke 's answer and provided an explanation for the required shares along with how to easily handle the share
- Changed the header Playbooks to Sample Playbooks so user's would have a better idea of what was there

dellemc_configure_idrac_eventing.py
dellemc_configure_idrac_services.py
dellemc_idrac_lc_attributes.py
dellemc_system_lockdown_mode.py
idrac_bios.py
idrac_firmware.py
idrac_network.py
idrac_syslog.pyidrac_timezone_ntp.py:
- Added error handling such that if a share is used and not valid the module gracefully fails.
- Fixes #266
- Fixes #194
- Fixes #154

All files:
- optimized imports

Signed-off-by: Grant Curell <grant_curell@dell.com>
  • Loading branch information
grantcurell committed May 3, 2021
1 parent 54eed8c commit c1a3af8
Show file tree
Hide file tree
Showing 29 changed files with 137 additions and 29 deletions.
61 changes: 60 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,21 @@ Dell EMC OpenManage Ansible Modules allows data center and IT administrators to

OpenManage Ansible Modules simplifies and automates provisioning, deployment, and updates of PowerEdge servers and modular infrastructure. It allows system administrators and software developers to introduce the physical infrastructure provisioning into their software provisioning stack, integrate with existing DevOps pipelines and manage their infrastructure using version-controlled playbooks, server configuration profiles, and templates in line with the Infrastructure-as-Code (IaC) principles.

- [Supported Platforms](#supported-platforms)
- [Prerequisites](#prerequisites)
- [Installation](#installation)
- [Sample Playbooks](#sample-playbooks)
- [Handling Modules with Required Shares](#handling-modules-with-required-shares)
- [Why is a share required?](#why-is-a-share-required)
- [How to handle required shares easily](#how-to-handle-required-shares-easily)
- [Documentation](#documentation)
- [LICENSE](#license)
- [Contributing](#contributing)
- [Testing](#testing)
- [Maintenance](#maintenance)
- [Support](#support)
- [Authors](#authors)

## Supported Platforms
* iDRAC 7 and 8 based Dell EMC PowerEdge Servers with Firmware versions 2.60.60.60 and above.
* iDRAC 9 based Dell EMC PowerEdge Servers with Firmware versions 3.34.34.34 and above.
Expand All @@ -29,9 +44,53 @@ OpenManage Ansible Modules simplifies and automates provisioning, deployment, an
Install the collection from the github repository using the latest commit on the branch 'collections'
```ansible-galaxy collection install git+https://github.com/dell/dellemc-openmanage-ansible-modules.git,collections```

## Playbooks
## Sample Playbooks
Latest sample playbooks and examples are available at [playbooks](https://github.com/dell/dellemc-openmanage-ansible-modules/tree/collections/playbooks).

## Handling Modules with Required Shares

### Why is a share required?

Many modules use what's called a server configuration profile (SCP) to update the iDRAC attributes on iDRAC 7/8 and iDRAC 9.
When we were first developing these Ansible modules, iDRAC7/8 only supported importing a SCP file from a remote
network share (CIFS or NFS). Subsquently share_name argument was added to specify the network share location that
iDRAC uses to import the SCP. iDRAC7/8 now also support local file streaming within the HTTPS message playload itself
(firmare version 2.50.50.50 and above). We are currently working to update the modules to leverage these new mechanisms.
For a detailed explanation see [this post](https://github.com/dell/omsdk/blob/devel/docs/idrac.rst#prerequisites)

### How to handle required shares easily

In the meantime, you do not actually need to provide a share. You can pass {{ playbook_dir }} to share name like this:

- name: Setup iDRAC NIC
idrac_network:
idrac_ip: "{{ idrac_ip }}"
idrac_user: "{{ idrac_user }}"
idrac_password: "{{ idrac_password }}"
share_name: "{{ playbook_dir }}"
enable_nic: "Enabled"
nic_selection: "Dedicated"
failover_network: "T_None"
auto_detect: "Disabled"
auto_negotiation: "Enabled"
network_speed: "T_1000"
duplex_mode: "Full"

tags:
- idrac_nic

or if you are debugging a module it would look like this:

{
"ANSIBLE_MODULE_ARGS": {
"idrac_ip": "192.168.1.63",
"idrac_user": "root",
"idrac_password": "calvin",
"share_name": "/home/gelante/programs/dellemc-openmanage-ansible-modules",
"ip_address": "192.168.1.64"
}
}

## Documentation
Use `ansible-doc` to view the documentation of each module and plugin.
For example-```ansible-doc dellemc.openmanage.<module_name>```
Expand Down
7 changes: 6 additions & 1 deletion plugins/modules/dellemc_configure_idrac_eventing.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@
from ansible_collections.dellemc.openmanage.plugins.module_utils.dellemc_idrac import iDRACConnection
from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.six.moves.urllib.error import URLError, HTTPError
from ansible.module_utils.urls import open_url, ConnectionError, SSLValidationError
from ansible.module_utils.urls import ConnectionError, SSLValidationError
try:
from omdrivers.enums.iDRAC.iDRAC import (State_SNMPAlertTypes, Enable_EmailAlertTypes,
AlertEnable_IPMILanTypes,
Expand All @@ -203,6 +203,11 @@ def run_idrac_eventing_config(idrac, module):
module.params['share_user'],
module.params['share_password']))

if not upd_share.IsValid:
module.fail_json(msg=str("The share you provided is not valid. Make sure the path and credentials you passed"
" are correct and try again. Tip: You can use the local playbook directory by "
"passing \"{{ playbook_dir }}\" as the argument to \"share_name\""))

set_liason = idrac.config_mgr.set_liason_share(upd_share)
if set_liason['Status'] == "Failed":
try:
Expand Down
7 changes: 6 additions & 1 deletion plugins/modules/dellemc_configure_idrac_services.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@
import json
from ansible_collections.dellemc.openmanage.plugins.module_utils.dellemc_idrac import iDRACConnection
from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.urls import open_url, ConnectionError, SSLValidationError
from ansible.module_utils.urls import ConnectionError, SSLValidationError
from ansible.module_utils.six.moves.urllib.error import URLError, HTTPError

try:
Expand Down Expand Up @@ -214,6 +214,11 @@ def run_idrac_services_config(idrac, module):
module.params['share_password'])
)

if not upd_share.IsValid:
module.fail_json(msg=str("The share you provided is not valid. Make sure the path and credentials you passed"
" are correct and try again. Tip: You can use the local playbook directory by "
"passing \"{{ playbook_dir }}\" as the argument to \"share_name\""))

set_liason = idrac.config_mgr.set_liason_share(upd_share)
if set_liason['Status'] == "Failed":
try:
Expand Down
7 changes: 6 additions & 1 deletion plugins/modules/dellemc_idrac_lc_attributes.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@
import json
from ansible_collections.dellemc.openmanage.plugins.module_utils.dellemc_idrac import iDRACConnection
from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.urls import open_url, ConnectionError, SSLValidationError
from ansible.module_utils.urls import ConnectionError, SSLValidationError
from ansible.module_utils.six.moves.urllib.error import URLError, HTTPError

try:
Expand Down Expand Up @@ -150,6 +150,11 @@ def run_setup_idrac_csior(idrac, module):
module.params['share_password'])
)

if not upd_share.IsValid:
module.fail_json(msg=str("The share you provided is not valid. Make sure the path and credentials you passed"
" are correct and try again. Tip: You can use the local playbook directory by "
"passing \"{{ playbook_dir }}\" as the argument to \"share_name\""))

set_liason = idrac.config_mgr.set_liason_share(upd_share)
if set_liason['Status'] == "Failed":
try:
Expand Down
7 changes: 6 additions & 1 deletion plugins/modules/dellemc_system_lockdown_mode.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@
import json
from ansible_collections.dellemc.openmanage.plugins.module_utils.dellemc_idrac import iDRACConnection
from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.urls import open_url, ConnectionError, SSLValidationError
from ansible.module_utils.urls import ConnectionError, SSLValidationError
from ansible.module_utils.six.moves.urllib.error import URLError, HTTPError
try:
from omsdk.sdkfile import file_share_manager
Expand Down Expand Up @@ -154,6 +154,11 @@ def run_system_lockdown_mode(idrac, module):
module.params['share_password'])
)

if not upd_share.IsValid:
module.fail_json(msg=str("The share you provided is not valid. Make sure the path and credentials you passed"
" are correct and try again. Tip: You can use the local playbook directory by "
"passing \"{{ playbook_dir }}\" as the argument to \"share_name\""))

set_liason = idrac.config_mgr.set_liason_share(upd_share)
if set_liason['Status'] == "Failed":
try:
Expand Down
8 changes: 7 additions & 1 deletion plugins/modules/idrac_bios.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@
import tempfile
import json
from ansible.module_utils.six.moves.urllib.error import URLError, HTTPError
from ansible.module_utils.urls import open_url, ConnectionError, SSLValidationError
from ansible.module_utils.urls import ConnectionError, SSLValidationError
from ansible_collections.dellemc.openmanage.plugins.module_utils.dellemc_idrac import iDRACConnection
from ansible.module_utils.basic import AnsibleModule
try:
Expand All @@ -259,6 +259,12 @@ def run_server_bios_config(idrac, module):
module.params['share_user'],
module.params['share_password'])
)

if not upd_share.IsValid:
module.fail_json(msg=str("The share you provided is not valid. Make sure the path and credentials you passed"
" are correct and try again. Tip: You can use the local playbook directory by "
"passing \"{{ playbook_dir }}\" as the argument to \"share_name\""))

if module.params['boot_sources']:
_validate_params(module.params['boot_sources'])
if module.check_mode:
Expand Down
9 changes: 8 additions & 1 deletion plugins/modules/idrac_firmware.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@
from ansible_collections.dellemc.openmanage.plugins.module_utils.idrac_redfish import iDRACRedfishAPI
from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.six.moves.urllib.parse import urlparse
from ansible.module_utils.urls import open_url, ConnectionError, SSLValidationError
from ansible.module_utils.urls import ConnectionError, SSLValidationError
from ansible.module_utils.six.moves.urllib.error import URLError, HTTPError
try:
from omsdk.sdkcreds import UserCredentials
Expand Down Expand Up @@ -411,6 +411,13 @@ def update_firmware_omsdk(idrac, module):
upd_share = FileOnShare(remote="{0}{1}{2}".format(share_name, os.sep, catalog_file_name),
mount_point=module.params['share_mnt'], isFolder=False,
creds=UserCredentials(share_user, share_pwd))

if not upd_share.IsValid:
module.fail_json(
msg=str("The share you provided is not valid. Make sure the path and credentials you passed"
" are correct and try again. Tip: You can use the local playbook directory by "
"passing \"{{ playbook_dir }}\" as the argument to \"share_name\""))

msg['update_status'] = idrac.update_mgr.update_from_repo(upd_share, apply_update=apply_update,
reboot_needed=reboot, job_wait=job_wait)
get_check_mode_status(msg['update_status'], module)
Expand Down
2 changes: 1 addition & 1 deletion plugins/modules/idrac_firmware_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@
import json
from ansible_collections.dellemc.openmanage.plugins.module_utils.dellemc_idrac import iDRACConnection
from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.urls import open_url, ConnectionError, SSLValidationError
from ansible.module_utils.urls import ConnectionError, SSLValidationError
from ansible.module_utils.six.moves.urllib.error import URLError, HTTPError
try:
from omsdk.sdkfile import LocalFile
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
import json
from ansible_collections.dellemc.openmanage.plugins.module_utils.dellemc_idrac import iDRACConnection
from ansible.module_utils.six.moves.urllib.error import URLError, HTTPError
from ansible.module_utils.urls import open_url, ConnectionError, SSLValidationError
from ansible.module_utils.urls import ConnectionError, SSLValidationError
from ansible.module_utils.basic import AnsibleModule


Expand Down
2 changes: 1 addition & 1 deletion plugins/modules/idrac_lifecycle_controller_logs.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@
from ansible_collections.dellemc.openmanage.plugins.module_utils.dellemc_idrac import iDRACConnection
from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.six.moves.urllib.error import URLError, HTTPError
from ansible.module_utils.urls import open_url, ConnectionError, SSLValidationError
from ansible.module_utils.urls import ConnectionError, SSLValidationError
import json
try:
from omsdk.sdkfile import file_share_manager
Expand Down
2 changes: 1 addition & 1 deletion plugins/modules/idrac_lifecycle_controller_status_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@

from ansible_collections.dellemc.openmanage.plugins.module_utils.dellemc_idrac import iDRACConnection
from ansible.module_utils.six.moves.urllib.error import URLError, HTTPError
from ansible.module_utils.urls import open_url, ConnectionError, SSLValidationError
from ansible.module_utils.urls import ConnectionError, SSLValidationError
from ansible.module_utils.basic import AnsibleModule
import json

Expand Down
8 changes: 7 additions & 1 deletion plugins/modules/idrac_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@

import json
from ansible.module_utils.six.moves.urllib.error import URLError, HTTPError
from ansible.module_utils.urls import open_url, ConnectionError, SSLValidationError
from ansible.module_utils.urls import ConnectionError, SSLValidationError
from ansible_collections.dellemc.openmanage.plugins.module_utils.dellemc_idrac import iDRACConnection
from ansible.module_utils.basic import AnsibleModule
try:
Expand All @@ -229,6 +229,7 @@

def run_idrac_network_config(idrac, module):
idrac.use_redfish = True

upd_share = file_share_manager.create_share_obj(share_path=module.params['share_name'],
mount_point=module.params['share_mnt'],
isFolder=True,
Expand All @@ -237,6 +238,11 @@ def run_idrac_network_config(idrac, module):
module.params['share_password'])
)

if not upd_share.IsValid:
module.fail_json(msg=str("The share you provided is not valid. Make sure the path and credentials you passed"
" are correct and try again. Tip: You can use the local playbook directory by "
"passing \"{{ playbook_dir }}\" as the argument to \"share_name\""))

idrac.config_mgr.set_liason_share(upd_share)
if module.params['register_idrac_on_dns'] is not None:
idrac.config_mgr.configure_dns(
Expand Down
2 changes: 1 addition & 1 deletion plugins/modules/idrac_reset.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@
from ansible_collections.dellemc.openmanage.plugins.module_utils.dellemc_idrac import iDRACConnection
from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.six.moves.urllib.error import URLError, HTTPError
from ansible.module_utils.urls import open_url, ConnectionError, SSLValidationError
from ansible.module_utils.urls import ConnectionError, SSLValidationError


def run_idrac_reset(idrac, module):
Expand Down
8 changes: 7 additions & 1 deletion plugins/modules/idrac_syslog.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@
from ansible_collections.dellemc.openmanage.plugins.module_utils.dellemc_idrac import iDRACConnection
from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.six.moves.urllib.error import URLError, HTTPError
from ansible.module_utils.urls import open_url, ConnectionError, SSLValidationError
from ansible.module_utils.urls import ConnectionError, SSLValidationError

try:
from omsdk.sdkfile import file_share_manager
Expand All @@ -141,6 +141,12 @@ def run_setup_idrac_syslog(idrac, module):
creds=UserCredentials(
module.params['share_user'],
module.params['share_password']))

if not upd_share.IsValid:
module.fail_json(msg=str("The share you provided is not valid. Make sure the path and credentials you passed"
" are correct and try again. Tip: You can use the local playbook directory by "
"passing \"{{ playbook_dir }}\" as the argument to \"share_name\""))

idrac.config_mgr.set_liason_share(upd_share)
if module.check_mode:
if module.params['syslog'] == 'Enabled':
Expand Down
2 changes: 1 addition & 1 deletion plugins/modules/idrac_system_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
from ansible_collections.dellemc.openmanage.plugins.module_utils.dellemc_idrac import iDRACConnection
from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.six.moves.urllib.error import URLError, HTTPError
from ansible.module_utils.urls import open_url, ConnectionError, SSLValidationError
from ansible.module_utils.urls import ConnectionError, SSLValidationError


# Main
Expand Down
7 changes: 6 additions & 1 deletion plugins/modules/idrac_timezone_ntp.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@
from ansible_collections.dellemc.openmanage.plugins.module_utils.dellemc_idrac import iDRACConnection
from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.six.moves.urllib.error import URLError, HTTPError
from ansible.module_utils.urls import open_url, ConnectionError, SSLValidationError
from ansible.module_utils.urls import ConnectionError, SSLValidationError
import json
try:
from omdrivers.enums.iDRAC.iDRAC import NTPEnable_NTPConfigGroupTypes
Expand All @@ -153,6 +153,11 @@ def run_idrac_timezone_config(idrac, module):
module.params['share_user'],
module.params['share_password']))

if not upd_share.IsValid:
module.fail_json(msg=str("The share you provided is not valid. Make sure the path and credentials you passed"
" are correct and try again. Tip: You can use the local playbook directory by "
"passing \"{{ playbook_dir }}\" as the argument to \"share_name\""))

idrac.config_mgr.set_liason_share(upd_share)

if module.params['setup_idrac_timezone'] is not None:
Expand Down
2 changes: 1 addition & 1 deletion plugins/modules/idrac_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@
import re
import time
from ansible.module_utils.six.moves.urllib.error import URLError, HTTPError
from ansible.module_utils.urls import open_url, ConnectionError, SSLValidationError
from ansible.module_utils.urls import ConnectionError, SSLValidationError
from ansible_collections.dellemc.openmanage.plugins.module_utils.idrac_redfish import iDRACRedfishAPI
from ansible.module_utils.basic import AnsibleModule

Expand Down
2 changes: 1 addition & 1 deletion plugins/modules/ome_application_network_address.py
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@
from ssl import SSLError
from ansible.module_utils.basic import AnsibleModule
from ansible_collections.dellemc.openmanage.plugins.module_utils.ome import RestOME
from ansible.module_utils.urls import open_url, ConnectionError, SSLValidationError
from ansible.module_utils.urls import ConnectionError, SSLValidationError
from ansible.module_utils.six.moves.urllib.error import URLError, HTTPError

IP_CONFIG = "ApplicationService/Network/AddressConfiguration"
Expand Down
2 changes: 1 addition & 1 deletion plugins/modules/ome_application_network_proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@
from ssl import SSLError
from ansible.module_utils.basic import AnsibleModule
from ansible_collections.dellemc.openmanage.plugins.module_utils.ome import RestOME
from ansible.module_utils.urls import open_url, ConnectionError, SSLValidationError
from ansible.module_utils.urls import ConnectionError, SSLValidationError
from ansible.module_utils.six.moves.urllib.error import URLError, HTTPError

PROXY_CONFIG = "ApplicationService/Network/ProxyConfiguration"
Expand Down
2 changes: 1 addition & 1 deletion plugins/modules/ome_application_network_time.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@
from ssl import SSLError
from ansible.module_utils.basic import AnsibleModule
from ansible_collections.dellemc.openmanage.plugins.module_utils.ome import RestOME
from ansible.module_utils.urls import open_url, ConnectionError, SSLValidationError
from ansible.module_utils.urls import ConnectionError, SSLValidationError
from ansible.module_utils.six.moves.urllib.error import URLError, HTTPError

TIME_CONFIG = "ApplicationService/Network/TimeConfiguration"
Expand Down
Loading

0 comments on commit c1a3af8

Please sign in to comment.