Skip to content

Commit 4b2899b

Browse files
committed
Fix replicaset config without authentication
According to MongoDB documentation[1], "enabling internal authentication (in a replicaset) enables access control". Therefore, if MongoDB is configured without authentication (`auth = no`) a `keyFile` line must not appear in the configuration file. This commit attempts to solve the problem described above. An extra check has been added to ensure the `keyFile` configuration option is added only if replicaset authorization _and_ authentication is enabled. [1]: https://docs.mongodb.org/v3.0/tutorial/enable-internal-authentication/
1 parent c996d6e commit 4b2899b

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

templates/mongod.conf.j2

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,7 @@ smallfiles = {{ mongodb_conf_smallfiles|to_nice_json }}
2727
replSet = {{ mongodb_conf_replSet }}
2828
replIndexPrefetch = {{ mongodb_conf_replIndexPrefetch }}
2929
oplogSize = {{ mongodb_conf_oplogSize }}
30+
{% endif %}
31+
{% if mongodb_conf_replSet and mongodb_conf_auth %}
3032
keyFile = {{ mongodb_conf_keyFile }}
3133
{% endif %}

0 commit comments

Comments
 (0)