Debian Codegraph @

ansible_collections/community/dns/plugins/modules/adguardhome_rewrite_info.py

raw
1 #!/usr/bin/python
2 # Copyright (c) 2025 Markus Bergholz
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 from __future__ import annotations
6
7 DOCUMENTATION = r"""
8 module: adguardhome_rewrite_info
9
10 short_description: Retrieve DNS rewrite rules from AdGuardHome
11
12 version_added: 3.3.0
13
14 description:
15 - Retrieves DNS rewrite rules from AdGuardHome.
16 extends_documentation_fragment:
17 - community.dns._adguardhome.connectivity
18 - community.dns._attributes
19 - community.dns._attributes.info_module
20 - community.dns._attributes.idempotent_not_modify_state
21
22 author:
23 - Markus Bergholz (@markuman) <[email protected]>
24 """
25
26 EXAMPLES = r"""
27 - name: Get DNS rewrites from AdGuardHome
28 register: rewrite
29 community.dns.adguardhome_rewrite_info:
30 username: admin
31 password: admin
32 host: https://dns.osuv.de
33
34 - name: Display the rewrite rules
35 debug:
36 var: rewrite
37 """
38
39 RETURN = r"""
40 rules:
41 description: The list of fetched rewrite rules.
42 type: list
43 elements: dict
44 returned: success
45 contains:
46 answer:
47 description: Value of the rewrite.
48 type: str
49 sample: 192.168.178.71
50 domain:
51 description: Domain of the rewrite.
52 type: str
53 sample: dns.osuv.de
54 """
55
56 from ansible.module_utils.basic import AnsibleModule
57
58 from ansible_collections.community.dns.plugins.module_utils._adguardhome.api import (
59 AdGuardHomeAPIHandler,
60 create_adguardhome_argument_spec,
61 )
62
63
64 def main() -> None:
65 argument_spec = create_adguardhome_argument_spec()
66 module = AnsibleModule(supports_check_mode=True, **argument_spec.to_kwargs())
67
68 adguardhome = AdGuardHomeAPIHandler(module.params, module.fail_json)
69
70 result = {"changed": False, "rules": adguardhome.list()}
71
72 module.exit_json(**result)
73
74
75 if __name__ == "__main__":
76 main()