Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add replication role detection from runtime Redis information #128

Open
wants to merge 17 commits into
base: master
Choose a base branch
from

Conversation

danielkza
Copy link
Contributor

@danielkza danielkza commented Nov 16, 2016

Make the role aware of the runtime-assigned replication roles of existing Redis instances to avoid forcing role changes to instances (which might cause downtime).

Do it by sourcing data from the INFO Redis command through a fact script, then using that information to determine whether an already running instance is a master or a slave. Then, if the option is enabled, ignore the manually assigned role in favor of the detected role. That fact script can also possibly replace the existing redis one, which is really not that useful, since a) you likely already have the data it contains from the inventory b) it doesn't support/can't distinguish more than once instance.

Hopefully is enough to fix #22 without requiring any weird configuration generation. Unfortunately that was too optimistic, it seems some weird stuff will be necessary.

Tests are pending - I'm posting this for some feedback before going further.

@danielkza
Copy link
Contributor Author

@DavidWittman I did some work to try and solve the problems that #25 couldn't, by attempting to merge rewritten configuration with our managed config at daemon startup time, with some other assorted fixes. Please check it out if you can.

@danielkza danielkza force-pushed the replication-role-detection branch 3 times, most recently from 3305c0f to b5187fe Compare November 25, 2016 20:42
Export Redis information (as retrieved by the INFO) command as local
facts for each configured server/sentinel instance.

Those facts are created in addition to the existing global facts, and
are identified by keys in the form of `redis_{{ redis_port }}` and
`redis_sentinel_{{ redis_sentinel_port }}`.
The script will copy over the contents of the main configuration file,
then any new lines added to the running config file after the CONFIG
REWRITE tag line. This way Redis Sentinel information and dynamic
master/slave status is not lost when re-configuring instances.
The service module doesn't accept implementation-specific arguments
before Ansible 2.2.
The Sentinel config file contains the Redis password, and therefore,
cannot be publicly readable.

Also ensure files have the redis group set.
- Reduce verbosity
- Only set permissions of dynamic config file (not it's containing
directory)
- Correctly use redis user and group from template
@danielkza
Copy link
Contributor Author

danielkza commented Nov 25, 2016

I fixed systemd quoting issues (as #30) by rebasing some commits.

@danielkza
Copy link
Contributor Author

danielkza commented Nov 25, 2016

It seems Ansible 1.9 doesn't support the systemd module :(

edit: scratch that, it's actually just in 2.2. I guess I need to call daemon-reload manually instead.

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

Successfully merging this pull request may close these issues.

Dynamic selection of master
1 participant