ansible - 我们可以在 ansible playbook 中设置 remote_tmp 值吗
问题描述
我想为每个剧本在 ansible 中设置不同的 remote_tmp 变量值。是否可以在剧本中定义这个变量值?
解决方案
问: “我们可以在 ansible playbook 中设置 remote_tmp 值吗?”
答:是的。您可以设置ansible_remote_tmp。例如,下面的剧本使用默认值~/.ansible/tmp
shell> cat playbook.yml
- hosts: test_01
tasks:
- debug:
var: ansible_remote_tmp
- shell: uname -a
shell> ansible-playbook playbook.yml -vvv
TASK [debug] ****
task path: /export/scratch/tmp/playbook.yml:3
ok: [test_01] =>
ansible_remote_tmp: 'VARIABLE IS NOT DEFINED!:
''ansible_remote_tmp'' is undefined'
TASK [shell] ****
task path: /export/scratch/tmp/playbook.yml:5
<test_01> ESTABLISH SSH CONNECTION FOR USER: admin
... echo /home/admin/.ansible/tmp/ansible-tmp-1599833593. ...
在下面的剧本中,远程 tmp 设置为/tmp
shell> cat playbook.yml
- hosts: test_01
vars:
ansible_remote_tmp: /tmp
tasks:
- debug:
var: ansible_remote_tmp
- shell: uname -a
shell> ansible-playbook playbook.yml -vvv
TASK [debug] ****
task path: /export/scratch/tmp/playbook.yml:11
ok: [test_01] =>
ansible_remote_tmp: /tmp
TASK [shell] ****
task path: /export/scratch/tmp/playbook.yml:13
<test_01> ESTABLISH SSH CONNECTION FOR USER: admin
... echo /tmp/ansible-tmp-1599833597. ...
推荐阅读
- mysql - 运行“sudo find / -iname 'mysql*' -exec rm -rf {} \;”后是否可以恢复 Ubuntu 16.04 并安装 mysql?
- flask - 如何在 Google Cloud Functions 的 python 环境中检查 HTTP 基本身份验证
- entity-framework - Entity Framework Plus - foreach 循环中的 FutureValue()
- cakephp - 在 CAKEPHP 检查所有视图的内容,如果不正常则发送邮件
- server - CPanel - 直接打开内部链接设置
- logstash - logstash 过滤器 docker 容器名称
- sql - MSSQL 从 12 列中获取前 4 个值
- php - 如何使用 symfony 日期类型放置或发布日期值
- node.js - 从具有节点和角度 5 的 linux 服务器下载 zip 文件时,zip 文件成功下载但为空
- python - 在特定文件列的每一行上应用 for 循环