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-test uses hardcoded /tmp with tempfile.mkdtemp() instead of relying on env vars #82214

Open
1 task done
sonomac opened this issue Nov 14, 2023 · 4 comments
Open
1 task done
Labels
affects_2.14 bug This issue/PR relates to a bug.

Comments

@sonomac
Copy link

sonomac commented Nov 14, 2023

Summary

when executing ansible-test on a Linux system having mounted /tmp with the options noexec,nosuid, the following error appears:

FATAL: Path "/tmp/ansible-test-xxxxxx-injector/python.py" should be executable, but is not. Is the filesystem mounted with the "noexec" option?

from my point of view, the code in question should rather use os.environment.get('TMPDIR', '/tmp') instead of just /tmp with tempfile.mkdtemp():
https://github.com/ansible/ansible/blob/devel/test/lib/ansible_test/_internal/util_common.py#L296

Issue Type

Bug Report

Component Name

ansible-test

Ansible Version

$ ansible --version
ansible [core 2.14.1]
  config file = None
  configured module search path = ['/home/me/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/me/projects/ansible/lib/python3.9/site-packages/ansible
  ansible collection location = /home/me/.ansible/collections:/usr/share/ansible/collections
  executable location = /home/me/.venvs/ansible-2.14.1/bin/ansible
  python version = 3.10.12 (main, Jul  5 2023, 18:54:27) [GCC 11.2.0] (/home/me/.venvs/ansible-2.14.1/bin/python)
  jinja version = 3.1.2
  libyaml = True

Configuration

# if using a version older than ansible-core 2.12 you should omit the '-t all'
$ ansible-config dump --only-changed -t all
CONFIG_FILE() = None

OS / Environment

RHEL 7, any Linux distribution

Steps to Reproduce

execute ansible-test sanity on any Linux system having /tmp mounted with the options noexec,nosuid,nodev:

$ ansible-test sanity -vvv

Expected Results

respect the environment variable TMPDIR to point to a file-system not having the restrictions of noexec,nosuid,nodev when using ansible-test

Actual Results

$ ansible-test sanity -vvv
Configured locale: en_US.UTF-8
Creating container database.
>>> Container Database
{}
Read 0 sanity test ignore line(s) for Ansible 2.14 from: tests/sanity/ignore-2.14.txt
Running sanity test "action-plugin-docs"
Initializing "/tmp/ansible-test-kvworxnz-injector" as the temporary directory.
FATAL: Path "/tmp/ansible-test-kvworxnz-injector/python.py" should be executable, but is not. Is the filesystem mounted with the "noexec" option?

Code of Conduct

  • I agree to follow the Ansible Code of Conduct
@ansibot ansibot added bug This issue/PR relates to a bug. needs_triage Needs a first human triage before being processed. affects_2.14 labels Nov 14, 2023
@ansibot
Copy link
Contributor

ansibot commented Nov 14, 2023

Files identified in the description:

If these files are incorrect, please update the component name section of the description or use the component bot command.

@ansibot
Copy link
Contributor

ansibot commented Nov 14, 2023

@sonomac ansible-core 2.14 is not supported and no longer receives bug fixes. Please test against one of the supported versions of ansible-core, preferably the most recent one, to see whether the bug has been fixed.

click here for bot help

@sonomac
Copy link
Author

sonomac commented Nov 14, 2023

based on the current code in the develop branch, the issue is still there with the newest Ansible Version 2.17

@s-hertel s-hertel removed the needs_triage Needs a first human triage before being processed. label Nov 14, 2023
@bcoca
Copy link
Member

bcoca commented Nov 14, 2023

Not really a bug, this is by design, we set dir=/tmp which overrides TMPDIR/TEMP/TMP env vars, which tempfile uses by default.

Maybe a feature request to make this configurable?

@sivel sivel changed the title ansible-test shall use TMPDIR with tempfile.mkdtemp() ansible-test uses hardcoded /tmp tempfile.mkdtemp() instead of relying on env vars Nov 14, 2023
@sivel sivel changed the title ansible-test uses hardcoded /tmp tempfile.mkdtemp() instead of relying on env vars ansible-test uses hardcoded /tmp with tempfile.mkdtemp() instead of relying on env vars Nov 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects_2.14 bug This issue/PR relates to a bug.
Projects
None yet
Development

No branches or pull requests

4 participants