File tree Expand file tree Collapse file tree 4 files changed +171
-0
lines changed Expand file tree Collapse file tree 4 files changed +171
-0
lines changed Original file line number Diff line number Diff line change 175
175
- [ 使用 Ansible 网络角色] ( network/roles.md )
176
176
- [ 进阶] ( network/beyond.md )
177
177
- [ 使用网络设备连接选项] ( network/connection.md )
178
+ - [ 资源及接下来的措施] ( network/resources.md )
179
+
180
+ - [ 网络高级主题] ( adv_nework.md )
181
+ - [ 网络资源模组] ( adv_network/resource_mod.md )
178
182
179
183
180
184
---
Original file line number Diff line number Diff line change
1
+ # 网络高级主题
2
+
3
+
4
+ 一旦掌握了 [ 网络入门] ( ./network.md ) 中介绍的 Ansible 下网络自动化基础知识,咱们就可以使用这个指南,掌握 Ansible 实现网络自动化的特定平台细节、优化与故障排除技巧等。
5
+
6
+
7
+ ** 谁应使用本指南** ?
8
+
9
+
10
+ 这个指南面向使用 Ansible 进行自动化的网络工程师。他涵盖了一些高级主题。如果咱们了解网络和 Ansible,本指南就是为咱们准备的。咱们可以通读整个指南,或使用下面的链接查找咱们所需的特定信息。
11
+
12
+
13
+ 如果咱们是 Ansible 新手,或者是使用 Ansible 实现网络自动化新手,请从 [ 网络入门] ( ./network.md ) 开始。
14
+
15
+
16
+
17
+
Original file line number Diff line number Diff line change
1
+ # 网络资源模组
2
+
3
+
4
+ Ansible 的网络资源模组简化了咱们管理不同网络设备的方式,并使之标准化。网络设备会将其配置分离为适用于某项网络服务的多个小节(比如接口与 VLAN 小节)。Ansible 的网络资源模组利用这一优势,允许咱们在网络设备的配置内,配置一些子小节或称为 ** 资源** 。网络资源模组为不同的网络设备,提供了一种一致体验。
5
+
6
+
7
+ ## 网络资源模组的状态
8
+
9
+
10
+ 咱们通过指定出咱们所想要的某个网络资源模组状态的方式,使用这些网络资源模组。资源模组支持以下这些状态:
11
+
12
+ - ` merged `
13
+
14
+ Ansible 会将设备上的配置,与任务中提供的配置合并。
15
+
16
+ - ` replaced `
17
+
18
+ Ansible 会用任务中提供的配置子小节,替换设备上的配置子小节。
19
+
20
+ - ` overridden `
21
+
22
+ Ansible 会用任务中提供的配置,覆盖该项资源在设备上的配置。请谨慎使用这种状态,因为咱们可能会移除咱们对设备的访问权限(例如,由移除管理接口的配置造成)。
23
+
24
+ - ` deleted `
25
+
26
+ Ansible 会删除设备上的配置子小节,并恢复所有默认设置。
27
+
28
+ - ` gathered `
29
+
30
+ Ansible 会显示从网络设备收集到的该项资源详细信息,并在结果中使用 ` gathered ` 键进行访问。
31
+
32
+ - ` rendered `
33
+
34
+ Ansible 会以设备原生格式,the device-native format,(比如 Cisco IOS CLI),渲染任务中提供的配置。Ansible 会在结果的 ` rendered ` 键中,返回这种渲染后的配置。请注意,这种状态不会与网络设备通信,而可脱机使用。
35
+
36
+
37
+ - ` parsed `
38
+
39
+
40
+ Ansible 会将 ` running_config ` 选项中的配置,解析为结果中 ` parsed ` 键下的 Ansible 的结构化数据。请注意此过程不会从网络设备收集配置,因此这种状态可以离线使用。
41
+
42
+
43
+ ## 使用网络资源模组
44
+
45
+
46
+ 下面这个示例会根据不同的状态,配置某个 Cisco IOS 设备的 L3 接口资源。
47
+
48
+
49
+ ``` yaml
50
+ - name : configure l3 interface
51
+ cisco.ios.ios_l3_interfaces :
52
+ config : " {{ config }}"
53
+ state : <state>
54
+ ` ` `
55
+
56
+ 下面举例说明在给定资源初始配置,与给定任务提供的配置下,资源配置会如何随不同状态而变化。
57
+
58
+ - 资源起始配置
59
+
60
+ ` ` ` console
61
+ interface loopback100
62
+ ip address 10.10.1.100 255.255.255.0
63
+ ipv6 address FC00:100/64
64
+ ```
65
+
66
+ - 任务提供的配置(YAML 格式)
67
+
68
+ ``` yaml
69
+ config :
70
+ - ipv6 :
71
+ - address : fc00::100/64
72
+ - address : fc00::101/64
73
+ name : loopback100
74
+ ` ` `
75
+
76
+
77
+ + 设备上的最终资源配置
78
+ - ` merged`
79
+
80
+ ` ` ` console
81
+ interface loopback100
82
+ ip address 10.10.1.100 255.255.255.0
83
+ ipv6 address FC00:100/64
84
+ ipv6 address FC00:101/64
85
+ ` ` `
86
+
87
+ - ` replaced`
88
+
89
+ ` ` ` console
90
+ interface loopback100
91
+ no ip address
92
+ ipv6 address FC00:100/64
93
+ ipv6 address FC00:101/64
94
+ ` ` `
95
+
96
+ - ` overridden`
97
+
98
+ 不正确的用例。这将从设备上删除所有接口 **(包括 `mgmt` 接口),除了** 那个已配置的 `loopback100`。
99
+
100
+
101
+ - ` deleted`
102
+
103
+ ` ` ` console
104
+ interface loopback100
105
+ no ip address
106
+ ` ` `
Original file line number Diff line number Diff line change
1
+ # 资源与接下来的措施
2
+
3
+
4
+ ## 社区
5
+
6
+ 请访问 [ Ansible 交流指南] ( ../community_guide/getting_started.md#与-ansible-社区交流 ) ,了解如何加入社区。
7
+
8
+
9
+ ## 文档
10
+
11
+ 要阅读更多有关 Ansible 网络自动化的内容:
12
+
13
+ - [ 网络平台的各种选项] ( https://docs.ansible.com/ansible/latest/network/user_guide/platform_index.html#platform-options ) ;
14
+ - [ Ansible 网站] ( https://www.ansible.com/overview/networking ) 上的网络自动化内容;
15
+ - Ansible 网络的 [ 博客帖子] ( https://www.ansible.com/blog/topic/networks ) 。
16
+
17
+
18
+ ## 活动(视频和现场)
19
+
20
+
21
+ Ansible 活动的所有会议都有录音,其中包括许多与网络相关的主题(使用 “类别筛选器” 仅查看网络相关主题)。咱们也可以参加我们在咱们所在地区举办的活动。参见:
22
+
23
+ - [ 录制的 AnsibleFests] ( https://www.ansible.com/resources/videos/ansiblefest ) ;
24
+ - [ 录制的 AnsibleAutomates] ( https://www.ansible.com/resources/webinars-training ) ;
25
+ - [ 接下来的 Ansible 活动] ( https://www.ansible.com/community/events ) 页面。
26
+
27
+
28
+ ## GitHub 代码仓库
29
+
30
+
31
+ Ansible 在 GitHub 上托管模组代码、示例、演示和其他内容。任何有 GitHub 账户的人,都可以在这些代码仓库上创建拉取请求(PR)或问题:
32
+
33
+
34
+ - [ ` network-automation ` ] ( https://github.com/network-automation ) 是个面向所有网络自动化事物的开放社区。有想法、playbook 或角色要分享?请发送电子邮件至 ansible-network@redhat.com ,我们会将您添加为这个代码仓库的贡献者;
35
+ - [ ` ansible-collections ` ] ( https://github.com/ansible-collections ) 是 Ansible 维护的以及社区的专辑(包括了网络设备专辑)的主要代码仓库。
36
+
37
+
38
+ ## 聊天频道
39
+
40
+ 请访问 [ Ansible 交流指南] ( ../community_guide/getting_started.md#与-ansible-社区交流 ) ,了解如何加入对话,包括可用的聊天选项。
41
+
42
+
43
+ (End)
44
+
You can’t perform that action at this time.
0 commit comments