Skip to content

Commit a85d6bb

Browse files
committed
Updated 'src/adv_network/platform_optoins/netconf_enabled.md'.
1 parent c256316 commit a85d6bb

File tree

3 files changed

+166
-0
lines changed

3 files changed

+166
-0
lines changed
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
# 已启用 `netconf` 的平台选项
2+
3+
本页提供了有关 Ansible 中 `netconf` 工作原理及使用方法的详细说明。
4+
5+
6+
## 可用连接
7+
8+
| | NETCONF,除 `junos_netconf` 外的那些启用了 NETCONF 的模组 |
9+
| 协议 | 透过 SSH 的 XML |
10+
| 凭据 | 若存在 SSH 密钥/ `ssh-agent`,则使用 SSH 密钥/ `ssh-agent`,若使用密码,则接受 `-u my_user -k` |
11+
| 间接访问 | 经由堡垒机(跳转主机) |
12+
| 连接设置 | `ansible_connection: ansible.netcommon.netconf` |
13+
14+
15+
16+
`ansible_connection: local` 已被弃用。请使用 `ansible_connection: ansible.netcommon.netconf`
17+
18+
19+
## 在 Ansible 中使用 NETCONF
20+
21+
22+
### 启用 NETCONF
23+
24+
25+
{{#include ./junos.md:56:59}}
26+
27+
28+
要经由 Ansible 在新交换机上启用 NETCONF,就要通过 CLI 连接使用平台特定的模组或手动设置。比如像上面的 CLI 示例一样设置咱们的平台级变量,然后运行一个像下面这样的 playbook 任务:
29+
30+
31+
{{#include ./junos.md:65:96}}
32+
33+
34+
### 带有可配置变量的示例 NETCONF 任务
35+
36+
37+
```yaml
38+
- name: configure interface while providing different private key file path
39+
junipernetworks.junos.netconf_config:
40+
backup: yes
41+
register: backup_junos_location
42+
vars:
43+
ansible_private_key_file: /home/admin/.ssh/newprivatekeyfile
44+
```
45+
46+
47+
注意:有关 `netconf` 连接插件的可配置变量,请参阅 [`ansible.netcommon.netconf`](https://docs.ansible.com/ansible/latest/collections/ansible/netcommon/netconf_connection.html#ansible-collections-ansible-netcommon-netconf-connection)。
48+
49+
50+
### 堡垒机/跳转主机配置
51+
52+
要使用跳转主机连接某个启用了 NETCONF 的设备,咱们必须设置 `ANSIBLE_NETCONF_SSH_CONFIG` 这个环境变量。
53+
54+
55+
** `ANSIBLE_NETCONF_SSH_CONFIG` 可设置为以下其中之一**:
56+
57+
- `1` 或 `TRUE`(触发默认 SSH 配置文件 `~/.ssh/config` 的使用);
58+
- 某个自定义 SSH 配置文件的绝对路径。
59+
60+
61+
SSH 配置文件看起来应是下面这样的:
62+
63+
```config
64+
Host *
65+
proxycommand ssh -o StrictHostKeyChecking=no -W %h:%p jumphost-username@jumphost.fqdn.com
66+
StrictHostKeyChecking no
67+
```
68+
69+
跳转主机的身份验证,必须使用基于密钥的身份验证。
70+
71+
72+
咱们既可以在 SSH 配置文件中,指定出所使用的私钥:
73+
74+
```config
75+
IdentityFile "/absolute/path/to/private-key.pem"
76+
```
77+
78+
也可以使用某种 `ssh-agent`。
79+
80+
81+
### `ansible_network_os` 的自动检测
82+
83+
如果没有为某个主机指定 `ansible_network_os` 变量,则 Ansible 将尝试自动检测要使用的 `network_os` 插件。
84+
85+
86+
`ansible_network_os` 自动检测也可以通过使用 `auto` 作为 `ansible_network_os` 变量的值来触发。(注意:早先使用的是 `default` 代替 `auto`)。
87+
88+
89+
90+
91+
{{#include ./ce.md:193:}}
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
# WeOS 4 平台选项
2+
3+
Westermo WeOS 4 是 [`community.network`](https://galaxy.ansible.com/ui/repo/published/community/network) 专辑的一部分,仅支持 CLI 连接。本页提供了有关如何在 Ansible 中于 WeOS 4 上使用 `ansible.netcommon.network_cli` 的详细介绍。
4+
5+
6+
> **译注**:Westermo 是 ARESKOM 旗下的子品牌。
7+
>
8+
> _ARESKOM Communication 成立于 2004 年,是土耳其伊斯坦布尔阿塔谢希尔的一家公司,业务涉及数据通信、工业网络和移动宽带、M2M 和物联网、电信产品和解决方案领域值得信赖的增值分销商和解决方案提供商,提供最佳的集成通信解决方案_
9+
>
10+
> _Westermo 为物理要求苛刻的环境中的关键任务系统设计和制造数据通信产品。这些产品既用于社会基础设施,如交通、供水和能源供应,也用于加工工业,如采矿和石化_
11+
>
12+
>
13+
>
14+
> 参考:
15+
>
16+
> - [WESTERMO](https://areskom.com/brands/westermo/)
17+
>
18+
> - [WeOS 4, Westermo Operating System](../../images/westermo_ds_weos_1909_en_revb.pdf)
19+
20+
21+
## 可用连接
22+
23+
| | `CLI` |
24+
| :-- | :-- |
25+
| 协议 | SSH |
26+
| 凭据 | 在存在 SSH 密钥/ `ssh-agent` 时使用 SSH 密钥/`ssh-agent`,在使用密码时接受 `-u my_user -k` 参数 |
27+
| 间接访问 | 通过堡垒机(跳转主机) |
28+
| 连接设置 | `ansible_connection: ansible.netcommon.network_cli` |
29+
| `enable` 模式(权限提升) | 不受 WeOS 4 支持 |
30+
| 返回数据格式 | `stdout[0].` |
31+
32+
WeOS 4 不支持 `ansible_connection: local`。咱们必须使用 `ansible_connection: ansible.netcommon.network_cli`
33+
34+
## 在 Ansible 中使用 CLI
35+
36+
37+
### 示例 CLI `group_vars/weos4.yml`
38+
39+
```yaml
40+
ansible_connection: ansible.netcommon.network_cli
41+
ansible_network_os: community.network.weos4
42+
ansible_user: myuser
43+
ansible_password: !vault...
44+
ansible_ssh_common_args: '-o ProxyCommand="ssh -W %h:%p -q bastion01"'
45+
```
46+
47+
48+
{{#include ./ce.md:43:45}}
49+
50+
51+
### 示例 CLI 任务
52+
53+
```yaml
54+
- name: Get version information (WeOS 4)
55+
ansible.netcommon.cli_command:
56+
commands: "show version"
57+
register: show_ver
58+
when: ansible_network_os == 'community.network.weos4'
59+
```
60+
61+
62+
### 示例配置任务
63+
64+
```yaml
65+
- name: Replace configuration with file on ansible host (WeOS 4)
66+
ansible.netcommon.cli_config:
67+
config: "{{ lookup('file', 'westermo.conf') }}"
68+
replace: "yes"
69+
diff_match: exact
70+
diff_replace: config
71+
when: ansible_network_os == 'community.network.weos4'
72+
```
73+
74+
75+
{{#include ./ce.md:193:}}
817 KB
Binary file not shown.

0 commit comments

Comments
 (0)