Skip to content
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

ansible_async_dir not working with mitogen strategy #1084

Open
deribaucourt opened this issue Jun 5, 2024 · 0 comments
Open

ansible_async_dir not working with mitogen strategy #1084

deribaucourt opened this issue Jun 5, 2024 · 0 comments
Labels
affects-0.3 Issues related to 0.3.X Mitogen releases bug Code feature that hinders desired execution outcome

Comments

@deribaucourt
Copy link

deribaucourt commented Jun 5, 2024

Hello,

My playbook requires to change ansible_async_dir because the home directory is not writable on my system. However, that variable is not having effect when I use the mitogen_linear strategy.

- name: Asynchronous task example
  ansible.builtin.command: sleep 5
  async: 10
  poll: 0
  vars:
    ansible_async_dir: '/tmp/.ansible_async'

With strategy: mitogen_linear, I get this error with ansible-playbook -vvv:

The full traceback is:
Traceback (most recent call last):
  File "/home/deribaucourt/.pyenv/versions/3.9.6/envs/sw_ansible/lib/python3.9/site-packages/ansible/executor/task_executor.py", line 158, in run
    res = self._execute()
  File "/home/deribaucourt/.pyenv/versions/3.9.6/envs/sw_ansible/lib/python3.9/site-packages/ansible/executor/task_executor.py", line 600, in _execute
    result = self._handler.run(task_vars=variables)
  File "/home/deribaucourt/.pyenv/versions/sw_ansible/lib/python3.9/site-packages/ansible_mitogen/mixins.py", line 146, in run
    return super(ActionModuleMixin, self).run(tmp, task_vars)
  File "/home/deribaucourt/.pyenv/versions/3.9.6/envs/sw_ansible/lib/python3.9/site-packages/ansible/plugins/action/command.py", line 26, in run
    results = merge_hash(results, self._execute_module(module_name='ansible.legacy.command', task_vars=task_vars, wrap_async=wrap_async))
  File "/home/deribaucourt/.pyenv/versions/ansible/lib/python3.9/site-packages/ansible_mitogen/mixins.py", line 386, in _execute_module
    result = ansible_mitogen.planner.invoke(
  File "/home/deribaucourt/.pyenv/versions/sw_ansible/lib/python3.9/site-packages/ansible_mitogen/planner.py", line 603, in invoke
    response = _invoke_async_task(invocation, planner)
  File "/home/deribaucourt/.pyenv/versions/sw_ansible/lib/python3.9/site-packages/ansible_mitogen/planner.py", line 500, in _invoke_async_task
    raise msg.unpickle()
  File "/home/deribaucourt/.pyenv/versions/sw_ansible/lib/python3.9/site-packages/mitogen/core.py", line 977, in unpickle
    raise obj
mitogen.core.CallError: builtins.OSError: [Errno 30] Read-only file system: '/home/root/.ansible_async'
  File "<stdin>", line 3706, in _dispatch_one
  File "master:/home/deribaucourt/.pyenv/versions/sw_ansible/lib/python3.9/site-packages/ansible_mitogen/target.py", line 569, in run_module_async
    arunner = AsyncRunner(
  File "master:/home/deribaucourt/.pyenv/versions/sw_ansible/lib/python3.9/site-packages/ansible_mitogen/target.py", line 441, in __init__
    self._init_path()
  File "master:/home/deribaucourt/.pyenv/versions/sw_ansible/lib/python3.9/site-packages/ansible_mitogen/target.py", line 446, in _init_path
    os.makedirs(async_dir)
  File "/usr/lib/python3.10/os.py", line 225, in makedirs
    mkdir(name, mode)

fatal: [machine-ci]: FAILED! => {
    "msg": "Unexpected failure during module execution.",
    "stdout": ""
}

While without strategy: mitogen_linear, the proper path is used:

<machine-ci SSH: EXEC ssh -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=false -o UserKnownHostsFile=/dev/null -o PreferredAuthentications=publickey -o StrictHostKeyChecking=no -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="root"' -o ConnectTimeout=10 -o 'ControlPath="/home/deribaucourt/.ansible/cp/ae18666470"' -tt machine-ci '/bin/sh -c '"'"'ANSIBLE_ASYNC_DIR=/tmp/.ansible_async /usr/bin/python3.10 /tmp/.ansible/ansible-tmp-1717582130.3118248-3038467-249614727883124/async_wrapper.py 934601666532 10 /tmp/.ansible/ansible-tmp-1717582130.3118248-3038467-249614727883124/AnsiballZ_command.py _ && sleep 0'"'"''
<machine-ci (0, b'{"failed": 0, "started": 1, "finished": 0, "ansible_job_id": "84557796358.2597", "results_file": "/tmp/.ansible_async/84557796358.2597", "_ansible_suppress_tmpdir_delete": true}\r\n', b'Shared connection to 192.168.47.50 closed.\r\n')

This looks a bit like #297 which should have been resolved for host variables. However, ansible_async_dir is more internal to ansible it looks like.

I'm using Ansible 2.12.3 with mitogen 0.3.3 on Ubuntu 22.04 with Python 3.9.6

Any help to understand or fix this issue would be welcome 😄 . Meanwhile, I can figure some workarounds with overlayfs, or use start-stop-daemon instead of async.

@deribaucourt deribaucourt added affects-0.3 Issues related to 0.3.X Mitogen releases bug Code feature that hinders desired execution outcome labels Jun 5, 2024
@deribaucourt deribaucourt changed the title ansible_async_dir variable not working with mitogen strategy ansible_async_dir not working with mitogen strategy Jun 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects-0.3 Issues related to 0.3.X Mitogen releases bug Code feature that hinders desired execution outcome
Projects
None yet
Development

No branches or pull requests

1 participant