物理网络配置

Kayobe 支持物理网络设备的配置。此功能是可选的,如果网络设备配置将通过其他方式管理,则可以跳过本节。

设备会添加到 Ansible 库存中,并使用 Ansible 的网络模块进行配置。配置通过 kayobe physical network configure 命令应用。有关详细信息,请参阅 物理网络

目前支持以下交换机操作系统:

注意

在开发交换机配置时,查看将生成哪些命令可能会有所帮助。可以使用 --display 参数用于 kayobe physical network configure,它会将交换机全局和端口配置作为终端输出显示,而不会应用它。

将设备添加到库存

网络设备应添加到 Kayobe Ansible 库存中,并且应该是 switches 组的成员。

inventory/hosts
[switches]
switch0
switch1

在某些情况下,区分不同类型的交换机可能很有用。例如,mgmt 网络可能承载带外管理流量,而 ctl 网络可能承载控制平面流量。可以为每个网络创建一个组,每个组都是 switches 组的子组。

inventory/hosts
[switches:children]
mgmt-switches
ctl-switches

[mgmt-switches]
switch0

[ctl-switches]
switch1

网络设备配置

配置通常特定于每个网络设备。因此,通常最好为库存中的每个设备添加一个 host_vars 文件。可以将网络设备的通用配置添加到 switches 组或其子组的 group_vars 文件中。

inventory/host_vars/switch0
---
# Host configuration for switch0
ansible_host: 1.2.3.4
inventory/host_vars/switch1
---
# Host configuration for switch1
ansible_host: 1.2.3.5
inventory/group_vars/switches
---
# Group configuration for 'switches' group.
ansible_user: alice

通用配置变量

应通过 switch_type 变量配置交换机类型。有关为每种设备类型设置值的详细信息,请参阅 设备特定配置变量

ansible_host 应设置为用于访问设备的管理 IP 地址。ansible_user 应设置为用于访问设备的用户名。

全局交换机配置通过 switch_config 变量指定。它应该是一个要应用的配置行列表。

每接口配置通过 switch_interface_config 变量指定。它应该是一个对象,将交换机接口名称映射到配置对象。每个配置对象包含一个 description 项和一个 config 项。config 项应包含一个每接口配置行列表。

switch_interface_config_enable_discoveryswitch_interface_config_disable_discovery 变量采用与 switch_interface_config 变量相同的格式。它们定义了应用于启用或禁用裸机计算节点硬件发现的接口配置。

inventory/host_vars/switch0
---
ansible_host: 1.2.3.4

ansible_user: alice

switch_config:
  - global config line 1
  - global config line 2

switch_interface_config:
  interface-0:
    description: controller0
    config:
      - interface-0 config line 1
      - interface-0 config line 2
  interface-1:
    description: compute0
    config:
      - interface-1 config line 1
      - interface-1 config line 2

网络设备配置可能会变得非常重复,因此定义可以被多个设备引用的组变量可能会有所帮助。例如

inventory/group_vars/switches
---
# Group configuration for the 'switches' group.
switch_config_default:
  - default global config line 1
  - default global config line 2

switch_interface_config_controller:
  - controller interface config line 1
  - controller interface config line 2

switch_interface_config_compute:
  - compute interface config line 1
  - compute interface config line 2
inventory/host_vars/switch0
---
ansible_host: 1.2.3.4

ansible_user: alice

switch_config: "{{ switch_config_default }}"

switch_interface_config:
  interface-0:
    description: controller0
    config: "{{ switch_interface_config_controller }}"
  interface-1:
    description: compute0
    config: "{{ switch_interface_config_compute }}"

对旧设备的的支持

某些网络设备可能使用 Ansible 控制主机不再支持的 SSH 密钥交换算法。这将导致 ssh-keyscan 失败,从而阻止 Kayobe 配置设备。要解决此问题,请将 switch_skip_keyscan 设置为 true,对于受影响的设备。Ansible 控制主机上的 SSH known_hosts 文件需要手动填充。

设备特定配置变量

Arista EOS

使用 Kayobe 中的 arista-switch Ansible 角色应用这些设备的配置。该角色使用 eos Ansible 模块配置 Arista 交换机。

switch_type 应设置为 arista

  • ansible_host 是主机名或 IP 地址。可选。

  • ansible_user 是 SSH 用户名。

  • ansible_ssh_pass 是 SSH 密码。

  • ansible_connection 应为 ansible.netcommon.network_cli

  • ansible_network_os 应为 arista.eos.eos

  • ansible_become 应为 true

  • ansible_become_method 应为 enable

Cumulus Linux(使用 NCLU)

使用 nclu Ansible 模块应用这些设备的配置。

switch_type 应设置为 nclu

Cumulus Linux(使用 NVUE)

使用 nvidia.nvue.command Ansible 模块应用这些设备的配置。

switch_type 应设置为 nvue

SSH 配置

与库存中的任何非交换机主机一样,nclunvidia.nvue.command 模块依赖于 Ansible 使用的默认连接参数。

  • ansible_host 是主机名或 IP 地址。可选。

  • ansible_user 是 SSH 用户名。

Dell OS6、OS9 和 OS10

使用 dellos6_configdellos9_configdellos10_config Ansible 模块应用这些设备的配置。

switch_type 应设置为 dellos6dellos9dellos10

switch_config_save 可以设置为 true 以启用在应用配置后保存配置。

提供程序

  • ansible_host 是主机名或 IP 地址。可选。

  • ansible_user 是 SSH 用户名。

  • ansible_ssh_pass 是 SSH 密码。

  • switch_auth_pass 是“enable”密码。

或者,将 switch_dellos_provider 设置为作为 provider 参数传递给 dellos*_config 模块的值。

Dell PowerConnect

使用 stackhpc.network.dell_powerconnect_switch Ansible 角色应用这些设备的配置。该角色使用 expect Ansible 模块通过 SSH 自动化与交换机 CLI 的交互。

switch_type 应设置为 dell-powerconnect

提供程序

  • ansible_host 是主机名或 IP 地址。可选。

  • ansible_user 是 SSH 用户名。

  • switch_auth_pass 是 SSH 密码。

Juniper Junos OS

使用 junos_config Ansible 模块应用这些设备的配置。

switch_type 应设置为 junos

switch_junos_config_format 可用于设置配置的格式。该变量作为 src_format 参数传递给 junos_config 模块。默认值为 text

  • ansible_host 是主机名或 IP 地址。可选。

  • ansible_user 是 SSH 用户名。

  • ansible_ssh_pass 是 SSH 密码。与 ansible_ssh_private_key_file 互斥。

  • ansible_ssh_private_key_file 是 SSH 私钥文件。与 ansible_ssh_pass 互斥。

  • ansible_connection 应为 ansible.netcommon.netconf

  • ansible_network_os 应为 junipernetworks.junos.junos

Mellanox MLNX OS

使用 stackhpc.network.mellanox_switch Ansible 角色应用这些设备的配置。该角色使用 expect Ansible 模块通过 SSH 自动化与交换机 CLI 的交互。

switch_type 应设置为 mellanox

提供程序

  • ansible_host 是主机名或 IP 地址。可选。

  • ansible_user 是 SSH 用户名。

  • switch_auth_pass 是 SSH 密码。