1.5. 使用 RHEL 系统角色管理网络

您可以使用 network 角色在多目标机器上配置网络连接。

network 角色可以配置以下类型的接口:

  • Ethernet
  • Bridge
  • Bonded
  • VLAN
  • MacVLAN
  • InfiniBand

每个主机所需的网络连接都作为 network_connections 变量中的列表提供。

警告

network 角色更新或者创建目标系统中的所有连接配置集,与在 network_connections 变量中指定的方法完全相同。因此,如果选项只在系统中出现而没有出现在 network_connections 变量中,network 角色会从指定的配置集中删除选项。

以下示例演示了如何应用 network 角色来确保存在与所需参数的以太网连接:

应用网络角色的 playbook 示例,以设置使用所需参数的以太网连接

# SPDX-License-Identifier: BSD-3-Clause
---
- hosts: managed-node-01.example.com
  vars:
    network_connections:

      # Create one Ethernet profile and activate it.
      # The profile uses automatic IP addressing
      # and is tied to the interface by MAC address.
      - name: prod1
        state: up
        type: ethernet
        autoconnect: yes
        mac: "00:00:5e:00:53:00"
        mtu: 1450

  roles:
    - rhel-system-roles.network