|
154 | 154 | description: |
155 | 155 | Ensure presence or absence of entries. Use C(present) and C(absent) only |
156 | 156 | for zone-only operations, or for target operations. |
157 | | - required: true |
| 157 | + required: false |
158 | 158 | type: str |
159 | 159 | choices: ["enabled", "disabled", "present", "absent"] |
160 | 160 | __report_changed: |
@@ -315,7 +315,9 @@ def main(): |
315 | 315 | ], |
316 | 316 | ), |
317 | 317 | state=dict( |
318 | | - choices=["enabled", "disabled", "present", "absent"], required=True |
| 318 | + choices=["enabled", "disabled", "present", "absent"], |
| 319 | + required=False, |
| 320 | + default=None, |
319 | 321 | ), |
320 | 322 | __report_changed=dict(required=False, type="bool", default=True), |
321 | 323 | ), |
@@ -359,6 +361,19 @@ def main(): |
359 | 361 | runtime = module.params["runtime"] |
360 | 362 | state = module.params["state"] |
361 | 363 |
|
| 364 | + # All options that require state to be set |
| 365 | + state_required = any( |
| 366 | + ( |
| 367 | + interface, |
| 368 | + source, |
| 369 | + service, |
| 370 | + source_port, |
| 371 | + port, |
| 372 | + forward_port, |
| 373 | + icmp_block, |
| 374 | + rich_rule, |
| 375 | + ) |
| 376 | + ) |
362 | 377 | if permanent is None: |
363 | 378 | runtime = True |
364 | 379 | elif not any((permanent, runtime)): |
@@ -460,6 +475,9 @@ def main(): |
460 | 475 | if len(source) > 0 and permanent is None: |
461 | 476 | module.fail_json(msg="source cannot be set without permanent") |
462 | 477 |
|
| 478 | + if state is None and state_required: |
| 479 | + module.fail_json(msg="Options invalid without state option set") |
| 480 | + |
463 | 481 | if not HAS_FIREWALLD: |
464 | 482 | module.fail_json(msg="No firewalld") |
465 | 483 |
|
|
0 commit comments