SOLVED nodebb setup config/scripted admin setup failing (ansible)


  • MWE for config.json used for the above nodebb setup call:

    {
      "admin": {
        "username": "nodebb-admin"
      }
    

    The full blown config.json is equally failing.


  • @bejan You're missing a closing bracket.


  • @bejan Yes, I know. Noticed the typo too late, cannot edit any more. Stupid.


  • My investigation was:

    Case 1:

    • mongodb: db.<collection>.remove({}) # configured admin user will remain in db, though
    • copy config.json in place
    • exec nodebb setup
    • copy config.json in place (req'd as nodebb setup truncates the config which is in itself bad enough)

    config.json contains a valid admin/passwd/email configuration. Mongodb has the same nodebb admin username configured.

    Result: no login possible.

    Case 2:
    => Running nodebb setup without cleaning up mongod database beforehand but with valid admin config in config.json makes nodebb setup create "admin" username with random password.

    Result: login using "admin" username and provided random password is successful.

    Case 3:
    Using environment variables with nodebb setup like this (w/ database cleaned up):

    export admin__username=my-nodebb-admin; export admin__password=mypasswd; export admin__password__confirm=mypasswd; ./nodebb setup
    

    yields:

    [...]
    This looks like a new installation, so you'll have to answer a few questions about your environment before we can proceed.                                                                   
    Press enter to accept the default setting (shown in brackets).
    2021-06-23T21:31:03.849Z [1261005] - info: 
    Now configuring mongo database:
    2021-06-23T21:31:03.979Z [1261005] - info: [database] Checking database indices.
    2021-06-23T21:31:03.984Z [1261005] - info: [database] Checking database indices done!
    2021-06-23T21:31:04.851Z [1261005] - verbose: [minifier] utilizing a maximum of 0 additional threads
    Configuration Saved OK
    Populating database with default configs, if not already set...
    [...]
    Schema update complete!
    

    Result: login with "my-nodebb-admin" username and preconfigured password is successful.

    Tests done with nodebb/v1.17.1 . Switched midway from npm to yarn as npm failed to accomplish it's task once too often.

    Conclusion: automated nodebb setup

    • using environment variables as of the given nodebb/node/npm versions is working
    • using preconfigured config.json as of the given nodebb/node/npm versions is NOT working

    Furthermore, nodebb setup truncates a preconfigured config.json, preventing successful startup of nodebb.

    In case preconfigured config.json was once working there is some regression. A possible fix for the above discrepencies/failures should prevent future regressions.

    NB: If there is interest, the final ansible playbook could possibly be open-sourced on github.


  • @bejan
    The setup json that you can provide with --setup=<content> has a different format than config.json, have a look at the github actions scripts in the main nodebb repo.

  • Global Moderator Plugin & Theme Dev

    @max-0 the scripts on GitHub use node app --setup but his question is about ./nodebb setup


  • @pitaj Maybe I do not get the main point but IMHO (by looking at the code) you can't simply provide a ready-made config.json because it is a "result" of the install. The --setup <content> provides the answers to the questions the installer would ask but aside from gathering this info, the installer would create the DB schema (and update it if necessary), create default user, push default content.


  • @pitaj Are you familiar with the code in question and if so can you acknowledge or not whether it is the same syntax for both as @Max-0 is suggesting?

  • Global Moderator Plugin & Theme Dev

    @bejan ./nodebb setup <config> and node app --setup=<config> should be functionally identical. If they don't behave the same, let me know.

    The "unexpected end of json input" error is either caused by a bad json file or a conflict between how shell arguments are escaped and how our tool expects input.

    The input to these isn't the same format as config.json, but is instead the answers to the setup questions as @Max-0 said. Here's an example of how we do it in GitHub actions:
    https://github.com/NodeBB/NodeBB/blob/edefac964556513dc2a65078f1fb62a26073cfbc/.github/workflows/test.yaml#L95


  • @pitaj Well, this info is golden.

    This clearly needs to be documented well and easily found. The usage message of ./nodebb setup --help should indicate the expected syntax and strikingly point out config.json is the wrong syntax in this case to be fed into ./nodebb setup.

    In the long run, there should be no special case or different syntax between node app --setup and ./nodebb setup.

    Thank you, @PitaJ, @Max-0 .

Suggested Topics

| |