7

Ansible version 2.9.2

Is it possible to change ansible temp dir for one playbook only? I have VMs with r/o root. So, the playbook fails. Even if I run my playbook under root user on target VM it can't create ansible temp files that it creates in current user's home dir on target VM. I know that I can change it in ansible.cfg file, but I need it only for one VM type.

I need to make changes to other not r/o drives.

Kirill Vakhrushev
  • 103
  • 1
  • 1
  • 5

2 Answers2

9

Q: "Is it possible to change ansible temp dir for one playbook only? I have VMs with r/o root."

A: Yes. It's possible. Configure the variable ansible_remote_tmp.

In some cases, a better solution to this problem is ANSIBLE_PIPELINING. Quoting from Risks and limitations of become:

Use pipelining. When pipelining is enabled, Ansible does not save the module to a temporary file on the client. Instead, it pipes the module to the remote python interpreter’s stdin. Pipelining does not work for python modules involving file transfer (for example: copy, fetch, template), or for non-python modules.


Notes:

The ANSIBLE_REMOTE_TMP environment variable has been added to supplement (and override) ANSIBLE_REMOTE_TEMP. This matches the spelling of the config value. ANSIBLE_REMOTE_TEMP will be deprecated in the future.

Vladimir Botka
  • 2,081
  • 8
  • 12
3

I understood with the help of the documentation above how to replace environment variables.

For example:

- hosts: hostnames
  remote_user: root
  gather_facts: no
  vars:
    ansible_remote_tmp: /tmp
  tasks:
  ...

Also, it's possible to replace in the separate tasks.

Ansible documentation about playbook environment

Kirill Vakhrushev
  • 103
  • 1
  • 1
  • 5