Skip to content

Commit e396e5c

Browse files
Merge pull request #254 from saito-hideki/pr/variable_warning
Display warning message for masquerade and icmp-block-inversion SUMMARY Display warning message if the wrong parameter set to masquerade or icmp-block-inversion Fixes #249 It is a part of #249. Currently, the variable type of the above two parameters is str, but will be changed to bool in the future. As a starting point, this fix displays a warning message if a non-boolean value is specified. ISSUE TYPE Bugfix Pull Request COMPONENT NAME ansible.posix.firewalld ADDITIONAL INFORMATION None Reviewed-by: Andrew Klychkov <[email protected]> Reviewed-by: Hideki Saito <[email protected]> Reviewed-by: Abhijeet Kasurde <None> Reviewed-by: None <None>
2 parents 7f16f56 + 4a67de7 commit e396e5c

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
minor_changes:
3+
- firewalld - Show warning message that variable type of ``masquerade`` and
4+
``icmp_block_inversion`` will be changed from ``str`` to ``boolean``
5+
in the future release (https://github.com/ansible-collections/ansible.posix/pull/254).

plugins/modules/firewalld.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,7 @@
213213
'''
214214

215215
from ansible.module_utils.basic import AnsibleModule
216+
from ansible.module_utils.parsing.convert_bool import boolean
216217
from ansible_collections.ansible.posix.plugins.module_utils.firewalld import FirewallTransaction, fw_offline
217218

218219
try:
@@ -875,6 +876,14 @@ def main():
875876
if changed is True:
876877
msgs.append("Changed icmp-block-inversion %s to %s" % (icmp_block_inversion, desired_state))
877878

879+
# Type of icmp_block_inversion will be changed to boolean in a future release.
880+
try:
881+
boolean(icmp_block_inversion, True)
882+
except TypeError:
883+
module.warn('The value of the icmp_block_inversion option is "%s". '
884+
'The type of the option will be changed from string to boolean in a future release. '
885+
'To avoid unexpected behavior, please change the value to boolean.' % icmp_block_inversion)
886+
878887
if service is not None:
879888

880889
transaction = ServiceTransaction(
@@ -992,6 +1001,14 @@ def main():
9921001
changed, transaction_msgs = transaction.run()
9931002
msgs = msgs + transaction_msgs
9941003

1004+
# Type of masquerade will be changed to boolean in a future release.
1005+
try:
1006+
boolean(masquerade, True)
1007+
except TypeError:
1008+
module.warn('The value of the masquerade option is "%s". '
1009+
'The type of the option will be changed from string to boolean in a future release. '
1010+
'To avoid unexpected behavior, please change the value to boolean.' % masquerade)
1011+
9951012
if target is not None:
9961013

9971014
transaction = ZoneTargetTransaction(

0 commit comments

Comments
 (0)