Open pstrzelczak opened 6 months ago
Now I've done a lot of digging around in ansible_mitogen/transport_config.py and ansible_mitogen/connection.py I can probably diagnose this. Prime suspect is
and https://github.com/mitogen-hq/mitogen/commit/833e2845e9d25fac94b5aab6fd0b613a3bd97007 probably contains the building blocks to fix it.
Still occurs with master,
➜ mitogen git:(master) ✗ ANSIBLE_STRATEGY=mitogen_linear ansible -i issue1079_inv.yml localhost -m ansible.builtin.wait_for_connection -a "timeout=10"
localhost | FAILED! => {
"changed": false,
"elapsed": 10,
"msg": "timed out waiting for ping module test: 'int' object has no attribute 'template'"
}
same -vvv
doesn't occur with vanilla Ansible
➜ mitogen git:(master) ✗ ANSIBLE_STRATEGY=linear ansible -i issue1079_inv.yml localhost -m ansible.builtin.wait_for_connection -a "timeout=10"
[WARNING]: Reset is not implemented for this connection
localhost | SUCCESS => {
"changed": false,
"elapsed": 0
}
all:
hosts:
localhost:
ansible_connection: local
ansible_python_interpreter: "{{ ansible_playbook_python }}"
Untemplated ansible_interpreter_python
makes the problem go away
➜ mitogen git:(master) ✗ ANSIBLE_STRATEGY=mitogen_linear ansible -i issue1079_inv.yml localhost -m ansible.builtin.wait_for_connection -a "timeout=20"
localhost | SUCCESS => {
"changed": false,
"elapsed": 0
}
all:
hosts:
localhost:
ansible_connection: local
ansible_python_interpreter: python3
I need to ponder this some more. The templar made available in '_mitogen.smuggled.reset_connection' is only available during a meta: reset_connection
task.
Note to self: There's already some special handling for wait_for_connection
➜ mitogen git:(issue1079-templated-python-interpreter) ✗ ag wait_for_connection
ansible_mitogen/mixins.py
367: # wait_for_connection, the `ping` test from Ansible won't pass because we lost connection
369: # see https://github.com/dw/mitogen/issues/655 and Ansible's `wait_for_connection` module for more info
370: if module_name == 'ansible.legacy.ping' and type(self).__name__ == 'wait_for_connection':
ansible_mitogen/services.py
162: # and then a `wait_for_connection` right afterwards
ansible_mitogen/connection.py
865: Ansible 2.4 wait_for_connection plug-in.
984: # Compatibility with Ansible 2.4 wait_for_connection plug-in.
tests/ansible/integration/context_service/reconnection.yml
24: - wait_for_connection:
tests/ansible/regression/issue_655__wait_for_connection_error.yml
2:# Spins up a Centos8 container and runs the wait_for_connection test inside of it
7:- name: regression/issue_655__wait_for_connection_error.yml
85: wait_for_connection:
tests/ansible/regression/all.yml
15:- import_playbook: issue_655__wait_for_connection_error.yml
docs/changelog.rst
242:* :gh:issue:`655` wait_for_connection gives errors
Reproduction steps:
where
Result:
Suprisingly, with implicit inventory it works fine:
Which version of Ansible are you running?
Is your version of Ansible patched in any way? No
Are you running with any custom modules, or
module_utils
loaded? NoHave you tried the latest master version from Git? Yes
Do you have some idea of what the underlying problem may be? https://mitogen.networkgenomics.com/ansible_detailed.html#common-problems has instructions to help figure out the likely cause and how to gather relevant logs. No
Mention your host and target OS and versions Rocky 8.8
Mention your host and target Python versions Python 3.8
If reporting a performance issue, mention the number of targets and a rough description of your workload (lots of copies, lots of tiny file edits, etc.)
If reporting a crash or hang in Ansible, please rerun with -vvv and include 200 lines of output around the point of the error, along with a full copy of any traceback or error text in the log. Beware "-vvv" may include secret data! Edit as necessary before posting.
If reporting any kind of problem with Ansible, please include the Ansible version along with output of "ansible-config dump --only-changed". Empty
EDIT: 2024-10-07 @moreati Syntax highlighting