|
31 | 31 | - "You can obtain your API token from the bottom of the Cloudflare 'My Account' page, found here: U(https://dash.cloudflare.com/)."
|
32 | 32 | - Can be specified in E(CLOUDFLARE_TOKEN) environment variable since community.general 2.0.0.
|
33 | 33 | type: str
|
34 |
| - required: false |
35 | 34 | version_added: '0.2.0'
|
36 | 35 | account_api_key:
|
37 | 36 | description:
|
38 | 37 | - Account API key.
|
39 | 38 | - Required for api keys authentication.
|
40 | 39 | - "You can obtain your API key from the bottom of the Cloudflare 'My Account' page, found here: U(https://dash.cloudflare.com/)."
|
41 | 40 | type: str
|
42 |
| - required: false |
43 | 41 | aliases: [ account_api_token ]
|
44 | 42 | account_email:
|
45 | 43 | description:
|
46 | 44 | - Account email. Required for API keys authentication.
|
47 | 45 | type: str
|
48 |
| - required: false |
49 | 46 | algorithm:
|
50 | 47 | description:
|
51 | 48 | - Algorithm number.
|
|
57 | 54 | - Required for O(type=TLSA) when O(state=present).
|
58 | 55 | type: int
|
59 | 56 | choices: [ 0, 1, 2, 3 ]
|
| 57 | + comment: |
| 58 | + description: |
| 59 | + - Comments or notes about the DNS record. |
| 60 | + type: str |
| 61 | + version_added: 10.1.0 |
60 | 62 | flag:
|
61 | 63 | description:
|
62 | 64 | - Issuer Critical Flag.
|
|
134 | 136 | type: str
|
135 | 137 | choices: [ absent, present ]
|
136 | 138 | default: present
|
| 139 | + tags: |
| 140 | + description: |
| 141 | + - Custom tags for the DNS record. |
| 142 | + type: list |
| 143 | + elements: str |
| 144 | + version_added: 10.1.0 |
137 | 145 | timeout:
|
138 | 146 | description:
|
139 | 147 | - Timeout for Cloudflare API calls.
|
|
191 | 199 | value: 127.0.0.1
|
192 | 200 | api_token: dummyapitoken
|
193 | 201 |
|
| 202 | +- name: Create a record with comment and tags |
| 203 | + community.general.cloudflare_dns: |
| 204 | + zone: example.net |
| 205 | + record: test |
| 206 | + type: A |
| 207 | + value: 127.0.0.1 |
| 208 | + comment: Local test website |
| 209 | + tags: |
| 210 | + - test |
| 211 | + - local |
| 212 | + api_token: dummyapitoken |
| 213 | +
|
194 | 214 | - name: Create a example.net CNAME record to example.com
|
195 | 215 | community.general.cloudflare_dns:
|
196 | 216 | zone: example.net
|
|
299 | 319 | returned: success, except on record deletion
|
300 | 320 | type: complex
|
301 | 321 | contains:
|
| 322 | + comment: |
| 323 | + description: Comments or notes about the DNS record. |
| 324 | + returned: success |
| 325 | + type: str |
| 326 | + sample: Domain verification record |
| 327 | + version_added: 10.1.0 |
| 328 | + comment_modified_on: |
| 329 | + description: When the record comment was last modified. Omitted if there is no comment. |
| 330 | + returned: success |
| 331 | + type: str |
| 332 | + sample: "2024-01-01T05:20:00.12345Z" |
| 333 | + version_added: 10.1.0 |
302 | 334 | content:
|
303 | 335 | description: The record content (details depend on record type).
|
304 | 336 | returned: success
|
|
333 | 365 | type: bool
|
334 | 366 | sample: false
|
335 | 367 | meta:
|
336 |
| - description: No documentation available. |
| 368 | + description: Extra Cloudflare-specific information about the record. |
337 | 369 | returned: success
|
338 | 370 | type: dict
|
339 | 371 | sample: { auto_added: false }
|
|
362 | 394 | returned: success
|
363 | 395 | type: bool
|
364 | 396 | sample: false
|
| 397 | + tags: |
| 398 | + description: Custom tags for the DNS record. |
| 399 | + returned: success |
| 400 | + type: list |
| 401 | + elements: str |
| 402 | + sample: ['production', 'app'] |
| 403 | + version_added: 10.1.0 |
| 404 | + tags_modified_on: |
| 405 | + description: When the record tags were last modified. Omitted if there are no tags. |
| 406 | + returned: success |
| 407 | + type: str |
| 408 | + sample: "2025-01-01T05:20:00.12345Z" |
| 409 | + version_added: 10.1.0 |
365 | 410 | ttl:
|
366 | 411 | description: The time-to-live for the record.
|
367 | 412 | returned: success
|
@@ -410,9 +455,11 @@ def __init__(self, module):
|
410 | 455 | self.account_email = module.params['account_email']
|
411 | 456 | self.algorithm = module.params['algorithm']
|
412 | 457 | self.cert_usage = module.params['cert_usage']
|
| 458 | + self.comment = module.params['comment'] |
413 | 459 | self.hash_type = module.params['hash_type']
|
414 | 460 | self.flag = module.params['flag']
|
415 | 461 | self.tag = module.params['tag']
|
| 462 | + self.tags = module.params['tags'] |
416 | 463 | self.key_tag = module.params['key_tag']
|
417 | 464 | self.port = module.params['port']
|
418 | 465 | self.priority = module.params['priority']
|
@@ -662,7 +709,7 @@ def delete_dns_records(self, **kwargs):
|
662 | 709 | def ensure_dns_record(self, **kwargs):
|
663 | 710 | params = {}
|
664 | 711 | for param in ['port', 'priority', 'proto', 'proxied', 'service', 'ttl', 'type', 'record', 'value', 'weight', 'zone',
|
665 |
| - 'algorithm', 'cert_usage', 'hash_type', 'selector', 'key_tag', 'flag', 'tag']: |
| 712 | + 'algorithm', 'cert_usage', 'hash_type', 'selector', 'key_tag', 'flag', 'tag', 'tags', 'comment']: |
666 | 713 | if param in kwargs:
|
667 | 714 | params[param] = kwargs[param]
|
668 | 715 | else:
|
@@ -798,6 +845,9 @@ def ensure_dns_record(self, **kwargs):
|
798 | 845 | }
|
799 | 846 | search_value = None
|
800 | 847 |
|
| 848 | + new_record['comment'] = params['comment'] or None |
| 849 | + new_record['tags'] = params['tags'] or [] |
| 850 | + |
801 | 851 | zone_id = self._get_zone_id(params['zone'])
|
802 | 852 | records = self.get_dns_records(params['zone'], params['type'], search_record, search_value)
|
803 | 853 | # in theory this should be impossible as cloudflare does not allow
|
@@ -826,6 +876,10 @@ def ensure_dns_record(self, **kwargs):
|
826 | 876 | do_update = True
|
827 | 877 | if (params['type'] == 'CNAME') and (cur_record['content'] != new_record['content']):
|
828 | 878 | do_update = True
|
| 879 | + if cur_record['comment'] != new_record['comment']: |
| 880 | + do_update = True |
| 881 | + if sorted(cur_record['tags']) != sorted(new_record['tags']): |
| 882 | + do_update = True |
829 | 883 | if do_update:
|
830 | 884 | if self.module.check_mode:
|
831 | 885 | result = new_record
|
@@ -856,11 +910,13 @@ def main():
|
856 | 910 | account_email=dict(type='str', required=False),
|
857 | 911 | algorithm=dict(type='int'),
|
858 | 912 | cert_usage=dict(type='int', choices=[0, 1, 2, 3]),
|
| 913 | + comment=dict(type='str'), |
859 | 914 | hash_type=dict(type='int', choices=[1, 2]),
|
860 | 915 | key_tag=dict(type='int', no_log=False),
|
861 | 916 | port=dict(type='int'),
|
862 | 917 | flag=dict(type='int', choices=[0, 1]),
|
863 | 918 | tag=dict(type='str', choices=['issue', 'issuewild', 'iodef']),
|
| 919 | + tags=dict(type='list', elements='str'), |
864 | 920 | priority=dict(type='int', default=1),
|
865 | 921 | proto=dict(type='str'),
|
866 | 922 | proxied=dict(type='bool', default=False),
|
|
0 commit comments