On 2023-01-30 12:08:10 -0800 (-0800), Mark Sapiro wrote: [...]
Domains can be created via Postorius or via the Mailman Core REST API that postorius uses or implicitly by the
mailman create
command when creating a list in a new domain. However, none of this can create a new site. You can do this through the Django admin site at sites/site/add/.See https://docs.djangoproject.com/en/4.1/ref/contrib/sites/ for methods you can use to do this programmatically.
Thanks, I'm still doing my best to wrap my brain around how Django uses database migrations to create sites (seems like a very strange use of a migration, I'm only accustomed to seeing them applied for database schema updates). Once I work out how to script site creation, I'm still not completely finding the explanations I need for how to map them to domains in Mailman though.
The Mailman documentation about domains says "Domains are how Mailman interacts with email host names and web host names" but doesn't actually go on to say (that I can find anywhere) how it actually associates them. I can see in the API docs that a POST to the domains endpoint will create a new domain with a specific mail_host FQDN, but there's some association somewhere of that to a web host (Django site), right? How is that set or manipulated through the API? Or is that something which has to be set directly in Django's data structures instead?
To recap, on creation of a mailing list server I want to populate it automatically with multiple lists on different domains and have dynamic SITE_ID=0 domain guessing performed so that the correct site name and list filtering is performed depending on which domain name is used in a URL the client requests. I believe I need to have the automation perform the following steps:
Instantiate the Mailman installation and run initial migrations with SITE_ID=1 in order to avoid the problem mentioned in the docs about not using SITE_ID=0 until the tables have been populated, then switch the settings.py to use SITE_ID=0 once done.
Create the individual sites I need in Django (Mailman web hosts) by creating and applying database migrations.
Create the individual domains I need in Mailman (Mailman mail hosts) through its REST API.
"Somehow" tell Mailman (or Django?) which mail hosts correspond to what web hosts.
As I said, I'm still trying to understand how to make step 2 happen (Django has a steep learning curve for me), but beyond that I'm unsure how to do step 4 at all. I can do all of this through the WebUI of course, and have confirmed that it works as expected when I do, I'm just trying to work out the automation so that our other sysadmins don't have to perform these steps by hand the next time we need to rebuild the server.
Thanks again for all the help so far, and for any additional insight anyone may have into how I can correct my mental model of all this.
Jeremy Stanley