一.playbooks概述以及实例操作
1.1 playbooks的组成
playbooks本身由以下各部分组成
1>Tasks: 任务,即通过task调用ansible的模板将多一个组织在一个playbook中运行
2>Variables: 变量
3>Templates: 模板
4>Handlers: 处理器,当changed状态条件满足时,(notify)触发执行的操作
5>Roles: 角色
1.2 操作实例一
1.2.1 编写yaml文件也就是playbook
![](https://img-blog.csdnimg.cn/img_convert/b1b78bd7db48a94d46c256fb2feebc66.png)
1.2.2修改配置文件并放入/opt/目录下
![](https://img-blog.csdnimg.cn/img_convert/16208891bcd552129a693a1f4308ef32.png)
![](https://img-blog.csdnimg.cn/img_convert/582569d09c8bcf7bd8360641bfc4ab32.png)
![](https://img-blog.csdnimg.cn/img_convert/3a6d22c5a0de4cc8d292f133eafb782e.png)
1.2.3 运行playbook
![](https://img-blog.csdnimg.cn/img_convert/168b8ce43e66163b0eb6fadba0ed64ef.png)
![](https://img-blog.csdnimg.cn/img_convert/4c139bf46a51cefeb23a777118dc6e6f.png)
![](https://img-blog.csdnimg.cn/img_convert/54e1e60cfc78424ba6699f55927be103.png)
![](https://img-blog.csdnimg.cn/img_convert/1d68a5808966e7fb37632da8da1da2f5.png)
1.3 操作实例二:定义,应用变量
![](https://img-blog.csdnimg.cn/img_convert/0bed3e4c8917e237ad94fafd220db1bc.png)
![](https://img-blog.csdnimg.cn/img_convert/cba699034ccf27966775c2e0b144bfa2.png)
![](https://img-blog.csdnimg.cn/img_convert/5134d6f0321726e277c0cb477cae180e.png)
![](https://img-blog.csdnimg.cn/img_convert/501a4c150a6def72c9e5224a0a19bc64.png)
![](https://img-blog.csdnimg.cn/img_convert/5c8f5beeba64083f1af0e74bc1494be7.png)