Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Key authentication doesn't work #89

Closed
ecke66 opened this issue Nov 8, 2022 · 3 comments
Closed

Key authentication doesn't work #89

ecke66 opened this issue Nov 8, 2022 · 3 comments

Comments

@ecke66
Copy link

ecke66 commented Nov 8, 2022

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:
- name: create lpar
powervm_lpar_instance:
hmc_host: '{{ inventory_hostname }}'
hmc_auth:
username: '{{ ansible_user }}'
...

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

  • HMC: V9R2 M953
  • Python Version: 3.7.12
  • OpenSSH Version: 8.1
  • Ansible control host: AIX 7.2TL5SP4
@AnilVijayan
Copy link
Member

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
Copy link
Author

ecke66 commented Nov 8, 2022

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
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants