标签:service container ons handlers 必须 strong roles str lsp
ansible 基础概念
|
1
2
3
4
5
6
7
8
9
10
11
|
inventory 主机源playbooks 一组运行任务的命令集合roles 角色tasks 运行任务列表handlers 运行任务后的触发动作variables 定义的变量 |
ansible目录结构
使用Role组织任务,可以将复杂的Playbook剧本进行拆分,达到缩小文件,任务重用的作用
通常创建一个role的方法有两种:
命令mkdir和touch行手动创建
使用ansible-galaxy自动初始化一个role
ansible-galaxy init huazai007
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
[root@master huazai007]# tree.├── defaults│ └── main.yml├── files├── handlers│ └── main.yml├── meta│ └── main.yml├── README.md├── tasks│ └── main.yml├── templates├── tests│ ├── inventory│ └── test.yml└── vars └── main.yml |
defaults
必须存在的目录,存放默认的变量,模板文件中的变量就是引用自这里。defaults中的变量优先级最低,通常我们可以临时指定变量来进行覆盖
tasks
play中运行的任务命令,也就是执行的哪些ansible模块,如command,shell,service,yum等
templates
存放模板文件。template模块会将模板文件中的变量替换为实际值,然后覆盖到客户机指定路径上
定义的主机变量和主机组变量。若group_vars,host_vars,role/vars目录中定义了相同变量名,优先级group_vars < host_vars < vars。
标签:service container ons handlers 必须 strong roles str lsp
原文地址:https://www.cnblogs.com/xiaonan1/p/12759512.html