Skip to content

Commit 55f215f

Browse files
committed
Updated src/configuring.md'.
1 parent 2e50f5f commit 55f215f

File tree

9 files changed

+282
-318
lines changed

9 files changed

+282
-318
lines changed

src/building_an_inventory.md

Lines changed: 73 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -19,79 +19,78 @@
1919

2020
2. 把一个新的 `[myhosts]` 组,添加到 `inventory.ini` 文件,并指定出每个主机系统的 IP 地址或完全限定域名 (FQDN);
2121

22-
```ini
23-
{{#include ../ansible_quickstart/inventory.ini}}
24-
```
22+
```ini
23+
{{#include ../ansible_quickstart/inventory.ini}}
24+
```
2525

2626
3. 检查咱们的仓库;
2727

28-
```console
29-
> ansible-inventory -i ansible_quickstart/inventory.ini --list
30-
```
31-
32-
> **译注**: 该命令的输出如下。
33-
34-
<a name="ini_inventory_list_output"></a>
35-
```json
36-
{
37-
"_meta": {
38-
"hostvars": {}
39-
},
40-
"all": {
41-
"children": [
42-
"ungrouped",
43-
"myhosts"
44-
]
45-
},
46-
"myhosts": {
47-
"hosts": [
48-
"almalinux-6",
49-
"almalinux-100",
50-
"almalinux-109",
51-
"almalinux-213"
52-
]
53-
}
54-
}
55-
```
28+
```console
29+
> ansible-inventory -i ansible_quickstart/inventory.ini --list
30+
```
31+
32+
> **译注**: 该命令的输出如下。
33+
> <a name="ini_inventory_list_output"></a>
34+
> ```json
35+
> {
36+
> "_meta": {
37+
> "hostvars": {}
38+
> },
39+
> "all": {
40+
> "children": [
41+
> "ungrouped",
42+
> "myhosts"
43+
> ]
44+
> },
45+
> "myhosts": {
46+
> "hosts": [
47+
> "almalinux-6",
48+
> "almalinux-100",
49+
> "almalinux-109",
50+
> "almalinux-213"
51+
> ]
52+
> }
53+
> }
54+
> ```
5655

5756
4. 对咱们仓库中的 `myhosts` 组,进行 `ping` 操作。
5857

59-
```console
60-
ansible myhosts -u root -m ping -i ansible_quickstart/inventory.ini
61-
```
62-
63-
> ****:如果控制节点和托管节点上的用户名不同,请传递 `ansible` 命令下的 `-u` 选项。
64-
65-
```console
66-
almalinux-100 | SUCCESS => {
67-
"ansible_facts": {
68-
"discovered_interpreter_python": "/usr/bin/python3.8"
69-
},
70-
"changed": false,
71-
"ping": "pong"
72-
}
73-
almalinux-213 | SUCCESS => {
74-
"ansible_facts": {
75-
"discovered_interpreter_python": "/usr/bin/python3.8"
76-
},
77-
"changed": false,
78-
"ping": "pong"
79-
}
80-
almalinux-109 | SUCCESS => {
81-
"ansible_facts": {
82-
"discovered_interpreter_python": "/usr/bin/python3.8"
83-
},
84-
"changed": false,
85-
"ping": "pong"
86-
}
87-
almalinux-6 | SUCCESS => {
88-
"ansible_facts": {
89-
"discovered_interpreter_python": "/usr/bin/python3.8"
90-
},
91-
"changed": false,
92-
"ping": "pong"
93-
}
94-
```
58+
```console
59+
ansible myhosts -u root -m ping -i ansible_quickstart/inventory.ini
60+
```
61+
62+
> **注**:如果控制节点和托管节点上的用户名不同,请传递 `ansible` 命令下的 `-u` 选项。
63+
>
64+
> ```console
65+
> almalinux-100 | SUCCESS => {
66+
> "ansible_facts": {
67+
> "discovered_interpreter_python": "/usr/bin/python3.8"
68+
> },
69+
> "changed": false,
70+
> "ping": "pong"
71+
> }
72+
> almalinux-213 | SUCCESS => {
73+
> "ansible_facts": {
74+
> "discovered_interpreter_python": "/usr/bin/python3.8"
75+
> },
76+
> "changed": false,
77+
> "ping": "pong"
78+
> }
79+
> almalinux-109 | SUCCESS => {
80+
> "ansible_facts": {
81+
> "discovered_interpreter_python": "/usr/bin/python3.8"
82+
> },
83+
> "changed": false,
84+
> "ping": "pong"
85+
> }
86+
> almalinux-6 | SUCCESS => {
87+
> "ansible_facts": {
88+
> "discovered_interpreter_python": "/usr/bin/python3.8"
89+
> },
90+
> "changed": false,
91+
> "ping": "pong"
92+
> }
93+
> ```
9594

9695
恭喜,咱们已成功建立了一个仓库。
9796

@@ -146,27 +145,21 @@ almalinux-6 | SUCCESS => {
146145
## 建立仓库的一些技巧
147146

148147
- 确保组的名字有意义且唯一。组的名字同样区分大小写;
149-
150148
- 组的名字中要避免使用空格、连字符(`-`)和先导数字(比如要使用 `floor_19`,而不是 `19th_floor`);
151-
152149
+ 要根据主机是什么(**What**)、位于何处(**Where**)以及何时存在(**When**),对清单中的主机进行逻辑分组。
153150

154151
- **What**
155-
156-
根据拓扑对主机进行分组,例如:`db``web``leaf``spine`
157-
158-
> **译注**:这里的 `leaf``spine` 是指 Spine-Leaf 网络拓扑,特指数据中心网络拓扑。spine 有枝干,而 leaf即叶子的字面意思。
159-
> 参考:
160-
> - [[] 数据中心网络:Spine-Leaf 架构设计综述(2016)](http://arthurchiao.art/blog/spine-leaf-design-zh/)
161-
> - [什么是 Spine-Leaf架构?](https://www.arubanetworks.com/zh-hans/faq/what-is-spine-leaf-architecture/)
152+
根据拓扑对主机进行分组,例如:`db``web``leaf``spine`
153+
> **译注**:这里的 `leaf``spine` 是指 Spine-Leaf 网络拓扑,特指数据中心网络拓扑。spine 有枝干,而 leaf即叶子的字面意思。
154+
> 参考:
155+
> - [[] 数据中心网络:Spine-Leaf 架构设计综述(2016)](http://arthurchiao.art/blog/spine-leaf-design-zh/)
156+
> - [什么是 Spine-Leaf架构?](https://www.arubanetworks.com/zh-hans/faq/what-is-spine-leaf-architecture/)
162157

163158
- **Where**
164-
165-
按地理位置对主机进行分组,例如:数据中心、区域、楼层、建筑物。
159+
按地理位置对主机进行分组,例如:数据中心、区域、楼层、建筑物。
166160

167161
- **When**
168-
169-
按阶段对主机进行分组,例如:开发、测试、灰度发布(staging)、生产。
162+
按阶段对主机进行分组,例如:开发、测试、灰度发布(staging)、生产。
170163

171164
### 使用元组别
172165

src/configuring.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,8 @@ Ansible 中的某些设置项,可以通过配置文件(`ansible.cfg`)进
1212
可在配置文件中进行更改和使用,配置文件将按以下顺序进行搜索:
1313

1414
- `ANSIBLE_CONFIG` (若设置了该环境变量)
15-
1615
- `ansible.cfg` (当前目录下)
17-
1816
- `~/.ansible.cfg` (主目录下)
19-
2017
- `/etc/ansible/ansible.cfg`
2118

2219
Ansible 将处理上述列表,并使用找到的第一个文件,其他文件将被忽略。

src/creating_a_playbook.md

Lines changed: 41 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -14,62 +14,59 @@
1414
- **Playbook**
1515
定义出 Ansible 从上到下执行操作,以实现总体目标顺序的 play 列表。
1616

17-
> **译注**:下图是 Ansible 模组、任务、play 与 playbook 的关系图示。
17+
> **译注**:下图是 Ansible 模组、任务、play 与 playbook 的关系图示。
1818
19-
![Ansible 模组、任务、play 与 playbook 之间的关系图示](images/ansible-playbooks.jpeg)
19+
![Ansible 模组、任务、play 与 playbook 之间的关系图示](images/ansible-playbooks.jpeg)
2020

21-
*图 2-1,Ansible 模组、任务、play 与 playbook 之间的关系图*
21+
*图 2-1,Ansible 模组、任务、play 与 playbook 之间的关系图*
2222

2323

24-
> 可以看出:
25-
>
26-
> - 其中模组是直接作用于托管主机/系统的单元;
27-
>
28-
> - 任务是介于模组与 play 之间的桥梁(模组 <--> 任务 <--> play);
29-
>
30-
> - 任务、play 和 playbook 是将简单的模组,组织为复杂操作的方式。
24+
> 可以看出:
25+
>
26+
> - 其中模组是直接作用于托管主机/系统的单元;
27+
>
28+
> - 任务是介于模组与 play 之间的桥梁(模组 <--> 任务 <--> play);
29+
>
30+
> - 任务、play 和 playbook 是将简单的模组,组织为复杂操作的方式。
3131
3232
请完成以下步骤,创建一个用于对咱们主机进行 `ping` 操作,并打印出 “Hello World” 消息的 playbook:
3333

3434
1. 在先前创建的 `ansible_quickstart` 目录中,创建一个名为 `playbook.yaml` 的文件,内容如下:
3535

36-
```yaml
37-
{{#include ../ansible_quickstart/playbook.yaml}}
38-
```
36+
```yaml
37+
{{#include ../ansible_quickstart/playbook.yaml}}
38+
```
3939

4040
2. 运行咱们的 playbook。
4141

42-
```console
43-
ansible-playbook -i ansible_quickstart/inventory_updated.yaml ansible_quickstart/playbook.yaml
44-
```
45-
46-
Ansible 会返回以下输出:
47-
48-
```console
49-
{{#include ../ansible_quickstart/playbook.output}}
50-
```
51-
52-
> **译注**:输出中包含有关托管主机上发现的 Python 版本告警已被省略:
53-
54-
```console
55-
[WARNING]: Platform linux on host web_100 is using the discovered Python
56-
interpreter at /usr/bin/python3.8, but future installation of another Python
57-
interpreter could change the meaning of that path. See
58-
https://docs.ansible.com/ansible-
59-
core/2.18/reference_appendices/interpreter_discovery.html for more information.
60-
61-
...
62-
```
63-
64-
在此输出中咱们可以看到:
65-
66-
- 咱们给 play 和每个任务起的名字。应始终使用描述性的名称,以便于验证和故障排除;
67-
68-
- “Gathering Facts” 任务会隐式运行。默认情况下,Ansible 会收集有关可在 playbook 中使用的咱们仓库信息;
69-
70-
- 每个任务的状态。每个任务的状态都是 `ok`,表示其运行成功;
71-
72-
- Play 回顾,the paly recap,总结了每个主机上,playbook 中所有任务的结果。本例中有三个任务,因此 `ok=3` 表示每个任务都运行成功了。
42+
```console
43+
ansible-playbook -i ansible_quickstart/inventory_updated.yaml ansible_quickstart/playbook.yaml
44+
```
45+
46+
Ansible 会返回以下输出:
47+
48+
```console
49+
{{#include ../ansible_quickstart/playbook.output}}
50+
```
51+
52+
> **译注**:输出中包含有关托管主机上发现的 Python 版本告警已被省略:
53+
>
54+
> ```console
55+
> [WARNING]: Platform linux on host web_100 is using the discovered Python
56+
> interpreter at /usr/bin/python3.8, but future installation of another Python
57+
> interpreter could change the meaning of that path. See
58+
> https://docs.ansible.com/ansible-
59+
> core/2.18/reference_appendices/interpreter_discovery.html for more information.
60+
>
61+
> ...
62+
> ```
63+
64+
在此输出中咱们可以看到:
65+
66+
- 咱们给 play 和每个任务起的名字。应始终使用描述性的名称,以便于验证和故障排除;
67+
- “Gathering Facts” 任务会隐式运行。默认情况下,Ansible 会收集有关可在 playbook 中使用的咱们仓库信息;
68+
- 每个任务的状态。每个任务的状态都是 `ok`,表示其运行成功;
69+
- Play 回顾,the paly recap,总结了每个主机上,playbook 中所有任务的结果。本例中有三个任务,因此 `ok=3` 表示每个任务都运行成功了。
7370

7471
恭喜,咱们已开始使用 Ansible!
7572

src/ee.md

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,20 @@
55
执行环境镜像,包含以下标准软件包:
66

77
- `ansible-core`
8-
98
- `ansible-runner`
10-
119
- Python
12-
1310
- Ansible 内容依赖
1411

1512
除标准包外,EE 还可以包含:
1613

1714
- 一或多个 Ansible 专辑以及他们的依赖项;
18-
1915
- 其他定制组件。
2016

2117

2218
本入门指南向,展示如何建立及测试一种简单执行环境。生成的容器映像,代表一个 Ansible 控制节点,其中包含:
2319

2420
- 标准 EE 包;
25-
2621
- `community.postgresql` 专辑;
27-
2822
- `psycopg2-binary` Python 包。
2923

3024

@@ -37,9 +31,7 @@ Ansible 执行环境,旨在解决复杂度问题,并提供咱们可从容器
3731
EE 可在三个主要领域,降低复杂性:
3832

3933
- 软件的依赖;
40-
4134
- 可移植性;
42-
4335
- 内容分离。
4436

4537

@@ -52,13 +44,9 @@ EE 可在三个主要领域,降低复杂性:
5244
Ansible 专辑就可能依赖于以下软件及其版本:
5345

5446
- `ansible-core`
55-
5647
- Python
57-
5848
- Python 包
59-
6049
- 系统软件包
61-
6250
- 别的 Ansible 专辑
6351

6452

0 commit comments

Comments
 (0)