Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
configuration
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
configuration
Commits
cd42cdf4
Commit
cd42cdf4
authored
Dec 11, 2015
by
Max Rothman
Committed by
Kevin Falcone
Jan 25, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Switch to more accurate name
parent
b0e95a74
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
12 deletions
+13
-12
playbooks/library/mongodb_replica_set
+13
-12
No files found.
playbooks/library/mongodb_r
s_member
→
playbooks/library/mongodb_r
eplica_set
100755 → 100644
View file @
cd42cdf4
...
...
@@ -2,13 +2,14 @@
DOCUMENTATION
=
"""
---
module: mongo
_rs_member
module: mongo
db_replica_set
short_description: Modify replica set config.
description:
- Modify replica set config, including modifing/adding/removing members from a replica set
and changing replica set options. Uses replSetReconfig and replSetInitiate.
changing replica set options, and initiating the replica set if necessary.
Uses replSetReconfig and replSetInitiate.
version_added: "1.9"
author:
author:
- Max Rothman
- Feanil Patel
options:
...
...
@@ -54,7 +55,7 @@ options:
EXAMPLES
=
'''
- name: Basic example
mongo
_rs_member
:
mongo
db_replica_set
:
username: root
password: password
rs_config:
...
...
@@ -65,7 +66,7 @@ EXAMPLES = '''
hidden: true
- name: Fully specify a whole document
mongo
_rs_member
:
mongo
db_replica_set
:
username: admin
password: password
rs_config:
...
...
@@ -149,7 +150,7 @@ def set_member_ids(members, old_members=None):
return
members
def
get_matching_member
(
member
,
members
):
'''Return the rs_member from `members` that "matches" `member`'''
'''Return the rs_member from `members` that "matches" `member`
(currently on host)
'''
match
=
[
m
for
m
in
members
if
m
[
'host'
]
==
member
[
'host'
]]
return
match
[
0
]
if
len
(
match
)
>
0
else
None
...
...
@@ -168,7 +169,7 @@ def fix_host_port(rs_config):
if
'members'
in
rs_config
:
if
not
isinstance
(
rs_config
[
'members'
],
list
)
module
.
fail_json
(
msg
=
'rs_config.members must be a list'
)
for
member
in
rs_config
[
'members'
]:
if
':'
not
in
member
[
'host'
]:
member
[
'host'
]
=
'{}:{}'
.
format
(
member
[
'host'
],
member
.
get
(
'port'
,
27017
))
...
...
@@ -198,17 +199,17 @@ def update_replset(rs_config):
if
rs_config_non_collections
!=
old_rs_config_non_collections
\
or
rs_config
[
'settings'
]
!=
old_rs_config
[
'settings'
]
\
or
not
members_match
(
rs_config
[
'members'
],
old_rs_config
[
'members'
]):
changed
=
True
if
'_id'
not
in
rs_config
:
rs_config
[
'_id'
]
=
get_rs_config_id
(
client
)
#Errors if no replSet specified to mongod
if
'version'
not
in
rs_config
:
#Using manual increment to prevent race condition
rs_config
[
'version'
]
=
old_rs_config
[
'version'
]
+
1
#Noop if all _ids are set
rs_config
[
'members'
]
=
set_member_ids
(
rs_config
[
'members'
],
old_rs_config
[
'members'
])
reconfig_replset
(
module
,
client
,
rs_config
)
#Validate it worked
...
...
@@ -216,7 +217,7 @@ def update_replset(rs_config):
changed_rs_config
=
get_replset
(
client
)
if
changed_rs_config
!=
rs_config
:
module
.
fail_json
(
msg
=
"Failed to validate that the replica set was changed"
,
config
=
rs_config
)
module
.
exit_json
(
changed
=
changed
,
config
=
rs_config
)
...
...
@@ -280,7 +281,7 @@ def validate_args():
if
__name__
==
'__main__'
:
module
=
validate_args
():
if
not
pymongo_found
:
module
.
fail_json
(
msg
=
"The python pymongo module is not installed."
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment