diff --git a/doc/source/install/include/configure-ironic-api-wsgi.inc b/doc/source/install/include/configure-ironic-api-wsgi.inc index a248ee9fc1..aa31a39760 100644 --- a/doc/source/install/include/configure-ironic-api-wsgi.inc +++ b/doc/source/install/include/configure-ironic-api-wsgi.inc @@ -92,19 +92,17 @@ Passing Configuration Options ------------------------------ By default, Ironic will use its standard configuration file search paths. -If you need to specify a custom configuration file: +See https://docs.openstack.org/oslo.config/latest/configuration/options.html +for more info. -For the initialization method with arguments:: +If you need to specify a custom configuration file, you can set the +``IRONIC_CONFIG_FILE`` and/or ``IRONIC_CONFIG_DIR`` environment variable: + +.. code-block:: cfg - # uWSGI with custom config (in ini file) [uwsgi] - module = ironic.api.wsgi:initialize_wsgi_app(argv=["--config-file=/etc/ironic/ironic.conf"]) - -Alternatively, you can set environment variables before starting the WSGI server:: - - export OS_CLOUD=mycloud - # or - export IRONIC_CONF=/etc/ironic/ironic.conf + ... + env = IRONIC_CONFIG_DIR=/etc/mycustomdir/ Important Considerations ~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/ironic/common/config.py b/ironic/common/config.py index fedf5c2725..bb535b66a9 100644 --- a/ironic/common/config.py +++ b/ironic/common/config.py @@ -15,6 +15,8 @@ # License for the specific language governing permissions and limitations # under the License. +import os + from oslo_config import cfg import osprofiler.opts as profiler_opts @@ -23,10 +25,21 @@ from ironic import version def parse_args(argv, default_config_files=None): + # NOTE(amorin) allow wsgi app to start with custom config file/dir + conf_file_from_env = os.environ.get('IRONIC_CONFIG_FILE') + if conf_file_from_env and not default_config_files: + default_config_files = [conf_file_from_env] + conf_dir_from_env = os.environ.get('IRONIC_CONFIG_DIR') + if conf_dir_from_env: + default_config_dirs = [conf_dir_from_env] + else: + default_config_dirs = None + rpc.set_defaults(control_exchange='ironic') cfg.CONF(argv[1:], project='ironic', version=version.version_info.release_string(), - default_config_files=default_config_files) + default_config_files=default_config_files, + default_config_dirs=default_config_dirs) rpc.init(cfg.CONF) profiler_opts.set_defaults(cfg.CONF) diff --git a/releasenotes/notes/deprecate-wsgi-args-31112fb7db5499d1.yaml b/releasenotes/notes/deprecate-wsgi-args-31112fb7db5499d1.yaml new file mode 100644 index 0000000000..d8969419e5 --- /dev/null +++ b/releasenotes/notes/deprecate-wsgi-args-31112fb7db5499d1.yaml @@ -0,0 +1,8 @@ +--- +deprecations: + - | + Using ``ironic.api.wsgi:initialize_wsgi_app`` to provide custom config file + to ironic is now deprecated. + + Instead, two new environment variables ``IRONIC_CONFIG_DIR`` and + ``IRONIC_CONFIG_FILE`` are introduced to provide the same functionality.