DEFAULT_REMOTE_TMP not working

Hi,

I want to fetch the custom controller remote directory and create it if required, I used the remote_tmp in my ansible.cfg to set a custom value.

Previously I was using DEFAULT_REMOTE_TMP to get the custom value but I see a lot has changed after 2.4.0. Is there now a new way to do it?

I have a task using it as:

  • name: Create remote_tmp for it is used by another module
    file:
    path: “{{ lookup(‘config’, ‘DEFAULT_REMOTE_TMP’, on_missing=‘skip’, wantlist=True) | first | default(‘~/.ansible/tmp’) }}”
    state: directory
    mode: 0700

Regards,
Qasim Sarfraz

The remote tmp was changed around this version to become a shell plugin option and not a global option. You can see the ‘remote_tmp’ option at https://docs.ansible.com/ansible/latest/plugins/shell/sh.html, it’s defined using the same ini, env, and vars it’s just used by the shell plugin instead and made sense moving it there.

The DEFAULT_LOCAL_TMP is still global though but that’s not really what you should be doing.

As for looking up the value you are probably going at this the wrong way. If you want to rely on creating the tmp dir with your own permissions then it is better to set your own dir as a fact/var so you ensure that the directory is being used for that host, e.g.

`

  • hosts: my host
    vars:
    ansible_remote_tmp: ~/.ansible-custom/tmp

tasks:

  • name: Create remote_tmp for it used by another module
    file:
    path: “{{ ansible_remote_tmp }}”
    state: directory
    mode: 0700

`

This way you are not stuck if the internal option name changes and you are now following the contracted interface which should be stable across versions.

Thanks

Jordan