mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
(cherry picked from commit 3d19e15a7d
)
Co-authored-by: Mikhail Khvoinitsky <m-khvoinitsky@users.noreply.github.com>
This commit is contained in:
parent
d7c4849473
commit
25474f657a
2 changed files with 8 additions and 3 deletions
|
@ -0,0 +1,2 @@
|
||||||
|
bugfixes:
|
||||||
|
- django_manage - fix idempotence for ``createcachetable`` (https://github.com/ansible-collections/community.general/pull/699).
|
|
@ -164,8 +164,8 @@ def _ensure_virtualenv(module):
|
||||||
os.environ["VIRTUAL_ENV"] = venv_param
|
os.environ["VIRTUAL_ENV"] = venv_param
|
||||||
|
|
||||||
|
|
||||||
def createcachetable_filter_output(line):
|
def createcachetable_check_changed(output):
|
||||||
return "Already exists" not in line
|
return "already exists" not in output
|
||||||
|
|
||||||
|
|
||||||
def flush_filter_output(line):
|
def flush_filter_output(line):
|
||||||
|
@ -282,7 +282,7 @@ def main():
|
||||||
rc, out, err = module.run_command(cmd, cwd=app_path)
|
rc, out, err = module.run_command(cmd, cwd=app_path)
|
||||||
if rc != 0:
|
if rc != 0:
|
||||||
if command == 'createcachetable' and 'table' in err and 'already exists' in err:
|
if command == 'createcachetable' and 'table' in err and 'already exists' in err:
|
||||||
out = 'Already exists.'
|
out = 'already exists.'
|
||||||
else:
|
else:
|
||||||
if "Unknown command:" in err:
|
if "Unknown command:" in err:
|
||||||
_fail(module, cmd, err, "Unknown django command: %s" % command)
|
_fail(module, cmd, err, "Unknown django command: %s" % command)
|
||||||
|
@ -296,6 +296,9 @@ def main():
|
||||||
filtered_output = list(filter(filt, lines))
|
filtered_output = list(filter(filt, lines))
|
||||||
if len(filtered_output):
|
if len(filtered_output):
|
||||||
changed = True
|
changed = True
|
||||||
|
check_changed = globals().get("{0}_check_changed".format(command), None)
|
||||||
|
if check_changed:
|
||||||
|
changed = check_changed(out)
|
||||||
|
|
||||||
module.exit_json(changed=changed, out=out, cmd=cmd, app_path=app_path, virtualenv=virtualenv,
|
module.exit_json(changed=changed, out=out, cmd=cmd, app_path=app_path, virtualenv=virtualenv,
|
||||||
settings=module.params['settings'], pythonpath=module.params['pythonpath'])
|
settings=module.params['settings'], pythonpath=module.params['pythonpath'])
|
||||||
|
|
Loading…
Add table
Reference in a new issue