ansible-collections / ibm_zos_core

Red Hat Ansible Certified Content for IBM Z
77 stars 44 forks source link

[Bug][zos_copy] Temporary files are set up in '/tmp/' with no means to override #1481

Open ketankelkar opened 5 months ago

ketankelkar commented 5 months ago

Is there an existing issue for this?

Bug description

TL;DR: zos_copy will always copy temporary files to /tmp/. If a user cannot read and write there, the module fails.

The module builds the temporary path (temp_path) with a call to gettempprefix(), which is built-in to the python tempfile library (python docs) and always returns 'tmp'.

temp_path = "/{0}/{1}".format(gettempprefix(), _create_temp_path_name())

Link to src

Even when the ansible_remote_tmp (doc) variable is set in ansible.cfg, the module logic fails to check that configuration and builds the tempfile(s) under /tmp.

The module should honor the configuration set in the ansible_remote_tmp variable and build all temporary dirs/files at the configured location.

Find a way to set up temp_path so that the value of ansible_remote_tmp is honored instead of effectively hard-coding /tmp/... into temp_path.

Reported in IBM internal SLACK thread C0YPDHTGB/p1713974037809719.

IBM z/OS Ansible core Version

v1.8.0 (default)

IBM Z Open Automation Utilities

v1.2.5 (default)

IBM Enterprise Python

v3.12.x

ansible-version

v2.16.x (default)

z/OS version

v2.5 (default)

Ansible module

zos_copy

Playbook verbosity output.

See SLACK thread (verbosity dump may contain some internal IBM info)

Ansible configuration.

No response

Contents of the inventory

No response

Contents of group_vars or host_vars

No response

richp405 commented 5 months ago

Review after first development for potential second ticket