Modifying ALLOWED_HOSTS

Can a plugin modify the values in production.py? I’m new to patching and I don’t see any examples of plugins changing py files yet, only json/yml values. I’ve been setting this value in the configmap after each deployment but that is definitely cumbersome, and the sites I add don’t have proper SSL support. I’m trying to write a plugin to patch caddy, and nginx to do this, I just need a tip on how to also patch the ALLOWED_HOSTS value?

I found it - patching openedx-lms-production-settings seems to let me add / overwrite a value - testing now.

this combined with patching caddy and nginx allows me to have nice proper ssl support for extra sites. I was able to do it with 1 yml file in the plugin. nice!

Dean do you have an example of this that you could post

name: multiplesites
version: 0.0.1
patches:
  openedx-lms-production: |
    # caddy special settings
      "ALLOWED_HOSTS": "hostname.com"

Hi @dbates,
I have no idea what you are trying to achieve exactly, but I’m pretty sure the plugin you wrote is wrong. First, the correct patch name you want is (probably) “openedx-lms-production-settings” and not “openedx-lms-production”. Second, the patch need to be Python-formatted. So it’s likely that you need instead:

name: multiplesites
version: 0.0.1
patches:
  openedx-lms-production-settings: |
    # caddy special settings
    ALLOWED_HOSTS.append("hostname.com")
1 Like

@regis I’m 100% sure its wrong

I was hoping dean would post an example of the single yaml file he created as a plugin for dissection. Thanks for correcting it.

Dennis