从配置文件变量创建Ansibles远程\u tmp
我想通过手动创建路径修复以下警告:从配置文件变量创建Ansibles远程\u tmp,ansible,ansible-2.x,temp,Ansible,Ansible 2.x,Temp,我想通过手动创建路径修复以下警告: 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 anoth
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
为了保持干燥,我不想只使用文件
指令中的模式进行创建。相反,我希望访问playbook中的remote\u tmp
变量来动态获取路径,即使路径被环境变量或ansible.cfg
文件更改
我找不到有关此变量的文档,并尝试:
- debug:
#var: remote_tmp
#var: hostvars[remote_tmp]
var: ansible_remote_tmp
但总有一个错误,变量没有定义
如何从playbook中的配置中获取
remote\u tmp
变量?如果这是您需要的,请参见下文
---
- hosts: "localhost"
tasks:
- name: ansible conf file
shell: cat /etc/ansible/ansible.cfg | grep remote_tmp | awk '{print $3}'
register: remote_tmp
- name: print
debug:
msg: "{{remote_tmp.stdout}}"
输出:
TASK [print]
****************************************************
ok: [localhost] => {
"msg": "~/.ansible/tmp"
}
这将是一个解决办法。但我想知道,似乎没有办法直接访问
remote\u tmp
值,因为可以使用Ansible中的其他变量。