Allow raw mongodb uri to be used

This commit is contained in:
Daniel Berteaud 2023-08-31 22:59:39 +02:00
parent c0a31b8b3a
commit c9601e9fc8
2 changed files with 12 additions and 10 deletions

View File

@ -6,14 +6,17 @@ unifi.stun.port={{ env "NOMAD_PORT_stun" }}
unifi.db.nojournal=true
db.mongo.local=false
[[- $mongo := urlParse .unifi.controller.mongo.address ]]
[[- $mongo_stats := urlParse .unifi.controller.mongo.stats_address ]]
db.mongo.uri=[[ $mongo.Scheme ]]://
[[- if has .unifi.controller.mongo "user" ]]
db.mongo.uri=[[ $mongo.Scheme ]]://[[ .unifi.controller.mongo.user ]]:{{ with secret "[[ .env.suffix ]]kv/service/unifi" }}{{ urlquery .Data.data.mongo_pwd }}{{ end }}@[[ $mongo.Host ]]/[[ .unifi.controller.mongo.db ]]
statdb.mongo.uri=[[ $mongo.Scheme ]]://[[ .unifi.controller.mongo.user ]]:{{ with secret "[[ .env.suffix ]]kv/service/unifi" }}{{ urlquery .Data.data.mongo_pwd }}{{ end }}@[[ $mongo.Host ]]/[[ .unifi.controller.mongo.stats_db ]]
[[- else ]]
db.mongo.uri=[[ $mongo.Scheme ]]://[[ $mongo.Host ]]/[[ .unifi.controller.mongo.db ]]
statdb.mongo.uri=[[ $mongo.Scheme ]]://[[ $mongo.Host ]]/[[ .unifi.controller.mongo.stats_db ]]
[[- .unifi.controller.mongo.user ]]:{{ with secret "[[ .env.suffix ]]kv/service/unifi" }}{{ urlquery .Data.data.mongo_pwd }}{{ end }}@
[[- end ]]
unifi.db.name=[[ .unifi.controller.mongo.db ]]
[[- $mongo.Host ]][[ $mongo.Path ]]?[[ $mongo.RawQuery ]]
statdb.mongo.uri=[[ $mongo_stats.Scheme ]]://
[[- if has .unifi.controller.mongo "user" ]]
[[- .unifi.controller.mongo.user ]]:{{ with secret "[[ .env.suffix ]]kv/service/unifi" }}{{ urlquery .Data.data.mongo_pwd }}{{ end }}@
[[- end ]]
[[- $mongo_stats.Host ]][[ $mongo_stats.Path ]]?[[ $mongo_stats.RawQuery ]]
debug.device=info
debug.mgmt=info
debug.system=info

View File

@ -26,11 +26,10 @@ unifi:
mongo:
# The address of the mongo service. Leave the default
# unless you use an external mongo service
address: mongodb://127.0.0.1:27017/
address: mongodb://127.0.0.1:27017/unifi
# For stats
stats_address: mongodb://127.0.0.1:27017/unifi_stats
# DB names for unifi and the statistics
db: unifi
stats_db: unifi_stats
# If username is set, the password must be available in vault at [[ .env.suffix ]]/kv/service/unifi in key mongo_pwd
# user: unifi