Repository: ansible-collections/community.general

Issue:
iptables_state seems broken on ansible/ansible devel branch
### Summary

See:
- https://dev.azure.com/ansible/b24bf3ca-6168-45d7-99e2-bf8029e67c87/_apis/build/builds/16166/logs/1615
- https://dev.azure.com/ansible/b24bf3ca-6168-45d7-99e2-bf8029e67c87/_apis/build/builds/16167/logs/1563

```

2021-05-26T07:41:32.0705450Z 03:47 [0;31mThe full traceback is:[0m
2021-05-26T07:41:32.0706158Z 03:47 [0;31mTraceback (most recent call last):[0m
2021-05-26T07:41:32.0706897Z 03:47 [0;31m  File "/root/ansible/lib/ansible/executor/task_executor.py", line 158, in run[0m
2021-05-26T07:41:32.0707540Z 03:47 [0;31m    res = self._execute()[0m
2021-05-26T07:41:32.0708228Z 03:47 [0;31m  File "/root/ansible/lib/ansible/executor/task_executor.py", line 588, in _execute[0m
2021-05-26T07:41:32.0708923Z 03:47 [0;31m    result = self._handler.run(task_vars=variables)[0m
2021-05-26T07:41:32.0709716Z 03:47 [0;31m  File "/root/ansible_collections/community/general/plugins/action/iptables_state.py", line 130, in run[0m
2021-05-26T07:41:32.0710714Z 03:47 [0;31m    result = merge_hash(result, self._async_result(async_status_args, task_vars, 0))[0m
2021-05-26T07:41:32.0711599Z 03:47 [0;31m  File "/root/ansible_collections/community/general/plugins/action/iptables_state.py", line 55, in _async_result[0m
2021-05-26T07:41:32.0712343Z 03:47 [0;31m    if async_result['finished'] == 1:[0m
2021-05-26T07:41:32.0712928Z 03:47 [0;31mKeyError: 'finished'[0m
2021-05-26T07:41:32.0713495Z 03:47 [0;31mfatal: [testhost]: FAILED! => {[0m
2021-05-26T07:41:32.0714159Z 03:47 [0;31m    "msg": "Unexpected failure during module execution.",[0m
2021-05-26T07:41:32.0714756Z 03:47 [0;31m    "stdout": ""[0m
2021-05-26T07:41:32.0715240Z 03:47 [0;31m}[0m
```

### Issue Type

Bug Report

### Component Name

iptables_state

### Ansible Version

devel

### Configuration

*

### OS / Environment

*

### Steps to Reproduce

*

### Expected Results

*

### Actual Results

*

### Code of Conduct

- [X] I agree to follow the Ansible Code of Conduct


Discussion:
Files identified in the description:
* [`plugins/modules/system/iptables_state.py`](https://github.com/ansible-collections/community.general/blob/master/plugins/modules/system/iptables_state.py)

If these files are inaccurate, please update the `component name` section of the description or use the `!component` bot command.

[click here for bot help](https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md)
<!--- boilerplate: components_banner --->
cc @quidame
[click here for bot help](https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md)
<!--- boilerplate: notify --->
This is likely related to https://github.com/ansible/ansible/pull/74577
!component +plugins/action/system/iptables_state.py
Files identified in the description:
* [`plugins/action/system/iptables_state.py`](https://github.com/ansible-collections/community.general/blob/master/plugins/action/system/iptables_state.py)
* [`plugins/modules/system/iptables_state.py`](https://github.com/ansible-collections/community.general/blob/master/plugins/modules/system/iptables_state.py)

If these files are inaccurate, please update the `component name` section of the description or use the `!component` bot command.

[click here for bot help](https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md)
<!--- boilerplate: components_banner --->
#2641 will temporarily disable the iptables_state tests until this is fixed.

Resolving patch:
diff --git a/plugins/action/system/iptables_state.py b/plugins/action/system/iptables_state.py
--- a/plugins/action/system/iptables_state.py
+++ b/plugins/action/system/iptables_state.py
@@ -52,7 +52,7 @@ def _async_result(self, module_args, task_vars, timeout):
                 module_args=module_args,
                 task_vars=task_vars,
                 wrap_async=False)
-            if async_result['finished'] == 1:
+            if async_result.get('finished', 0) == 1:
                 break
             time.sleep(min(1, timeout))
 


Test patch:
diff --git a/tests/integration/targets/iptables_state/aliases b/tests/integration/targets/iptables_state/aliases
--- a/tests/integration/targets/iptables_state/aliases
+++ b/tests/integration/targets/iptables_state/aliases
@@ -5,4 +5,3 @@ skip/freebsd            # no iptables/netfilter (Linux specific)
 skip/osx                # no iptables/netfilter (Linux specific)
 skip/macos              # no iptables/netfilter (Linux specific)
 skip/aix                # no iptables/netfilter (Linux specific)
-disabled  # FIXME