Question

I've enjoyed using Rails on Heroku, and like that I can adjust the configuration property of a Heroku app without having to commit a change to xyz.yml and redeploy.

It would be nice to completely do away with the Yaml config files in my Rails app, and rely as much as possible on storing configuration in ENV. This goes along with the 12-factor config principle.

However, there are some trade-offs in switching from a Yaml-based configuration management to a Heroku/12-factor-based one.

  • While it's true that a proliferation of deployments (qa, stage, prod, dev, demo, labs) can lead to a proliferation of Yaml files, it's very easy to copy-paste to create a new configuration profile. I don't see a way to 'copy' configuration profiles from one deployment to another in Heroku.
  • Storing configuration data in the repo means that, in the case of Heroku, deploying and configuring and application are accomplished in a single operation. If I were to move my configuration out of Yaml files and into ENV variables, I would have to configure my application in a separate step after deployment.

Would like to hear from people who have used 12-factor style configuration in their private applications, and how they have managed lots of configuration variables across lots of deployments.

  • How do you quickly configure a new deployment?
  • Where do you keep your authoritative source of configuration variables, if not the repo? How do you distribute it among developers?

Thanks!

Était-ce utile?

La solution

You can accomplish this relatively easy with some simple shell scripts, iterate existing variables via heroku config or heroku release:info v99, and then set heroku config:set k=v --app

But if its a problem/pain/friction perhaps you have too much inside your env var configuration.

Autres conseils

What I typically use is Yaml using the ENV and provide defaults. For instance, YAML can be ERB'ed happily to include your ENV vars:

foo:
  var: ENV["MY_CONFIG"] || "default_value"

You just need to make sure that you load the Yaml with ERB when you read it:

YAML.load(ERB.new(File.read("#{Rails.root}/config/app_config.yml")).result)

By doing this your code works fine in dev, but also allows you to set config vars in the environment as well.

A bit of a late answer, but I believe this is what you are looking for.

I developed a gem called settei, allowing you to use YAML files to configure the app. However the gem will serialize the YAML file as one environment variable during deploy. This way one get the best of both worlds: YAML for ease of management/creating derivative environment, and ENV for 12-factor compliance.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top