linux-system-roles.network

linux-system-roles/network

Lint Status Test Status Code Quality Integration Status Markdown Lint Status Python Unit Test Status Shell Check Status Terraform Status Terraform Bad Status Code Quality Coverage Status Code Style: black Language Grade: Python

Overview

The network role helps users set up networking on target machines. It can configure:

  • Ethernet connections
  • Bridge connections
  • Bonded connections
  • VLAN connections
  • MacVLAN connections
  • Infiniband connections
  • Wireless (WiFi) connections
  • IP settings
  • 802.1x authentication

Introduction

The network role works with two providers: nm (NetworkManager) and initscripts. The nm provider is the default starting from RHEL7, while initscripts is used in RHEL6. Note that initscripts requires the network-scripts package, which is old in RHEL8 and removed in RHEL9. You can set the provider for each host using the network_provider variable. If not set, it will auto-detect based on the Linux distribution.

The network role has two main modules: network_connections for managing connection profiles and network_state for defining device states.

Configuration Notes

  • For initscripts, profiles correspond to ifcfg files in /etc/sysconfig/network-scripts/, with NM_CONTROLLED=no.
  • For nm, profiles are handled by NetworkManager and stored in /etc/NetworkManager/system-connections/.
  • The network role updates or creates connection profiles as specified in the network_connections variable and can remove options that are not defined in it.

Requirements

Collection Requirements

For managing rpm-ostree nodes, you need external collections. Install them with:

ansible-galaxy collection install -vv -r meta/collection-requirements.yml

Variables

The network role uses variables that start with network_. Here are the main ones:

  • network_provider: Sets the provider (nm or initscripts). Default is based on the OS.
  • network_connections: Defines connection profiles in a list.
  • network_allow_restart: Allows restarting NetworkManager if set to true; defaults to false.
  • network_state: Configures the network state on the managed host.

Examples of Configuration

Here’s how you can set variables:

network_provider: nm
network_connections:
  - name: eth0
    #...
network_allow_restart: true
network_provider: nm
network_state:
  interfaces:
    - name: eth0
    #...

Connection Options

name (usually required)

Identifies the connection profile. It is not the interface name. You can have multiple profiles for the same device, but only one can be active at a time.

state

Sets the operational state of the connection profile to up (active) or down (inactive).

persistent_state

Indicates if the profile should be saved on disk:

  • present (default): Profile is created or updated.
  • absent: Deletes the profile.

type

Defines the type of connection, including options such as ethernet, bridge, bond, team, vlan, and more.

Examples of Options

Here’s how to define a persistent connection profile:

network_connections:
  - name: eth0
    persistent_state: present  # default
    type: ethernet
    autoconnect: true
    ip:
      dhcp4: true

To activate a preexisting profile:

network_connections:
  - name: eth0
    state: up

To deactivate a preexisting profile:

network_connections:
  - name: eth0
    state: down

Potential Issues

When changes are made remotely, ensure you can access the machine physically if something goes wrong. NetworkManager has a rollback feature, but its effectiveness can vary.

For detailed examples and additional features, refer to the official documentation.

Want to contribute? Check our contributing guidelines!

rpm-ostree

See README-ostree.md for more information.

Installa
ansible-galaxy install linux-system-roles.network
Licenza
bsd-3-clause
Download
263.3k
Proprietario