Skip to content

Fix async_dir variable expansion to match remote_tmp - #85375

Open
seb-goodman wants to merge 1 commit into
ansible:develfrom
seb-goodman:devel
Open

Fix async_dir variable expansion to match remote_tmp#85375
seb-goodman wants to merge 1 commit into
ansible:develfrom
seb-goodman:devel

Conversation

@seb-goodman

Copy link
Copy Markdown
SUMMARY

Fix async_dir variable expansion to match remote_tmp behavior.

The async_wrapper module was using os.path.expanduser(). This caused shell variables like $HOME to be treated as literal directory names, resulting in directories like /home/admin/$HOME being created.

Adds os.path.expandvars() to the async directory setup in async_wrapper.py, and hopefully better aligns with the expansion behavior used by remote_tmp in basic.py.

I haven't addressed any ownership issues or made any changes to async_dir default, but can take a look at this if happy with current PR and this would be helpful.

Fixes #85370

ISSUE TYPE
  • Bugfix Pull Request

@ansibot ansibot added bug This issue/PR relates to a bug. needs_triage Needs a first human triage before being processed. module This issue/PR relates to a module. has_issue labels Jun 23, 2025
Comment thread lib/ansible/modules/async_wrapper.py
Comment thread lib/ansible/modules/async_wrapper.py
@ansibot ansibot added the needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. label Jun 25, 2025
Comment on lines +283 to +293
- name: test async with $HOME variable expansion
command: echo "test"
async: 5
poll: 1
vars:
ansible_async_dir: "$HOME/.ansible_test_var_expansion"

- name: verify $HOME was expanded and cleanup
file:
path: "{{ ansible_env.HOME }}/.ansible_test_var_expansion"
state: absent

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you also add a test using async_status to cleanup an async directory? https://docs.ansible.com/ansible/latest/collections/ansible/builtin/async_status_module.html#parameter-mode

@bcoca bcoca removed the needs_triage Needs a first human triage before being processed. label Jun 26, 2025
@ansibot ansibot added the stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. label Jul 3, 2025
@VannTen

VannTen commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Is the PR expected to fix #81805 as well ?

@ansibot ansibot added the stale_pr This PR has not been pushed to for more than one year. label Jun 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug This issue/PR relates to a bug. has_issue module This issue/PR relates to a module. needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. stale_pr This PR has not been pushed to for more than one year.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

async_dir not properly expanding variables

5 participants