mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-10-03 06:53:21 -07:00
django_dumpdata, django_loaddata: new modules (#10726)
Some checks failed
EOL CI / EOL Sanity (Ⓐ2.16) (push) Has been cancelled
EOL CI / EOL Units (Ⓐ2.16+py2.7) (push) Has been cancelled
EOL CI / EOL Units (Ⓐ2.16+py3.11) (push) Has been cancelled
EOL CI / EOL Units (Ⓐ2.16+py3.6) (push) Has been cancelled
EOL CI / EOL I (Ⓐ2.16+alpine3+py:azp/posix/1/) (push) Has been cancelled
EOL CI / EOL I (Ⓐ2.16+alpine3+py:azp/posix/2/) (push) Has been cancelled
EOL CI / EOL I (Ⓐ2.16+alpine3+py:azp/posix/3/) (push) Has been cancelled
EOL CI / EOL I (Ⓐ2.16+fedora38+py:azp/posix/1/) (push) Has been cancelled
EOL CI / EOL I (Ⓐ2.16+fedora38+py:azp/posix/2/) (push) Has been cancelled
EOL CI / EOL I (Ⓐ2.16+fedora38+py:azp/posix/3/) (push) Has been cancelled
EOL CI / EOL I (Ⓐ2.16+opensuse15+py:azp/posix/1/) (push) Has been cancelled
EOL CI / EOL I (Ⓐ2.16+opensuse15+py:azp/posix/2/) (push) Has been cancelled
EOL CI / EOL I (Ⓐ2.16+opensuse15+py:azp/posix/3/) (push) Has been cancelled
nox / Run extra sanity tests (push) Has been cancelled
Some checks failed
EOL CI / EOL Sanity (Ⓐ2.16) (push) Has been cancelled
EOL CI / EOL Units (Ⓐ2.16+py2.7) (push) Has been cancelled
EOL CI / EOL Units (Ⓐ2.16+py3.11) (push) Has been cancelled
EOL CI / EOL Units (Ⓐ2.16+py3.6) (push) Has been cancelled
EOL CI / EOL I (Ⓐ2.16+alpine3+py:azp/posix/1/) (push) Has been cancelled
EOL CI / EOL I (Ⓐ2.16+alpine3+py:azp/posix/2/) (push) Has been cancelled
EOL CI / EOL I (Ⓐ2.16+alpine3+py:azp/posix/3/) (push) Has been cancelled
EOL CI / EOL I (Ⓐ2.16+fedora38+py:azp/posix/1/) (push) Has been cancelled
EOL CI / EOL I (Ⓐ2.16+fedora38+py:azp/posix/2/) (push) Has been cancelled
EOL CI / EOL I (Ⓐ2.16+fedora38+py:azp/posix/3/) (push) Has been cancelled
EOL CI / EOL I (Ⓐ2.16+opensuse15+py:azp/posix/1/) (push) Has been cancelled
EOL CI / EOL I (Ⓐ2.16+opensuse15+py:azp/posix/2/) (push) Has been cancelled
EOL CI / EOL I (Ⓐ2.16+opensuse15+py:azp/posix/3/) (push) Has been cancelled
nox / Run extra sanity tests (push) Has been cancelled
* django module, module_utils: adjustments * more fixes * more fixes * further simplification * django_dumpdata/django_loaddata: new modules * Update plugins/modules/django_dumpdata.py Co-authored-by: Felix Fontein <felix@fontein.de> * add note about idempotency --------- Co-authored-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
parent
aed763dae7
commit
d0123a1038
9 changed files with 364 additions and 4 deletions
92
plugins/modules/django_loaddata.py
Normal file
92
plugins/modules/django_loaddata.py
Normal file
|
@ -0,0 +1,92 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright (c) 2025, Alexei Znamensky <russoz@gmail.com>
|
||||
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
from __future__ import absolute_import, division, print_function
|
||||
__metaclass__ = type
|
||||
|
||||
DOCUMENTATION = r"""
|
||||
module: django_loaddata
|
||||
author:
|
||||
- Alexei Znamensky (@russoz)
|
||||
short_description: Wrapper for C(django-admin loaddata)
|
||||
version_added: 11.3.0
|
||||
description:
|
||||
- This module is a wrapper for the execution of C(django-admin loaddata).
|
||||
extends_documentation_fragment:
|
||||
- community.general.attributes
|
||||
- community.general.django
|
||||
- community.general.django.database
|
||||
- community.general.django.data
|
||||
attributes:
|
||||
check_mode:
|
||||
support: none
|
||||
diff_mode:
|
||||
support: none
|
||||
options:
|
||||
app:
|
||||
description: Specifies a single app to look for fixtures in rather than looking in all apps.
|
||||
type: str
|
||||
ignore_non_existent:
|
||||
description: Ignores fields and models that may have been removed since the fixture was originally generated.
|
||||
type: bool
|
||||
fixtures:
|
||||
description:
|
||||
- List of paths to the fixture files.
|
||||
type: list
|
||||
elements: path
|
||||
"""
|
||||
|
||||
EXAMPLES = r"""
|
||||
- name: Dump all data
|
||||
community.general.django_dumpdata:
|
||||
settings: myproject.settings
|
||||
|
||||
- name: Create cache table in the other database
|
||||
community.general.django_createcachetable:
|
||||
database: myotherdb
|
||||
settings: fancysite.settings
|
||||
pythonpath: /home/joedoe/project/fancysite
|
||||
venv: /home/joedoe/project/fancysite/venv
|
||||
"""
|
||||
|
||||
RETURN = r"""
|
||||
run_info:
|
||||
description: Command-line execution information.
|
||||
type: dict
|
||||
returned: success and O(verbosity) >= 3
|
||||
version:
|
||||
description: Version of Django.
|
||||
type: str
|
||||
returned: always
|
||||
sample: 5.1.2
|
||||
"""
|
||||
|
||||
from ansible_collections.community.general.plugins.module_utils.django import DjangoModuleHelper
|
||||
|
||||
|
||||
class DjangoLoadData(DjangoModuleHelper):
|
||||
module = dict(
|
||||
argument_spec=dict(
|
||||
app=dict(type="str"),
|
||||
ignore_non_existent=dict(type="bool"),
|
||||
fixtures=dict(type="list", elements="path"),
|
||||
),
|
||||
supports_check_mode=False,
|
||||
)
|
||||
django_admin_cmd = "loaddata"
|
||||
django_admin_arg_order = "database_dash ignore_non_existent app format excludes fixtures"
|
||||
_django_args = ["data", "database_dash"]
|
||||
|
||||
def __init_module__(self):
|
||||
self.vars.set("database_dash", self.vars.database, output=False)
|
||||
|
||||
|
||||
def main():
|
||||
DjangoLoadData.execute()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
Loading…
Add table
Add a link
Reference in a new issue