格式 .yml | .yaml
--- ======>剧本开头
- hosts: jack7 ======>指定主机或主机组
remote_user: root ====>客户端执行用户
tasks: =========>任务标记
- name: FIRST PLAYBOOK ===>PLAY名称
fetch: =======>调用的模块
src: /tmp/test =======>模块的参数及值
dest: /root/ =======>其他参数及值
注意yaml的语法缩进,必须对齐,并且“:”后面有空格
如下两种写法也是可以的
[root@jack7-1 ansible]# cat test4.yml test5.yml
- hosts: PD
remote_user: root
tasks:
-
name: touch wang.txt
file: path=/root/wang.txt state=touch mode=0777 owner=jack group=root
- hosts: PD
remote_user: root
tasks:
- name: absent file
file: path=/root/wang.txt
state=absent
ansible剧本playbook
原文:https://blog.51cto.com/13434656/2527951