Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running MeshCentral Sate-less with MariaDB #4645

Closed
aRafeymasood opened this issue Oct 19, 2022 · 5 comments
Closed

Running MeshCentral Sate-less with MariaDB #4645

aRafeymasood opened this issue Oct 19, 2022 · 5 comments

Comments

@aRafeymasood
Copy link

aRafeymasood commented Oct 19, 2022

I was trying to run Meshcentral state-less so the certificates and the config files are stored in the databased with encryption
The following commands worked to put the configs/certs into the database as per documentation

node ./node_modules/meshcentral --dbpushconfigfiles * --configkey mypassword

However, I am running MariaDB and could not figure out the equivalent command for MariaDB. The below is available in the doco for MongoDB

node ./node_modules/meshcentral --loadconfigfromdb mypassword --mongodb "mongodb://127.0.0.1:27017/meshcentral"

Moreover, I tried setting up a test server with MongoDB > used the same commands above and it does what it is designed to do except that when I tried to run it as a service - it fails

node ./node_modules/meshcentral --loadconfigfromdb mypassword --mongodb "mongodb://127.0.0.1:27017/meshcentral --install"

Once the service starts - it creates new certificates and config files and cannot load the config from the server.

@Ylianst
Copy link
Owner

Ylianst commented Oct 24, 2022

Hi. Sorry for the delay. First, note that passing command line switches is the same as putting a value in the "Settings" section of the config.json. So:

node ./node_modules/meshcentral --mongodb "mongodb://127.0.0.1:27017/meshcentral"

Is the same as placing this value in your config.json file:

{
  "settings": {
    "mongodb": "mongodb://127.0.0.1:27017/meshcentral"
  }
}

So, you can configure MariaDB in the config.json as you want and run this:

node ./node_modules/meshcentral --dbpushconfigfiles *

Then to start the server, run:

node ./node_modules/meshcentral --loadconfigfromdb mypassword

Of course the issue here is that your going to have a minimal config.json to connect to the database to get the rest of the config.json.

I am going to give this a try myself just for kicks, will report back.

@Ylianst
Copy link
Owner

Ylianst commented Oct 25, 2022

Ok, I just did some testing and put fixes for the state-less server stuff. Fixes will be in v1.0.90.

I tried with PostgreSQL, but it's the same code for MariaDB. I setup the config.json with the DB settings, then loaded the configuration like this:

node ./node_modules/meshcentral --dbpushconfigfiles * --configkey mypassword

I then switched the config.json to this. With only the database stuff:

{
  "settings": {
    "Postgres": {
      "user": "postgres",
      "password": "tools",
      "port": 5432,
      "host": "localhost"
    }
  }
}

I then run the server like this:

node meshcentral --loadconfigfromdb mypassword

Now, you still need this mini config.json to get the database to connect. Let me know if that is a problem.

Once v1.0.90 is published, let me know if this works.

@Ylianst
Copy link
Owner

Ylianst commented Oct 25, 2022

Another option is to use this mini config.json:

{
  "settings": {
    "LoadConfigFromDB": "mypassword",
    "Postgres": {
      "user": "postgres",
      "password": "tools",
      "port": 5432,
      "host": "localhost"
    }
  }
}

In this case, you don't need any command line switches. Again, same for MariaDB.

@aRafeymasood
Copy link
Author

Thanks heaps for this, will test and report back soon.

@aRafeymasood
Copy link
Author

Tried and it works as advised. Thanks heaps again

Had to provide database name as well.
{ "settings": { "LoadConfigFromDB": "myPassword", "MariaDB": { "user": "admin", "password": "myPassword", "port": 3306, "host": "localhost", "database": "MyDbName" } } }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants