stackhpc.vxlan
VXLAN
此角色使用 网络脚本、NetworkManager 或 Systemd-Networkd 创建持久的 VXLAN 接口。
角色变量
该角色使用与 网络脚本
相同的变量名称。建议查看 网络脚本 的文档。以下是与此角色相关并支持的变量。
vxlan_vni
:设置 VXLAN 接口的网络标识符
vxlan_ttl
:设置通过接口传输的包的生存时间
vxlan_phys_dev
:设置与 VXLAN 接口配对的物理设备
vxlan_dstport
:设置 VXLAN 所在的端口
vxlan_bootproto
:指定与接口一起使用的启动协议(在使用 NetworkManager 或 Systemd-Networkd 时不支持,始终为 none)
vxlan_onboot
:如果 VXLAN 接口在启动时应启用,则设置为 yes
,否则设置为 no
(在 Systemd-networkd 上不支持)
vxlan_interfaces
:待创建的接口列表,可以设置上述变量的特定实例以及其他一些变量
device
:分配给 VXLAN 接口的名称
ipaddr
:分配给 VXLAN 接口的 IPV4 地址(在使用 NetworkManager 或 Systemd-Networkd 时不支持)
prefix
:与ipaddr
一起使用的子网掩码(在使用 NetworkManager 或 Systemd-Networkd 时不支持)
group
:VXLAN 将操作的组播组
bridge
:如果设置,则在此 VXLAN 与指定接口之间建立桥接
默认情况下,将使用网络脚本,除非不可用。通过将 force_ns
、force_nm
或 force_sd
设置为 true,可以强制使用任意网络脚本、NetworkManager 或 Systemd-Networkd。
示例剧本
在剧本中像使用其他角色那样包含该角色。
- hosts: host1
roles:
- role: vxlan
vars:
vxlan_vni: 10
vxlan_interfaces:
- device: vxlan0
ipaddr: 192.168.0.2
group: 224.0.0.100
对于诸如 vxlan_ipaddr
的变量,最好在每台主机上单独定义它们。
/host_vars/host1
vxlan_interfaces:
- device: vxlan0
ipaddr: 192.168.0.2
group: 224.0.0.100
/host_vars/host2
vxlan_interfaces:
- device: vxlan0
ipaddr: 192.168.0.3
group: 224.0.0.100
您还可以为每台主机定义多个 VXLAN 接口,但必须为 vxlan_interfaces
中定义的每个设备提供唯一的 vxlan_vni
。
/host_vars/host1
vxlan_interfaces:
- device: vxlan0
vni: 10
group: 224.0.0.200
- device: vxlan1
vni: 20
group: 224.0.0.200
您还可以为 VXLAN 接口设置桥接。
/host_vars/host1
vxlan_interfaces:
- device: vxlan0
group: 224.0.0.10
bridge: breth1
许可
Apache 许可证 2.0
作者信息
Create persistent VXLAN interfaces with the use of Network Scripts
ansible-galaxy install stackhpc.vxlan