-
Notifications
You must be signed in to change notification settings - Fork 284
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
Fix login and session issues connecting to zabbix #1380
Fix login and session issues connecting to zabbix #1380
Conversation
* zabbix httpapi plugin - if login failed, it would not be attempted again by later tasks. fix now marks the connection as disconnected on failed login so that later tasks can try * zabbix_user - if the api user's password was changed, session errors would occur in later tasks. fix will relogin to zabbix after changing password of the api user
@pyrodie18 Thanks for running the tests. I will look into the failures and hopefully have a resolution later today. |
* Remove "Internal" group from the admin pass modification task * Don't attempt to reset back to default zabbix password, just update the password fact. (default 'zabbix' is too short to reset to)
So there are a few issues with the build as it stands. It will take me a few days to address these issues but I have a roadmap. Unfortunately its become quite a rabbit hole of bugs and or constraints. I noted that tests are failing strangely for zabbix version 6.0. I will have to look into this further after I resolve the other issues. Tests after zabbix_user module changes zabbix password failI see the tests are sharing the same zabbix instance and I thought maybe we could try rewriting the test so that its changing the password of another user. Unfortunately, due to how connections are reused, this does not trigger the required code branch. My current approach is to use the zabbix_authentication module to change the passwd_check_rules so that we can reset the password back to the default "zabbix" Unfortunately, there is a bug in the zabbix_authentication module when updating the passwd_check_rules and you cannot set it to an empty list to turn off all checks. As such, I will be putting together the required tests and fixes to to address the sub-bugs and hopefully get this PR into the green |
Sorry for coming so late to this discussion (being busy with real life). |
No problem, let me know your preferred direction for solving this issue. |
The issue solved by #1386 |
SUMMARY
Fixes #1209 because reset_connection will no longer be necessary in that context
Disconnect when a failed login happens
Why do we need this ?
In the case of writing an Ansible role to:
We may need to use a test login call to see if our new password works or if its still the default
failed_when: false
on the task so our play doesn't fail if we get a failed loginWhere this fails
Currently the codebase doesn't mark the connection as disconnected when a login fails so subsequent attempts will assume we are logged in and provide a bad auth token
The fix
In
community/zabbix/plugins/httpapi/zabbix.py
we update thelogin()
method so that when the login is failed, the connection is marked as disconnected.Update zabbix_user module to notify on successful password changes
Why do we have to do this?
It would be nice if we could detect changing the current Zabbix API user's password and re-login the user instead of seeing session terminated errors on subsequent calls
The original intent was to do this all from inside the Zabbix HTTPAPI class but it turns out the update user request is actually two separate requests made by the zabbix_user module:
Zabbix_user module User::update_user() method
password_changed_for_user()
method of theZabbixApiRequest
classcommunity/zabbix/plugins/modules/zabbix_user.py
:Add the password_changed_for_user method to ZabbixApiRequest
community/zabbix/plugins/module_utils/api_request.py
:Add password_changed_for_user method to Zabbix Ansible/HTTPAPI
community/zabbix/plugins/httpapi/zabbix.py
If so, we login with the new credentials
JSON-RPC communication between module and connection
password_changed_for_user()
method, the marshaller for the json-rpc requests automatically adds the header data including the correct request idISSUE TYPE
COMPONENT NAME
ADDITIONAL INFORMATION
See the integration test for a playbook on how to reproduce the issue: tests/integration/targets/test_zabbix_user/tasks/change_api_user_pass.yml