How to configure a model

Note: Incorporated into How to manage a model. Please see that doc instead.

See also: Configuration, List of model configuration keys

This document demonstrates how to get and set model configuration values.

A model’s configuration influences all the machines residing within it and, in turn, the applications that get deployed onto those machines.


Get values

See also: model-config, model-defaults

To get the current model configuration, use the model-config command, as shown below. This will show all the currently set key values—whether they were set by you, inherited as a default value, or dynamically set by Juju.

juju model-config

You can also see a list of all the default model configuration values. For this, use the model-defaults command, as shown below.

juju model-defaults

Set values

During controller creation

See also: juju bootstrap --config ..., juju bootstrap --model-default ..., How to create a controller

The first chance to set model configuration keys is during controller creation, via the bootstrap command plus an option—either --config or --model-default followed by a key-value pair. The difference is that --config affects just the ‘controller’ and ‘default’ models while --model-default affects all models, including any future ones. For example:

juju bootstrap --config image-stream=daily localhost lxd-daily

To pass multiple key-value pairs, repeat --config or --model-default for every pair. For example:

juju bootstrap microk8s uk8s \
  --model-default logging-config="<root>=WARNING; unit=DEBUG" \
  --model-default update-status-hook-interval="60m"

After controller creation

You can also set model configuration(s / defaults) after controller creation. This can happen during model creation or after model creation.

During model creation

See also: add-model --config

To configure a model while adding it, use the add-model command with the --config option. You can pass the key-value pair(s) directly or via a YAML file. The example below illustrates both:

juju add-model mymodel --config my-config.yaml --config image-stream=daily

After model creation

See also: model-config ..., model-config --reset ..., model-defaults ...

To configure a model after you’ve already added it, you can set a value by using juju model-config followed by the relevant key-value pair:

juju model-config

It is also possible to specify a list of key-value pairs:

juju model-config test-mode=true enable-os-upgrade=false

And you can also specify a YAML file containing a list of key-value pairs:

juju model-config more-config-values.yaml

Juju does not currently check that the provided key is a valid setting, so make sure you spell it correctly.

You can also set a null value:

juju model-config apt-mirror=""

To return a value to the default setting, use the --reset flag followed by the key name:

juju model-config --reset test-mode

You can also set default values that all new models will use. These values can even be specified for each cloud region instead of just the controller. For example, to set a default value for ‘ftp-proxy’, do:

juju model-defaults ftp-proxy=

While doing this, you can also specify a controller region:

juju model-defaults us-east-1 test-mode=true enable-os-upgrade=false

And you can also pass the key-value pairs from a YAML file:

juju model-defaults more-default-config-values.yaml

These defaults can be overridden, on a per-model basis, during the invocation of the add-model command (option --config) as well as by resetting specific options to their original defaults through the use of the model-config command (option --reset).

In Juju 3.0, the model-config interface will be changed slightly to bring it in line with juju config. Specifically:

  • You will now need to use the --file flag to set config values from a yaml file. This fixes a known bug in Juju 2 where ambiguity arises from a model config key having the same name as a file or directory.
  • You can no longer specify multiple actions to do simultaneously (e.g. get a key and set a key). Doing this is ambiguous because sometimes the order of operations will matter, and then it’s not clear which action should be done first.

In terms of changes to the above doc, the command

juju model-config more-config-values.yaml

will now return an error, since you can’t set from command-line args and set from a file in the same command. However, the sequence

juju model-config
juju model-config --file more-config-values.yaml

is perfectly okay.

1 Like

@barrettj12 I’ve put a note to remind us to update the help / Ref doc when we reach 3.0 .