mongodb: Add authentication support
* nixos/mongodb: Add authentication support * nixos/mongodb: Add initial script option * nixos/mongodb: Make initial root password configurable * nixos/mongodb: Start only on loopback interface for setup procedure * nixos/mongodb: Test auth/initial script * nixos/mongodb: Code formatting Co-Authored-By: Lassulus <github@lassul.us>
This commit is contained in:
committed by
Lassulus
co-authored by
Lassulus
parent
e06dc0b5a9
commit
62d4c2b34a
@@ -8,7 +8,7 @@ import ./make-test.nix ({ pkgs, ...} : let
|
||||
in {
|
||||
name = "mongodb";
|
||||
meta = with pkgs.stdenv.lib.maintainers; {
|
||||
maintainers = [ bluescreen303 offline cstrahan rvl ];
|
||||
maintainers = [ bluescreen303 offline cstrahan rvl phile314 ];
|
||||
};
|
||||
|
||||
nodes = {
|
||||
@@ -17,6 +17,12 @@ in {
|
||||
{
|
||||
services = {
|
||||
mongodb.enable = true;
|
||||
mongodb.enableAuth = true;
|
||||
mongodb.initialRootPassword = "root";
|
||||
mongodb.initialScript = pkgs.writeText "mongodb_initial.js" ''
|
||||
db = db.getSiblingDB("nixtest");
|
||||
db.createUser({user:"nixtest",pwd:"nixtest",roles:[{role:"readWrite",db:"nixtest"}]});
|
||||
'';
|
||||
mongodb.extraConfig = ''
|
||||
# Allow starting engine with only a small virtual disk
|
||||
storage.journal.enabled: false
|
||||
@@ -29,6 +35,6 @@ in {
|
||||
testScript = ''
|
||||
startAll;
|
||||
$one->waitForUnit("mongodb.service");
|
||||
$one->succeed("mongo nixtest ${testQuery}") =~ /hello/ or die;
|
||||
$one->succeed("mongo -u nixtest -p nixtest nixtest ${testQuery}") =~ /hello/ or die;
|
||||
'';
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user