Add support for setting defroute

Change-Id: I483d8f4189a569d58bc95591c7c86a88c9c5b5f3
Story: 2004884
Task: 29165
This commit is contained in:
Pierre Riteau 2019-01-29 14:58:21 +00:00
parent 9156fa0e2d
commit 55f73c52ca
4 changed files with 23 additions and 1 deletions

View File

@ -128,6 +128,7 @@ net_routes = _make_attr_filter('routes')
net_rules = _make_attr_filter('rules')
net_physical_network = _make_attr_filter('physical_network')
net_bootproto = _make_attr_filter('bootproto')
net_defroute = _make_attr_filter('defroute')
@jinja2.contextfilter
@ -202,6 +203,7 @@ def net_interface_obj(context, name, inventory_hostname=None):
routes = [_route_obj(route) for route in routes]
rules = net_rules(context, name, inventory_hostname)
bootproto = net_bootproto(context, name, inventory_hostname)
defroute = net_defroute(context, name, inventory_hostname)
interface = {
'device': device,
'address': ip,
@ -212,6 +214,7 @@ def net_interface_obj(context, name, inventory_hostname=None):
'route': routes,
'rules': rules,
'bootproto': bootproto or 'static',
'defroute': defroute,
'onboot': 'yes',
}
interface = {k: v for k, v in interface.items() if v is not None}
@ -244,6 +247,7 @@ def net_bridge_obj(context, name, inventory_hostname=None):
routes = [_route_obj(route) for route in routes]
rules = net_rules(context, name, inventory_hostname)
bootproto = net_bootproto(context, name, inventory_hostname)
defroute = net_defroute(context, name, inventory_hostname)
interface = {
'device': device,
'address': ip,
@ -255,6 +259,7 @@ def net_bridge_obj(context, name, inventory_hostname=None):
'route': routes,
'rules': rules,
'bootproto': bootproto or 'static',
'defroute': defroute,
'onboot': 'yes',
}
interface = {k: v for k, v in interface.items() if v is not None}
@ -293,6 +298,7 @@ def net_bond_obj(context, name, inventory_hostname=None):
routes = [_route_obj(route) for route in routes]
rules = net_rules(context, name, inventory_hostname)
bootproto = net_bootproto(context, name, inventory_hostname)
defroute = net_defroute(context, name, inventory_hostname)
interface = {
'device': device,
'address': ip,
@ -310,6 +316,7 @@ def net_bond_obj(context, name, inventory_hostname=None):
'route': routes,
'rules': rules,
'bootproto': bootproto or 'static',
'defroute': defroute,
'onboot': 'yes',
}
interface = {k: v for k, v in interface.items() if v is not None}
@ -464,6 +471,7 @@ class FilterModule(object):
'net_rules': net_rules,
'net_physical_network': net_physical_network,
'net_bootproto': net_bootproto,
'net_defroute': net_defroute,
'net_interface_obj': net_interface_obj,
'net_bridge_obj': net_bridge_obj,
'net_bond_obj': net_bond_obj,

View File

@ -240,6 +240,12 @@ The following attributes are supported:
Boot protocol for the interface. Valid values are ``static`` and ``dhcp``.
The default is ``static``. When set to ``dhcp``, an external DHCP server
must be provided.
``defroute``
Whether to set the interface as the default route. This attribute can be
used to disable configuration of the default gateway by a specific
interface. This is particularly useful to ignore a gateway address provided
via DHCP. Should be set to a boolean value. The default is unset. This
attribute is only supported on distributions of the Red Hat family.
``bridge_ports``
For bridge interfaces, a list of names of network interfaces to add to the
bridge.

View File

@ -0,0 +1,8 @@
---
features:
- |
Adds support for the ``defroute`` network attribute. This attribute can be
used to disable configuration of the default gateway by a specific
interface. This is particularly useful to ignore a gateway address provided
via DHCP. Note that this attribute is only supported on distributions of
the Red Hat family.

View File

@ -5,7 +5,7 @@
# There are no versioned releases of this role.
version: 6b5f1d55bc3f27fa2855d8dd59b5c224d160d806
- src: MichaelRigart.interfaces
version: v1.1.0
version: v1.2.0
- src: mrlesmithjr.manage-lvm
version: v0.1.4
- src: resmo.ntp