mitogen icon indicating copy to clipboard operation
mitogen copied to clipboard

mitogen_sudo connection plugin and friends are the wrong plugin type for `get_option('become_...')`

Open moreati opened this issue 1 year ago • 2 comments

ansible_mitogen.plugins.connection contains 3 "connections" that aren't connections in the Ansible world view

  • mitogen_doas
  • mitogen_sudo
  • mitogen_su

In Ansible land these would be become plugins. This wasn't a problem, but may become a problem now. I'm moving the PlaybookSpec to Ansible's plugin options API, but the options become_exe and become_flags are associated with become plugins and these plugins are connection plugins.

As a result the tests in tests/ansible/integration/stub_connections/all.yml fail with

PLAY [integration/stub_connections/mitogen_sudo.yml] ***************************

TASK [include_tasks _raw_params=../_mitogen_only.yml] **************************
Monday 28 October 2024  21:22:28 +0000 (0:00:00.372)       0:09:28.173 ******** 
included: /home/runner/work/mitogen/mitogen/tests/ansible/integration/_mitogen_only.yml for target-centos7-1, target-centos8-2, target-debian9-3, target-debian10-4, target-debian11-5, target-ubuntu1604-6, target-ubuntu1804-7, target-ubuntu2004-8

TASK [meta _raw_params=end_play] ***********************************************
Monday 28 October 2024  21:22:28 +0000 (0:00:00.159)       0:09:28.333 ******** 
skipping: [target-centos7-1]

TASK [custom_python_detect_environment ] ***************************************
Monday 28 October 2024  21:22:28 +0000 (0:00:00.012)       0:09:28.345 ******** 
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: AttributeError: 'NoneType' object has no attribute 'get_option'
fatal: [target-centos7-1]: FAILED! => 
  msg: 'Unexpected failure during module execution: ''NoneType'' object has no attribute ''get_option'''
  stdout: ''
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: AttributeError: 'NoneType' object has no attribute 'get_option'
fatal: [target-centos8-2]: FAILED! => 
  msg: 'Unexpected failure during module execution: ''NoneType'' object has no attribute ''get_option'''
  stdout: ''

moreati avatar Oct 28 '24 22:10 moreati

see #1172

moreati avatar Oct 28 '24 22:10 moreati

I believe this is because Mitogen predates Ansible become plugins, introduced in Ansible 2.8 (https://github.com/ansible/ansible/pull/50991). This matches when ansible.plugins.connection.ConnectionBase.become_methods was removed. This may have bearing on #1072.

moreati avatar Jan 31 '25 21:01 moreati