ansible-playbook文件结构:
1 --- 2 - name: play1 #指定的playbook名字 3 hosts: webservers #指定主机组 4 remote_user: root #指定运行用户 5 vars: #指定变量名 6 var_name: value 7 tasks: #指定要在playbook要做的那些事情 8 - name: echo #指定输出的哪个阶段显示 9 shell: "echo {{var_name}}" #指定需要执行的命令 10 11 - name: play2 12 hosts: webservers 13 remote_user: root 14 vars: 15 var_name: value 16 tasks: 17 - name: echo 18 shell: "echo {{var_name}}" 19 20 21 --- 22 - hosts: webservers 23 remote_user: root 24 vars: 25 var_name: value 26 tasks: 27 - name: echo 28 shell: "echo {{var_name}}"