IBM / ansible-power-hmc

Developer contributions for Ansible Automation on Power (HMC)
GNU General Public License v3.0
26 stars 41 forks source link

Key authentication doesn't work #89

Closed ecke66 closed 10 months ago

ecke66 commented 1 year ago

Using version 1.6.0 of the collection, I found that for module powervm_lpar_instance authentication with SSH public/private key does not work. The hscroot user can login to the HMC remotely using keys.

The issue The respective part in the playbook looks like this: ... tasks:

Running the playbook, I got this error: ... The full traceback is: File "/tmp/ansible_powervm_lpar_instance_payload_g9343xdc/ansible_powervm_lpar_instance_payload.zip/ansible_collections/ibm/power_hmc/plugins/modules/powervm_lpar_instance.py", line 987, in create_partition File "/tmp/ansible_powervm_lpar_instance_payload_g9343xdc/ansible_powervm_lpar_instance_payload.zip/ansible_collections/ibm/power_hmc/plugins/module_utils/hmc_rest_client.py", line 239, in init self.session = self.logon() File "/tmp/ansible_powervm_lpar_instance_payload_g9343xdc/ansible_powervm_lpar_instance_payload.zip/ansible_collections/ibm/power_hmc/plugins/module_utils/hmc_rest_client.py", line 253, in logon timeout=300) File "/tmp/ansible_powervm_lpar_instance_payload_g9343xdc/ansible_powervm_lpar_instance_payload.zip/ansible/module_utils/urls.py", line 1390, in open_url unredirected_headers=unredirected_headers) File "/tmp/ansible_powervm_lpar_instance_payload_g9343xdc/ansible_powervm_lpar_instance_payload.zip/ansible/module_utils/urls.py", line 1294, in open r = urllib_request.urlopen(urlopen_args) File "/opt/freeware/lib64/python3.7/urllib/request.py", line 222, in urlopen return opener.open(url, data, timeout) File "/opt/freeware/lib64/python3.7/urllib/request.py", line 531, in open response = meth(req, response) File "/opt/freeware/lib64/python3.7/urllib/request.py", line 641, in http_response 'http', request, response, code, msg, hdrs) File "/opt/freeware/lib64/python3.7/urllib/request.py", line 569, in error return self._call_chain(args) File "/opt/freeware/lib64/python3.7/urllib/request.py", line 503, in _call_chain result = func(*args) File "/opt/freeware/lib64/python3.7/urllib/request.py", line 649, in http_error_default raise HTTPError(req.full_url, code, msg, hdrs, fp) fatal: [XXXXXXXX]: FAILED! => { "changed": false, "invocation": { "module_args": { "action": null, "advanced_info": null, "all_resources": null, "delete_vdisks": null, "hmc_auth": { "password": null, "username": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER" }, ... "msg": "PMCSS007: The authorization filter did not detect a valid session. Access has been denied. Check the allow remote access via the web setting in the console user properties, or check the request for a valid session id. "

Expected behavior Playbook is being executed on HMC. The same authentication scheme is working without problems using module hmc_command.

Environment

AnilVijayan commented 1 year ago

HMC REST API wont support passwordless login (login using ssh keys) . Since powervm_lpar_instance module rely on REST API, it wont support this. And hmc_command is purely CLI based module, hence it support passwordless.

ecke66 commented 1 year ago

Thanks, that explains it. Tried with password, it does not work either in our case. The password contains a "(" character, which leads to:

The full traceback is: File "/tmp/ansible_powervm_lpar_instance_payload_th83x584/ansible_powervm_lpar_instance_payload.zip/ansible_collections/ibm/power_hmc/plugins/modules/powervm_lpar_instance.py", line 1076, in create_partition File "/tmp/ansible_powervm_lpar_instance_payload_th83x584/ansible_powervm_lpar_instance_payload.zip/ansible_collections/ibm/power_hmc/plugins/module_utils/hmc_resource.py", line 31, in listHMCVersion result = self.hmcconn.execute(lshmcCmd) File "/tmp/ansible_powervm_lpar_instance_payload_th83x584/ansible_powervm_lpar_instance_payload.zip/ansible_collections/ibm/power_hmc/plugins/module_utils/hmc_cli_client.py", line 71, in execute raise HmcError(errMsg) fatal: [XXXXXXXX]: FAILED! => { "changed": false, "invocation": { "module_args": { "action": null, "advanced_info": null, "all_resources": null, "delete_vdisks": null, "hmc_auth": { "password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER", "username": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER" }, ... "msg": "HmcError: b\"/bin/sh: 0403-057 Syntax error at line 1 : `(' is not expected.\""

AnilVijayan commented 1 year ago

This looks like any issue. Will drop the fix along with Dec release. As a work around you may proceed with escape character like: pass\(\)word