Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create Ansibles remote_tmp from config file variable

I want to fix the following warning by manually creating the path:

Wednesday 22 January 2020  12:50:41 +0100 (0:00:05.878)       0:20:16.431 ***** 
[WARNING]: Module remote_tmp /home/db2inst1/.ansible/tmp did not exist and was created with a mode of 0700, this may cause issues when running as another user. To avoid this, create the remote_tmp dir with the correct permissions
manually

To keep things DRY, I don't want to just use the pattern in a file directive for creation. Instead, I'd like to access the remote_tmp variable inside my playbook to dynamically fetch the path, even when it's changed by environment variables or the ansible.cfg file.

I couldn't find a documentation about this variable and tried:

- debug:
    #var: remote_tmp
    #var: hostvars[remote_tmp]
    var: ansible_remote_tmp

but always got an error that the variable is not defined.

How can I get the remote_tmp variable from the config inside a playbook?

like image 884
Lion Avatar asked Aug 31 '25 03:08

Lion


1 Answers

As far as I understand you just have to define

allow_world_readable_tmpfiles: true in your vars.yml file, so somehow this solution works in my case.


Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!