Is it possible to programmatically configure a new site via the API?
What do you mean by “configure a new site”?
I’m most interested in setting up admin users, running through the steps in the Admin Quick Start Guide, and configuring SSO.
If you’re fluent in Ruby, you can change pretty much everything by simply loading up the Discourse app in a Ruby script:
require "/path/to/discourse/config/environment" SiteSetting.must_approve_users = true u = User.new(username: "admin", email: "email@example.com", ...) u.save!
Obviously, this script must live and be executed inside Discourse’s docker container. Also, note that the first line loads the entire Discourse app into the script and is fairly time consuming.
I’ve come across the same requirement to programatically configure Discourse configuration. Unfortunately for me, i’m not fluent in Ruby. There must be some magic somewhere that I didn’t get yet.
In discourse code, at
config/site_settings.yml which would be nice we could superseed via configuration files. So far, I know we can do a few things via a file we install from discourse_docker from
samples/standalone.yml, and that we can extend keys from discourse at
Is there a way to do the same with site_settings.yml?
Site settings are all in the database so you can easily set overrides by using our object model.
I was hoping there was a way to inject settings so that I dont need to use database to do it. If there is none, its OK
not following are you looking to provision 1000s of sites
you can change site settings in the UI, if you must pre-populate site settings you can add hook that runs post migration that forces a setting. you can not change defaults.