Skip to content

Commit 91d7c58

Browse files
committed
Added 'src/adv_network/platform_options/eos.md'.
1 parent 869925d commit 91d7c58

File tree

8 files changed

+292
-3
lines changed

8 files changed

+292
-3
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
! Command: show running-config
2+
! device: arista-sw (vEOS, EOS-4.24.3M)
3+
!
4+
! boot system flash:/vEOS-lab.swi
5+
!
6+
transceiver qsfp default-mode 4x10G
7+
!
8+
service routing protocols model ribd
9+
!
10+
hostname arista-sw
11+
!
12+
spanning-tree mode mstp
13+
!
14+
no aaa root
15+
!
16+
username admin role network-admin secret sha512 $6$lfj1EzzYJ.6buAHt$.44sM3Oyv2b1z7IYMuTqfXU3Ny1z8YvUXbcaBij8jlDvEWN7hunDIKzR0Iwo2jTFjIFCmcxQbn12CMQm.Xllx.
17+
username admin ssh-key ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBNFE9PbuiHGgpwiQmkBIJ0cQQmziTKgIfL2lqZZhsZgMzaBBR/+xzjgLsrQZXTNQZ7Q4+K+q5C8vfQmQTHmBb2w= hector@laptop
18+
!
19+
vlan 10
20+
name oa-vlan
21+
!
22+
interface Ethernet1
23+
switchport access vlan 10
24+
!
25+
interface Ethernet2
26+
!
27+
interface Ethernet3
28+
!
29+
interface Ethernet4
30+
!
31+
interface Ethernet5
32+
!
33+
interface Ethernet6
34+
!
35+
interface Ethernet7
36+
!
37+
interface Management1
38+
ip address dhcp
39+
!
40+
no ip routing
41+
!
42+
management api http-commands
43+
no shutdown
44+
!
45+
end

network_run/demo_eapi_task.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
- hosts: eos-sw
3+
gather_facts: no
4+
5+
6+
tasks:
7+
- name: Backup current switch config (eos)
8+
arista.eos.eos_config:
9+
backup: yes
10+
register: backup_eos_location
11+
12+
- debug:
13+
msg: "{{ backup_eos_location }}"

network_run/enable_eapi.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
- hosts: eos-sw
3+
gather_facts: no
4+
5+
tasks:
6+
- name: Enable eAPI
7+
arista.eos.eos_eapi:
8+
enable_https: yes

network_run/inventory.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,16 @@ switches:
2929
ansible_ssh_user: admin
3030
ansible_ssh_private_key_file: /home/hector/.ssh/id_ecdsa
3131

32-
arista-sw:
33-
ansible_host: arista-sw
32+
eos-sw:
33+
ansible_host: eos-sw
3434
ansible_network_os: arista.eos.eos
35+
ansible_connection: ansible.netcommon.httpapi
36+
ansible_httpapi_use_ssl: true
37+
ansible_httpapi_validate_certs: false
3538
ansible_user: admin
39+
ansible_password: admin
3640
ansible_ssh_private_key_file: /home/hector/.ssh/id_ecdsa
41+
ansible_httpapi_ciphers: AES256-SHA:DHE-RSA-AES256-SHA:AES128-SHA:DHE-RSA-AES128-SHA
3742
vars:
3843
ansible_connection: ansible.netcommon.network_cli
3944
show_interfaces: 'show ip int br'

src/SUMMARY.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,8 @@
190190
- [CNOS 平台选项](adv_network/platform_options/cnos.md)
191191
- [DELL OS6 平台选项](adv_network/platform_options/dellemc_os6.md)
192192
- [DELL OS9 平台选项](adv_network/platform_options/dnos9.md)
193-
193+
- [DELL OS10 平台选项](adv_network/platform_options/os10.md)
194+
- [ENOS 平台选项](adv_network/platform_options/enos.md)
194195

195196
---
196197

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# ENOS 平台选项
2+
3+
4+
ENOS 是 `community.network` 专辑的一部分,支持 `enable` 模式(权限提升)。本页提供了如何在 Ansible 中于 ENOS 上使用 `enable` 模式的详细说明。
5+
6+
> **译注**:Enterprise Networking Operating System, ENOS 是联想公司交换机所搭载的操作系统,参见 [CNOS 平台选项](./cnos.md)
7+
8+
9+
## 可用连接
10+
11+
12+
{{#include ./cnos.md:22:31}}
13+
14+
15+
## 在 Ansible 中使用 CLI
16+
17+
### 示例 CLI `group_vars/enos.yml`
18+
19+
```yaml
20+
ansible_connection: ansible.netcommon.network_cli
21+
ansible_network_os: community.network.enos
22+
ansible_user: myuser
23+
ansible_password: !vault...
24+
ansible_become: true
25+
ansible_become_method: enable
26+
ansible_become_password: !vault...
27+
ansible_ssh_common_args: '-o ProxyCommand="ssh -W %h:%p -q bastion01"'
28+
```
29+
30+
{{#include ./ce.md:43:45}}
31+
32+
33+
### 示例 CLI 任务
34+
35+
```yaml
36+
- name: Retrieve ENOS OS version
37+
community.network.enos_command:
38+
commands: show version
39+
when: ansible_network_os == 'community.network.enos'
40+
```
41+
42+
43+
44+
{{#include ./ce.md:193:}}
Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
# EOS 平台选项
2+
3+
4+
[Arista EOS](https://galaxy.ansible.com/ui/repo/published/arista/eos) 专辑支持多种连接。本页详细介绍了每种连接在 Ansible 中的工作原理及使用方法。
5+
6+
7+
## 可用连接
8+
9+
| | CLI | eAPI |
10+
| :-- | :-- | :-- |
11+
| 协议 | SSH | HTTP(S) |
12+
| 凭据 | 在存在 SSH 密钥/ `ssh-agent` 时使用 SSH 密钥/`ssh-agent`,在使用密码时接受 `-u my_user -k` 参数 | 存在 HTTPS 证书时使用 HTTPS 证书 |
13+
| 间接访问 | 通过堡垒机(跳转主机) | 经由 web 代理 |
14+
| 连接设置 | `ansible_connection: ansible.netcommon.network_cli` | `ansible_connection: ansible.netcommon.httpapi` |
15+
| `enable` 模式(权限提升) | 受支持的:与 `ansible_become_method: enable` 一起使用 `ansible_become: true` | 受支持的:`httpapi` 会使用与 `ansible_become_method: enable` 一起的 `ansible_become: true` |
16+
| 返回的数据格式 | `stdout[0].` | `stdout[0].messages[0].` |
17+
18+
19+
`ansible_connection: local` 已被弃用。要使用 `ansible_connection: ansible.netcommon.network_cli``ansible_connection: ansible.netcommon.httpapi` 代替。
20+
21+
22+
## 在 Ansible 中使用 CLI
23+
24+
### 示例 CLI `group_vars/eos.yml`
25+
26+
```yaml
27+
ansible_connection: ansible.netcommon.network_cli
28+
ansible_network_os: arista.eos.eos
29+
ansible_user: myuser
30+
ansible_password: !vault...
31+
ansible_become: true
32+
ansible_become_method: enable
33+
ansible_become_password: !vault...
34+
ansible_ssh_common_args: '-o ProxyCommand="ssh -W %h:%p -q bastion01"'
35+
```
36+
37+
{{#include ./ce.md:43:45}}
38+
39+
### 示例 CLI 任务
40+
41+
```yaml
42+
- name: Backup current switch config (eos)
43+
arista.eos.eos_config:
44+
backup: yes
45+
register: backup_eos_location
46+
when: ansible_network_os == 'arista.eos.eos'
47+
```
48+
49+
50+
## 在 Ansible 中使用 eAPI
51+
52+
### 启用 eAPI
53+
54+
使用 eAPI 连接交换机前,咱们必须启用 eAPI。要在某个新交换机上使用 Ansible 启用 eAPI,就要经由 CLI 连接,用到 `arista.eos.eos_eapi` 模组。如同上面 CLI 示例中一样,设置 `group_vars/eos.yml`,然后运行类似下面的 playbook 任务:
55+
56+
```yaml
57+
{{#include ../../../network_run/enable_eapi.yml}}
58+
```
59+
60+
> **译注**:
61+
>
62+
> - 运行此 playbook 需要使用 `-bK` 命令行开关进行权限提升;
63+
>
64+
> - 需要更多操作才能启用 HTTPS 的 eAPI。否则会报出错误:`"Could not connect to https://eos-sw:443/command-api: [Errno 111] 连接被拒绝"`;
65+
>
66+
> - 在 Arista EOS 交换机上启用 eAPI 后,会报出错误:`"Could not connect to https://eos-sw:443/command-api: [SSL: SSLV3_ALERT_HANDSHAKE_FAILURE] ssl/tls alert handshake failure (_ssl.c:1000)"`;
67+
>
68+
> - 在 Arista EOS 交换机上成功启用 HTTPS 的 eAPI 后,可直接访问 https://eos-sw/,但因为使用的自签名证书,而会报出证书错误。要往分组/主机加入变量 `ansible_httpapi_ciphers: AES256-SHA:DHE-RSA-AES256-SHA:AES128-SHA:DHE-RSA-AES128-SHA` 解决此问题;
69+
>
70+
> - 需要 `ansible_user` 与 `ansible_password` 变量。否则报出错误 `"HTTP Error 401: Unauthorized"`。示例配置如下。
71+
72+
```yaml
73+
eos-sw:
74+
ansible_host: eos-sw
75+
ansible_network_os: arista.eos.eos
76+
ansible_connection: ansible.netcommon.httpapi
77+
ansible_httpapi_use_ssl: true
78+
ansible_httpapi_validate_certs: false
79+
ansible_user: admin
80+
ansible_password: my_secret
81+
ansible_ssh_private_key_file: /home/hector/.ssh/id_ecdsa
82+
ansible_httpapi_ciphers: AES256-SHA:DHE-RSA-AES256-SHA:AES128-SHA:DHE-RSA-AES128-SHA
83+
84+
```
85+
>
86+
> 参考:
87+
>
88+
> - [Arista eAPI 101](https://arista.my.site.com/AristaCommunity/s/article/arista-eapi-101)
89+
>
90+
> - [Python >= 3.10 and SSLV3_ALERT_HANDSHAKE_FAILURE error](https://arista.my.site.com/AristaCommunity/s/article/Python-3-10-and-SSLV3-ALERT-HANDSHAKE-FAILURE-error)
91+
92+
咱们可在 [`arista.eos.eos_eapi`](https://docs.ansible.com/ansible/latest/collections/arista/eos/eos_eapi_module.html#ansible-collections-arista-eos-eos-eapi-module) 模组文档中,找到启用 HTTP/HTTPS 连接的更多选项。
93+
94+
95+
启用 eAPI 后,就要修改咱们的 `group_vars/eos.yml` 以使用 eAPI 连接。
96+
97+
98+
### 示例 eAPI `group_vars/eos.yml`
99+
100+
101+
```yaml
102+
ansible_connection: ansible.netcommon.httpapi
103+
ansible_network_os: arista.eos.eos
104+
ansible_user: myuser
105+
ansible_password: !vault...
106+
ansible_become: true
107+
ansible_become_method: enable
108+
proxy_env:
109+
http_proxy: http://proxy.example.com:8080
110+
```
111+
112+
- 如果咱们是直接访问主机(而非通过 web 代理),咱们可移除 `proxy_env` 配置项;
113+
- 如果咱们通过某个使用 `https` 的 web 代理服务器访问主机,则要将 `http_proxy` 更改为 `https_proxy`。
114+
115+
116+
### 示例 eAPI 任务
117+
118+
```yaml
119+
- name: Backup current switch config (eos)
120+
arista.eos.eos_config:
121+
backup: yes
122+
register: backup_eos_location
123+
environment: "{{ proxy_env }}"
124+
when: ansible_network_os == 'arista.eos.eos'
125+
```
126+
127+
在这个示例中,`group_vars` 中定义的 `proxy_env` 变量,被传递给任务中模组的 `environment` 选项。
128+
129+
130+
{{#include ./ce.md:193:}}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# DELL OS10 平台选项
2+
3+
[`dellemc.os10`](https://galaxy.ansible.com/ui/repo/published/dellemc_networking/os10) 专辑支持 `enable` 模式(权限提升)。本页提供了关于如何在 Ansible 中于 OS10 上使用 `enable` 模式的详细说明。
4+
5+
6+
## 可用连接
7+
8+
9+
{{#include ./cnos.md:22:31}}
10+
11+
12+
## 在 Ansible 中使用 CLI
13+
14+
15+
### 示例 CLI `group_vars/dellos10.yml`
16+
17+
18+
```yaml
19+
ansible_connection: ansible.netcommon.network_cli
20+
ansible_network_os: dellemc.os10.os10
21+
ansible_user: myuser
22+
ansible_password: !vault...
23+
ansible_become: true
24+
ansible_become_method: enable
25+
ansible_become_password: !vault...
26+
ansible_ssh_common_args: '-o ProxyCommand="ssh -W %h:%p -q bastion01"'
27+
```
28+
29+
{{#include ./ce.md:43:45}}
30+
31+
32+
### 示例 CLI 任务
33+
34+
```yaml
35+
- name: Backup current switch config (dellos10)
36+
dellemc.os10.os10_config:
37+
backup: yes
38+
register: backup_dellos10_location
39+
when: ansible_network_os == 'dellemc.os10.os10'
40+
```
41+
42+
43+
{{#include ./ce.md:193:}}

0 commit comments

Comments
 (0)