Skip to content
This repository has been archived by the owner on Oct 30, 2018. It is now read-only.

return a proper result set for getmaster/getslave #2595

Merged
merged 2 commits into from
Aug 4, 2016

Conversation

srgvg
Copy link
Contributor

@srgvg srgvg commented Jul 20, 2016

ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME

database/mysql/mysql_replication.py

ANSIBLE VERSION

2.1.0.0

SUMMARY

When doing a getslave on a master or getmaster on a slave, the module fails, and doesn't return a clean error message.

tns1270 | FAILED! => {
    "changed": false, 
    "failed": true, 
    "msg": "Server is not configured as mysql slave. ERROR: exit_json() argument after ** must be a mapping, not NoneType"
}

This patch makes the module return a proper result set, which can more cleanly be handled in a playbook.

tns1270 | SUCCESS => {
    "changed": false, 
    "msg": "Server is not configured as mysql slave", 
    "slave": false
}

when not on a master/slave.
This allows for a cleaner error handling.
@gregdek
Copy link
Contributor

gregdek commented Jul 20, 2016

Thanks @srvg. To the current maintainers, @banyek please review according to guidelines (http://docs.ansible.com/ansible/developing_modules.html#module-checklist) and comment with text 'shipit', 'needs_revision' or 'close_me' as appropriate.

[This message brought to you by your friendly Ansibull-bot.]

@gundalow
Copy link
Contributor

gundalow commented Aug 1, 2016

Change looks sensible

shipit

@gregdek
Copy link
Contributor

gregdek commented Aug 1, 2016

Thanks again to @srvg for this PR, and thanks @banyek for reviewing. Marking for inclusion.

[This message brought to you by your friendly Ansibull-bot.]

@srgvg
Copy link
Contributor Author

srgvg commented Aug 4, 2016

I added a small patch to this to make sure getslave and getmaster always return at least a boolean Is_Slave and Is_Master key in their result, for a more uniform result set, and typically to be used in further conditionals.

@gundalow
Copy link
Contributor

gundalow commented Aug 4, 2016

my shipit still stands

@abadger abadger merged commit fc76455 into ansible:devel Aug 4, 2016
@abadger
Copy link
Contributor

abadger commented Aug 4, 2016

Thanks @srvg ! merged to devel.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants