1

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.

2

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.

1

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.