Re: How to setup admin user in config.json in nodebb
Trying to setup nodebb via ansible. I provide nodebb setup with a config.json. The config.json file is linted by jsonlint-php, jq and validjson, rc==0.
However, when running
cd /opt/nodebb && ./nodebb setup --skip-build "$(cat config.json)"
Invalid JSON passed as initial config value.
If you meant to pass in an initial config value, please try again.
2021-06-23T12:50:20.579Z [undefined/905674] - error: uncaughtException: Unexpected end of JSON input
SyntaxError: Unexpected end of JSON input
at JSON.parse (<anonymous>)
at Command.<anonymous> (/opt/nodebb/src/cli/index.js:174:23)
at Command.listener [as _actionHandler] (/opt/nodebb/node_modules/commander/index.js:922:31)
at Command._parseCommand (/opt/nodebb/node_modules/commander/index.js:1503:14)
at Command._dispatchSubcommand (/opt/nodebb/node_modules/commander/index.js:1443:18)
at Command._parseCommand (/opt/nodebb/node_modules/commander/index.js:1460:12)
at Command.parse (/opt/nodebb/node_modules/commander/index.js:1292:10)
at Object.<anonymous> (/opt/nodebb/src/cli/index.js:316:9)
at Module._compile (node:internal/modules/cjs/loader:1109:14)
[...]
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1138:10)","exception":true,"date":"Wed Jun 23 2021 15:01:36 GMT+0200 (Central European Summer Time)","process":{"pid":912816,"uid":998,"gid":998,"cwd":"/opt/nodebb","execPath":"/usr/bin/node","version":"v16.3.0","argv":["/usr/bin/node","/opt/nodebb/nodebb","setup","--skip-build","{\n admin: {\n username: nodebb-admin\n }\n}"]
[...]
I got to try this as I set up a mongod database "nodebb" as per the installation instructions. The admin user and the "nodebb" db user (named "nodebb-admin", here) are created and verified in mongod. After installing and starting nodebb/nginx a login using "nodebb-admin" is failing, though.
After running nodebb setup manually and answering the questions for admin user/pw/email (using i.e. "another-admin") a login using "another-admin" is successful. A login using "nodebb-admin" which has been setup in the mongod "nodebb" database is not working.
This is suggesting there is some additional configuration happening when using nodebb setup
with a manually typed admin user at the prompt as opposed to a prepared user in the "nodebb" database. What are those invisible steps? Some "nodebb" database objects?
Why is this so and how to automate the creation of the admin user? The installation instructions given in the nodebb documentation are either not working (anymore) or I missed some point. But what is it?
npm -v; node -v"
npm verb cli [ '/usr/bin/node', '/opt/nodebb/node_modules/.bin/npm', '-v' ]
npm info using [email protected]
npm info using [email protected]
Thanks for any helpful feedback