network/defaults/main.yml
Jack Adolph 4af8f23955 Add support for 802.1x wired connections (EAP-TLS only)
Only EAP-TLS method is supported. Must use NetworkManager as the network_provider.
Also fixed bug in do_connections_validate_nm() function.
2020-03-25 10:49:10 +01:00

91 lines
3.9 KiB
YAML

# SPDX-License-Identifier: BSD-3-Clause
---
network_connections: []
# Use initscripts for RHEL/CentOS < 7, nm otherwise
network_provider_os_default: "{{
'initscripts' if ansible_distribution in [
'RedHat',
'CentOS',
'OracleLinux'
] and ansible_distribution_major_version is version('7', '<')
else 'nm' }}"
# If NetworkManager.service is running, assume that 'nm' is currently in-use,
# otherwise initscripts
network_provider_current: "{{
'nm' if 'NetworkManager.service' in ansible_facts.services and
ansible_facts.services['NetworkManager.service']['state'] == 'running'
else 'initscripts'
}}"
# Default to the auto-detected value
network_provider: "{{ network_provider_current }}"
# wpa_supplicant is required if any 802.1x connections are defined
wpa_supplicant_required: "{{ network_connections |
json_query('[*][\"802.1x\"]') | flatten | count > 0 }}"
_network_packages_default_802_1x: ["{% if wpa_supplicant_required
%}wpa_supplicant{% endif %}"]
# The python-gobject-base package depends on the python version and
# distribution:
# - python-gobject-base on RHEL7 (no python2-gobject-base :-/)
# - python3-gobject-base on Fedora 28+
_network_packages_default_gobject_packages: ["python{{
ansible_python['version']['major'] | replace('2', '')}}-gobject-base"]
network_service_name_default_nm: NetworkManager
network_packages_default_nm: "{{ ['ethtool', 'NetworkManager']
+ _network_packages_default_gobject_packages|select()|list()
+ _network_packages_default_802_1x|select()|list()}}"
network_service_name_default_initscripts: network
# initscripts requires bridge-utils to manage bridges, install it when the
# 'bridge' type is used in network_connections
_network_packages_default_initscripts_bridge: ["{%
if ['bridge'] in network_connections|json_query('[*][type]') and
ansible_distribution in ['RedHat', 'CentOS', 'OracleLinux'] and
ansible_distribution_major_version is version('7', '<=')
%}bridge-utils{% endif %}"]
_network_packages_default_initscripts_network_scripts: ["{%
if ansible_distribution in ['RedHat', 'CentOS', 'OracleLinux'] and
ansible_distribution_major_version is version('7', '<=')
%}initscripts{% else %}network-scripts{% endif %}"]
# convert _network_packages_default_initscripts_bridge to an empty list if it
# contains only the empty string and add it to the default package list
# |select() filters the list to include only values that evaluate to true
# (the empty string is false)
# |list() converts the generator that |select() creates to a list
network_packages_default_initscripts: "{{ ['ethtool']
+ _network_packages_default_initscripts_bridge|select()|list()
+ _network_packages_default_initscripts_network_scripts|select()|list()
}}"
# The user can explicitly set host variables "network_provider",
# "network_service_name" and "network_packages".
#
# Usually, the user only wants to select the "network_provider"
# (or not set it at all and let it be autodetected via the
# internal variable "{{ network_provider_current }}". Hence,
# depending on the "network_provider", a different set of
# service-name and packages is chosen.
#
# That is done via the internal "_network_provider_setup" dictionary.
# If the user doesn't explicitly set "network_service_name" or
# "network_packages" (which he usually wouldn't), then the defaults
# from "network_service_name_default_*" and "network_packages_default_*"
# apply. These values are hard-coded in this file, but they also could
# be overwritten as host variables or via vars/*.yml.
_network_provider_setup:
nm:
service_name: "{{ network_service_name_default_nm }}"
packages: "{{ network_packages_default_nm }}"
initscripts:
service_name: "{{ network_service_name_default_initscripts }}"
packages: "{{ network_packages_default_initscripts }}"
network_packages: "{{
_network_provider_setup[network_provider]['packages'] }}"
network_service_name: "{{
_network_provider_setup[network_provider]['service_name'] }}"