mitogen
mitogen copied to clipboard
Mitogen is not compatible with 'become_exe = "sudo su -" ' in ansible.cfg
Ansible 2.9.2 with ansible.cfg:
[defaults] inventory = /home/xxx/ansible/staging remote_user = xxx host_key_checking = False callback_whitelist = profile_tasks strategy_plugins = /home/xxx/ansible/mitogen-0.2.9/ansible_mitogen/plugins/strategy strategy = mitogen_linear
[privilege_escalation] become = True become_method = su become_user = root become_exe = "/usr/bin/sudo su -"
Mitogen 0.2.9
Python (host 2.7.5 and target is 2.6.6)
OS(Host is CentOS 7.7 and target is RHEL 6.10)
Error:
ansible-playbook site.yml -vvv
The command above failed when going into 'gather fact' step. But will be successful if deleting the 'become_exe' in ansible.cfg.
[mux 18510] 19:00:25.388312 D mitogen.importer.[ssh.xxxxxx]: received mitogen.su [mux 18510] 19:00:25.390934 D mitogen.parent.[ssh.xxxxxx]: creating connection to context 4 using mitogen.su [mux 18510] 19:00:25.399658 D mitogen.importer.[ssh.xxxxxx]: encodings.ascii is submodule of a locally loaded package [mux 18510] 19:00:25.400047 D mitogen.importer.[ssh.xxxxxx]: encodings.base64_codec is submodule of a locally loaded package [mux 18510] 19:00:25.400244 D mitogen.importer.[ssh.xxxxxx]: encodings.base64 is submodule of a locally loaded package [mux 18510] 19:00:25.401381 D mitogen.parent.[ssh.xxxxxx]: command line for Connection(None): "/usr/bin/sudo su -" root -c "/usr/bin/python -c "import codecs,os,sys;=codecs.decode;exec(((\"eNqFkc1OwzAQhO95itxsq1bqFMpPJEugHhAHhBQhcoAKObEDhsS2nKShPD3bFNGkHLjt5xnvrHZTmnHbRE47hUngaT8iXYYApfUfmCTBrpadW2BGY8bIgVM6Jg9qvOeiso3C6Rj8GLIx9AAQ2GwhvhItpNYh5yGSwvfaoFAYOYjqUxVdK/JKDfK8a/w812butu2bNQjmPLbN+PCyUb7R1jwlJ+shVpmN9sDoOr15ZGjNp9/2HsAKTwU6xRnCtW7tqzLJe6W7K93Um7o6W0ZQFMIIKaLC1snpJVsSRAJo2nvdKhxTdHf7cM8YezYIhimshJ2TYMVf8G7r0jplYNfI54hEXgmJ43O2vCAUfWkHnUrHD76Moj5Hu0OU7idgNdT75R65+//cf6eMp1P+nm1BvgFIrbci\".encode(),\"base64\"),\"zip\"))"" [mux 18510] 19:00:25.406699 D mitogen.importer.[ssh.xxxxxx]: encodings.string_escape is submodule of a locally loaded package [mux 18510] 19:00:25.406837 D mitogen.parent.[ssh.xxxxxx]: failed to start child Traceback (most recent call last): File "master:/home/xxx/ansible/mitogen-0.2.9/mitogen/parent.py", line 1681, in async_connect self.proc = self.start_child() File "master:/home/xxx/ansible/mitogen-0.2.9/mitogen/parent.py", line 1527, in start_child raise mitogen.core.StreamError(msg) StreamError: Child start failed: [Errno 2] No such file or directory. Command was: "/usr/bin/sudo su -" root -c "/usr/bin/python -c "import codecs,os,sys;=codecs.decode;exec((_(\"eNqFkc1OwzAQhO95itxsq1bqFMpPJEugHhAHhBQhcoAKObEDhsS2nKShPD3bFNGkHLjt5xnvrHZTmnHbRE47hUngaT8iXYYApfUfmCTBrpadW2BGY8bIgVM6Jg9qvOeiso3C6Rj8GLIx9AAQ2GwhvhItpNYh5yGSwvfaoFAYOYjqUxVdK/JKDfK8a/w812butu2bNQjmPLbN+PCyUb7R1jwlJ+shVpmN9sDoOr15ZGjNp9/2HsAKTwU6xRnCtW7tqzLJe6W7K93Um7o6W0ZQFMIIKaLC1snpJVsSRAJo2nvdKhxTdHf7cM8YezYIhimshJ2TYMVf8G7r0jplYNfI54hEXgmJ43O2vCAUfWkHnUrHD76Moj5Hu0OU7idgNdT75R65+//cf6eMp1P+nm1BvgFIrbci\".encode(),\"base64\"),\"zip\"))""
Can you try current master of mitogen?
Can you try current
masterof mitogen?
Thanks for the reply. I just tried, but still the same problem. Based on the error, it seems missing some file or directory, but I can't figure out what it was looking for.
I think it's because of how mitogen creates the su and sudo command to use 🤔
Here's an alternative to what could work in the meantime though:
become = True
become_method = su
become_user = root
become_exe = sudo
I think it's because of how mitogen creates the
suandsudocommand to use 🤔 Here's an alternative to what could work in the meantime though:become = True become_method = su become_user = root become_exe = sudo
Yep, that may work, but unfortunately, I need to use 'sudo su -' to switch to the user root. The setting above didn't generate 'sudo su -' and gave me the sudo warnings "We trust you have received the usual lecture from the local System".
ahh ok. In that case I'm not sure of a fix you can use in the meantime :/ Once I finish collections support I'll try and repro/fix this if it hasn't been fixed by then :)
ahh ok. In that case I'm not sure of a fix you can use in the meantime :/ Once I finish collections support I'll try and repro/fix this if it hasn't been fixed by then :)
Much appreciated.
I'm running a similar setup with RHEL7 where the target system has a custom sudo exe which requires the - at the end of the become_exe option.
Until this issue isn't solved I'm not able to get onto mitogen ;(
@tdluckyboy @mongrelion to aid in debugging, could someone create a minimal Dockerfile with a reproducible environment I can use to test with? Collections support will probably take awhile to complete (much discussion around it here: #715 ); I can try and get to this ticket at the same time, but I don't have a ton of extra dev time to spare at the moment. A Dockerfile would make that a faster process 😅
@s1113950, this issue still happens and is pretty annoying. I kind of assume that the cause of it seems to be that somewhere in Mitogen's code there's a check that if become_exe exists/is file/is executable. Since using sudo su - is kind of a hacky way doing things by defining become_method: su and become_exe: sudo su - then Mitogen fails to account that become_exe also might contain executable arguments and thinks that sudo su - should be the executable's filename and checks if it exists/is file/is executable, which obviously fails because there is no such thing as sudo su -, thats why the No such file or directory error.
Edit:
It seems that the offending part could be https://github.com/mitogen-hq/mitogen/blob/master/mitogen/parent.py#L336