felixfontein.hosttech_dns.hosttech_dns_record – Add or delete entries in Hosttech DNS service

Note

This plugin is part of the felixfontein.hosttech_dns collection (version 1.2.0).

To install it use: ansible-galaxy collection install felixfontein.hosttech_dns.

To use it in a playbook, specify: felixfontein.hosttech_dns.hosttech_dns_record.

New in version 1.0.0: of felixfontein.hosttech_dns

Synopsis

Requirements

The below requirements are needed on the host that executes this module.

  • lxml

Parameters

Parameter Choices/Defaults Comments
hosttech_password
string / required
The password for the Hosttech API user.
hosttech_username
string / required
The username for the Hosttech API user.
overwrite
boolean
    Choices:
  • no ←
  • yes
Whether an existing record should be overwritten on create if values do not match.
record
string / required
The full DNS record to create or delete.
state
string / required
    Choices:
  • present
  • absent
Specifies the state of the resource record.
ttl
integer
Default:
3600
The TTL to give the new record, in seconds.
type
string / required
    Choices:
  • A
  • CNAME
  • MX
  • AAAA
  • TXT
  • PTR
  • SRV
  • SPF
  • NS
  • CAA
The type of DNS record to create or delete.
value
list / elements=string / required
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.
zone
string / required
The DNS zone to modify.

Notes

Note

  • Supports check_mode and --diff.

Examples

- name: Add new.foo.com as an A record with 3 IPs
  felixfontein.hosttech_dns.hosttech_dns_record:
    state: present
    zone: foo.com
    record: new.foo.com
    type: A
    ttl: 7200
    value: 1.1.1.1,2.2.2.2,3.3.3.3
    hosttech_username: foo
    hosttech_password: bar

- name: Update new.foo.com as an A record with a list of 3 IPs
  felixfontein.hosttech_dns.hosttech_dns_record:
    state: present
    zone: foo.com
    record: new.foo.com
    type: A
    ttl: 7200
    value:
      - 1.1.1.1
      - 2.2.2.2
      - 3.3.3.3
    hosttech_username: foo
    hosttech_password: bar

- name: Retrieve the details for new.foo.com
  felixfontein.hosttech_dns.hosttech_dns_record_info:
    zone: foo.com
    record: new.foo.com
    type: A
    hosttech_username: foo
    hosttech_password: bar
  register: rec

- name: Delete new.foo.com A record using the results from the facts retrieval command
  felixfontein.hosttech_dns.hosttech_dns_record:
    state: absent
    zone: foo.com
    record: "{{ rec.set.record }}"
    ttl: "{{ rec.set.ttl }}"
    type: "{{ rec.set.type }}"
    value: "{{ rec.set.value }}"
    hosttech_username: foo
    hosttech_password: bar

- name: Add an AAAA record
  # Note that because there are colons in the value that the IPv6 address must be quoted!
  felixfontein.hosttech_dns.hosttech_dns_record:
    state: present
    zone: foo.com
    record: localhost.foo.com
    type: AAAA
    ttl: 7200
    value: "::1"
    hosttech_username: foo
    hosttech_password: bar

- name: Add a TXT record
  felixfontein.hosttech_dns.hosttech_dns_record:
    state: present
    zone: foo.com
    record: localhost.foo.com
    type: TXT
    ttl: 7200
    value: 'bar'
    hosttech_username: foo
    hosttech_password: bar

- name: Remove the TXT record
  felixfontein.hosttech_dns.hosttech_dns_record:
    state: absent
    zone: foo.com
    record: localhost.foo.com
    type: TXT
    ttl: 7200
    value: 'bar'
    hosttech_username: foo
    hosttech_password: bar

- name: Add a CAA record
  felixfontein.hosttech_dns.hosttech_dns_record:
    state: present
    zone: foo.com
    record: foo.com
    type: CAA
    ttl: 3600
    value:
    - "128 issue letsencrypt.org"
    - "128 iodef mailto:webmaster@foo.com"
    hosttech_username: foo
    hosttech_password: bar

- name: Add an MX record
  felixfontein.hosttech_dns.hosttech_dns_record:
    state: present
    zone: foo.com
    record: foo.com
    type: MX
    ttl: 3600
    value:
    - "10 mail.foo.com"
    hosttech_username: foo
    hosttech_password: bar

- name: Add a CNAME record
  felixfontein.hosttech_dns.hosttech_dns_record:
    state: present
    zone: bla.foo.com
    record: foo.com
    type: CNAME
    ttl: 3600
    value:
    - foo.foo.com
    hosttech_username: foo
    hosttech_password: bar

- name: Add a PTR record
  felixfontein.hosttech_dns.hosttech_dns_record:
    state: present
    zone: foo.foo.com
    record: foo.com
    type: PTR
    ttl: 3600
    value:
    - foo.foo.com
    hosttech_username: foo
    hosttech_password: bar

- name: Add an SPF record
  felixfontein.hosttech_dns.hosttech_dns_record:
    state: present
    zone: foo.com
    record: foo.com
    type: SPF
    ttl: 3600
    value:
    - "v=spf1 a mx ~all"
    hosttech_username: foo
    hosttech_password: bar

- name: Add a PTR record
  felixfontein.hosttech_dns.hosttech_dns_record:
    state: present
    zone: foo.com
    record: foo.com
    type: PTR
    ttl: 3600
    value:
    - "10 100 3333 service.foo.com"
    hosttech_username: foo
    hosttech_password: bar

Authors

  • Felix Fontein (@felixfontein)