diff options
Diffstat (limited to 'ansible_collections/dellemc/openmanage/roles/idrac_attributes')
20 files changed, 885 insertions, 0 deletions
diff --git a/ansible_collections/dellemc/openmanage/roles/idrac_attributes/README.md b/ansible_collections/dellemc/openmanage/roles/idrac_attributes/README.md new file mode 100644 index 000000000..2458b1ab5 --- /dev/null +++ b/ansible_collections/dellemc/openmanage/roles/idrac_attributes/README.md @@ -0,0 +1,308 @@ +# idrac_attributes + +Role to configure the iDRAC system, manager and lifecycle attributes for Dell PowerEdge servers. + +## Requirements + +### Development +Requirements to develop and contribute to the role. +``` +ansible +docker +molecule +python +``` +### Production +Requirements to use the role. +``` +ansible +python +``` + +### 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 or hostname.</td> + </tr> + <tr> + <td>username</td> + <td>true</td> + <td></td> + <td></td> + <td>str</td> + <td>- iDRAC username with admin privileges</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>idrac_attributes</td> + <td>false</td> + <td></td> + <td></td> + <td>dict</td> + <td>- Dictionary of iDRAC attributes and value. The attributes should be part of the Integrated Dell Remote Access Controller Attribute Registry.<br>- To view the list of attributes in Attribute Registry for iDRAC9 and above, use the Role idrac_gather_facts with idrac components.<br>- For iDRAC8 based servers, derive the manager attribute name from Server Configuration Profile.<br>- If the manager attribute name in Server Configuration Profile is <GroupName><Instance>#<AttributeName>(for Example, 'SNMP.1#AgentCommunity') then the equivalent attribute name for Redfish is <GroupName>.<Instance>.<AttributeName> (for Example, 'SNMP.1.AgentCommunity').</td> + </tr> + <tr> + <td>system_attributes</td> + <td>false</td> + <td></td> + <td></td> + <td>dict</td> + <td>- Dictionary of System attributes and value. The attributes should be part of the Integrated Dell Remote Access Controller Attribute Registry.<br>- To view the list of attributes in Attribute Registry for iDRAC9 and above, use the Role idrac_gather_facts with idrac components.<br>- For iDRAC8 based servers, derive the manager attribute name from Server Configuration Profile.<br>- If the manager attribute name in Server Configuration Profile is <GroupName><Instance>#<AttributeName> for Example, 'ThermalSettings.1#ThermalProfile') then the equivalent attribute name for Redfish is <GroupName>.<Instance>.<AttributeName> (for Example, 'ThermalSettings.1.ThermalProfile').</td> + </tr> + <tr> + <td>lifecycle_controller_attributes</td> + <td>false</td> + <td></td> + <td></td> + <td>dict</td> + <td>- Dictionary of Lifecycle Controller attributes and value. The attributes should be part of the Integrated Dell Remote Access Controller Attribute Registry.<br>- To view the list of attributes in Attribute Registry for iDRAC9 and above, use the Role idrac_gather_facts with idrac components.<br>- For iDRAC8 based servers, derive the manager attribute name from Server Configuration Profile.<br>- If the manager attribute name in Server Configuration Profile is <GroupName>.<Instance>#<AttributeName>(for Example, 'LCAttributes.1#AutoUpdate') then the equivalent attribute name for Redfish is <GroupName>.<Instance>.<AttributeName>(for Example, 'LCAttributes.1.AutoUpdate')</td> + <tr> + <td>manager_id</td> + <td>false</td> + <td></td> + <td></td> + <td>str</td> + <td>- Redfish ID of the resource. If the Redfish ID of the resource is not specified, then the first ID from the Manager IDs list will be picked up.</td> + </tr> +</tbody> +</table> + +## Fact variables + +<table> +<thead> + <tr> + <th>Name</th> + <th>Sample</th> + <th>Description</th> + </tr> +</thead> + <tbody> + <tr> + <td>idrac_attributes_out</td> + <td>{"changed": true, + "failed": false, + "msg": "Successfully updated the attributes." +}</td> +<td>Module output of idrac attributes</td> +</tbody> +</table> + +## Examples +----- + +``` +- name: Configure iDRAC attributes + ansible.builtin.include_role: + name: idrac_attributes + vars: + hostname: "192.168.0.1" + username: "username" + password: "password" + idrac_attributes: + SNMP.1.AgentCommunity: public + +- name: Configure System attributes + ansible.builtin.include_role: + name: idrac_attributes + vars: + hostname: "192.168.0.1" + username: "username" + password: "password" + system_attributes: + ThermalSettings.1.ThermalProfile: Sound Cap + +- name: Configure Lifecycle Controller attributes + ansible.builtin.include_role: + name: idrac_attributes + vars: + hostname: "192.168.0.1" + username: "username" + password: "password" + lifecycle_controller_attributes: + LCAttributes.1.AutoUpdate: Enabled + +- name: Configure the iDRAC attributes for email alert settings. + ansible.builtin.include_role: + name: idrac_attributes + vars: + hostname: "192.168.0.1" + username: "username" + password: "password" + idrac_attributes: + EmailAlert.1.CustomMsg: Display Message + EmailAlert.1.Enable: Enabled + EmailAlert.1.Address: test@test.com + +- name: Configure the iDRAC attributes for SNMP alert settings. + ansible.builtin.include_role: + name: idrac_attributes + vars: + hostname: "192.168.0.1" + username: "username" + password: "password" + idrac_attributes: + SNMPAlert.1.Destination: 192.168.0.2 + SNMPAlert.1.State: Enabled + SNMPAlert.1.SNMPv3Username: username + +- name: Configure the iDRAC attributes for SMTP alert settings. + ansible.builtin.include_role: + name: idrac_attributes + vars: + hostname: "192.168.0.1" + username: "username" + password: "password" + idrac_attributes: + RemoteHosts.1.SMTPServerIPAddress: 192.168.0.3 + RemoteHosts.1.SMTPAuthentication: Enabled + RemoteHosts.1.SMTPPort: 25 + RemoteHosts.1.SMTPUserName: username + RemoteHosts.1.SMTPPassword: password + +- name: Configure the iDRAC attributes for webserver settings. + ansible.builtin.include_role: + name: idrac_attributes + vars: + hostname: "192.168.0.1" + username: "username" + password: "password" + idrac_attributes: + WebServer.1.SSLEncryptionBitLength: 128-Bit or higher + WebServer.1.TLSProtocol: TLS 1.1 and Higher + +- name: Configure the iDRAC attributes for SNMP settings. + ansible.builtin.include_role: + name: idrac_attributes + vars: + hostname: "192.168.0.1" + username: "username" + password: "password" + idrac_attributes: + SNMP.1.SNMPProtocol: All + SNMP.1.AgentEnable: Enabled + SNMP.1.TrapFormat: SNMPv1 + SNMP.1.AlertPort: 162 + SNMP.1.AgentCommunity: public + +- name: Configure the iDRAC LC attributes for collecting system inventory. + ansible.builtin.include_role: + name: idrac_attributes + vars: + hostname: "192.168.0.1" + username: "username" + password: "password" + lifecycle_controller_attributes: + LCAttributes.1.CollectSystemInventoryOnRestart: Enabled + +- name: Configure the iDRAC system attributes for LCD configuration. + ansible.builtin.include_role: + name: idrac_attributes + vars: + hostname: "192.168.0.1" + username: "username" + password: "password" + system_attributes: + LCD.1.Configuration: Service Tag + LCD.1.vConsoleIndication: Enabled + LCD.1.FrontPanelLocking: Full-Access + LCD.1.UserDefinedString: custom string + +- name: Configure the iDRAC attributes for Timezone settings. + ansible.builtin.include_role: + name: idrac_attributes + vars: + hostname: "192.168.0.1" + username: "username" + password: "password" + idrac_attributes: + Time.1.Timezone: CST6CDT + NTPConfigGroup.1.NTPEnable: Enabled + NTPConfigGroup.1.NTP1: 192.168.0.5 + NTPConfigGroup.1.NTP2: 192.168.0.6 + NTPConfigGroup.1.NTP3: 192.168.0.7 + +- name: Configure all attributes + ansible.builtin.include_role: + name: idrac_attributes + vars: + hostname: "192.168.0.1" + username: "username" + password: "password" + idrac_attributes: + SNMP.1.AgentCommunity: test + SNMP.1.AgentEnable: Enabled + SNMP.1.DiscoveryPort: 161 + system_attributes: + ServerOS.1.HostName: demohostname + lifecycle_controller_attributes: + LCAttributes.1.AutoUpdate: Disabled +``` + +## Author Information +------------------ + +Dell Technologies <br> +Kritika Bhateja (Kritika.Bhateja@Dell.com) 2023
\ No newline at end of file diff --git a/ansible_collections/dellemc/openmanage/roles/idrac_attributes/defaults/main.yml b/ansible_collections/dellemc/openmanage/roles/idrac_attributes/defaults/main.yml new file mode 100644 index 000000000..60830a744 --- /dev/null +++ b/ansible_collections/dellemc/openmanage/roles/idrac_attributes/defaults/main.yml @@ -0,0 +1,5 @@ +--- +# defaults file for idrac_attributes +validate_certs: true +https_timeout: 30 +https_port: 443 diff --git a/ansible_collections/dellemc/openmanage/roles/idrac_attributes/handlers/main.yml b/ansible_collections/dellemc/openmanage/roles/idrac_attributes/handlers/main.yml new file mode 100644 index 000000000..ed09341c4 --- /dev/null +++ b/ansible_collections/dellemc/openmanage/roles/idrac_attributes/handlers/main.yml @@ -0,0 +1,2 @@ +--- +# handlers file for idrac_attributes diff --git a/ansible_collections/dellemc/openmanage/roles/idrac_attributes/meta/argument_specs.yml b/ansible_collections/dellemc/openmanage/roles/idrac_attributes/meta/argument_specs.yml new file mode 100644 index 000000000..2109b32a0 --- /dev/null +++ b/ansible_collections/dellemc/openmanage/roles/idrac_attributes/meta/argument_specs.yml @@ -0,0 +1,71 @@ +--- +argument_specs: + main: + version_added: "7.6.0" + short_description: Role to configure the iDRAC attribute + description: + - Role to configure the iDRAC system, manager and lifecycle attributes for Dell PowerEdge servers. + 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 + https_timeout: + description: The HTTPS socket level timeout in seconds. + type: int + default: 30 + idrac_attributes: + description: + - Dictionary of iDRAC attributes and value. The attributes should be part of the + Integrated Dell Remote Access Controller Attribute Registry. + - To view the list of attributes in Attribute Registry for iDRAC9 and above, use + the Role idrac_gather_facts with idrac components. + - For iDRAC8 based servers, derive the manager attribute name from Server Configuration Profile. + - If the manager attribute name in Server Configuration Profile is <GroupName>.<Instance>#<AttributeName> + (for Example, 'SNMP.1#AgentCommunity') then the equivalent attribute name for Redfish is <GroupName>. + <Instance>.<AttributeName> (for Example, 'SNMP.1.AgentCommunity'). + type: dict + system_attributes: + description: + - Dictionary of System attributes and value. The attributes should be part of the Integrated Dell Remote Access Controller Attribute Registry. + - To view the list of attributes in Attribute Registry for iDRAC9 and above, use the Role idrac_gather_facts with idrac components + - For iDRAC8 based servers, derive the manager attribute name from Server Configuration Profile. + - If the manager attribute name in Server Configuration Profile is <GroupName>.<Instance>#<AttributeName> + (for Example, 'ThermalSettings.1#ThermalProfile') then the equivalent attribute name for Redfish is <GroupName>.<Instance>.<AttributeName> + (for Example, 'ThermalSettings.1.ThermalProfile'). + type: dict + lifecycle_controller_attributes: + description: + - Dictionary of Lifecycle Controller attributes and value. The attributes should be part of the + Integrated Dell Remote Access Controller Attribute Registry. + - To view the list of attributes in Attribute Registry for iDRAC9 and above, use the Role idrac_gather_facts with idrac components + - For iDRAC8 based servers, derive the manager attribute name from Server Configuration Profile. + - If the manager attribute name in Server Configuration Profile is <GroupName>.<Instance>#<AttributeName> + (for Example, 'LCAttributes.1#AutoUpdate') then the equivalent attribute name for Redfish is <GroupName>.<Instance>.<AttributeName> + (for Example, 'LCAttributes.1.AutoUpdate')." + type: dict + manager_id: + description: + Redfish ID of the resource. If the Redfish ID of the resource is not specified, then the first ID from the Manager IDs list + will be picked up. + type: str diff --git a/ansible_collections/dellemc/openmanage/roles/idrac_attributes/meta/main.yml b/ansible_collections/dellemc/openmanage/roles/idrac_attributes/meta/main.yml new file mode 100644 index 000000000..737f01569 --- /dev/null +++ b/ansible_collections/dellemc/openmanage/roles/idrac_attributes/meta/main.yml @@ -0,0 +1,25 @@ +galaxy_info: + role_name: idrac_attributes + author: "Kritika Bhateja" + description: The role helps to configure the iDRAC system, manager and lifecycle attributes for Dell PowerEdge servers. + company: Dell Technologies + + license: GPL-3.0-only + + min_ansible_version: "2.13" + + platforms: + - name: EL + versions: + - "9" + - "8" + - name: Ubuntu + versions: + - jammy + - name: SLES + versions: + - "15SP3" + - "15SP4" + + galaxy_tags: [] +dependencies: [] diff --git a/ansible_collections/dellemc/openmanage/roles/idrac_attributes/molecule/default/converge.yml b/ansible_collections/dellemc/openmanage/roles/idrac_attributes/molecule/default/converge.yml new file mode 100644 index 000000000..f1ae0f548 --- /dev/null +++ b/ansible_collections/dellemc/openmanage/roles/idrac_attributes/molecule/default/converge.yml @@ -0,0 +1,306 @@ +--- +- name: Converge file for default/negative scenarios + hosts: all + gather_facts: false + tasks: + - name: Perform update with wrong hostname + ansible.builtin.import_role: + name: idrac_attributes + vars: + hostname: "randomHostname" + username: "{{ lookup('env', 'IDRAC_USER') }}" + password: "{{ lookup('env', 'IDRAC_PASSWORD') }}" + validate_certs: false + idrac_attributes: + SSH.1.Timeout: 1800 + ignore_errors: true + ignore_unreachable: true + register: idrac_attributes_error_msg + + - name: Asserting after performing operation with wrong hostname + ansible.builtin.assert: + that: + - "'Incorrect username or password, + unreachable iDRAC IP' in '{{ idrac_attributes_out.msg }}' or + 'Name or service not known' in '{{ idrac_attributes_out.msg }}'" + + - name: Perform update with wrong username + ansible.builtin.import_role: + name: idrac_attributes + vars: + hostname: "{{ lookup('env', 'IDRAC_IP') }}" + username: "WrongUsername123" + password: "{{ lookup('env', 'IDRAC_PASSWORD') }}" + validate_certs: false + idrac_attributes: + SSH.1.Timeout: 1800 + ignore_errors: true + ignore_unreachable: true + register: idrac_attributes_error_msg + + - name: Asserting after performing operation with wrong username + ansible.builtin.assert: + that: + - '"HTTP Error 401" in idrac_attributes_out.msg' + + - name: Perform update with wrong password + ansible.builtin.import_role: + name: idrac_attributes + vars: + hostname: "{{ lookup('env', 'IDRAC_IP') }}" + username: "{{ lookup('env', 'IDRAC_USER') }}" + password: "WrongPassword@123" + validate_certs: false + idrac_attributes: + SSH.1.Timeout: 1800 + ignore_errors: true + ignore_unreachable: true + register: idrac_attributes_error_msg + + - name: Asserting after performing operation with wrong password + ansible.builtin.assert: + that: |- + ('"HTTP Error 401" in idrac_attributes_out.msg') + or + ('"urlopen error timed out" in idrac_attributes_out.msg') + + - name: Perform update with invalid https_port + ansible.builtin.import_role: + name: idrac_attributes + vars: + hostname: "{{ lookup('env', 'IDRAC_IP') }}" + username: "{{ lookup('env', 'IDRAC_USER') }}" + password: "{{ lookup('env', 'IDRAC_PASSWORD') }}" + validate_certs: false + https_port: 9999999 + idrac_attributes: + SSH.1.Timeout: 1800 + ignore_errors: true + ignore_unreachable: true + register: idrac_attributes_error_msg + + - name: Asserting after performing operation with invalid https_port + ansible.builtin.assert: + that: + - ('"Connection refused" in idrac_attributes_out.msg') + or + ('"urlopen error timed out" in idrac_attributes_out.msg') + + - name: Perform update with invalid validate_certs + ansible.builtin.import_role: + name: idrac_attributes + vars: + hostname: "{{ lookup('env', 'IDRAC_IP') }}" + username: "{{ lookup('env', 'IDRAC_USER') }}" + password: "{{ lookup('env', 'IDRAC_PASSWORD') }}" + https_port: 443 + validate_certs: "someStringValue" + idrac_attributes: + SSH.1.Timeout: 1800 + ignore_errors: true + ignore_unreachable: true + register: idrac_attributes_error_msg + + - name: Asserting after performing operation with invalid validate_certs + ansible.builtin.assert: + that: + - '"Valid booleans include" in idrac_attributes_out.msg' + + - name: Perform update with wrong ca_path + ansible.builtin.import_role: + name: idrac_attributes + vars: + hostname: "{{ lookup('env', 'IDRAC_IP') }}" + username: "{{ lookup('env', 'IDRAC_USER') }}" + password: "{{ lookup('env', 'IDRAC_PASSWORD') }}" + https_port: 443 + ca_path: "" + validate_certs: true + idrac_attributes: + SSH.1.Timeout: 1800 + ignore_errors: true + ignore_unreachable: true + register: idrac_attributes_error_msg + + - name: Asserting after performing operation with wrong ca_path + ansible.builtin.assert: + that: + - '"certificate verify failed" in idrac_attributes_out.msg' + + - name: Perform update with wrong manager_id + ansible.builtin.import_role: + name: idrac_attributes + vars: + hostname: "{{ lookup('env', 'IDRAC_IP') }}" + username: "{{ lookup('env', 'IDRAC_USER') }}" + password: "{{ lookup('env', 'IDRAC_PASSWORD') }}" + https_port: 443 + validate_certs: false + idrac_attributes: + SSH.1.Timeout: 1800 + manager_id: idrac.random.5 + ignore_errors: true + ignore_unreachable: true + register: idrac_attributes_error_msg + + - name: Asserting after performing operation with wrong manager_id + ansible.builtin.assert: + that: + - '"HTTP Error 404" in idrac_attributes_out.msg' + + - name: Perform update with read only attributes + ansible.builtin.import_role: + name: idrac_attributes + vars: + hostname: "{{ lookup('env', 'IDRAC_IP') }}" + username: "{{ lookup('env', 'IDRAC_USER') }}" + password: "{{ lookup('env', 'IDRAC_PASSWORD') }}" + https_port: 443 + validate_certs: false + idrac_attributes: + SSH.1.MaxSessions: 5 + manager_id: "{{ null | default(omit) }}" + ignore_errors: true + ignore_unreachable: true + register: idrac_attributes_error_msg + + - name: Asserting after performing operation with read only attributes + ansible.builtin.assert: + that: + - idrac_attributes_out.msg == "Attributes have invalid values." + + - name: Perform idrac_attributes update with invalid attributes + ansible.builtin.import_role: + name: idrac_attributes + vars: + hostname: "{{ lookup('env', 'IDRAC_IP') }}" + username: "{{ lookup('env', 'IDRAC_USER') }}" + password: "{{ lookup('env', 'IDRAC_PASSWORD') }}" + https_port: 443 + validate_certs: false + idrac_attributes: + invalidAttr: enabled + manager_id: "{{ null | default(omit) }}" + ignore_errors: true + register: idrac_attributes_error_msg + + - name: Asserting after performing operation with invalid attributes + ansible.builtin.assert: + that: + - idrac_attributes_out.msg == "Attributes have invalid values." + + - name: Perform idrac_attributes update with + valid attributes and invalid values + ansible.builtin.import_role: + name: idrac_attributes + vars: + hostname: "{{ lookup('env', 'IDRAC_IP') }}" + username: "{{ lookup('env', 'IDRAC_USER') }}" + password: "{{ lookup('env', 'IDRAC_PASSWORD') }}" + https_port: 443 + validate_certs: false + idrac_attributes: + SSH.1.Timeout: false + manager_id: "{{ null | default(omit) }}" + ignore_errors: true + register: idrac_attributes_error_msg + + - name: Asserting after performing operation with + valid attributes and invalid values + ansible.builtin.assert: + that: + - idrac_attributes_out.msg == "Attributes have invalid values." + + - name: Perform system_attributes update with invalid attributes + ansible.builtin.import_role: + name: idrac_attributes + vars: + hostname: "{{ lookup('env', 'IDRAC_IP') }}" + username: "{{ lookup('env', 'IDRAC_USER') }}" + password: "{{ lookup('env', 'IDRAC_PASSWORD') }}" + https_port: 443 + validate_certs: false + system_attributes: + invalidAttr: enabled + idrac_attributes: "{{ null | default(omit) }}" + manager_id: "{{ null | default(omit) }}" + ignore_errors: true + register: idrac_attributes_error_msg + + - name: Asserting after performing operation for system_attributes + with invalid attributes + ansible.builtin.assert: + that: + - idrac_attributes_out.msg == "Attributes have invalid values." + + - name: Perform system_attributes update with + valid attributes and invalid values + ansible.builtin.import_role: + name: idrac_attributes + vars: + hostname: "{{ lookup('env', 'IDRAC_IP') }}" + username: "{{ lookup('env', 'IDRAC_USER') }}" + password: "{{ lookup('env', 'IDRAC_PASSWORD') }}" + https_port: 443 + validate_certs: false + system_attributes: + Job.1.JobTimeout: stringValue + manager_id: "{{ null | default(omit) }}" + idrac_attributes: "{{ null | default(omit) }}" + ignore_errors: true + register: idrac_attributes_error_msg + + - name: Asserting after performing operation for system_attributes + with valid attributes and invalid values + ansible.builtin.assert: + that: + - idrac_attributes_out.msg == "Attributes have invalid values." + + - name: Perform lifecycle_controller_attributes update + with invalid attributes + ansible.builtin.import_role: + name: idrac_attributes + vars: + hostname: "{{ lookup('env', 'IDRAC_IP') }}" + username: "{{ lookup('env', 'IDRAC_USER') }}" + password: "{{ lookup('env', 'IDRAC_PASSWORD') }}" + https_port: 443 + validate_certs: false + lifecycle_controller_attributes: + invalidAttr: false + idrac_attributes: "{{ null | default(omit) }}" + system_attributes: "{{ null | default(omit) }}" + manager_id: "{{ null | default(omit) }}" + ignore_errors: true + register: idrac_attributes_error_msg + + - name: Asserting after performing operation for + lifecycle_controller_attributes with invalid attributes + ansible.builtin.assert: + that: + - idrac_attributes_out.msg == "Attributes have invalid values." + + - name: Perform lifecycle_controller_attributes update with + valid attributes and invalid values + ansible.builtin.import_role: + name: idrac_attributes + vars: + hostname: "{{ lookup('env', 'IDRAC_IP') }}" + username: "{{ lookup('env', 'IDRAC_USER') }}" + password: "{{ lookup('env', 'IDRAC_PASSWORD') }}" + https_port: 443 + validate_certs: false + lifecycle_controller_attributes: + LCAttributes.1.AutoUpdate: 12345 + manager_id: "{{ null | default(omit) }}" + idrac_attributes: "{{ null | default(omit) }}" + system_attributes: "{{ null | default(omit) }}" + ignore_errors: true + register: idrac_attributes_error_msg + + - name: Asserting after performing operation for + lifecycle_controller_attributes with + valid attributes and invalid values + ansible.builtin.assert: + that: + - idrac_attributes_out.msg == "Attributes have invalid values." diff --git a/ansible_collections/dellemc/openmanage/roles/idrac_attributes/molecule/default/molecule.yml b/ansible_collections/dellemc/openmanage/roles/idrac_attributes/molecule/default/molecule.yml new file mode 100644 index 000000000..210914970 --- /dev/null +++ b/ansible_collections/dellemc/openmanage/roles/idrac_attributes/molecule/default/molecule.yml @@ -0,0 +1,6 @@ +--- +scenario: + test_sequence: + - create + - converge + - destroy diff --git a/ansible_collections/dellemc/openmanage/roles/idrac_attributes/molecule/idrac_attr/cleanup.yml b/ansible_collections/dellemc/openmanage/roles/idrac_attributes/molecule/idrac_attr/cleanup.yml new file mode 100644 index 000000000..58b3846e3 --- /dev/null +++ b/ansible_collections/dellemc/openmanage/roles/idrac_attributes/molecule/idrac_attr/cleanup.yml @@ -0,0 +1,12 @@ +--- +- name: Cleanup + hosts: all + gather_facts: false + vars: + hostname: "{{ lookup('env', 'IDRAC_IP') }}" + username: "{{ lookup('env', 'IDRAC_USER') }}" + password: "{{ lookup('env', 'IDRAC_PASSWORD') }}" + validate_certs: false + reset_to_default: Default + roles: + - role: idrac_reset diff --git a/ansible_collections/dellemc/openmanage/roles/idrac_attributes/molecule/idrac_attr/converge.yml b/ansible_collections/dellemc/openmanage/roles/idrac_attributes/molecule/idrac_attr/converge.yml new file mode 100644 index 000000000..a116aad93 --- /dev/null +++ b/ansible_collections/dellemc/openmanage/roles/idrac_attributes/molecule/idrac_attr/converge.yml @@ -0,0 +1,32 @@ +--- +- name: Converge file for idrac_attributes + hosts: all + gather_facts: false + vars: + hostname: "{{ lookup('env', 'IDRAC_IP') }}" + username: "{{ lookup('env', 'IDRAC_USER') }}" + password: "{{ lookup('env', 'IDRAC_PASSWORD') }}" + validate_certs: false + roles: + - role: idrac_attributes + vars: + idrac_attributes: + SSH.1.Timeout: 1700 + tasks: + - name: Asserting idrac_attributes update in check mode + ansible.builtin.assert: + that: idrac_attributes_out.msg == "Changes found to be applied." + when: ansible_check_mode + tags: molecule-idempotence-notest + + - name: Asserting idrac_attributes update in normal mode + ansible.builtin.assert: + that: + - idrac_attributes_out.msg == "Successfully updated the attributes." + when: not ansible_check_mode and idrac_attributes_out.changed + + - name: Asserting idrac_attributes update in idempotence mode + ansible.builtin.assert: + that: + - idrac_attributes_out.msg == "No changes found to be applied." + when: not ansible_check_mode and not idrac_attributes_out.changed diff --git a/ansible_collections/dellemc/openmanage/roles/idrac_attributes/molecule/idrac_attr/molecule.yml b/ansible_collections/dellemc/openmanage/roles/idrac_attributes/molecule/idrac_attr/molecule.yml new file mode 100644 index 000000000..ed97d539c --- /dev/null +++ b/ansible_collections/dellemc/openmanage/roles/idrac_attributes/molecule/idrac_attr/molecule.yml @@ -0,0 +1 @@ +--- diff --git a/ansible_collections/dellemc/openmanage/roles/idrac_attributes/molecule/lifecycle_controller_attr/cleanup.yml b/ansible_collections/dellemc/openmanage/roles/idrac_attributes/molecule/lifecycle_controller_attr/cleanup.yml new file mode 100644 index 000000000..58b3846e3 --- /dev/null +++ b/ansible_collections/dellemc/openmanage/roles/idrac_attributes/molecule/lifecycle_controller_attr/cleanup.yml @@ -0,0 +1,12 @@ +--- +- name: Cleanup + hosts: all + gather_facts: false + vars: + hostname: "{{ lookup('env', 'IDRAC_IP') }}" + username: "{{ lookup('env', 'IDRAC_USER') }}" + password: "{{ lookup('env', 'IDRAC_PASSWORD') }}" + validate_certs: false + reset_to_default: Default + roles: + - role: idrac_reset diff --git a/ansible_collections/dellemc/openmanage/roles/idrac_attributes/molecule/lifecycle_controller_attr/converge.yml b/ansible_collections/dellemc/openmanage/roles/idrac_attributes/molecule/lifecycle_controller_attr/converge.yml new file mode 100644 index 000000000..b9e7b2124 --- /dev/null +++ b/ansible_collections/dellemc/openmanage/roles/idrac_attributes/molecule/lifecycle_controller_attr/converge.yml @@ -0,0 +1,32 @@ +--- +- name: Converge file for lifecycle_controller_attributes + hosts: all + gather_facts: false + vars: + hostname: "{{ lookup('env', 'IDRAC_IP') }}" + username: "{{ lookup('env', 'IDRAC_USER') }}" + password: "{{ lookup('env', 'IDRAC_PASSWORD') }}" + validate_certs: false + roles: + - role: idrac_attributes + vars: + lifecycle_controller_attributes: + LCAttributes.1.AutoUpdate: Enabled + tasks: + - name: Asserting lifecycle_controller_attributes update in check mode + ansible.builtin.assert: + that: idrac_attributes_out.msg == "Changes found to be applied." + when: ansible_check_mode + tags: molecule-idempotence-notest + + - name: Asserting lifecycle_controller_attributes update in normal mode + ansible.builtin.assert: + that: + - idrac_attributes_out.msg == "Successfully updated the attributes." + when: not ansible_check_mode and idrac_attributes_out.changed + + - name: Asserting lifecycle_controller_attributes update in idempotence mode + ansible.builtin.assert: + that: + - idrac_attributes_out.msg == "No changes found to be applied." + when: not ansible_check_mode and not idrac_attributes_out.changed diff --git a/ansible_collections/dellemc/openmanage/roles/idrac_attributes/molecule/lifecycle_controller_attr/molecule.yml b/ansible_collections/dellemc/openmanage/roles/idrac_attributes/molecule/lifecycle_controller_attr/molecule.yml new file mode 100644 index 000000000..ed97d539c --- /dev/null +++ b/ansible_collections/dellemc/openmanage/roles/idrac_attributes/molecule/lifecycle_controller_attr/molecule.yml @@ -0,0 +1 @@ +--- diff --git a/ansible_collections/dellemc/openmanage/roles/idrac_attributes/molecule/system_attr/cleanup.yml b/ansible_collections/dellemc/openmanage/roles/idrac_attributes/molecule/system_attr/cleanup.yml new file mode 100644 index 000000000..58b3846e3 --- /dev/null +++ b/ansible_collections/dellemc/openmanage/roles/idrac_attributes/molecule/system_attr/cleanup.yml @@ -0,0 +1,12 @@ +--- +- name: Cleanup + hosts: all + gather_facts: false + vars: + hostname: "{{ lookup('env', 'IDRAC_IP') }}" + username: "{{ lookup('env', 'IDRAC_USER') }}" + password: "{{ lookup('env', 'IDRAC_PASSWORD') }}" + validate_certs: false + reset_to_default: Default + roles: + - role: idrac_reset diff --git a/ansible_collections/dellemc/openmanage/roles/idrac_attributes/molecule/system_attr/converge.yml b/ansible_collections/dellemc/openmanage/roles/idrac_attributes/molecule/system_attr/converge.yml new file mode 100644 index 000000000..ae59956e7 --- /dev/null +++ b/ansible_collections/dellemc/openmanage/roles/idrac_attributes/molecule/system_attr/converge.yml @@ -0,0 +1,32 @@ +--- +- name: Converge file for system_attributes + hosts: all + gather_facts: false + vars: + hostname: "{{ lookup('env', 'IDRAC_IP') }}" + username: "{{ lookup('env', 'IDRAC_USER') }}" + password: "{{ lookup('env', 'IDRAC_PASSWORD') }}" + validate_certs: false + roles: + - role: idrac_attributes + vars: + system_attributes: + ServerOS.1.HostName: demohostname + tasks: + - name: Asserting system_attributes update in check mode + ansible.builtin.assert: + that: idrac_attributes_out.msg == "Changes found to be applied." + when: ansible_check_mode + tags: molecule-idempotence-notest + + - name: Asserting system_attributes update in normal mode + ansible.builtin.assert: + that: + - idrac_attributes_out.msg == "Successfully updated the attributes." + when: not ansible_check_mode and idrac_attributes_out.changed + + - name: Asserting system_attributes update in idempotence mode + ansible.builtin.assert: + that: + - idrac_attributes_out.msg == "No changes found to be applied." + when: not ansible_check_mode and not idrac_attributes_out.changed diff --git a/ansible_collections/dellemc/openmanage/roles/idrac_attributes/molecule/system_attr/molecule.yml b/ansible_collections/dellemc/openmanage/roles/idrac_attributes/molecule/system_attr/molecule.yml new file mode 100644 index 000000000..ed97d539c --- /dev/null +++ b/ansible_collections/dellemc/openmanage/roles/idrac_attributes/molecule/system_attr/molecule.yml @@ -0,0 +1 @@ +--- diff --git a/ansible_collections/dellemc/openmanage/roles/idrac_attributes/tasks/main.yml b/ansible_collections/dellemc/openmanage/roles/idrac_attributes/tasks/main.yml new file mode 100644 index 000000000..80bc1edb4 --- /dev/null +++ b/ansible_collections/dellemc/openmanage/roles/idrac_attributes/tasks/main.yml @@ -0,0 +1,16 @@ +--- +- name: Configure attributes + dellemc.openmanage.idrac_attributes: + idrac_ip: "{{ hostname }}" + idrac_user: "{{ username }}" + idrac_password: "{{ password }}" + idrac_port: "{{ https_port }}" + ca_path: "{{ ca_path | default(omit) }}" + validate_certs: "{{ validate_certs }}" + idrac_attributes: "{{ idrac_attributes | default(omit) }}" + system_attributes: "{{ system_attributes | default(omit) }}" + lifecycle_controller_attributes: "{{ lifecycle_controller_attributes | default(omit) }}" + resource_id: "{{ manager_id | default(omit) }}" + timeout: "{{ https_timeout }}" + register: idrac_attributes_out + delegate_to: "{{ idrac_attributes_delegate }}" diff --git a/ansible_collections/dellemc/openmanage/roles/idrac_attributes/tests/inventory b/ansible_collections/dellemc/openmanage/roles/idrac_attributes/tests/inventory new file mode 100644 index 000000000..878877b07 --- /dev/null +++ b/ansible_collections/dellemc/openmanage/roles/idrac_attributes/tests/inventory @@ -0,0 +1,2 @@ +localhost + diff --git a/ansible_collections/dellemc/openmanage/roles/idrac_attributes/tests/test.yml b/ansible_collections/dellemc/openmanage/roles/idrac_attributes/tests/test.yml new file mode 100644 index 000000000..0016e133a --- /dev/null +++ b/ansible_collections/dellemc/openmanage/roles/idrac_attributes/tests/test.yml @@ -0,0 +1,6 @@ +--- +- name: Tests for idrac attributes + hosts: localhost + remote_user: root + roles: + - idrac_attributes diff --git a/ansible_collections/dellemc/openmanage/roles/idrac_attributes/vars/main.yml b/ansible_collections/dellemc/openmanage/roles/idrac_attributes/vars/main.yml new file mode 100644 index 000000000..9684f674f --- /dev/null +++ b/ansible_collections/dellemc/openmanage/roles/idrac_attributes/vars/main.yml @@ -0,0 +1,3 @@ +--- +# vars file for idrac_attributes +idrac_attributes_delegate: "{{ lookup('ansible.builtin.env', 'RUNON', default='localhost') }}" |