community.dns.hosttech_dns_record_set (2.8.3) — module

Add or delete record sets in Hosttech DNS service

| "added in version" 2.0.0 of community.dns"

Authors: Felix Fontein (@felixfontein)

Install collection

Install with ansible-galaxy collection install community.dns:==2.8.3


Add to requirements.yml

  collections:
    - name: community.dns
      version: 2.8.3

Description

Creates and deletes DNS record sets in Hosttech DNS service.

This module replaces C(hosttech_dns_record) from community.dns before 2.0.0.


Requirements

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Add new.foo.com as an A record with 3 IPs
  community.dns.hosttech_dns_record_set:
    state: present
    zone_name: foo.com
    record: new.foo.com
    type: A
    ttl: 7200
    value: 1.1.1.1,2.2.2.2,3.3.3.3
    hosttech_token: access_token
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Update new.foo.com as an A record with a list of 3 IPs
  community.dns.hosttech_dns_record_set:
    state: present
    zone_name: foo.com
    record: new.foo.com
    type: A
    ttl: 7200
    value:
      - 1.1.1.1
      - 2.2.2.2
      - 3.3.3.3
    hosttech_token: access_token
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Retrieve the details for new.foo.com
  community.dns.hosttech_dns_record_set_info:
    zone_name: foo.com
    record: new.foo.com
    type: A
    hosttech_username: foo
    hosttech_password: bar
  register: rec
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Delete new.foo.com A record using the results from the facts retrieval command
  community.dns.hosttech_dns_record_set:
    state: absent
    zone_name: foo.com
    record: "{{ rec.set.record }}"
    ttl: "{{ rec.set.ttl }}"
    type: "{{ rec.set.type }}"
    value: "{{ rec.set.value }}"
    hosttech_username: foo
    hosttech_password: bar
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Add an AAAA record
  # Note that because there are colons in the value that the IPv6 address must be quoted!
  community.dns.hosttech_dns_record_set:
    state: present
    zone_name: foo.com
    record: localhost.foo.com
    type: AAAA
    ttl: 7200
    value: "::1"
    hosttech_token: access_token
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Add a TXT record
  community.dns.hosttech_dns_record_set:
    state: present
    zone_name: foo.com
    record: localhost.foo.com
    type: TXT
    ttl: 7200
    value: 'bar'
    hosttech_username: foo
    hosttech_password: bar
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Remove the TXT record
  community.dns.hosttech_dns_record_set:
    state: absent
    zone_name: foo.com
    record: localhost.foo.com
    type: TXT
    ttl: 7200
    value: 'bar'
    hosttech_username: foo
    hosttech_password: bar
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Add a CAA record
  community.dns.hosttech_dns_record_set:
    state: present
    zone_name: foo.com
    record: foo.com
    type: CAA
    ttl: 3600
    value:
    - '128 issue "letsencrypt.org"'
    - '128 iodef "mailto:webmaster@foo.com"'
    hosttech_token: access_token
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Add an MX record
  community.dns.hosttech_dns_record_set:
    state: present
    zone_name: foo.com
    record: foo.com
    type: MX
    ttl: 3600
    value:
    - "10 mail.foo.com"
    hosttech_token: access_token
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Add a CNAME record
  community.dns.hosttech_dns_record_set:
    state: present
    zone_name: bla.foo.com
    record: foo.com
    type: CNAME
    ttl: 3600
    value:
    - foo.foo.com
    hosttech_username: foo
    hosttech_password: bar
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Add a PTR record
  community.dns.hosttech_dns_record_set:
    state: present
    zone_name: foo.foo.com
    record: foo.com
    type: PTR
    ttl: 3600
    value:
    - foo.foo.com
    hosttech_token: access_token
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Add an SPF record
  community.dns.hosttech_dns_record_set:
    state: present
    zone_name: foo.com
    record: foo.com
    type: SPF
    ttl: 3600
    value:
    - "v=spf1 a mx ~all"
    hosttech_username: foo
    hosttech_password: bar
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Add a PTR record
  community.dns.hosttech_dns_record_set:
    state: present
    zone_name: foo.com
    record: foo.com
    type: PTR
    ttl: 3600
    value:
    - "10 100 3333 service.foo.com"
    hosttech_token: access_token

Inputs

    
ttl:
    default: 3600
    description:
    - The TTL to give the new record, in seconds.
    type: int

type:
    choices:
    - A
    - AAAA
    - CAA
    - CNAME
    - MX
    - NS
    - PTR
    - SPF
    - SRV
    - TXT
    description:
    - The type of DNS record to create or delete.
    required: true
    type: str

state:
    choices:
    - present
    - absent
    description:
    - Specifies the state of the resource record.
    required: true
    type: str

value:
    description:
    - The new value when creating a DNS record.
    - YAML lists or multiple comma-spaced values are allowed.
    - When deleting a record all values for the record must be specified or it will not
      be deleted.
    - Must be specified if O(state=present) or when O(on_existing) is not V(replace).
    - Will be ignored if O(state=absent) and O(on_existing=replace).
    elements: str
    type: list

prefix:
    description:
    - The prefix of the DNS record.
    - This is the part of O(record) before O(zone_name). For example, if the record to
      be modified is C(www.example.com) for the zone C(example.com), the prefix is V(www).
      If the record in this example would be C(example.com), the prefix would be V('')
      (empty string).
    - Exactly one of O(record) and O(prefix) must be specified.
    type: str
    version_added: 0.2.0
    version_added_collection: community.dns

record:
    description:
    - The full DNS record to create or delete.
    - Exactly one of O(record) and O(prefix) must be specified.
    type: str

zone_id:
    description:
    - The ID of the DNS zone to modify.
    - Exactly one of O(zone_name) and O(zone_id) must be specified.
    type: int
    version_added: 0.2.0
    version_added_collection: community.dns

zone_name:
    aliases:
    - zone
    description:
    - The DNS zone to modify.
    - Exactly one of O(zone_name) and O(zone_id) must be specified.
    type: str

on_existing:
    choices:
    - replace
    - keep_and_fail
    - keep_and_warn
    - keep
    default: replace
    description:
    - This option defines the behavior if the record set already exists, but differs from
      the specified record set. For this comparison, O(value) and O(ttl) are used for
      all records of type O(type) matching the O(prefix) resp. O(record).
    - If set to V(replace), the record will be updated (O(state=present)) or removed (O(state=absent)).
      This is the old O(ignore:overwrite=true) behavior.
    - If set to V(keep_and_fail), the module will fail and not modify the records. This
      is the old O(ignore:overwrite=false) behavior if O(state=present).
    - If set to V(keep_and_warn), the module will warn and not modify the records.
    - If set to V(keep), the module will not modify the records. This is the old O(ignore:overwrite=false)
      behavior if O(state=absent).
    - If O(state=absent) and the value is not V(replace), O(value) must be specified.
    type: str

hosttech_token:
    aliases:
    - api_token
    description:
    - The password for the Hosttech API user.
    - Mutually exclusive with O(hosttech_username) and O(hosttech_password).
    - Since community.dns 1.2.0, the alias O(ignore:api_token) can be used.
    type: str
    version_added: 0.2.0
    version_added_collection: community.dns

hosttech_password:
    description:
    - The password for the Hosttech API user.
    - If provided, O(hosttech_username) must also be provided.
    - Mutually exclusive with O(hosttech_token).
    type: str

hosttech_username:
    description:
    - The username for the Hosttech API user.
    - If provided, O(hosttech_password) must also be provided.
    - Mutually exclusive with O(hosttech_token).
    type: str

txt_transformation:
    choices:
    - api
    - quoted
    - unquoted
    default: unquoted
    description:
    - Determines how TXT entry values are converted between the API and this module's
      input and output.
    - The value V(api) means that values are returned from this module as they are returned
      from the API, and pushed to the API as they have been passed to this module. For
      idempotency checks, the input string will be compared to the strings returned by
      the API. The API might automatically transform some values, like splitting long
      values or adding quotes, which can cause problems with idempotency.
    - The value V(unquoted) automatically transforms values so that you can pass in unquoted
      values, and the module will return unquoted values. If you pass in quoted values,
      they will be double-quoted.
    - The value V(quoted) automatically transforms values so that you must use quoting
      for values that contain spaces, characters such as quotation marks and backslashes,
      and that are longer than 255 bytes. It also makes sure to return values from the
      API in a normalized encoding.
    - The default value, V(unquoted), ensures that you can work with values without having
      to care about how to correctly quote for DNS. Most users should use one of V(unquoted)
      or V(quoted), but not V(api).
    - B(Note:) the conversion code assumes UTF-8 encoding for values. If you need another
      encoding use O(txt_transformation=api) and handle the encoding yourself.
    type: str

txt_character_encoding:
    choices:
    - decimal
    - octal
    description:
    - Whether to treat numeric escape sequences (V(\\xyz)) as octal or decimal numbers.
      This is only used when O(txt_transformation=quoted).
    - The current default is V(octal) which is deprecated. It will change to V(decimal)
      in community.dns 3.0.0. The value V(decimal) is compatible to L(RFC 1035, https://www.ietf.org/rfc/rfc1035.txt).
    type: str
    version_added: 2.5.0
    version_added_collection: community.dns

Outputs

zone_id:
  description: The ID of the zone.
  returned: success
  sample: 23
  type: int
  version_added: 0.2.0
  version_added_collection: community.dns