Debian Codegraph @

ansible_collections/community/general/plugins/modules/django_createcachetable.py

raw
1 #!/usr/bin/python
2 # Copyright (c) 2024, Alexei Znamensky <[email protected]>
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
6 from __future__ import annotations
7
8 DOCUMENTATION = r"""
9 module: django_createcachetable
10 author:
11 - Alexei Znamensky (@russoz)
12 short_description: Wrapper for C(django-admin createcachetable)
13 version_added: 9.1.0
14 description:
15 - This module is a wrapper for the execution of C(django-admin createcachetable).
16 extends_documentation_fragment:
17 - community.general._attributes
18 - community.general._django
19 - community.general._django.database
20 attributes:
21 check_mode:
22 support: full
23 diff_mode:
24 support: none
25 """
26
27 EXAMPLES = r"""
28 - name: Create cache table in the default database
29 community.general.django_createcachetable:
30 settings: myproject.settings
31
32 - name: Create cache table in the other database
33 community.general.django_createcachetable:
34 database: myotherdb
35 settings: fancysite.settings
36 pythonpath: /home/joedoe/project/fancysite
37 venv: /home/joedoe/project/fancysite/venv
38 """
39
40 RETURN = r"""
41 run_info:
42 description: Command-line execution information.
43 type: dict
44 returned: success and O(verbosity) >= 3
45 version:
46 description: Version of Django.
47 type: str
48 returned: always
49 sample: 5.1.2
50 version_added: 10.0.0
51 """
52
53 from ansible_collections.community.general.plugins.module_utils._django import DjangoModuleHelper
54
55
56 class DjangoCreateCacheTable(DjangoModuleHelper):
57 module = dict(
58 supports_check_mode=True,
59 )
60 django_admin_cmd = "createcachetable"
61 django_admin_arg_order = "noinput database_dash dry_run"
62 _django_args = ["database_dash"]
63 _check_mode_arg = "dry_run"
64
65 def __init_module__(self):
66 self.vars.set("database_dash", self.vars.database, output=False)
67
68
69 def main():
70 DjangoCreateCacheTable.execute()
71
72
73 if __name__ == "__main__":
74 main()