Disable IP address lookups in iptables -module when listing (#78828)

* add --numeric to list

Co-authored-by: Mikko Toivola <mikko.toivola@insta.fi>
pull/79113/head
mtoivo 2 years ago committed by GitHub
parent 5d253a1380
commit cc2e7501db
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,2 @@
minor_changes:
- add parameter ``numeric`` to the iptables module to disable dns lookups when running list -action internally (https://github.com/ansible/ansible/issues/78793).

@ -383,6 +383,15 @@ options:
type: bool
default: false
version_added: "2.13"
numeric:
description:
- This parameter controls the running of the list -action of iptables, which is used internally by the module
- Does not affect the actual functionality. Use this if iptables hangs when creating chain or altering policy
- If C(true), then iptables skips the DNS-lookup of the IP addresses in a chain when it uses the list -action
- Listing is used internally for example when setting a policy or creting of a chain
type: bool
default: false
version_added: "2.15"
'''
EXAMPLES = r'''
@ -721,6 +730,8 @@ def set_chain_policy(iptables_path, module, params):
def get_chain_policy(iptables_path, module, params):
cmd = push_arguments(iptables_path, '-L', params, make_rule=False)
if module.params['numeric']:
cmd.append('--numeric')
rc, out, _ = module.run_command(cmd, check_rc=True)
chain_header = out.split("\n")[0]
result = re.search(r'\(policy ([A-Z]+)\)', chain_header)
@ -742,6 +753,8 @@ def create_chain(iptables_path, module, params):
def check_chain_present(iptables_path, module, params):
cmd = push_arguments(iptables_path, '-L', params, make_rule=False)
if module.params['numeric']:
cmd.append('--numeric')
rc, _, __ = module.run_command(cmd, check_rc=False)
return (rc == 0)
@ -809,6 +822,7 @@ def main():
flush=dict(type='bool', default=False),
policy=dict(type='str', choices=['ACCEPT', 'DROP', 'QUEUE', 'RETURN']),
chain_management=dict(type='bool', default=False),
numeric=dict(type='bool', default=False),
),
mutually_exclusive=(
['set_dscp_mark', 'set_dscp_mark_class'],

Loading…
Cancel
Save