-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cloudflare_dns: unable to add SRV records using example from docs #5167
Comments
Files identified in the description: If these files are incorrect, please update the |
After fiddling aroung with the raw cloudflare api I think I found the problem. In line 404 if self.record == '@':
self.record = self.zone In line 690 "name": params['record'][:-len('.' + params['zone'])], This results in an empty name and throws errors at the cloudflare api. In order to get this to work you have to specify a
Is this really intended? All other record types (a, aaaa, cname, ...) expect |
The easiest fix would be to simply remove the splicing of @@ -7,7 +7,7 @@
"port": params['port'],
"weight": params['weight'],
"priority": params['priority'],
- "name": params['record'][:-len('.' + params['zone'])],
+ "name": params['record'],
"proto": params['proto'],
"service": params['service']
} |
This commit removes the splicing of the record entry which resulted in malformed api calls. record must be the name of the subdomain or "@"
But isn't that breaking the module for everyone who creates a SRV entry for a proper subdomain? How about to simply replace |
Why? Just use the subdomain as - name: Create SRV records
community.general.cloudflare_dns:
zone: mydomain.tld
record: subdomain
type: SRV
proto: tcp
service: mysrv
value: example.com
port: 443
api_token: "{{ cloudflare_api_token }}" This works with my modified code: |
I don't know, I neither wrote the original code nor am using that API. You wrote
which indicates that the empty string is a problem. That's why I did that suggestion. I still don't know whether your change breaks the module for use-cases that worked so far or not. |
Actually this is not the only problem. The whole line makes no sense to me.: "name": params['record'][:-len('.' + params['zone'])], Quick test: def test(record, zone ):
print("name: ''" + record[:-len('.' + zone)])
>>> test("@", "example.net")
name: ''
>>> test("", "example.net")
name: ''
>>> test("subdomain", "example.net")
name: ''
>>> test("verylongsubdomain", "example.net")
name: 'veryl'
>>> test("another.subdomain", "example.net")
name: 'anoth'
>>> test("subdomain.example.net", "example.net")
name: 'subdomain'
>>> test("@.example.net", "example.net")
name: '@' |
The way I understand it,
make no sense. |
But then, this is contrary to what the docs say: https://github.com/ansible-collections/community.general/blob/main/plugins/modules/net_tools/cloudflare_dns.py#L88-L95 Now the problem is that if someone was using this module with specifying the record for SRV records in the way the module expected it, then your change will suddenly break them. Since this has been the behavior for the module for at least the last 3+ years, this is not a good idea. |
In fact, this change has been there since December 2016: ansible/ansible@85d41db |
Files identified in the description: If these files are incorrect, please update the |
Should be fixed by #5972. That fix will appear in the next 5.x.y and 6.x.y releases. |
Summary
I'm unable to add SRV records using the example from the official documentation:
This will result in an api error:
After digging a little bit in the code I noticed that the
name
item requires therecord
item to be set (which is not documented): https://github.com/ansible-collections/community.general/blob/main/plugins/modules/net_tools/cloudflare_dns.py#L690In order to get this to work you have to modify the yaml to:Either therecord
item should be generated automatically or settingproto
andservice
is useless.EDIT: Does also not work. This will create an "_foo._tcp._foo._tcp.example.net" entry
Issue Type
Bug Report
Component Name
cloudflare_dns
Ansible Version
Community.general Version
Configuration
$ ansible-config dump --only-changed
OS / Environment
Fedora 36
Steps to Reproduce
Expected Results
domain entries should be added
Actual Results
api error
Code of Conduct
The text was updated successfully, but these errors were encountered: