mirror of
https://github.com/linux-system-roles/network.git
synced 2026-08-01 15:30:08 +00:00
Add 'auto_gateway' option
If enabled, a default route will be configured using the default gateway. If disabled, the default route will be removed. If this variable is not specified, the role will use the default behavior of the `network_provider` selected. Setting this option to `no` is equivalent to: - `DEFROUTE = no` in initscripts, or - `ipv4.never-default/ipv6.never-default yes` in nmcli Signed-off-by: Jack Adolph <jack.adolph@gmail.com>
This commit is contained in:
parent
6fdac168a9
commit
b368bce8aa
7 changed files with 409 additions and 0 deletions
|
|
@ -578,6 +578,7 @@ class ArgValidator_DictIP(ArgValidatorDict):
|
|||
nested=ArgValidatorIPAddr("address[?]"),
|
||||
default_value=list,
|
||||
),
|
||||
ArgValidatorBool("auto_gateway", default_value=None),
|
||||
ArgValidatorList(
|
||||
"route", nested=ArgValidatorIPRoute("route[?]"), default_value=list
|
||||
),
|
||||
|
|
@ -611,6 +612,7 @@ class ArgValidator_DictIP(ArgValidatorDict):
|
|||
"gateway6": None,
|
||||
"route_metric6": None,
|
||||
"address": [],
|
||||
"auto_gateway": None,
|
||||
"route": [],
|
||||
"route_append_only": False,
|
||||
"rule_append_only": False,
|
||||
|
|
@ -665,6 +667,20 @@ class ArgValidator_DictIP(ArgValidatorDict):
|
|||
raise ValidationError(
|
||||
name, "'dhcp4_send_hostname' is only valid if 'dhcp4' is enabled"
|
||||
)
|
||||
|
||||
ipv4_gw_defined = result["gateway4"] is not None
|
||||
ipv6_gw_defined = result["gateway6"] is not None
|
||||
dhcp_enabled = result["dhcp4"] or result["auto6"]
|
||||
|
||||
if result["auto_gateway"] and not (
|
||||
ipv4_gw_defined or ipv6_gw_defined or dhcp_enabled
|
||||
):
|
||||
raise ValidationError(
|
||||
name,
|
||||
"must define 'gateway4', 'gateway6', or use dhcp "
|
||||
"if 'auto_gateway' is enabled",
|
||||
)
|
||||
|
||||
return result
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue