| 1 |
.. |
| 2 |
Copyright (c) Ansible Project |
| 3 |
GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) |
| 4 |
SPDX-License-Identifier: GPL-3.0-or-later |
| 5 |
|
| 6 |
.. _ansible_collections.community.dns.docsite.hetzner_guide: |
| 7 |
|
| 8 |
Hetzner DNS Guide |
| 9 |
================= |
| 10 |
|
| 11 |
.. contents:: Contents |
| 12 |
:local: |
| 13 |
:depth: 2 |
| 14 |
|
| 15 |
The :anscollection:`community.dns collection <community.dns>` offers several modules for working with the `Hetzner DNS service <https://docs.hetzner.com/dns-console/dns/>`_. |
| 16 |
The modules use the `JSON REST based API <https://dns.hetzner.com/api-docs/>`_. |
| 17 |
|
| 18 |
The collection provides six modules for working with Hetzner DNS: |
| 19 |
|
| 20 |
- :ansplugin:`community.dns.hetzner_dns_record#module`: create/update/delete single DNS records |
| 21 |
- :ansplugin:`community.dns.hetzner_dns_record_info#module`: retrieve information on DNS records |
| 22 |
- :ansplugin:`community.dns.hetzner_dns_record_set#module`: create/update/delete DNS record sets |
| 23 |
- :ansplugin:`community.dns.hetzner_dns_record_set_info#module`: retrieve information on DNS record sets |
| 24 |
- :ansplugin:`community.dns.hetzner_dns_record_sets#module`: bulk synchronize DNS record sets |
| 25 |
- :ansplugin:`community.dns.hetzner_dns_zone_info#module`: retrieve zone information |
| 26 |
|
| 27 |
If you are interested in migrating from the `markuman.hetzner_dns collection <https://galaxy.ansible.com/ui/repo/published/markuman/hetzner_dns/>`_, please see :ref:`ansible_collections.community.dns.docsite.hetzner_guide.migration_markuman_hetzner_dns`. |
| 28 |
|
| 29 |
It also provides an inventory plugin: |
| 30 |
|
| 31 |
- :ansplugin:`community.dns.hetzner_dns_records#inventory`: create inventory from DNS records |
| 32 |
|
| 33 |
To find out which record types are supported and how to use them, look at :ref:`ansible_collections.community.dns.docsite.hetzner_guide.records`. |
| 34 |
|
| 35 |
Authentication |
| 36 |
-------------- |
| 37 |
|
| 38 |
To use Hetzner's API, you need to create an API token. You can manage API tokens in the "API tokens" menu entry in your user menu in the `DNS Console <https://dns.hetzner.com/>`_. You must provide the token to the :ansopt:`hetzner_token` option of the modules, its alias :ansopt:`api_token`, or pass it on in the :envvar:`HETZNER_DNS_TOKEN` environment variable: |
| 39 |
|
| 40 |
.. code-block:: yaml+jinja |
| 41 |
|
| 42 |
- community.dns.hetzner_dns_record: |
| 43 |
hetzner_token: '{{ token }}' |
| 44 |
# ... |
| 45 |
|
| 46 |
In the examples in this guide, we will leave the authentication options away. Please note that you can set them globally with ``module_defaults`` (see :ref:`module_defaults`) or with an environment variable for the user and machine where the modules are run on. |
| 47 |
|
| 48 |
Using the ``community.dns.hetzner`` module defaults group |
| 49 |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 50 |
|
| 51 |
To avoid having to specify common parameters for all Hetzner DNS modules in every task, you can use the ``community.dns.hetzner`` module defaults group: |
| 52 |
|
| 53 |
.. code-block:: yaml+jinja |
| 54 |
|
| 55 |
--- |
| 56 |
- name: Hetzner DNS |
| 57 |
hosts: localhost |
| 58 |
gather_facts: false |
| 59 |
module_defaults: |
| 60 |
group/community.dns.hetzner: |
| 61 |
hetzner_token: '{{ token }}' |
| 62 |
tasks: |
| 63 |
- name: Query zone information |
| 64 |
community.dns.hetzner_dns_zone_info: |
| 65 |
zone_name: example.com |
| 66 |
register: result |
| 67 |
|
| 68 |
- name: Set A records for www.example.com |
| 69 |
community.dns.hetzner_dns_record_set: |
| 70 |
state: present |
| 71 |
zone_name: example.com |
| 72 |
type: A |
| 73 |
prefix: www |
| 74 |
value: |
| 75 |
- 192.168.0.1 |
| 76 |
|
| 77 |
Here all two tasks will use the options set for the module defaults group. |
| 78 |
|
| 79 |
Working with DNS zones |
| 80 |
---------------------- |
| 81 |
|
| 82 |
The :ansplugin:`community.dns.hetzner_dns_zone_info module <community.dns.hetzner_dns_zone_info#module>` allows to query information on a zone. The zone can be identified both by its name and by its ID (which is an integer): |
| 83 |
|
| 84 |
.. code-block:: yaml+jinja |
| 85 |
|
| 86 |
- name: Query zone information by name |
| 87 |
community.dns.hetzner_dns_zone_info: |
| 88 |
zone_name: example.com |
| 89 |
register: result |
| 90 |
|
| 91 |
- name: Query zone information by ID |
| 92 |
community.dns.hetzner_dns_zone_info: |
| 93 |
zone_id: aBcDeFgHiJlMnOpQrStUvW |
| 94 |
register: result |
| 95 |
|
| 96 |
The module returns both the zone name and zone ID, so this module can be used to convert from zone ID to zone name and vice versa: |
| 97 |
|
| 98 |
.. code-block:: yaml+jinja |
| 99 |
|
| 100 |
- ansible.builtin.debug: |
| 101 |
msg: | |
| 102 |
The zone ID: {{ result.zone_id }} |
| 103 |
The zone name: {{ result.zone_name }} |
| 104 |
|
| 105 |
Working with DNS records |
| 106 |
------------------------ |
| 107 |
|
| 108 |
.. note:: |
| 109 |
|
| 110 |
By default, TXT record values returned and accepted by the modules and plugins in this collection are unquoted. This means that you do not have to add double quotes (``"``), and escape double quotes (as ``\"``) and backslashes (as ``\\``). All modules and plugins which work with DNS records support the :ansopt:`community.dns.hetzner_dns_record_set#module:txt_transformation` option which allows to configure this behavior. |
| 111 |
|
| 112 |
Querying DNS records and record sets |
| 113 |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 114 |
|
| 115 |
The :ansplugin:`community.dns.hetzner_dns_record_set_info module <community.dns.hetzner_dns_record_set_info#module>` allows to query DNS record sets from the API. It can be used to query a single record set: |
| 116 |
|
| 117 |
.. code-block:: yaml+jinja |
| 118 |
|
| 119 |
- name: Query single record |
| 120 |
community.dns.hetzner_dns_record_set_info: |
| 121 |
zone_name: example.com |
| 122 |
type: A # IPv4 addresses |
| 123 |
what: single_record # default value |
| 124 |
# Either specify a record name: |
| 125 |
record: www.example.com |
| 126 |
# Or a record prefix ('' is the zone itself): |
| 127 |
prefix: www |
| 128 |
register: result |
| 129 |
|
| 130 |
- name: Show IPv4 addresses if record exists |
| 131 |
ansible.builtin.debug: |
| 132 |
msg: > |
| 133 |
IPv4s are {{ result.set.value | join(', ') }}, |
| 134 |
TTL is {{ result.set.ttl }} |
| 135 |
when: result.set is truthy |
| 136 |
|
| 137 |
- name: Show that record is not set |
| 138 |
ansible.builtin.debug: |
| 139 |
msg: There is no A record for www.example.com |
| 140 |
when: result.set is falsy |
| 141 |
|
| 142 |
In all examples in this section, you can replace :ansopt:`community.dns.hetzner_dns_record_set_info#module:zone_name=example.com` by :ansopt:`community.dns.hetzner_dns_record_set_info#module:zone_id=aBcDeFgHiJlMnOpQrStUvW` with the zone's ID string. |
| 143 |
|
| 144 |
You can also query a list of all record sets for a record name or prefix: |
| 145 |
|
| 146 |
.. code-block:: yaml+jinja |
| 147 |
|
| 148 |
- name: Query all records for www.example.com |
| 149 |
community.dns.hetzner_dns_record_set_info: |
| 150 |
zone_name: example.com |
| 151 |
what: all_types_for_record |
| 152 |
# Either specify a record name: |
| 153 |
record: www.example.com |
| 154 |
# Or a record prefix ('' is the zone itself): |
| 155 |
prefix: www |
| 156 |
register: result |
| 157 |
|
| 158 |
- name: Show all records for www.example.com |
| 159 |
ansible.builtin.debug: |
| 160 |
msg: > |
| 161 |
{{ item.type }} record with TTL {{ item.ttl }} has |
| 162 |
values {{ item.value | join(', ') }} |
| 163 |
loop: result.sets |
| 164 |
|
| 165 |
Finally you can query all record sets for a zone: |
| 166 |
|
| 167 |
.. code-block:: yaml+jinja |
| 168 |
|
| 169 |
- name: Query all records for a zone |
| 170 |
community.dns.hetzner_dns_record_set_info: |
| 171 |
zone_name: example.com |
| 172 |
what: all_records |
| 173 |
register: result |
| 174 |
|
| 175 |
- name: Show all records for the example.com zone |
| 176 |
ansible.builtin.debug: |
| 177 |
msg: > |
| 178 |
{{ item.type }} record for {{ item.record }} with |
| 179 |
TTL {{ item.ttl }} has values {{ item.value | join(', ') }} |
| 180 |
loop: result.sets |
| 181 |
|
| 182 |
If you are interested in individual DNS records, and not record sets, you should use the :ansplugin:`community.dns.hetzner_dns_record_info module <community.dns.hetzner_dns_record_info#module>`. It supports the same limiting options as the :ansplugin:`community.dns.hetzner_dns_record_set_info module <community.dns.hetzner_dns_record_set_info#module>`. |
| 183 |
|
| 184 |
Creating and updating DNS single records |
| 185 |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 186 |
|
| 187 |
If you do not want to add/remove values, but replace values, you will be interested in modifying a **record set** and not a single record. This is in particular important when working with ``CNAME`` and ``SOA`` records. |
| 188 |
|
| 189 |
The :ansplugin:`community.dns.hetzner_dns_record module <community.dns.hetzner_dns_record#module>` allows to set, update and remove single DNS records. Setting and updating can be done as follows. Records will be matched by record name and type, and the TTL value will be updated if necessary: |
| 190 |
|
| 191 |
.. code-block:: yaml+jinja |
| 192 |
|
| 193 |
- name: Add an A record with value 1.1.1.1 for www.example.com, resp. make sure the TTL is 300 |
| 194 |
community.dns.hetzner_dns_record: |
| 195 |
state: present |
| 196 |
zone_name: example.com |
| 197 |
type: A # IPv4 addresses |
| 198 |
# Either specify a record name: |
| 199 |
record: www.example.com |
| 200 |
# Or a record prefix ('' is the zone itself): |
| 201 |
prefix: www |
| 202 |
value: 1.1.1.1 |
| 203 |
ttl: 300 |
| 204 |
|
| 205 |
To delete records, simply use :ansopt:`community.dns.hetzner_dns_record#module:state=absent`. Records will be matched by record name and type, and the TTL will be ignored: |
| 206 |
|
| 207 |
.. code-block:: yaml+jinja |
| 208 |
|
| 209 |
- name: Remove A values for www.example.com |
| 210 |
community.dns.hetzner_dns_record: |
| 211 |
state: absent |
| 212 |
zone_name: example.com |
| 213 |
type: A # IPv4 addresses |
| 214 |
record: www.example.com |
| 215 |
value: 1.1.1.1 |
| 216 |
|
| 217 |
Records of the same type for the same record name with other values are ignored. |
| 218 |
|
| 219 |
Creating and updating DNS record sets |
| 220 |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 221 |
|
| 222 |
The :ansplugin:`community.dns.hetzner_dns_record_set module <community.dns.hetzner_dns_record_set#module>` allows to set, update and remove DNS record sets. Setting and updating can be done as follows: |
| 223 |
|
| 224 |
.. code-block:: yaml+jinja |
| 225 |
|
| 226 |
- name: Make sure record is set to the given value |
| 227 |
community.dns.hetzner_dns_record_set: |
| 228 |
state: present |
| 229 |
zone_name: example.com |
| 230 |
type: A # IPv4 addresses |
| 231 |
# Either specify a record name: |
| 232 |
record: www.example.com |
| 233 |
# Or a record prefix ('' is the zone itself): |
| 234 |
prefix: www |
| 235 |
value: |
| 236 |
- 1.1.1.1 |
| 237 |
- 8.8.8.8 |
| 238 |
|
| 239 |
If you want to assert that a record has a certain value, set :ansopt:`community.dns.hetzner_dns_record_set#module:on_existing=keep`. Using :ansval:`keep_and_warn` instead will emit a warning if this happens, and :ansval:`keep_and_fail` will make the module fail. |
| 240 |
|
| 241 |
To delete values, you can either overwrite the values with value :ansval:`[]`, or use :ansopt:`community.dns.hetzner_dns_record_set#module:state=absent`: |
| 242 |
|
| 243 |
.. code-block:: yaml+jinja |
| 244 |
|
| 245 |
- name: Remove A values for www.example.com |
| 246 |
community.dns.hetzner_dns_record_set: |
| 247 |
state: present |
| 248 |
zone_name: example.com |
| 249 |
type: A # IPv4 addresses |
| 250 |
record: www.example.com |
| 251 |
value: [] |
| 252 |
|
| 253 |
- name: Remove TXT values for www.example.com |
| 254 |
community.dns.hetzner_dns_record_set: |
| 255 |
zone_name: example.com |
| 256 |
type: TXT |
| 257 |
prefix: www |
| 258 |
state: absent |
| 259 |
|
| 260 |
- name: Remove specific AAAA values for www.example.com |
| 261 |
community.dns.hetzner_dns_record_set: |
| 262 |
zone_name: example.com |
| 263 |
type: AAAA # IPv6 addresses |
| 264 |
prefix: www |
| 265 |
state: absent |
| 266 |
on_existing: keep_and_fail |
| 267 |
ttl: 300 |
| 268 |
value: |
| 269 |
- '::1' |
| 270 |
|
| 271 |
In the third example, :ansopt:`community.dns.hetzner_dns_record_set#module:on_existing=keep_and_fail` is present and an explicit value and TTL are given. This makes the module remove the current value only if there's a AAAA record for ``www.example.com`` whose current value is ``::1`` and whose TTL is 300. If another value is set, the module will not make any change, but fail. This can be useful to not accidentally remove values you do not want to change. To issue a warning instead of failing, use :ansopt:`community.dns.hetzner_dns_record_set#module:on_existing=keep_and_warn`, and to simply not do a change without any indication of this situation, use :ansopt:`community.dns.hetzner_dns_record_set#module:on_existing=keep`. |
| 272 |
|
| 273 |
Bulk synchronization of DNS record sets |
| 274 |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 275 |
|
| 276 |
If you want to set/update multiple records at once, or even make sure that the precise set of records you are providing are present and nothing else, you can use the :ansplugin:`community.dns.hetzner_dns_record_sets module <community.dns.hetzner_dns_record_sets#module>`. |
| 277 |
|
| 278 |
The following example shows up to set/update multiple records at once: |
| 279 |
|
| 280 |
.. code-block:: yaml+jinja |
| 281 |
|
| 282 |
- name: Make sure that multiple records are present |
| 283 |
community.dns.hetzner_dns_record_sets: |
| 284 |
zone_name: example.com |
| 285 |
record_sets: |
| 286 |
- prefix: www |
| 287 |
type: A |
| 288 |
value: |
| 289 |
- 1.1.1.1 |
| 290 |
- 8.8.8.8 |
| 291 |
- prefix: www |
| 292 |
type: AAAA |
| 293 |
value: |
| 294 |
- '::1' |
| 295 |
|
| 296 |
The next example shows how to make sure that only the given records are available and all other records are deleted. Note that for the :ansopt:`community.dns.hetzner_dns_record_sets#module:record_sets[].type=NS` record we used :ansopt:`community.dns.hetzner_dns_record_sets#module:record_sets[].ignore=true`, which allows us to skip the value. It tells the module that it should not touch the ``NS`` record for ``example.com``. |
| 297 |
|
| 298 |
.. code-block:: yaml+jinja |
| 299 |
|
| 300 |
- name: Make sure that multiple records are present |
| 301 |
community.dns.hetzner_dns_record_sets: |
| 302 |
zone_name: example.com |
| 303 |
prune: true |
| 304 |
record_sets: |
| 305 |
- prefix: www |
| 306 |
type: A |
| 307 |
value: |
| 308 |
- 1.1.1.1 |
| 309 |
- 8.8.8.8 |
| 310 |
- prefix: www |
| 311 |
type: AAAA |
| 312 |
value: |
| 313 |
- '::1' |
| 314 |
- prefix: '' |
| 315 |
type: NS |
| 316 |
ignore: true |
| 317 |
|
| 318 |
.. _ansible_collections.community.dns.docsite.hetzner_guide.migration_markuman_hetzner_dns: |
| 319 |
|
| 320 |
Migrating from ``markuman.hetzner_dns`` |
| 321 |
--------------------------------------- |
| 322 |
|
| 323 |
This section describes how to migrate playbooks and roles from using the `markuman.hetzner_dns collection <https://galaxy.ansible.com/ui/repo/published/markuman/hetzner_dns/>`_ to the Hetzner modules and plugins in the ``community.dns`` collection. |
| 324 |
|
| 325 |
There are three steps for migrating. Two of these steps must be done on migration, the third step can also be done later: |
| 326 |
|
| 327 |
1. Replace the modules and plugins used by the new ones. |
| 328 |
2. Adjust module and plugin options if necessary. |
| 329 |
3. Avoid deprecated aliases which ease the transition. |
| 330 |
|
| 331 |
The `markuman.hetzner_dns collection <https://galaxy.ansible.com/ui/repo/published/markuman/hetzner_dns/>`_ collection provides three modules and one inventory plugin. |
| 332 |
|
| 333 |
.. note:: |
| 334 |
|
| 335 |
When working with TXT records, please look at the :ansopt:`community.dns.hetzner_dns_record_set#module:txt_transformation` option. By default, the modules and plugins in this collection use **unquoted** values (you do not have to add double quotes and escape double quotes and backslashes), while the modules and plugins in ``markuman.hetzner_dns`` use partially quoted values. You can switch behavior of the ``community.dns`` modules by passing :ansopt:`community.dns.hetzner_dns_record_set#module:txt_transformation=api` or :ansopt:`community.dns.hetzner_dns_record_set#module:txt_transformation=quoted`. |
| 336 |
|
| 337 |
The markuman.hetzner_dns.record module |
| 338 |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 339 |
|
| 340 |
The ``markuman.hetzner_dns.zone_info`` module can be replaced by the :ansplugin:`community.dns.hetzner_dns_record module <community.dns.hetzner_dns_record#module>` and the :ansplugin:`community.dns.hetzner_dns_record_set module <community.dns.hetzner_dns_record_set#module>`, depending on what it is used for. |
| 341 |
|
| 342 |
When creating, updating or removing single records, the :ansplugin:`community.dns.hetzner_dns_record module <community.dns.hetzner_dns_record#module>` should be used. This is the case when :ansopt:`purge=false` is specified (the default value). Note that :ansopt:`replace`, :ansopt:`overwrite` and :ansopt:`solo` are aliases of :ansopt:`purge`. |
| 343 |
|
| 344 |
.. code-block:: yaml+jinja |
| 345 |
|
| 346 |
# Creating and updating DNS records |
| 347 |
|
| 348 |
- name: Creating or updating a single DNS record with markuman.hetzner_dns |
| 349 |
markuman.hetzner_dns.record: |
| 350 |
zone_name: example.com |
| 351 |
name: localhost |
| 352 |
type: A |
| 353 |
value: 127.0.0.1 |
| 354 |
ttl: 60 |
| 355 |
# This means the module operates on single DNS entries. If not specified, |
| 356 |
# this is the default value: |
| 357 |
purge: false |
| 358 |
|
| 359 |
- name: Creating or updating a single DNS record with community.dns |
| 360 |
community.dns.hetzner_dns_record: |
| 361 |
zone_name: example.com |
| 362 |
# 'state' must always be specified: |
| 363 |
state: present |
| 364 |
# 'name' is a deprecated alias of 'prefix', so it can be |
| 365 |
# kept during a first migration step: |
| 366 |
name: localhost |
| 367 |
# 'type', 'value' and 'ttl' do not change: |
| 368 |
type: A |
| 369 |
value: 127.0.0.1 |
| 370 |
ttl: 60 |
| 371 |
# If type is TXT, you either have to adjust the value you pass, |
| 372 |
# or keep the following option: |
| 373 |
txt_transformation: api |
| 374 |
|
| 375 |
When the ``markuman.hetzner_dns.record`` module is in replace mode, it should be replaced by the :ansplugin:`community.dns.hetzner_dns_record_set module <community.dns.hetzner_dns_record_set#module>`, since then it operates on the *record set* and not just on a single record: |
| 376 |
|
| 377 |
.. code-block:: yaml+jinja |
| 378 |
|
| 379 |
# Creating and updating DNS record sets |
| 380 |
|
| 381 |
- name: Creating or updating a record set with markuman.hetzner_dns |
| 382 |
markuman.hetzner_dns.record: |
| 383 |
zone_name: example.com |
| 384 |
name: localhost |
| 385 |
type: A |
| 386 |
value: 127.0.0.1 |
| 387 |
ttl: 60 |
| 388 |
# This means the module operates on the record set: |
| 389 |
purge: true |
| 390 |
|
| 391 |
- name: Creating or updating a record set with community.dns |
| 392 |
community.dns.hetzner_dns_record_set: |
| 393 |
zone_name: example.com |
| 394 |
# 'state' must always be specified: |
| 395 |
state: present |
| 396 |
# 'name' is a deprecated alias of 'prefix', so it can be |
| 397 |
# kept during a first migration step: |
| 398 |
name: localhost |
| 399 |
# 'type' and 'ttl' do not change: |
| 400 |
type: A |
| 401 |
ttl: 60 |
| 402 |
# 'value' is now a list: |
| 403 |
value: |
| 404 |
- 127.0.0.1 |
| 405 |
# Ansible allows to specify lists as a comma-separated string. |
| 406 |
# So for records which do not contain a comma, you can also |
| 407 |
# keep the old syntax, in this case: |
| 408 |
# |
| 409 |
# value: 127.0.0.1 |
| 410 |
# |
| 411 |
# If type is TXT, you either have to adjust the value you pass, |
| 412 |
# or keep the following option: |
| 413 |
txt_transformation: api |
| 414 |
|
| 415 |
When deleting a record, it depends on whether :ansopt:`value` is specified or not. If :ansopt:`value` is specified, the module is deleting a single DNS record, and the :ansplugin:`community.dns.hetzner_dns_record module <community.dns.hetzner_dns_record#module>` should be used: |
| 416 |
|
| 417 |
.. code-block:: yaml+jinja |
| 418 |
|
| 419 |
# Deleting single DNS records |
| 420 |
|
| 421 |
- name: Deleting a single DNS record with markuman.hetzner_dns |
| 422 |
markuman.hetzner_dns.record: |
| 423 |
zone_name: example.com |
| 424 |
state: absent |
| 425 |
name: localhost |
| 426 |
type: A |
| 427 |
value: 127.0.0.1 |
| 428 |
ttl: 60 |
| 429 |
|
| 430 |
- name: Deleting a single DNS record with community.dns |
| 431 |
community.dns.hetzner_dns_record: |
| 432 |
zone_name: example.com |
| 433 |
state: absent |
| 434 |
# 'name' is a deprecated alias of 'prefix', so it can be |
| 435 |
# kept during a first migration step: |
| 436 |
name: localhost |
| 437 |
# 'type', 'value' and 'ttl' do not change: |
| 438 |
type: A |
| 439 |
value: 127.0.0.1 |
| 440 |
ttl: 60 |
| 441 |
# If type is TXT, you either have to adjust the value you pass, |
| 442 |
# or keep the following option: |
| 443 |
txt_transformation: api |
| 444 |
|
| 445 |
When :ansopt:`value` is not specified, the ``markuman.hetzner_dns.record`` module will delete all records for this prefix and type. In that case, it operates on a record set and the :ansplugin:`community.dns.hetzner_dns_record_set module <community.dns.hetzner_dns_record_set#module>` should be used: |
| 446 |
|
| 447 |
.. code-block:: yaml+jinja |
| 448 |
|
| 449 |
# Deleting multiple DNS records |
| 450 |
|
| 451 |
- name: Deleting multiple DNS records with markuman.hetzner_dns |
| 452 |
markuman.hetzner_dns.record: |
| 453 |
zone_name: example.com |
| 454 |
state: absent |
| 455 |
name: localhost |
| 456 |
type: A |
| 457 |
|
| 458 |
- name: Deleting a single DNS record with community.dns |
| 459 |
community.dns.hetzner_dns_record_set: |
| 460 |
zone_name: example.com |
| 461 |
state: absent |
| 462 |
# 'name' is a deprecated alias of 'prefix', so it can be |
| 463 |
# kept during a first migration step: |
| 464 |
name: localhost |
| 465 |
# 'type' does not change: |
| 466 |
type: A |
| 467 |
|
| 468 |
A last step is replacing the removed alias ``name`` of :ansopt:`community.dns.hetzner_dns_record_set#module:prefix` by :ansopt:`community.dns.hetzner_dns_record_set#module:prefix`. |
| 469 |
|
| 470 |
The markuman.hetzner_dns.record_info module |
| 471 |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 472 |
|
| 473 |
The ``markuman.hetzner_dns.record_info`` module can be replaced by the :ansplugin:`community.dns.hetzner_dns_record_info module <community.dns.hetzner_dns_record_info#module>`. The main difference is that instead of by the :ansopt:`filters` option, the output is controlled by the :ansopt:`community.dns.hetzner_dns_record_info#module:what` option (choices :ansval:`single_record`, :ansval:`all_types_for_record`, and :ansval:`all_records`), the :ansopt:`community.dns.hetzner_dns_record_info#module:type` option (needed when :ansopt:`community.dns.hetzner_dns_record_info#module:what=single_record`), and the :ansopt:`community.dns.hetzner_dns_record_info#module:record` and :ansopt:`community.dns.hetzner_dns_record_info#module:prefix` options (needed when :ansopt:`community.dns.hetzner_dns_record_info#module:what` is not :ansval:`all_records`). |
| 474 |
|
| 475 |
The markuman.hetzner_dns.zone_info module |
| 476 |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 477 |
|
| 478 |
The ``markuman.hetzner_dns.zone_info`` module can be replaced by the :ansplugin:`community.dns.hetzner_dns_zone_info module <community.dns.hetzner_dns_zone_info#module>`. The main differences are: |
| 479 |
|
| 480 |
1. The parameter :ansopt:`name` must be changed to :ansopt:`community.dns.hetzner_dns_zone_info#module:zone_name` or :ansopt:`community.dns.hetzner_dns_zone_info#module:zone`. |
| 481 |
2. The return value :ansretval:`community.dns.hetzner_dns_zone_info#module:zone_info` no longer has the ``name`` and ``id`` entries. Use the return values :ansretval:`community.dns.hetzner_dns_zone_info#module:zone_name` and :ansretval:`community.dns.hetzner_dns_zone_info#module:zone_id` instead. |
| 482 |
|
| 483 |
The markuman.hetzner_dns.inventory inventory plugin |
| 484 |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 485 |
|
| 486 |
The ``markuman.hetzner_dns.inventory`` inventory plugin can be replaced by the :ansplugin:`community.dns.hetzner_dns_records inventory plugin <community.dns.hetzner_dns_records#inventory>`. Besides the plugin name, no change should be necessary. |
| 487 |
|
| 488 |
|
| 489 |
.. _ansible_collections.community.dns.docsite.hetzner_guide.records: |
| 490 |
|
| 491 |
Supported DNS records |
| 492 |
--------------------- |
| 493 |
|
| 494 |
Here you can find a list of supported DNS records together with their syntax for the :ansopt:`value` field: |
| 495 |
|
| 496 |
- **A** records: IPv4 address. |
| 497 |
|
| 498 |
Simply provide the IPv4 address as :ansopt:`value`, such as ``127.0.0.1``. |
| 499 |
- **AAAA** records: IPv6 address. |
| 500 |
|
| 501 |
Simply provide the IPv6 address as :ansopt:`value`, such as ``3fff::1:2``. |
| 502 |
- **CAA** records: Certification Authority Authorization |
| 503 |
|
| 504 |
The record's :ansopt:`value` is of the form ``<flags> <tag> <value>``, |
| 505 |
where ``<flags>`` is an unsigned integer between 0 and 255; |
| 506 |
``<tag>`` is a ASCII string such as ``issue``, ``issuewild``, or ``iodef``; |
| 507 |
and ``<value>`` is the value enclosed in double quotes. |
| 508 |
An example entry is ``0 issue "letsencrypt.org"``. |
| 509 |
The exact syntax is explained in L(Section 4.1.1 of RFC 8659, https://datatracker.ietf.org/doc/html/rfc8659#name-syntax). |
| 510 |
- **CNAME** records: Canonical Name. |
| 511 |
- **DANE** records: DNS-based Authentication of Named Entities. |
| 512 |
- **DS** records: Delegation Signer. |
| 513 |
- **HINFO** records: Host Information. |
| 514 |
- **MX** records: Mail Exchange. |
| 515 |
|
| 516 |
The record's :ansopt:`value` is of the form ``<priority> <hostname>``, |
| 517 |
where ``<priority>`` is an unsigned integer and ``<hostname>`` a DNS hostname. |
| 518 |
- **NS** records: Name Server record. |
| 519 |
|
| 520 |
The record's :ansopt:`value` is the list of DNS names of the authoritative nameservers for this zone. |
| 521 |
- **RP** records: Responsible Person. |
| 522 |
- **SOA** records: Start Of Authority record. |
| 523 |
- **SRV** records: Service locator. |
| 524 |
|
| 525 |
The record's :ansopt:`value` is of the form ``<priority> <weight> <port> <target>``. |
| 526 |
- **TLSA** records: TLSA certificate association. |
| 527 |
|
| 528 |
This record is for DANE. |
| 529 |
- **TXT** records: Text record. |
| 530 |
|
| 531 |
The value is simply a free form text. Its use depends on its context. |