diff options
Diffstat (limited to 'ansible_collections/dellemc/openmanage/roles/idrac_firmware')
25 files changed, 1164 insertions, 0 deletions
diff --git a/ansible_collections/dellemc/openmanage/roles/idrac_firmware/README.md b/ansible_collections/dellemc/openmanage/roles/idrac_firmware/README.md new file mode 100644 index 000000000..6b4dace7a --- /dev/null +++ b/ansible_collections/dellemc/openmanage/roles/idrac_firmware/README.md @@ -0,0 +1,342 @@ +# idrac_firmware + +Update the Firmware by connecting to a network share (CIFS, NFS, HTTP, HTTPS, FTP) that contains a catalog of available updates. + +## Requirements + +### Development +Requirements to develop and contribute to the role. +``` +ansible +docker +molecule +python +omsdk +``` +### Production +Requirements to use the role. +``` +ansible +python +omsdk +``` + +### Ansible collections +Collections required to use the role +``` +dellemc.openmanage +``` + +## Role Variables + +<table> +<thead> + <tr> + <th>Name</th> + <th>Required</th> + <th>Default Value</th> + <th>Choices</th> + <th>Type</th> + <th>Description</th> + </tr> +</thead> +<tbody> + <tr> + <td>hostname</td> + <td>true</td> + <td></td> + <td></td> + <td>str</td> + <td>- iDRAC IP Address</td> + </tr> + <tr> + <td>username</td> + <td>true</td> + <td></td> + <td></td> + <td>str</td> + <td>- iDRAC username</td> + </tr> + <tr> + <td>password</td> + <td>true</td> + <td></td> + <td></td> + <td>str</td> + <td>- iDRAC user password.</td> + </tr> + <tr> + <td>https_port</td> + <td>false</td> + <td>443</td> + <td></td> + <td>int</td> + <td>- iDRAC port.</td> + </tr> + <tr> + <td>validate_certs</td> + <td>false</td> + <td>true</td> + <td></td> + <td>bool</td> + <td>- If C(false), the SSL certificates will not be validated.<br>- Configure C(false) only on personally controlled sites where self-signed certificates are used.</td> + </tr> + <tr> + <td>ca_path</td> + <td>false</td> + <td></td> + <td></td> + <td>path</td> + <td>- The Privacy Enhanced Mail (PEM) file that contains a CA certificate to be used for the validation.</td> + </tr> + <tr> + <td>https_timeout</td> + <td>false</td> + <td>30</td> + <td></td> + <td>int</td> + <td>- The HTTPS socket level timeout in seconds.</td> + </tr> + <tr> + <td>share_name</td> + <td>true</td> + <td></td> + <td></td> + <td>str</td> + <td>- Network share path of update repository. CIFS, NFS, HTTP, HTTPS and FTP share types are supported.</td> + </tr> + <tr> + <td>share_user</td> + <td>false</td> + <td></td> + <td></td> + <td>str</td> + <td>- Network share user in the format 'user@domain' or 'domain\\user' if user is part of a domain else 'user'. This option is mandatory for CIFS Network Share.</td> + </tr> + <tr> + <td>share_password</td> + <td>false</td> + <td></td> + <td></td> + <td>str</td> + <td>- Network share user password. This option is mandatory for CIFS Network Share.</td> + </tr> + <tr> + <td>catalog_file_name</td> + <td>false</td> + <td>Catalog.xml</td> + <td></td> + <td>str</td> + <td>- Catalog file name relative to the I(share_name</td> + </tr> + <tr> + <td>ignore_cert_warning</td> + <td>false</td> + <td>true</td> + <td></td> + <td>bool</td> + <td>- Specifies if certificate warnings are ignored when HTTPS share is used.</br>- If C(true) option is set, then the certificate warnings are ignored.</td> + </tr> + <tr> + <td>apply_update</td> + <td>false</td> + <td>true</td> + <td></td> + <td>bool</td> + <td> - If I(apply_update) is set to C(true), then the packages are applied.</br>- If I(apply_update) is set to C(false), no updates are applied, and a catalog report of packages is generated and returned.</td> + </tr> + <tr> + <td>reboot</td> + <td>false</td> + <td>false</td> + <td></td> + <td>bool</td> + <td>- Provides the option to apply the update packages immediately or in the next reboot.</br> - If I(reboot) is set to C(true), then the packages are applied immediately.</br>- If I(reboot) is set to C(false), then the packages are staged and applied in the next reboot.</br>- Packages that do not require a reboot are applied immediately irrespective of I (reboot). + </td> + </tr> + <tr> + <td>proxy_support</td> + <td>false</td> + <td>Off</td> + <td>"ParametersProxy", "DefaultProxy", "Off"</td> + <td>str</td> + <td>- Specifies if a proxy should be used.</br>- Proxy parameters are applicable on C(HTTP), C(HTTPS), and C(FTP) share type of repositories.</br> - C(ParametersProxy), sets the proxy parameters for the current firmware operation.</br>- C(DefaultProxy), iDRAC uses the proxy values set by default.</br>- Default Proxy can be set in the Lifecycle Controller attributes using M(dellemc.openmanage.idrac_attributes).</br>- C(Off), will not use the proxy.</br>- For iDRAC8 based servers, use proxy server with basic authentication.</br>- For iDRAC9 based servers, ensure that you use digest authentication for the proxy server, basic authentication is not supported. + </td> + </tr> + <tr> + <td>proxy_server</td> + <td>false</td> + <td></td> + <td></td> + <td>str</td> + <td>- The IP address of the proxy server.</br>- This IP will not be validated. The download job will be created even for invalid I(proxy_server).</br>- Please check the results of the job for error details.</br>- This is required when I(proxy_support) is C(ParametersProxy). </td> + </tr> + <tr> + <td>proxy_port</td> + <td>false</td> + <td></td> + <td></td> + <td>int</td> + <td>- The Port for the proxy server.</br>- This is required when I(proxy_support) is C(ParametersProxy).</td> + </tr> + <tr> + <td>proxy_type</td> + <td>false</td> + <td></td> + <td>HTTP, SOCKS</td> + <td>str</td> + <td>- The proxy type of the proxy server.</br>- This is required when I(proxy_support) is C(ParametersProxy).</td> + </tr> + <tr> + <td>proxy_uname</td> + <td>false</td> + <td></td> + <td></td> + <td>str</td> + <td>- The user name for the proxy server.</td> + </tr> + <tr> + <td>proxy_passwd</td> + <td>false</td> + <td></td> + <td></td> + <td>str</td> + <td>- The password for the proxy server.</td> + </tr> + <tr> + <td>job_wait</td> + <td>false</td> + <td></td> + <td>true</td> + <td>bool</td> + <td>- Whether to wait for job completion or not.</td> + </tr> +</tbody> +</table> + +## Fact variables + +<table> +<thead> + <tr> + <th>Name</th> + <th>Sample</th> + <th>Description</th> + </tr> +</thead> + <tbody> + <tr> + <td>idrac_firmware_out</td> + <td>{ +msg: "Successfully updated the firmware." +update_status: { + 'InstanceID': 'JID_XXXXXXXXXXXX', + 'JobState': 'Completed', + 'Message': 'Job completed successfully.', + 'MessageId': 'REDXXX', + 'Name': 'Repository Update', + 'JobStartTime': 'NA', + 'Status': 'Success', + } +}</td> +<td>Returns the output of the firmware update status</td> +</tbody> +</table> + +## Examples +----- + +```yml +- name: Update firmware from repository on a NFS Share + ansible.builtin.include_role: + name: idrac_firmware + vars: + hostname: "192.168.0.1" + username: "username" + password: "password" + share_name: "192.168.0.0:/share" + reboot: true + job_wait: true + apply_update: true + catalog_file_name: "Catalog.xml" + +``` +```yml +- name: Update firmware from repository on a CIFS Share + ansible.builtin.ansible.builtin.include_role: + name: idrac_firmware + vars: + hostname: "192.168.0.1" + username: "username" + password: "password" + share_name: "full_cifs_path" + share_user: "share_user" + share_password: "share_password" + reboot: true + job_wait: true + apply_update: true + catalog_file_name: "Catalog.xml" +``` +```yml +- name: Update firmware from repository on a HTTP + ansible.builtin.include_role: + name: idrac_firmware + vars: + hostname: "192.168.0.1" + username: "username" + password: "password" + share_name: "http://downloads.dell.com" + reboot: true + job_wait: true + apply_update: true +``` +```yml +- name: Update firmware from repository on a HTTPS + ansible.builtin.include_role: + name: idrac_firmware + vars: + hostname: "192.168.0.1" + username: "username" + password: "password" + share_name: "https://downloads.dell.com" + reboot: true + job_wait: true + apply_update: true + ``` + ```yml +- name: Update firmware from repository on a HTTPS via proxy + ansible.builtin.include_role: + name: idrac_firmware + vars: + hostname: "192.168.0.1" + username: "username" + password: "password" + share_name: "https://downloads.dell.com" + reboot: true + job_wait: true + apply_update: true + proxy_support: ParametersProxy + proxy_server: 192.168.1.10 + proxy_type: HTTP + proxy_port: 80 + proxy_uname: "proxy_user" + proxy_passwd: "proxy_pwd" + ``` + ```yml +- name: Update firmware from repository on a FTP + ansible.builtin.include_role: + name: idrac_firmware + vars: + hostname: "192.168.0.1" + username: "username" + password: "password" + share_name: "ftp://ftp.mydomain.com" + reboot: true + job_wait: true + apply_update: true +``` +## Author Information +------------------ + +Dell Technologies <br> +Sachin Apagundi (Sachin.Apagundi@Dell.com) 2023
\ No newline at end of file diff --git a/ansible_collections/dellemc/openmanage/roles/idrac_firmware/defaults/main.yml b/ansible_collections/dellemc/openmanage/roles/idrac_firmware/defaults/main.yml new file mode 100644 index 000000000..a684e7406 --- /dev/null +++ b/ansible_collections/dellemc/openmanage/roles/idrac_firmware/defaults/main.yml @@ -0,0 +1,11 @@ +--- +# defaults file for idrac_firmware +https_port: 443 +validate_certs: true +https_timeout: 30 +apply_update: true +reboot: true +proxy_support: "Off" +job_wait: true +ignore_cert_warning: true +catalog_file_name: "Catalog.xml" diff --git a/ansible_collections/dellemc/openmanage/roles/idrac_firmware/handlers/main.yml b/ansible_collections/dellemc/openmanage/roles/idrac_firmware/handlers/main.yml new file mode 100644 index 000000000..af82235fe --- /dev/null +++ b/ansible_collections/dellemc/openmanage/roles/idrac_firmware/handlers/main.yml @@ -0,0 +1,2 @@ +--- +# handlers file for idrac_firmware diff --git a/ansible_collections/dellemc/openmanage/roles/idrac_firmware/meta/argument_specs.yml b/ansible_collections/dellemc/openmanage/roles/idrac_firmware/meta/argument_specs.yml new file mode 100644 index 000000000..b6ac77a86 --- /dev/null +++ b/ansible_collections/dellemc/openmanage/roles/idrac_firmware/meta/argument_specs.yml @@ -0,0 +1,114 @@ +--- +argument_specs: + main: + version_added: "7.5.0" + short_description: Firmware update from a repository on a network share (CIFS, NFS, HTTP, HTTPS, FTP) + description: + - Update the Firmware by connecting to a network share (CIFS, NFS, HTTP, HTTPS, FTP) that contains a catalog of available updates. + options: + hostname: + required: true + type: str + description: iDRAC IP Address or hostname. + username: + type: str + description: iDRAC username with admin privileges. + password: + type: str + description: iDRAC user password. + https_port: + type: int + description: iDRAC port. + default: 443 + validate_certs: + description: + - If C(false), the SSL certificates will not be validated. + - Configure C(false) only on personally controlled sites where self-signed certificates are used. + type: bool + default: true + ca_path: + description: + - The Privacy Enhanced Mail (PEM) file that contains a CA certificate to be used for the validation. + type: path + http_timeout: + description: The socket level timeout in seconds. + type: int + default: 30 + share_name: + description: Network share path of update repository. CIFS, NFS, HTTP, HTTPS and FTP share types are supported. + type: str + required: true + share_user: + description: + Network share user in the format 'user@domain' or 'domain\\user' if user is + part of a domain else 'user'. This option is mandatory for CIFS Network Share. + type: str + share_password: + description: Network share user password. This option is mandatory for CIFS Network Share. + type: str + catalog_file_name: + description: Catalog file name relative to the I(share_name). + type: str + default: "Catalog.xml" + ignore_cert_warning: + description: + Specifies if certificate warnings are ignored when HTTPS share is used. + If C(true) option is set, then the certificate warnings are ignored. + type: bool + default: true + apply_update: + description: + - If I(apply_update) is set to C(true), then the packages are applied. + - If I(apply_update) is set to C(false), no updates are applied, and a catalog report + of packages is generated and returned. + type: bool + default: true + reboot: + description: + - Provides the option to apply the update packages immediately or in the next reboot. + - If I(reboot) is set to C(true), then the packages are applied immediately. + - If I(reboot) is set to C(false), then the packages are staged and applied in the next reboot. + - Packages that do not require a reboot are applied immediately irrespective of I (reboot). + type: bool + default: false + proxy_support: + description: + - Specifies if a proxy should be used. + - Proxy parameters are applicable on C(HTTP), C(HTTPS), and C(FTP) share type of repositories. + - C(ParametersProxy), sets the proxy parameters for the current firmware operation. + - C(DefaultProxy), iDRAC uses the proxy values set by default. + - Default Proxy can be set in the Lifecycle Controller attributes using M(dellemc.openmanage.idrac_attributes). + - C(Off), will not use the proxy. + - For iDRAC8 based servers, use proxy server with basic authentication. + - For iDRAC9 based servers, ensure that you use digest authentication for the proxy server, basic authentication is not supported. + choices: ["ParametersProxy", "DefaultProxy", "Off"] + type: str + default: "Off" + proxy_server: + description: + - The IP address of the proxy server. + - This IP will not be validated. The download job will be created even for invalid I(proxy_server). + Please check the results of the job for error details. + - This is required when I(proxy_support) is C(ParametersProxy). + type: str + proxy_port: + description: + - The Port for the proxy server. + - This is required when I(proxy_support) is C(ParametersProxy). + type: int + proxy_type: + description: + - The proxy type of the proxy server. + - This is required when I(proxy_support) is C(ParametersProxy). + choices: [HTTP, SOCKS] + type: str + proxy_uname: + description: The user name for the proxy server. + type: str + proxy_passwd: + description: The password for the proxy server. + type: str + job_wait: + description: Whether to wait for job completion or not. + type: bool + default: true diff --git a/ansible_collections/dellemc/openmanage/roles/idrac_firmware/meta/main.yml b/ansible_collections/dellemc/openmanage/roles/idrac_firmware/meta/main.yml new file mode 100644 index 000000000..77872e297 --- /dev/null +++ b/ansible_collections/dellemc/openmanage/roles/idrac_firmware/meta/main.yml @@ -0,0 +1,20 @@ +galaxy_info: + author: "Sachin Apagundi" + description: Firmware update from a repository on a network share (CIFS, NFS, HTTP, HTTPS, FTP). + company: Dell Technologies + license: GPL-3.0-only + min_ansible_version: "2.13" + platforms: + - name: Ubuntu + versions: + - jammy + - name: SLES + versions: + - "15SP3" + - "15SP4" + - name: EL + versions: + - "9" + - "8" + galaxy_tags: [] +dependencies: [] diff --git a/ansible_collections/dellemc/openmanage/roles/idrac_firmware/molecule/cifs_share/converge.yml b/ansible_collections/dellemc/openmanage/roles/idrac_firmware/molecule/cifs_share/converge.yml new file mode 100644 index 000000000..161a35cf4 --- /dev/null +++ b/ansible_collections/dellemc/openmanage/roles/idrac_firmware/molecule/cifs_share/converge.yml @@ -0,0 +1,39 @@ +--- +- name: Converge idrac_firmware for cifsshare + hosts: all + gather_facts: false + tasks: + - name: Update firmware from repository on a CIFS Share + ansible.builtin.import_role: + name: "idrac_firmware" + vars: + hostname: "{{ lookup('env', 'hostname') }}" + username: "{{ lookup('env', 'username') }}" + password: "{{ lookup('env', 'password') }}" + validate_certs: false + share_name: "{{ lookup('env', 'cifsshare') }}" + share_user: "{{ lookup('env', 'shareuser') }}" + share_password: "{{ lookup('env', 'sharepassword') }}" + reboot: true + job_wait: true + apply_update: true + catalog_file_name: "Catalog.xml" + + - name: "Verifying update firmware from repository on a CIFS Share in check mode" + ansible.builtin.assert: + that: idrac_firmware_out.msg == "Changes found to commit!" + when: ansible_check_mode + tags: molecule-idempotence-notest + + - name: "Verifying update firmware from repository on a CIFS Share in normal mode" + ansible.builtin.assert: + that: + - idrac_firmware_out.msg == "Successfully updated the firmware." + when: not ansible_check_mode and idrac_firmware_out.changed + + - name: "Verifying update firmware from repository on a CIFS Share in idempotence mode" + ansible.builtin.assert: + that: + - idrac_firmware_out.msg == "Unable to complete the operation because the catalog name entered has either unsupported firmware packages + or same version installed on the server." + when: not ansible_check_mode and not idrac_firmware_out.changed diff --git a/ansible_collections/dellemc/openmanage/roles/idrac_firmware/molecule/cifs_share/molecule.yml b/ansible_collections/dellemc/openmanage/roles/idrac_firmware/molecule/cifs_share/molecule.yml new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/ansible_collections/dellemc/openmanage/roles/idrac_firmware/molecule/cifs_share/molecule.yml diff --git a/ansible_collections/dellemc/openmanage/roles/idrac_firmware/molecule/default/converge.yml b/ansible_collections/dellemc/openmanage/roles/idrac_firmware/molecule/default/converge.yml new file mode 100644 index 000000000..bc30806f4 --- /dev/null +++ b/ansible_collections/dellemc/openmanage/roles/idrac_firmware/molecule/default/converge.yml @@ -0,0 +1,101 @@ +--- +- name: Converge idrac_firmware + hosts: all + gather_facts: false + tasks: + - name: Update firmware from repository on HTTPS Share with apply_update as false + ansible.builtin.import_role: + name: "idrac_firmware" + vars: + hostname: "{{ lookup('env', 'hostname') }}" + username: "{{ lookup('env', 'username') }}" + password: "{{ lookup('env', 'password') }}" + validate_certs: false + share_name: "{{ lookup('env', 'httpsshare') }}" + share_user: "{{ lookup('env', 'shareuser') }}" + share_password: "{{ lookup('env', 'sharepassword') }}" + reboot: true + job_wait: true + apply_update: false + catalog_file_name: "Catalog.xml" + tags: molecule-idempotence-notest + + - name: "Verifying update firmware from repository on a HTTPS Share with apply_update as false" + ansible.builtin.assert: + that: + - idrac_firmware_out.msg == "Unable to complete the operation because the catalog name entered has either unsupported firmware packages + or same version installed on the server." + when: not ansible_check_mode + + - name: Update firmware from repository on HTTPS Share with ignore_cert_warning as false + ansible.builtin.import_role: + name: "idrac_firmware" + vars: + hostname: "{{ lookup('env', 'hostname') }}" + username: "{{ lookup('env', 'username') }}" + password: "{{ lookup('env', 'password') }}" + validate_certs: false + share_name: "{{ lookup('env', 'httpsshare') }}" + share_user: "{{ lookup('env', 'shareuser') }}" + share_password: "{{ lookup('env', 'sharepassword') }}" + reboot: true + job_wait: true + apply_update: true + catalog_file_name: "Catalog.xml" + ignore_cert_warning: false + tags: molecule-idempotence-notest + + - name: "Verifying update firmware from repository on a HTTPS Share with ignore_cert_warning as false" + ansible.builtin.assert: + that: + - idrac_firmware_out.msg == "Unable to complete the operation because the catalog name entered has either unsupported firmware packages + or same version installed on the server." + when: not ansible_check_mode + + - name: Update firmware from repository on HTTPS Share with reboot as false + ansible.builtin.import_role: + name: "idrac_firmware" + vars: + hostname: "{{ lookup('env', 'hostname') }}" + username: "{{ lookup('env', 'username') }}" + password: "{{ lookup('env', 'password') }}" + validate_certs: false + share_name: "{{ lookup('env', 'httpsshare') }}" + share_user: "{{ lookup('env', 'shareuser') }}" + share_password: "{{ lookup('env', 'sharepassword') }}" + reboot: false + job_wait: true + apply_update: true + catalog_file_name: "Catalog.xml" + tags: molecule-idempotence-notest + + - name: "Verifying update firmware from repository on a HTTPS Share with reboot as false" + ansible.builtin.assert: + that: + - idrac_firmware_out.msg == "Unable to complete the operation because the catalog name entered has either unsupported firmware packages + or same version installed on the server." + when: not ansible_check_mode + + - name: Update firmware from repository on HTTPS Share with job_wait as false + ansible.builtin.import_role: + name: "idrac_firmware" + vars: + hostname: "{{ lookup('env', 'hostname') }}" + username: "{{ lookup('env', 'username') }}" + password: "{{ lookup('env', 'password') }}" + validate_certs: false + share_name: "{{ lookup('env', 'httpsshare') }}" + share_user: "{{ lookup('env', 'shareuser') }}" + share_password: "{{ lookup('env', 'sharepassword') }}" + reboot: true + job_wait: false + apply_update: true + catalog_file_name: "Catalog.xml" + tags: molecule-idempotence-notest + + - name: "Verifying update firmware from repository on a HTTPS Share with job_wait as false" + ansible.builtin.assert: + that: + - idrac_firmware_out.msg == "Unable to complete the operation because the catalog name entered has either unsupported firmware packages + or same version installed on the server." + when: not ansible_check_mode diff --git a/ansible_collections/dellemc/openmanage/roles/idrac_firmware/molecule/default/molecule.yml b/ansible_collections/dellemc/openmanage/roles/idrac_firmware/molecule/default/molecule.yml new file mode 100644 index 000000000..de4ada585 --- /dev/null +++ b/ansible_collections/dellemc/openmanage/roles/idrac_firmware/molecule/default/molecule.yml @@ -0,0 +1,10 @@ +--- +scenario: + test_sequence: + - dependency + - cleanup + - destroy + - syntax + - create + - converge + - destroy diff --git a/ansible_collections/dellemc/openmanage/roles/idrac_firmware/molecule/ftp_share/converge.yml b/ansible_collections/dellemc/openmanage/roles/idrac_firmware/molecule/ftp_share/converge.yml new file mode 100644 index 000000000..a94da723a --- /dev/null +++ b/ansible_collections/dellemc/openmanage/roles/idrac_firmware/molecule/ftp_share/converge.yml @@ -0,0 +1,39 @@ +--- +- name: Converge idrac_firmware for ftp share + hosts: all + gather_facts: false + tasks: + - name: Update firmware from repository on a FTP Share + ansible.builtin.import_role: + name: idrac_firmware + vars: + hostname: "{{ lookup('env', 'hostname') }}" + username: "{{ lookup('env', 'username') }}" + password: "{{ lookup('env', 'password') }}" + validate_certs: false + share_name: "{{ lookup('env', 'ftpshare') }}" + share_user: "{{ lookup('env', 'shareuser') }}" + share_password: "{{ lookup('env', 'sharepassword') }}" + catalog_file_name: "Catalog.xml" + reboot: true + job_wait: true + apply_update: true + + - name: "Verifying update firmware from repository on a FTP Share in check mode" + ansible.builtin.assert: + that: idrac_firmware_out.msg == "Changes found to commit!" + when: ansible_check_mode + tags: molecule-idempotence-notest + + - name: "Verifying update firmware from repository on a FTP Share in normal mode" + ansible.builtin.assert: + that: + - idrac_firmware_out.msg == "Successfully updated the firmware." + when: not ansible_check_mode and idrac_firmware_out.changed + + - name: "Verifying update firmware from repository on a FTP Share in idempotence mode" + ansible.builtin.assert: + that: + - idrac_firmware_out.msg == "Unable to complete the operation because the catalog name entered has either unsupported firmware packages + or same version installed on the server." + when: not ansible_check_mode and not idrac_firmware_out.changed diff --git a/ansible_collections/dellemc/openmanage/roles/idrac_firmware/molecule/ftp_share/molecule.yml b/ansible_collections/dellemc/openmanage/roles/idrac_firmware/molecule/ftp_share/molecule.yml new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/ansible_collections/dellemc/openmanage/roles/idrac_firmware/molecule/ftp_share/molecule.yml diff --git a/ansible_collections/dellemc/openmanage/roles/idrac_firmware/molecule/http_share/converge.yml b/ansible_collections/dellemc/openmanage/roles/idrac_firmware/molecule/http_share/converge.yml new file mode 100644 index 000000000..82df756b5 --- /dev/null +++ b/ansible_collections/dellemc/openmanage/roles/idrac_firmware/molecule/http_share/converge.yml @@ -0,0 +1,39 @@ +--- +- name: Converge idrac_firmware for httpshare + hosts: all + gather_facts: false + tasks: + - name: Update firmware from repository on HTTP Share + ansible.builtin.import_role: + name: "idrac_firmware" + vars: + hostname: "{{ lookup('env', 'hostname') }}" + username: "{{ lookup('env', 'username') }}" + password: "{{ lookup('env', 'password') }}" + validate_certs: false + share_name: "{{ lookup('env', 'httpsshare') }}" + share_user: "{{ lookup('env', 'shareuser') }}" + share_password: "{{ lookup('env', 'sharepassword') }}" + reboot: true + job_wait: true + apply_update: true + catalog_file_name: "Catalog.xml" + + - name: "Verifying update firmware from repository on a HTTP Share in check mode" + ansible.builtin.assert: + that: idrac_firmware_out.msg == "Changes found to commit!" + when: ansible_check_mode + tags: molecule-idempotence-notest + + - name: "Verifying update firmware from repository on a HTTP Share in normal mode" + ansible.builtin.assert: + that: + - idrac_firmware_out.msg == "Successfully updated the firmware." + when: not ansible_check_mode and idrac_firmware_out.changed + + - name: "Verifying update firmware from repository on a HTTP Share in idempotence mode" + ansible.builtin.assert: + that: + - idrac_firmware_out.msg == "Unable to complete the operation because the catalog name entered has either unsupported firmware packages + or same version installed on the server." + when: not ansible_check_mode and not idrac_firmware_out.changed diff --git a/ansible_collections/dellemc/openmanage/roles/idrac_firmware/molecule/http_share/molecule.yml b/ansible_collections/dellemc/openmanage/roles/idrac_firmware/molecule/http_share/molecule.yml new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/ansible_collections/dellemc/openmanage/roles/idrac_firmware/molecule/http_share/molecule.yml diff --git a/ansible_collections/dellemc/openmanage/roles/idrac_firmware/molecule/https_share/converge.yml b/ansible_collections/dellemc/openmanage/roles/idrac_firmware/molecule/https_share/converge.yml new file mode 100644 index 000000000..a94983cae --- /dev/null +++ b/ansible_collections/dellemc/openmanage/roles/idrac_firmware/molecule/https_share/converge.yml @@ -0,0 +1,39 @@ +--- +- name: Converge idrac_firmware for httpsshare + hosts: all + gather_facts: false + tasks: + - name: Update firmware from repository on HTTPS Share + ansible.builtin.import_role: + name: "idrac_firmware" + vars: + hostname: "{{ lookup('env', 'hostname') }}" + username: "{{ lookup('env', 'username') }}" + password: "{{ lookup('env', 'password') }}" + validate_certs: false + share_name: "{{ lookup('env', 'httpsshare') }}" + share_user: "{{ lookup('env', 'shareuser') }}" + share_password: "{{ lookup('env', 'sharepassword') }}" + reboot: true + job_wait: true + apply_update: true + catalog_file_name: "Catalog.xml" + + - name: "Verifying update firmware from repository on a HTTPS Share in check mode" + ansible.builtin.assert: + that: idrac_firmware_out.msg == "Changes found to commit!" + when: ansible_check_mode + tags: molecule-idempotence-notest + + - name: "Verifying update firmware from repository on a HTTPS Share in normal mode" + ansible.builtin.assert: + that: + - idrac_firmware_out.msg == "Successfully updated the firmware." + when: not ansible_check_mode and idrac_firmware_out.changed + + - name: "Verifying update firmware from repository on a HTTPS Share in idempotence mode" + ansible.builtin.assert: + that: + - idrac_firmware_out.msg == "Unable to complete the operation because the catalog name entered has either unsupported firmware packages + or same version installed on the server." + when: not ansible_check_mode and not idrac_firmware_out.changed diff --git a/ansible_collections/dellemc/openmanage/roles/idrac_firmware/molecule/https_share/molecule.yml b/ansible_collections/dellemc/openmanage/roles/idrac_firmware/molecule/https_share/molecule.yml new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/ansible_collections/dellemc/openmanage/roles/idrac_firmware/molecule/https_share/molecule.yml diff --git a/ansible_collections/dellemc/openmanage/roles/idrac_firmware/molecule/httpsproxy_share/converge.yml b/ansible_collections/dellemc/openmanage/roles/idrac_firmware/molecule/httpsproxy_share/converge.yml new file mode 100644 index 000000000..b4bd4bdc1 --- /dev/null +++ b/ansible_collections/dellemc/openmanage/roles/idrac_firmware/molecule/httpsproxy_share/converge.yml @@ -0,0 +1,117 @@ +--- +- name: Converge idrac_firmware for https share via proxy + hosts: all + gather_facts: false + tasks: + - name: Update firmware from repository on a HTTPS via parameter proxy Share + ansible.builtin.import_role: + name: "idrac_firmware" + vars: + hostname: "{{ lookup('env', 'hostname') }}" + username: "{{ lookup('env', 'username') }}" + password: "{{ lookup('env', 'password') }}" + validate_certs: false + share_name: "{{ lookup('env', 'httpsproxy') }}" + share_user: "{{ lookup('env', 'shareuser') }}" + share_password: "{{ lookup('env', 'sharepassword') }}" + reboot: true + job_wait: true + apply_update: true + proxy_support: "ParametersProxy" + proxy_server: "{{ lookup('env', 'proxyserver') }}" + proxy_type: "HTTP" + proxy_port: 3128 + proxy_uname: "{{ lookup('env', 'proxyuname') }}" + proxy_passwd: "{{ lookup('env', 'proxypass') }}" + catalog_file_name: "Catalog.xml" + + - name: "Verifying update firmware from repository on a HTTPS via parameter proxy share in check mode" + ansible.builtin.assert: + that: idrac_firmware_out.msg == "Changes found to commit!" + when: ansible_check_mode + tags: molecule-idempotence-notest + + - name: "Verifying update firmware from repository on a HTTPS via parameter proxy share in normal mode" + ansible.builtin.assert: + that: + - idrac_firmware_out.msg == "Successfully updated the firmware." + when: not ansible_check_mode and idrac_firmware_out.changed + + - name: "Verifying update firmware from repository on a HTTPS via parameter proxy share in idempotence mode" + ansible.builtin.assert: + that: + - idrac_firmware_out.msg == "Unable to complete the operation because the catalog name entered has either unsupported firmware packages + or same version installed on the server." + when: not ansible_check_mode and not idrac_firmware_out.changed + + - name: Update firmware from repository on a HTTPS via default proxy Share + ansible.builtin.import_role: + name: "idrac_firmware" + vars: + hostname: "{{ lookup('env', 'hostname') }}" + username: "{{ lookup('env', 'username') }}" + password: "{{ lookup('env', 'password') }}" + validate_certs: false + reboot: true + job_wait: true + apply_update: true + proxy_support: "DefaultProxy" + catalog_file_name: "Catalog.xml" + + - name: "Verifying update firmware from repository on a HTTPS via default proxy share in check mode" + ansible.builtin.assert: + that: idrac_firmware_out.msg == "Changes found to commit!" + when: ansible_check_mode + tags: molecule-idempotence-notest + + - name: "Verifying update firmware from repository on a HTTPS via default proxy share in normal mode" + ansible.builtin.assert: + that: + - idrac_firmware_out.msg == "Successfully updated the firmware." + when: not ansible_check_mode and idrac_firmware_out.changed + + - name: "Verifying update firmware from repository on a HTTPS via default proxy share in idempotence mode" + ansible.builtin.assert: + that: + - idrac_firmware_out.msg == "Unable to complete the operation because the catalog name entered has either unsupported firmware packages + or same version installed on the server." + when: not ansible_check_mode and not idrac_firmware_out.changed + + - name: Update firmware from repository on a HTTPS via parameter proxy Share with proxy_type as SOCKS + ansible.builtin.import_role: + name: "idrac_firmware" + vars: + hostname: "{{ lookup('env', 'hostname') }}" + username: "{{ lookup('env', 'username') }}" + password: "{{ lookup('env', 'password') }}" + validate_certs: false + share_name: "{{ lookup('env', 'httpsproxy') }}" + share_user: "{{ lookup('env', 'shareuser') }}" + share_password: "{{ lookup('env', 'sharepassword') }}" + reboot: true + job_wait: true + apply_update: true + proxy_support: "ParametersProxy" + proxy_server: "{{ lookup('env', 'proxyserversocks') }}" + proxy_type: "SOCKS" + proxy_port: 1080 + catalog_file_name: "Catalog.xml" + + - name: "Verifying update firmware from repository on a HTTPS via parameter proxy with proxy_type as SOCKS share in check mode" + ansible.builtin.assert: + that: idrac_firmware_out.msg == "Changes found to commit!" + when: ansible_check_mode + tags: molecule-idempotence-notest + + - name: "Verifying update firmware from repository on a HTTPS via parameter proxy with proxy_type as SOCKS share in normal mode" + ansible.builtin.assert: + that: + - idrac_firmware_out.msg == "Successfully updated the firmware." + when: not ansible_check_mode and idrac_firmware_out.changed + + - name: "Verifying update firmware from repository on a HTTPS via parameter proxy share with proxy_type as SOCKS in idempotence mode" + ansible.builtin.assert: + that: + - idrac_firmware_out.msg == "Unable to complete the operation because the catalog name entered has either unsupported firmware packages + or same version installed on the server." + when: not ansible_check_mode and not idrac_firmware_out.changed diff --git a/ansible_collections/dellemc/openmanage/roles/idrac_firmware/molecule/httpsproxy_share/molecule.yml b/ansible_collections/dellemc/openmanage/roles/idrac_firmware/molecule/httpsproxy_share/molecule.yml new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/ansible_collections/dellemc/openmanage/roles/idrac_firmware/molecule/httpsproxy_share/molecule.yml diff --git a/ansible_collections/dellemc/openmanage/roles/idrac_firmware/molecule/negative_scenarios/converge.yml b/ansible_collections/dellemc/openmanage/roles/idrac_firmware/molecule/negative_scenarios/converge.yml new file mode 100644 index 000000000..37b959272 --- /dev/null +++ b/ansible_collections/dellemc/openmanage/roles/idrac_firmware/molecule/negative_scenarios/converge.yml @@ -0,0 +1,206 @@ +--- +- name: Converge idrac_firmware for negative scenarios + hosts: all + gather_facts: false + tasks: + - name: Updating firmware with an invalid hostname + ansible.builtin.import_role: + name: idrac_firmware + vars: + hostname: "invalidHostname" + username: "{{ lookup('env', 'username') }}" + password: "{{ lookup('env', 'password') }}" + share_name: "{{ lookup('env', 'httpshare') }}" + catalog_file_name: "Catalog.xml" + reboot: true + job_wait: true + apply_update: true + ignore_errors: true + register: idrac_firmware_result + + - name: "Verifying Updating firmware with an invalid hostname" + ansible.builtin.assert: + that: + - "'unreachable iDRAC IP' in idrac_firmware_out.msg" + + - name: Updating firmware with an invalid username + ansible.builtin.import_role: + name: idrac_firmware + vars: + hostname: "{{ lookup('env', 'hostname') }}" + username: "invalidUsername" + password: "{{ lookup('env', 'password') }}" + share_name: "{{ lookup('env', 'httpshare') }}" + catalog_file_name: "Catalog.xml" + reboot: true + job_wait: true + apply_update: true + ignore_errors: true + register: idrac_firmware_result + + - name: "Verifying Updating firmware with an invalid username" + ansible.builtin.assert: + that: + - "'Incorrect username' in idrac_firmware_out.msg" + + - name: Updating firmware with an invalid password + ansible.builtin.import_role: + name: idrac_firmware + vars: + hostname: "{{ lookup('env', 'hostname') }}" + username: "{{ lookup('env', 'username') }}" + password: "invalidPassword" + share_name: "{{ lookup('env', 'httpshare') }}" + catalog_file_name: "Catalog.xml" + reboot: true + job_wait: true + apply_update: true + ignore_errors: true + register: idrac_firmware_result + + - name: "Verifying Updating firmware with an invalid password" + ansible.builtin.assert: + that: + - "'password' in idrac_firmware_out.msg" + + - name: Updating firmware with an invalid ca_path + ansible.builtin.import_role: + name: idrac_firmware + vars: + hostname: "{{ lookup('env', 'hostname') }}" + username: "{{ lookup('env', 'username') }}" + password: "{{ lookup('env', 'password') }}" + share_name: "{{ lookup('env', 'httpshare') }}" + ca_path: "{{ lookup('env', 'capath') }}" + catalog_file_name: "Catalog.xml" + reboot: true + job_wait: true + apply_update: true + ignore_errors: true + register: idrac_firmware_result + + - name: "Verifying Updating firmware with an invalid ca_path" + ansible.builtin.assert: + that: + - idrac_firmware_out.msg == "Firmware update failed." + + - name: Updating firmware with catalog file without extension + ansible.builtin.import_role: + name: idrac_firmware + vars: + hostname: "{{ lookup('env', 'hostname') }}" + username: "{{ lookup('env', 'username') }}" + password: "{{ lookup('env', 'password') }}" + share_name: "{{ lookup('env', 'httpshare') }}" + reboot: true + job_wait: true + apply_update: true + catalog_file_name: Catalog + ignore_errors: true + register: idrac_firmware_result + + - name: "Verifying Updating firmware with catalog file without extension" + ansible.builtin.assert: + that: + - idrac_firmware_out.msg == "catalog_file_name should be an XML file." + + - name: Update firmware from repository on HTTPS Share with invalid share_user + ansible.builtin.import_role: + name: "idrac_firmware" + vars: + hostname: "{{ lookup('env', 'hostname') }}" + username: "{{ lookup('env', 'username') }}" + password: "{{ lookup('env', 'password') }}" + validate_certs: false + share_name: "{{ lookup('env', 'httpsshare') }}" + share_user: "invalidUser" + share_password: "{{ lookup('env', 'sharepassword') }}" + reboot: true + job_wait: true + apply_update: true + catalog_file_name: "Catalog.xml" + + - name: "Verifying update firmware from repository on a HTTPS Share with invalid share_user" + ansible.builtin.assert: + that: + - idrac_firmware_out.msg == "Unable to complete the operation because the catalog name entered has either unsupported firmware packages + or same version installed on the server." + + - name: Update firmware from repository on HTTPS Share with invalid share_password + ansible.builtin.import_role: + name: "idrac_firmware" + vars: + hostname: "{{ lookup('env', 'hostname') }}" + username: "{{ lookup('env', 'username') }}" + password: "{{ lookup('env', 'password') }}" + validate_certs: false + share_name: "{{ lookup('env', 'httpsshare') }}" + share_user: "{{ lookup('env', 'shareuser') }}" + share_password: "invalidPassword" + reboot: true + job_wait: true + apply_update: true + catalog_file_name: "Catalog.xml" + register: idrac_firmware_result + + - name: "Verifying update firmware from repository on a HTTPS Share with invalid share_password" + ansible.builtin.assert: + that: + - idrac_firmware_out.msg == "Unable to complete the operation because the catalog name entered has either unsupported firmware packages + or same version installed on the server." + + - name: Update firmware from repository on a HTTPS via parameter proxy Share with invalid proxy_uname + ansible.builtin.import_role: + name: "idrac_firmware" + vars: + hostname: "{{ lookup('env', 'hostname') }}" + username: "{{ lookup('env', 'username') }}" + password: "{{ lookup('env', 'password') }}" + validate_certs: false + share_name: "{{ lookup('env', 'httpsproxy') }}" + share_user: "{{ lookup('env', 'shareuser') }}" + share_password: "{{ lookup('env', 'sharepassword') }}" + reboot: true + job_wait: true + apply_update: true + proxy_support: "ParametersProxy" + proxy_server: "{{ lookup('env', 'proxyserver') }}" + proxy_type: "HTTP" + proxy_port: 3128 + proxy_uname: "invalidUname" + proxy_passwd: "{{ lookup('env', 'proxypass') }}" + catalog_file_name: "Catalog.xml" + + - name: "Verifying update firmware from repository on a HTTPS via parameter proxy share with invalid proxy_uname" + ansible.builtin.assert: + that: + - idrac_firmware_out.msg == "Unable to complete the operation because the catalog name entered has either unsupported firmware packages + or same version installed on the server." + + - name: Update firmware from repository on a HTTPS via parameter proxy Share with invalid proxy_passwd + ansible.builtin.import_role: + name: "idrac_firmware" + vars: + hostname: "{{ lookup('env', 'hostname') }}" + username: "{{ lookup('env', 'username') }}" + password: "{{ lookup('env', 'password') }}" + validate_certs: false + share_name: "{{ lookup('env', 'httpsproxy') }}" + share_user: "{{ lookup('env', 'shareuser') }}" + share_password: "{{ lookup('env', 'sharepassword') }}" + reboot: true + job_wait: true + apply_update: true + proxy_support: "ParametersProxy" + proxy_server: "{{ lookup('env', 'proxyserver') }}" + proxy_type: "HTTP" + proxy_port: 3128 + proxy_uname: "{{ lookup('env', 'proxyuname') }}" + proxy_passwd: "invalidPasswd" + catalog_file_name: "Catalog.xml" + + - name: "Verifying update firmware from repository on a HTTPS via parameter proxy share with invalid proxy_passwd" + ansible.builtin.assert: + that: + - idrac_firmware_out.msg == "Unable to complete the operation because the catalog name entered has either unsupported firmware packages + or same version installed on the server." diff --git a/ansible_collections/dellemc/openmanage/roles/idrac_firmware/molecule/negative_scenarios/molecule.yml b/ansible_collections/dellemc/openmanage/roles/idrac_firmware/molecule/negative_scenarios/molecule.yml new file mode 100644 index 000000000..de4ada585 --- /dev/null +++ b/ansible_collections/dellemc/openmanage/roles/idrac_firmware/molecule/negative_scenarios/molecule.yml @@ -0,0 +1,10 @@ +--- +scenario: + test_sequence: + - dependency + - cleanup + - destroy + - syntax + - create + - converge + - destroy diff --git a/ansible_collections/dellemc/openmanage/roles/idrac_firmware/molecule/nfs_share/converge.yml b/ansible_collections/dellemc/openmanage/roles/idrac_firmware/molecule/nfs_share/converge.yml new file mode 100644 index 000000000..89e55838c --- /dev/null +++ b/ansible_collections/dellemc/openmanage/roles/idrac_firmware/molecule/nfs_share/converge.yml @@ -0,0 +1,37 @@ +--- +- name: Converge idrac_firmware for nfsshare + hosts: all + gather_facts: false + tasks: + - name: Update firmware from repository on a NFS Share + ansible.builtin.import_role: + name: idrac_firmware + vars: + hostname: "{{ lookup('env', 'hostname') }}" + username: "{{ lookup('env', 'username') }}" + password: "{{ lookup('env', 'password') }}" + share_name: "{{ lookup('env', 'nfsshare') }}" + validate_certs: false + reboot: true + job_wait: true + apply_update: true + catalog_file_name: "Catalog.xml" + + - name: "Verifying update firmware from repository on a NFS Share in check mode" + ansible.builtin.assert: + that: idrac_firmware_out.msg == "Changes found to commit!" + when: ansible_check_mode + tags: molecule-idempotence-notest + + - name: "Verifying update firmware from repository on a NFS Share in normal mode" + ansible.builtin.assert: + that: + - idrac_firmware_out.msg == "Successfully updated the firmware." + when: not ansible_check_mode and idrac_firmware_out.changed + + - name: "Verifying update firmware from repository on a NFS Share in idempotence mode" + ansible.builtin.assert: + that: + - idrac_firmware_out.msg == "Unable to complete the operation because the catalog name entered has either unsupported firmware packages + or same version installed on the server." + when: not ansible_check_mode and not idrac_firmware_out.changed diff --git a/ansible_collections/dellemc/openmanage/roles/idrac_firmware/molecule/nfs_share/molecule.yml b/ansible_collections/dellemc/openmanage/roles/idrac_firmware/molecule/nfs_share/molecule.yml new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/ansible_collections/dellemc/openmanage/roles/idrac_firmware/molecule/nfs_share/molecule.yml diff --git a/ansible_collections/dellemc/openmanage/roles/idrac_firmware/tasks/main.yml b/ansible_collections/dellemc/openmanage/roles/idrac_firmware/tasks/main.yml new file mode 100644 index 000000000..c994373ce --- /dev/null +++ b/ansible_collections/dellemc/openmanage/roles/idrac_firmware/tasks/main.yml @@ -0,0 +1,27 @@ +--- +# tasks file for idrac_firmware +- name: Call iDRAC Firmware upgrade + dellemc.openmanage.idrac_firmware: + idrac_ip: "{{ hostname }}" + idrac_port: "{{ https_port }}" + idrac_user: "{{ username }}" + idrac_password: "{{ password }}" + ca_path: "{{ ca_path | default(omit) }}" + validate_certs: "{{ validate_certs }}" + timeout: "{{ https_timeout }}" + share_name: "{{ share_name | default(omit) }}" + share_user: "{{ share_user | default(omit) }}" + share_password: "{{ share_password | default(omit) }}" + job_wait: "{{ job_wait }}" + catalog_file_name: "{{ catalog_file_name }}" + ignore_cert_warning: "{{ ignore_cert_warning }}" + apply_update: "{{ apply_update }}" + reboot: "{{ reboot }}" + proxy_support: "{{ proxy_support }}" + proxy_server: "{{ proxy_server | default(omit) }}" + proxy_type: "{{ proxy_type | default(omit) }}" + proxy_port: "{{ proxy_port | default(omit) }}" + proxy_uname: "{{ proxy_uname | default(omit) }}" + proxy_passwd: "{{ proxy_passwd | default(omit) }}" + register: "idrac_firmware_out" + delegate_to: "{{ idrac_firmware_delegate }}" diff --git a/ansible_collections/dellemc/openmanage/roles/idrac_firmware/tests/inventory b/ansible_collections/dellemc/openmanage/roles/idrac_firmware/tests/inventory new file mode 100644 index 000000000..878877b07 --- /dev/null +++ b/ansible_collections/dellemc/openmanage/roles/idrac_firmware/tests/inventory @@ -0,0 +1,2 @@ +localhost + diff --git a/ansible_collections/dellemc/openmanage/roles/idrac_firmware/tests/test.yml b/ansible_collections/dellemc/openmanage/roles/idrac_firmware/tests/test.yml new file mode 100644 index 000000000..12bb9ffc6 --- /dev/null +++ b/ansible_collections/dellemc/openmanage/roles/idrac_firmware/tests/test.yml @@ -0,0 +1,6 @@ +--- +- name: Firmware update using catalog for idrac +- hosts: localhost + remote_user: root + roles: + - idrac_firmware diff --git a/ansible_collections/dellemc/openmanage/roles/idrac_firmware/vars/main.yml b/ansible_collections/dellemc/openmanage/roles/idrac_firmware/vars/main.yml new file mode 100644 index 000000000..ff6d7325f --- /dev/null +++ b/ansible_collections/dellemc/openmanage/roles/idrac_firmware/vars/main.yml @@ -0,0 +1,3 @@ +--- +# vars file for idrac_firmware +idrac_firmware_delegate: "{{ lookup('ansible.builtin.env', 'RUNON', default='localhost') }}" |