From c4d166d3bcfc03ea307574c787c6ec6c7640f925 Mon Sep 17 00:00:00 2001 From: "patchback[bot]" <45432694+patchback[bot]@users.noreply.github.com> Date: Sat, 23 Apr 2022 08:49:33 +0200 Subject: [PATCH] nmcli: Change hairpin default mode (#4334) (#4558) * nmcli: Deprecate default hairpin mode Deprecate the default hairpin mode for a bridge. Plain nmcli/bridge tools defaults to no, but for some reason ansible defaults to yes. We deprecate the default value so we can switch to default 'no' in ansible 6.0.0 * Code review fixes Co-authored-by: Felix Fontein * Fix comments * Update changelogs/fragments/4320-nmcli-hairpin.yml Co-authored-by: Felix Fontein * Update changelogs/fragments/4320-nmcli-hairpin.yml Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com> Co-authored-by: Felix Fontein Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com> (cherry picked from commit 53f6c68026b860c06547aee4deb533125005fb52) Co-authored-by: dupondje --- changelogs/fragments/4320-nmcli-hairpin.yml | 2 ++ plugins/modules/net_tools/nmcli.py | 20 +++++++++++++++++--- 2 files changed, 19 insertions(+), 3 deletions(-) create mode 100644 changelogs/fragments/4320-nmcli-hairpin.yml diff --git a/changelogs/fragments/4320-nmcli-hairpin.yml b/changelogs/fragments/4320-nmcli-hairpin.yml new file mode 100644 index 00000000000..bcda97eeafa --- /dev/null +++ b/changelogs/fragments/4320-nmcli-hairpin.yml @@ -0,0 +1,2 @@ +deprecated_features: + - nmcli - deprecate default hairpin mode for a bridge. This so we can change it to ``false`` in community.general 7.0.0, as this is also the default in ``nmcli`` (https://github.com/ansible-collections/community.general/pull/4334). diff --git a/plugins/modules/net_tools/nmcli.py b/plugins/modules/net_tools/nmcli.py index 6a6b3c548ff..3c59b7efea0 100644 --- a/plugins/modules/net_tools/nmcli.py +++ b/plugins/modules/net_tools/nmcli.py @@ -374,8 +374,9 @@ description: - This is only used with 'bridge-slave' - 'hairpin mode' for the slave, which allows frames to be sent back out through the slave the frame was received on. + - The default value is C(true), but that is being deprecated + and it will be changed to C(false) in community.general 7.0.0. type: bool - default: yes runner: description: - This is the type of device or network connection that you wish to create for a team. @@ -1376,7 +1377,8 @@ def __init__(self, module): self.hellotime = module.params['hellotime'] self.maxage = module.params['maxage'] self.ageingtime = module.params['ageingtime'] - self.hairpin = module.params['hairpin'] + # hairpin should be back to normal in 7.0.0 + self._hairpin = module.params['hairpin'] self.path_cost = module.params['path_cost'] self.mac = module.params['mac'] self.runner = module.params['runner'] @@ -1423,6 +1425,18 @@ def __init__(self, module): self.edit_commands = [] + @property + def hairpin(self): + if self._hairpin is None: + self.module.deprecate( + "Parameter 'hairpin' default value will change from true to false in community.general 7.0.0. " + "Set the value explicitly to supress this warning.", + version='7.0.0', collection_name='community.general', + ) + # Should be False in 7.0.0 but then that should be in argument_specs + self._hairpin = True + return self._hairpin + def execute_command(self, cmd, use_unsafe_shell=False, data=None): if isinstance(cmd, list): cmd = [to_text(item) for item in cmd] @@ -2119,7 +2133,7 @@ def main(): hellotime=dict(type='int', default=2), maxage=dict(type='int', default=20), ageingtime=dict(type='int', default=300), - hairpin=dict(type='bool', default=True), + hairpin=dict(type='bool'), path_cost=dict(type='int', default=100), # team specific vars runner=dict(type='str', default='roundrobin',