diff --git a/ansible/filter_plugins/networks.py b/ansible/filter_plugins/networks.py index 427fd2d5d..5af3aa5ea 100644 --- a/ansible/filter_plugins/networks.py +++ b/ansible/filter_plugins/networks.py @@ -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, diff --git a/doc/source/configuration/network.rst b/doc/source/configuration/network.rst index 58ec1ec8b..ebcc24269 100644 --- a/doc/source/configuration/network.rst +++ b/doc/source/configuration/network.rst @@ -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. diff --git a/releasenotes/notes/defroute-9bbcff8b2f8abc94.yaml b/releasenotes/notes/defroute-9bbcff8b2f8abc94.yaml new file mode 100644 index 000000000..c60af525d --- /dev/null +++ b/releasenotes/notes/defroute-9bbcff8b2f8abc94.yaml @@ -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. diff --git a/requirements.yml b/requirements.yml index 88ec47f67..29e487f95 100644 --- a/requirements.yml +++ b/requirements.yml @@ -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