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