1. ansible的变量
[root@server4 ~]# cat vars.yml
---
- hosts: testB
vars:
testvar1: testfile # 或者- testvar1: testfile
remote_user: root
tasks:
- name: task1
file:
path: /testdir/{
{
testvar1 }}
state: touch
# 测试:
[root@server4 ~]# ansible-playbook vars.yml
[root@server3 testdir]# ls
testfile
[root@server4 ~]# cat vars.yml
---
- hosts: testB
vars:
- testvar1: testfile
- testvar2: testdirectory
remote_user: root
tasks: