1. ansible-playbook文件结构
--- - name: play1 #指定的playbook名字 hosts: webservers #指定主机组 remote_user: root #指定运行用户 vars: #指定变量名 var_name: value tasks: #指定要在playbook要做的那些事情 - name: echo #指定输出的哪个阶段显示 shell: "echo {{var_name}}" #指定需要执行的命令 - name: play2 hosts: webservers remote_user: root vars: var_name: value tasks: - name: echo shell: "echo {{var_name}}"
--- - hosts: webservers remote_user: root vars: var_name: value tasks: - name: echo shell: "echo {{var_name}}"