[oslo] [config] Using environment variables for config options

Chris Dent cdent+os at anticdent.org
Thu Nov 22 11:57:24 UTC 2018

I don't recall seeing any specific announcement for this, and I
think it is a pretty useful feature, so I thought I'd write about
some functionality that I added to oslo.config and was released in
6.7.0.  Especially since a lot of people I've mentioned this to
thought we already had it.

The new version is able to satisfy any registered config option by
looking in the process environment for a variable with a predictable
name and using its value if set. Options are satisfied in this

* command line args
* environment
* config file(s)
* everything else (using the new(ish) "sources" concept)

In the past it was possible to get config from the environment if
the option had been pre-defined as using something in the
environment as its default.

This new way is much more flexible, and in my experience ideal for
container-based environments where you would like an immutable
container but want small differences between multiple instances of
the same container to be easy to control. Or if you don't need much
config at all, you can avoid using a config file entirely.

I've been using this with placement, where it's possible to set up a
testable placement service with just two environment variables:


This shows the pattern of the environment variable name:

   OS_<config group>__<config opt>

There are some docs at https://docs.openstack.org/oslo.config/latest/reference/drivers.html#module-oslo_config.sources._environment

I hope this proves as useful for other people as it has for me.

Chris Dent                       ٩◔̯◔۶           https://anticdent.org/
freenode: cdent                                         tw: @anticdent

More information about the openstack-discuss mailing list