Unwanted ansible-tmp in command
I’m currently working on getting ansible to work with gcp in the scenario that direct ssh is not possible (which it is in my case). I’m using code provided in How to tell Ansible to use GCP IAP tunneling - Xebia
During the execution of a ansible.builtin.file call I’m faced with an error:
gcloud compute ssh. ... -- -C /bin/sh -c 'rm -f -r ansible-tmp-1736873865.9504788-1510864-250879130520453=/tmp/ansible/ansible-tmp-1736873865.9504788-1510864-250879130520453/ > /dev/null 2>&1 && sleep 0'
Somehow the ansible-tmp-.....=
gets shoved in front of the remote path. In the gcloud command this breaks functionality.
If anybody know a way to omit this without me hacking the wrapper scripts it would be much appreciated.
I expect the my problem to lies somewhere in ansible/plugins/action/__init__.py
the _make_tmp_path
function that in turn calls mkdtemp
in ansible/plugins/shell/__init__.py
in the function the command is constructed in ansible/lib/ansible/plugins/shell/__init__.py at v2.14.18 · ansible/ansible · GitHub . This makes a command like this
( umask 77 && mkdir -p "` echo /tmp/ansible `"&& mkdir "` echo /tmp/ansible/ansible-tmp-1736873865.9504788-1510864-250879130520453 `" && echo ansible-tmp-1736873865.9504788-1510864-250879130520453="` echo /tmp/ansible/ansible-tmp-1736873865.9504788-1510864-250879130520453 `" )
The reason I think this is because the cleanup
function in action refers to the tmpdir
property in shell
which seems to be set by _make_tmp_path
where it is a result of the shell._generate_temp_dir_name
method. This seems to be a simple string passed from one function to another and the mangled string in the output looks much like the one I currently have trouble with.
Version info:
# molecule --version
molecule 6.0.3 using python 3.9
ansible:2.14.18
default:6.0.3 from molecule