network/defaults/main.yml
Thomas Haller 16ad34c20a role: improve making "network_provider" configurable via host vars
The role currently supports two providers: "nm" and "initscripts".

The provider is autodetected by loading one of the vars/*.yml files
(where the default is set via the internal "network_provider_default" variable).
The user can still overwrite the provider, by explicitly setting the
"network_provider" variable.

Depending on the provider there is the list of packages that shall be
installed and the service to start. Selecting this was broken before.

This is now fixed and works like following:

The variables "network_service_name" and "network_packages" can be
specified by the user as host variables. But usually the user wouldn't
want to do that. Instead, those settings depend on "network_provider".
The role looks into the internal "_network_provider_setup" dictionary,
which defaults to "network_service_name_nm", "network_service_name_initscripts",
"network_packages_nm", and "network_packages_initscripts".

These default variables are initialized in "defaults/main.yml" as well,
but they could be overwritten via "vars/*.yml" files, or via any other
mechanism.

https://github.com/linux-system-roles/network/pull/14
https://bugzilla.redhat.com/show_bug.cgi?id=1485074
2017-09-25 11:37:48 +02:00

35 lines
1.5 KiB
YAML

network_provider: "{{ network_provider_default }}"
network_connections: []
network_service_name_default_nm: NetworkManager
network_packages_default_nm: [ NetworkManager ]
network_service_name_default_initscripts: network
network_packages_default_initscripts: []
# 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_default }}". 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'] }}"