Debian Codegraph @

ansible_collections/community/proxmox/plugins/modules/proxmox_acme_plugins_info.py

raw
1 #!/usr/bin/python
2
3 # Copyright (c) 2026, Clément Cruau (@PendaGTP) <[email protected]>
4 # GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
5 # SPDX-License-Identifier: GPL-3.0-or-later
6
7
8 DOCUMENTATION = r"""
9 module: proxmox_acme_plugins_info
10 short_description: Retrieves the list of ACME plugins.
11 version_added: "2.0.0"
12 author:
13 - Clément Cruau (@PendaGTP)
14 description:
15 - Retrieves the list of ACME plugins.
16 attributes:
17 check_mode:
18 support: full
19 diff_mode:
20 support: none
21 options:
22 type:
23 description:
24 - ACME challenge type.
25 choices:
26 - dns
27 - standalone
28 type: str
29 aliases: ["plugin_type"]
30
31 seealso:
32 - module: community.proxmox.proxmox_acme_plugin_dns
33 description: Manage ACME DNS plugins on a Proxmox VE.
34 - module: community.proxmox.proxmox_acme_plugin_info
35 description: Retrieves a single ACME plugin
36
37 extends_documentation_fragment:
38 - community.proxmox.proxmox.actiongroup_proxmox
39 - community.proxmox.proxmox.documentation
40 - community.proxmox.attributes
41 """
42
43 EXAMPLES = r"""
44 - name: List ACME plugins
45 community.proxmox.proxmox_acme_plugins_info:
46 """
47
48 RETURN = r"""
49 plugins:
50 description: List of ACME plugins.
51 returned: on success
52 type: list
53 elements: dict
54 contains:
55 name:
56 description: ACME plugin instance identifier.
57 returned: on success
58 type: str
59 type:
60 description: ACME challenge type (dns, standalone).
61 returned: on success
62 type: str
63 plugin:
64 description: API implementation name.
65 returned: on success
66 type: str
67 data:
68 description: Plugin settings as string key/value pairs (values are masked).
69 returned: on success
70 type: dict
71 disable:
72 description: Whether the plugin configuration is disabled.
73 returned: on success
74 type: bool
75 validation_delay:
76 description: Validation delay in seconds.
77 returned: on success
78 type: int
79 digest:
80 description: Digest of the plugin configuration.
81 returned: on success
82 type: str
83 """
84
85 from ansible.module_utils.common.text.converters import to_native
86
87 from ansible_collections.community.proxmox.plugins.module_utils.proxmox import (
88 ProxmoxAnsible,
89 create_proxmox_module,
90 )
91 from ansible_collections.community.proxmox.plugins.module_utils.proxmox_acme_plugin import (
92 acme_plugin_to_ansible_result,
93 )
94
95
96 def module_args():
97 return dict(
98 type=dict(type="str", aliases=["plugin_type"], choices=["dns", "standalone"]),
99 )
100
101
102 def module_options():
103 return dict()
104
105
106 class ProxmoxClusterAcmePluginInfoAnsible(ProxmoxAnsible):
107 def __init__(self, module):
108 super().__init__(module)
109 self.params = module.params
110
111 def run(self):
112 plugin_type = self.params.get("type")
113 data = self._fetch_plugins(plugin_type)
114 result = []
115 for plugin in data:
116 result.append(acme_plugin_to_ansible_result(plugin))
117 self.module.exit_json(changed=False, plugins=result)
118
119 def _fetch_plugins(self, plugin_type):
120 try:
121 return self.proxmox_api.cluster().acme().plugins().get(type=plugin_type)
122 except Exception as e:
123 self.module.fail_json(msg=f"Failed to list ACME plugins: {to_native(e)}")
124
125
126 def main():
127 module = create_proxmox_module(module_args(), **module_options())
128 proxmox = ProxmoxClusterAcmePluginInfoAnsible(module)
129
130 try:
131 proxmox.run()
132 except Exception as e:
133 module.fail_json(msg=f"An error occurred: {to_native(e)}")
134
135
136 if __name__ == "__main__":
137 main()