diff --git a/plugins/module_utils/helper/main.py b/plugins/module_utils/helper/main.py index 7a2480b..c8951eb 100644 --- a/plugins/module_utils/helper/main.py +++ b/plugins/module_utils/helper/main.py @@ -506,6 +506,6 @@ def unset_check_error(params: dict, field: str, fail: bool) -> bool: return True def sanitize_module_args(args: dict) -> dict: - args.pop('api_key') - args.pop('api_secret') + args.pop('api_key', None) + args.pop('api_secret', None) return args diff --git a/plugins/module_utils/helper/rule.py b/plugins/module_utils/helper/rule.py index 28ca03a..7eb640e 100644 --- a/plugins/module_utils/helper/rule.py +++ b/plugins/module_utils/helper/rule.py @@ -2,6 +2,8 @@ from ansible_collections.ansibleguy.opnsense.plugins.module_utils.helper.main import \ get_matching +from ansible_collections.ansibleguy.opnsense.plugins.module_utils.defaults.rule import \ + RULE_DEFAULTS def validate_values(error_func, module: AnsibleModule, cnf: dict) -> None: @@ -45,6 +47,11 @@ def check_purge_configured(module: AnsibleModule, existing_rule: dict) -> bool: if rule_config is None: rule_config = {} + rule_config = { + **RULE_DEFAULTS, + **rule_config, + } + rule_config[module.params['key_field']] = rule_key configured_rules.append(rule_config)