# yaml在ansible中的用法
## 文件起始行
`playbook`文件以三个减号开头,不加也不影响。
## 注释
和`python`,`shell`一样使用`"#"`进行注释
## 字符串
YAML的字符串即使含有空格也不需要引号引起来。
## 变量
### 布尔型
`True`和`False`
### 列表
列表使用`'-'`作为分隔符,
```
- My Fair Lady
- The old boy
- The sea
```
YAML还有一种内联格式的列表
```
[My Fair Lady, The old boy, The sea]
```
### 字典
```
hello: world
hi: yang
```
YAML还有一种内联格式的字典
```
{hello: world, hi: yang}
```
### 自定义变量
### facts变量
### register注册器
### 命令行中传递变量
`--extra-vars='vars'`
## 条件测试
## 循环
## playbook 组成
### inventory
### Modules
### Ad Hoc Command
### Playbooks
#### tasks
#### vars
#### Template
#### handlers
- handler只会在所有任务都完成之后才会执行,即使被通知多次,也只执行一次;
- handler会按照play中定义的顺序执行,而不是被通知的顺序;
- 一般集合service模块用作重启服务
- 一个task状态改变并发起了notify,但是后边的task发生了错误;修复之后,再次运行playbook,不会有刚才的task状态改变,没法notify触发相应的handler;
#### role
- 目录
- ansible基础
- ansible简介
- ansible安装和测试
- ansible配置文件
- yaml在ansible中的用法
- inventory
- 变量与facts
- when语句
- handler模块
- 大杂烩
- ansible模块
- copy模块
- cron模块
- debug模块
- django_manage模块
- file模块
- git模块
- hostname模块
- lineinfile模块
- mysql_user模块
- mysql_db模块
- pip模块
- selinux
- setup模块
- shell 和 command模块
- stat模块
- supervisorctl
- systemd
- timezone
- unarchive模块
- user模块
- wait_for
- yum和service模块
- 其他模块或者方法
- 其他
- 报错处理
- playbooks
- 复杂的playbook
- 循环
- roles