playbook俗称剧本,yml文件,类似于shell脚本,一次编写,永久使用,方便快捷。
编写脚本,帮助文档是最重要的工具,学会使用帮助文档事半功倍。
帮助文档
1.ansible-doc 模块名 查看某个模块的帮助文档,里边有例子,各种参数,参数的使用。
ansible-doc -l 查看所有的模块
例如:ansible-doc service
模块
user模块
- name: Add the user 'johnd' with a specific uid and a primary group of 'admin'
user:
name: johnd #添加的用户名
comment: John Doe
uid: 1040 #所属ID
group: admin # 所属组
groups: admins,developers #所属组
state: absent #用户状态 present存在(默认值) absent 不存在
shell: /bin/bash #用户默认she