davidcaste 4b2899bb6e 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/
2015-12-16 09:24:08 +01:00

34 lines
1.2 KiB
Django/Jinja

# {{ ansible_managed }}
auth = {{ mongodb_conf_auth|to_nice_json }}
bind_ip = {{ mongodb_conf_bind_ip }}
cpu = {{ mongodb_conf_cpu|to_nice_json }}
dbpath = {{ mongodb_conf_dbpath }}
fork = {{ mongodb_conf_fork|to_nice_json }}
httpinterface = {{ mongodb_conf_httpinterface|to_nice_json }}
ipv6 = {{ mongodb_conf_ipv6|to_nice_json }}
journal = {{ mongodb_conf_journal|to_nice_json }}
logappend = {{ mongodb_conf_logappend|to_nice_json }}
logpath = {{ mongodb_conf_logpath }}
maxConns = {{ mongodb_conf_maxConns }}
noprealloc = {{ mongodb_conf_noprealloc|to_nice_json }}
noscripting = {{ mongodb_conf_noscripting|to_nice_json }}
notablescan = {{ mongodb_conf_notablescan|to_nice_json }}
port = {{ mongodb_conf_port }}
quota = {{ mongodb_conf_quota|to_nice_json }}
{% if mongodb_conf_quota %}
quotaFiles = {{ mongodb_conf_quotaFiles }}
{% endif %}
syslog = {{ mongodb_conf_syslog|to_nice_json }}
smallfiles = {{ mongodb_conf_smallfiles|to_nice_json }}
{% if mongodb_conf_replSet %}
# Replica set options:
replSet = {{ mongodb_conf_replSet }}
replIndexPrefetch = {{ mongodb_conf_replIndexPrefetch }}
oplogSize = {{ mongodb_conf_oplogSize }}
{% endif %}
{% if mongodb_conf_replSet and mongodb_conf_auth %}
keyFile = {{ mongodb_conf_keyFile }}
{% endif %}