community.dns.hosttech_dns_records (1.2.3) — module

Bulk synchronize DNS records in Hosttech DNS service

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

Authors: Felix Fontein (@felixfontein)

Install collection

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


Add to requirements.yml

  collections:
    - name: community.dns
      version: 1.2.3

Description

Bulk synchronize DNS records in Hosttech DNS service.

It is possible to ignore certain records by specifying I(ignore: true) for that record.

The module allows to set, modify and delete multiple DNS records at once.

With the I(purge) option, it is also possible to delete existing records that are not mentioned in the module parameters. With this, it is possible to synchronize the expected state of a DNS zone with the expected state.


Requirements

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Make sure some records exist and have the expected values
  community.dns.hosttech_dns_records:
    zone: foo.com
    records:
      - prefix: new
        type: A
        ttl: 7200
        value:
          - 1.1.1.1
          - 2.2.2.2
      - prefix: new
        type: AAAA
        ttl: 7200
        value:
          - "::1"
      - zone: foo.com
        type: TXT
        value:
          - test
    hosttech_token: access_token
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Synchronize DNS zone with a fixed set of records
  # If a record exists that is not mentioned here, it will be deleted
  community.dns.hosttech_dns_records:
    zone_id: 23
    purge: true
    records:
      - prefix: ''
        type: A
        value: 127.0.0.1
      - prefix: ''
        type: AAAA
        value: "::1"
      - prefix: ''
        type: NS
        value:
          - ns-1.hoster.com
          - ns-2.hoster.com
          - ns-3.hoster.com
    hosttech_token: access_token

Inputs

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

prune:
    default: false
    description:
    - If set to C(true), will remove all existing records in the zone that are not listed
      in I(records).
    type: bool

records:
    description:
    - The records that should be present in the zone.
    elements: dict
    required: true
    suboptions:
      ignore:
        default: false
        description:
        - If set to C(true), I(value) will be ignored.
        - This is useful when I(prune=true), but you do not want certain entries to be
          removed without having to know their current value.
        type: bool
      prefix:
        description:
        - The prefix of the DNS record.
        - This is the part of I(record) before I(zone). For example, if the record to
          be modified is C(www.example.com) for the zone C(example.com), the prefix is
          C(www). If the record in this example would be C(example.com), the prefix would
          be C('') (empty string).
        - Exactly one of I(record) and I(prefix) must be specified.
        type: str
      record:
        description:
        - The full DNS record to create or delete.
        - Exactly one of I(record) and I(prefix) must be specified.
        type: str
      ttl:
        default: 3600
        description:
        - The TTL to give the new record, in seconds.
        type: int
      type:
        choices:
        - A
        - CNAME
        - MX
        - AAAA
        - TXT
        - PTR
        - SRV
        - SPF
        - NS
        - CAA
        description:
        - The type of DNS record to create or delete.
        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 I(ignore=false).
        elements: str
        type: list
    type: list

zone_id:
    description:
    - The ID of the DNS zone to modify.
    - Exactly one of I(zone) and I(zone_id) must be specified.
    type: int

hosttech_token:
    aliases:
    - api_token
    description:
    - The password for the Hosttech API user.
    - Mutually exclusive with I(hosttech_username) and I(hosttech_password).
    - Since community.dns 1.2.0, the alias I(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, I(hosttech_username) must also be provided.
    - Mutually exclusive with I(hosttech_token).
    type: str

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

Outputs

zone_id:
  description: The ID of the zone.
  returned: success
  sample: 23
  type: int