community.dns.adguardhome_rewrite module – Add, update or delete DNS rewrite rules from AdGuardHome

Note

This module is part of the community.dns collection (version 3.3.0).

It is not included in ansible-core. To check whether it is installed, run ansible-galaxy collection list.

To install it, use: ansible-galaxy collection install community.dns.

To use it in a playbook, specify: community.dns.adguardhome_rewrite.

New in community.dns 3.3.0

Synopsis

  • Add, update or delete DNS rewrite rules from AdGuardHome.

Parameters

Parameter

Comments

answer

string

Value for the domain rewrite.

Required when state=present.

Value can be a CNAME, A or AAAA record.

domain

string / required

Domain or wildcard domain that you want to be rewritten by AdGuardHome.

host

string / required

URL of AdGuardHome host.

For example, https://my-adguard.my-domain or http://192.168.1.2.

password

string / required

Related password for the AdGuardHome user.

state

string

Wether a rewrite rule should be added/updated (state=present) or removed (state=absent).

Choices:

  • "present" ← (default)

  • "absent"

username

string / required

AdGuardHome user.

validate_certs

boolean

Ability to disable TLS certificate validation.

This should only set to false when the network path between the host the module is run on and the AdGuard host is fully under your control and trusted.

Choices:

  • false

  • true ← (default)

Attributes

Attribute

Support

Description

check_mode

Support: full

Can run in check_mode and return changed status prediction without modifying target.

diff_mode

Support: full

Will return details on what has changed (or possibly needs changing in check_mode), when in diff mode.

idempotent

Support: full

When run twice in a row outside check mode, with the same arguments, the second invocation indicates no change.

This assumes that the system controlled/queried by the module has not changed in a relevant way.

Examples

- name: Add DNS rewrite rule in AdGuardHome
  community.dns.adguardhome_rewrite:
    state: present
    answer: 127.0.0.1
    domain: example.org

# When removing a rewrite, the current answer value must also match.
# Therefore you can just leave it out and the existing value
# will be used.
- name: Remove rewrite for example.org
  community.dns.adguardhome_rewrite:
    state: absent
    domain: example.org

Return Values

Common return values are documented here, the following are the fields unique to this module:

Key

Description

rules

list / elements=dictionary

The modified list of rewrite rules afte rewrite rule is applied.

Returned: success

answer

string

Value of the rewrite.

Returned: success

Sample: "192.168.178.71"

domain

string

Domain of the rewrite.

Returned: success

Sample: "dns.osuv.de"

Authors

  • Markus Bergholz (@markuman)