Closed cosandr closed 1 year ago
This patch seems to fix it for me, I can also add regexp as expected, it does somewhat break check mode since it accepts invalid entries (missing both name and regexp).
diff --git a/plugins/module_utils/_api_data.py b/plugins/module_utils/_api_data.py
index 04f1f2b..37e5232 100644
--- a/plugins/module_utils/_api_data.py
+++ b/plugins/module_utils/_api_data.py
@@ -1329,7 +1329,7 @@ PATHS = {
),
('ip', 'dns', 'static'): APIData(
fully_understood=True,
- stratify_keys=('name', ),
+ # stratify_keys=('name', ),
fields={
'address': KeyInfo(),
'cname': KeyInfo(),
@@ -1338,8 +1338,9 @@ PATHS = {
'forward-to': KeyInfo(),
'mx-exchange': KeyInfo(),
'mx-preference': KeyInfo(),
- 'name': KeyInfo(required=True),
+ 'name': KeyInfo(),
'ns': KeyInfo(),
+ 'regexp': KeyInfo(),
'srv-port': KeyInfo(),
'srv-priority': KeyInfo(),
'srv-target': KeyInfo(),
- name: Add with api_modify
delegate_to: localhost
community.routeros.api_modify:
path: ip dns static
data:
- address: "10.1.2.3"
regexp: '.*\.ansible\.test$'
ttl: 1h
SUMMARY
If my DNS entries have regexp, the
api_modify
module breaks (fails with KeyError while parsing data from the router).The
api
module successfully adds it for example:api_modify
complains about missing "name".If I comment out satisfy_keys I can at least add the normal A record with a name, although I see regexp is missing from fields. RouterOS requires either
name
orregexp
to be present, I'm not familiar enough with the code to tell if that's possible to check for unfortunately.ISSUE TYPE
COMPONENT NAME
community.routeros.api_modify
ANSIBLE VERSION
COLLECTION VERSION
OS / ENVIRONMENT
RouterOS 7.6
STEPS TO REPRODUCE
For this to fail, a record without
name
must exist on the router.EXPECTED RESULTS
DNS entry to be added/modified.
ACTUAL RESULTS