Open Hornochs opened 5 months ago
I ran into the same issue, and I don't seem to be able to work around it.
The issue is caused by the fact that the module is needed in the type annotation here. This works fine when the module can be imported, but if not, the global variable that signals the import error to the remaining code is not interpreted within time. I suggest to just have the import fail.
For the record, I'm using ansible with pipx. I injected the dependency library and I can import it in the Python interpreter within the virtualenv created by pipx.
Are you able to tell me which module you injected via pipx? Unterwegs gesendet
Am 22.06.2024 um 02:13 schrieb TheAssassin - notifications at github.com @.***>:
I ran into the same issue, and I don't seem to be able to work around it.
The issue is caused by the fact that the module is needed in the type annotation here. This works fine when the module can be imported, but if not, the global variable that signals the import error to the remaining code is not interpreted within time. I suggest to just have the import fail.
For the record, I'm using ansible with pipx. I injected the dependency library and I can import it in the Python interpreter within the virtualenv created by pipx.
— Reply to this email directly, view it on GitHubhttps://github.com/lucasheld/ansible-uptime-kuma/issues/50#issuecomment-2183600284, or unsubscribehttps://github.com/notifications/unsubscribe-auth/APH6BQH5AJHIYX2GOWTWAHTZIS6RVAVCNFSM6AAAAABJIAGNB2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCOBTGYYDAMRYGQ. You are receiving this because you authored the thread.Message ID: @.***>
pipx inject ansible uptime-kuma-api==1.2.1
It's the equivalent of running pip in there to install the module mentioned in the README. However, it does not solve the problem.
I debugged the problem further. The issue is linked to how ansible runs modules on remote hosts. And yes, now it seems quite a bit more obvious to me than it used to.
Please see https://docs.ansible.com/ansible/latest/dev_guide/developing_program_flow_modules.html#ansiballz-framework. When ansible executes a module from any collection, the module needs to be transferred to the remote host. Including the library in the local interpreter doesn't make any difference. It'd need to be bundled with this collection's code to be available to the target system.
Executing a playbook with connection
resp. transport
set to local
does not make any difference. No matter what you do, ansible will pick some interpreter (likely the newest one that is available, according to my testing) and won't include the library. You can sometimes hack around this by setting PYTHONPATH
in the process's environment, but it's not a reliable solution.
At any rate, you likely want to execute these modules locally even when using an inventory anyway, so setting connection: local
in your playbook is a good idea. I still need to figure out how to make this collection use the installed Python package.
Edit: the instructions in the README are at least incomplete and definitely misleading.
What seems to work is to use delegate_to: 127.0.0.1
in all respective tasks.
Same issue. delegate_to didn't work for me
After installing uptime-kuma-api as root it did work
Hey there,
I'm not able to use the Modules :( Following is the Error: