Skip to content

Commit

Permalink
keep force_masquerade
Browse files Browse the repository at this point in the history
  • Loading branch information
Ch3LL committed Dec 20, 2019
1 parent ca1e30d commit 27e298f
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 22 deletions.
18 changes: 0 additions & 18 deletions doc/topics/releases/neon.rst
Original file line number Diff line number Diff line change
Expand Up @@ -167,12 +167,6 @@ Fileserver Deprecations
- The ``svnfs_env_whitelist`` config option has been removed in favor of ``svnfs_saltenv_whitelist``.
- The ``svnfs_env_blacklist`` config option has been removed in favor of ``svnfs_saltenv_blacklist``.

- The :py:mod`firewalld <salt.states.firewalld>` state has been changed as follows:

- The default setting for the ``prune_services`` option in the
:py:func:`firewalld.present <salt.states.firewalld.present>` function has changed
from ``True`` to ``False``.

Engine Removal
--------------

Expand All @@ -186,18 +180,6 @@ Returner Removal
to Slack, the :py:func:`slack <salt.returners.slack_returner>` returner may be a suitable
replacement.

- The :py:mod`firewalld <salt.modules.firewalld>` module has been changed as
follows:

- Support for the ``force_masquerade`` option has been removed from the
:py:func:`firewalld.add_port <salt.module.firewalld.add_port` function. Please
use the :py:func:`firewalld.add_masquerade <salt.modules.firewalld.add_masquerade`
function instead.
- Support for the ``force_masquerade`` option has been removed from the
:py:func:`firewalld.add_port_fwd <salt.module.firewalld.add_port_fwd` function. Please
use the :py:func:`firewalld.add_masquerade <salt.modules.firewalld.add_masquerade`
function instead.

Grain Deprecations
------------------

Expand Down
18 changes: 16 additions & 2 deletions salt/modules/firewalld.py
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,7 @@ def remove_masquerade(zone=None, permanent=True):
return __firewall_cmd(cmd)


def add_port(zone, port, permanent=True):
def add_port(zone, port, permanent=True, force_masquerade=False):
'''
Allow specific ports in a zone.
Expand All @@ -628,7 +628,14 @@ def add_port(zone, port, permanent=True):
.. code-block:: bash
salt '*' firewalld.add_port internal 443/tcp
force_masquerade
when a zone is created ensure masquerade is also enabled
on that zone.
'''
if force_masquerade and not get_masquerade(zone):
add_masquerade(zone)

cmd = '--zone={0} --add-port={1}'.format(zone, port)

if permanent:
Expand Down Expand Up @@ -677,7 +684,7 @@ def list_ports(zone, permanent=True):
return __firewall_cmd(cmd).split()


def add_port_fwd(zone, src, dest, proto='tcp', dstaddr='', permanent=True):
def add_port_fwd(zone, src, dest, proto='tcp', dstaddr='', permanent=True, force_masquerade=False):
'''
Add port forwarding.
Expand All @@ -688,7 +695,14 @@ def add_port_fwd(zone, src, dest, proto='tcp', dstaddr='', permanent=True):
.. code-block:: bash
salt '*' firewalld.add_port_fwd public 80 443 tcp
force_masquerade
when a zone is created ensure masquerade is also enabled
on that zone.
'''
if force_masquerade and not get_masquerade(zone):
add_masquerade(zone)

cmd = '--zone={0} --add-forward-port=port={1}:proto={2}:toport={3}:toaddr={4}'.format(
zone,
src,
Expand Down
2 changes: 0 additions & 2 deletions salt/states/firewalld.py
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,6 @@ def _present(name,
for port in new_ports:
if not __opts__['test']:
try:
# TODO: force_masquerade to be removed in future release
__salt__['firewalld.add_port'](name, port, permanent=True, force_masquerade=False)
except CommandExecutionError as err:
ret['comment'] = 'Error: {0}'.format(err)
Expand Down Expand Up @@ -550,7 +549,6 @@ def _present(name,
for fwd in new_port_fwd:
if not __opts__['test']:
try:
# TODO: force_masquerade to be removed in future release
__salt__['firewalld.add_port_fwd'](name, fwd.srcport,
fwd.destport, fwd.protocol, fwd.destaddr, permanent=True,
force_masquerade=False)
Expand Down

0 comments on commit 27e298f

Please sign in to comment.