from fabric.api import env, run, task
from envassert import detect, file, group, package, port, process, service, \
    user


@task
def check():
    env.platform_family = detect.detect()

    assert file.exists("/etc/mongod.conf"), "/etc/mongod.conf does not exist"
    assert port.is_listening(27017), "nothing is listening on port 27017"
    assert user.exists("mongodb"), "there is no mongodb user"
    assert group.is_exists("mongodb"), "there is no mongodb group"
    assert process.is_up("mongod"), "mongod is not running"
    assert service.is_enabled("mongod"), "service mongod is not enabled"

@@ -1,12 +1,24 @@
+import json%0A
 from fabric.
@@ -37,16 +37,22 @@
 nv, run,
+ hide,
  task%0Afr
@@ -127,16 +127,16 @@
 vice, %5C%0A
-
     user
@@ -138,16 +138,237 @@
  user%0A%0A%0A
+def replset_is_ok():%0A    with hide('running', 'stdout'):%0A        mongo_cmd = %22mongo --quiet --eval 'JSON.stringify(rs.status())'%22%0A        rs_status = json.loads(run(mongo_cmd))%0A        return rs_status.get('ok', False)%0A%0A%0A
 @task%0Ade
@@ -835,8 +835,68 @@
 nabled%22%0A
+    assert replset_is_ok(), %22replica set status was not ok%22%0A

add replset status test