Make docker_stack adhere to standard ansible return values (#63467)

* Make docker_stack adhere to standard return values

The names of the various fields returned from ansible modules are e.g defined here https://docs.ansible.com/ansible/latest/reference_appendices/common_return_values.html#msg.

Adhering to this improves usability and makes use of functionality for e.g stdout_lines etc.

* Update lib/ansible/modules/cloud/docker/docker_stack.py

Co-Authored-By: Felix Fontein <felix@fontein.de>

* Fix under-indentation of continuation line (pep8)

Issue exposed in test here https://app.shippable.com/github/ansible/ansible/runs/146667/1/console

* Don't break old playbooks/roles

Made sure the changes are only adding new variables, not removing anything existing yet.

* Added comment

* Minor fixes

* Update lib/ansible/modules/cloud/docker/docker_stack.py

Co-Authored-By: Felix Fontein <felix@fontein.de>

* Update lib/ansible/modules/cloud/docker/docker_stack.py

Co-Authored-By: Felix Fontein <felix@fontein.de>

* minor change to docker_stack.py

* Add changelog fragment for PR 63467

* Format changelog fragment

Co-Authored-By: Felix Fontein <felix@fontein.de>

* Add fragment about docker_stack return val depr

* Add docker_stack doc note about deprecated vals

* Remove whitespace in empty line

* Add docker_stack depr notice to porting guide

* Update changelogs/fragments/63467-docker-stack-return-fix.yml

Co-Authored-By: Felix Fontein <felix@fontein.de>

* Update docs/docsite/rst/porting_guides/porting_guide_2.10.rst

Co-Authored-By: Felix Fontein <felix@fontein.de>

* Update lib/ansible/modules/cloud/docker/docker_stack.py

Co-Authored-By: Felix Fontein <felix@fontein.de>

* Added back a missing new line

(cherry picked from commit a5d69f2a26)
pull/66383/head
parmsib 5 years ago committed by Matt Clay
parent b148d06bda
commit 636f26f07e

@ -0,0 +1,2 @@
minor_changes:
- docker_stack - Added ``stdout``, ``stderr``, and ``rc`` to return values.

@ -261,8 +261,9 @@ def main():
if rc != 0:
module.fail_json(msg="docker stack up deploy command failed",
out=out,
rc=rc, err=err)
rc=rc,
out=out, err=err,
stdout=out, stderr=err)
before_after_differences = json_diff(before_stack_services,
after_stack_services)
@ -274,10 +275,17 @@ def main():
before_after_differences.pop(k)
if not before_after_differences:
module.exit_json(changed=False)
module.exit_json(
changed=False,
rc=rc,
stdout=out,
stderr=err)
else:
module.exit_json(
changed=True,
rc=rc,
stdout=out,
stderr=err,
stack_spec_diff=json_diff(before_stack_services,
after_stack_services,
dump=True))
@ -287,11 +295,14 @@ def main():
rc, out, err = docker_stack_rm(module, name, absent_retries, absent_retries_interval)
if rc != 0:
module.fail_json(msg="'docker stack down' command failed",
out=out,
rc=rc,
err=err)
out=out, err=err,
stdout=out, stderr=err)
else:
module.exit_json(changed=True, msg=out, err=err, rc=rc)
module.exit_json(changed=True,
msg=out, rc=rc,
err=err,
stdout=out, stderr=err)
module.exit_json(changed=False)

Loading…
Cancel
Save