When deploying an application, the charm you use will often support or even require specific configuration options to be set.
Juju provides tools to help manage these options and respond to changes over the lifetime of the application deployment. These options apply to the entire application, as opposed to only a specific unit or relation. The configuration can be modified by an administrator at deployment time or after the applications are operational.
Each charm will have its own set of options and possible values. You can discover these in several ways:
- By running the
- By viewing the charm in the charm store.
- By examining the config.yaml file in the charm itself.
Configuration values for an application can be set during deployment in several ways:
- by using a yaml-formatted file
- by passing options/values directly on the command line
- a combination of the above
All these methods use the
For example, upon investigation we discover that the Mediawiki charm allows us to set values for the 'name' of the wiki and the 'skin' to use. We can put these inside a configuration file.
mediawiki: name: Juju Wiki skin: monobook
Assuming the file is called
myconfig.yaml, the application can be deployed
and configured in this way:
juju deploy --config myconfig.yaml mediawiki
Warning: If the configuration file cannot be read or contains syntax errors or invalid options, an error message will be printed to this effect. However, the application will still be deployed .
To pass the options directly:
juju deploy --config name='Juju Wiki' --config skin='monobook'
A combination can also be used. If a duplication arises, the last-mentioned value gets used. For instance, below, the wiki will be assigned the name of 'Juju Wiki':
juju deploy --config name='Juju Wookie' --config myconfig.yaml
It is possible to set or change configuration of an application which is already deployed.
Before you set any of these options, you may want to check what current options
are already set, using the
juju config <application> command. For example:
juju config mediawiki
Should return something like this:
charm: mediawiki application: mediawiki settings: admins: default: true description: Admin users to create, user:pass type: string value: null debug: default: true description: turn on debugging features of mediawiki type: boolean value: false logo: default: true description: URL to fetch logo from type: string value: null name: default: true description: The name, or Title of the Wiki type: string value: Please set name of wiki skin: default: true description: skin for the Wiki type: string value: vector use_suffix: description: If we should put '/mediawiki' suffix on the url type: boolean value: false
You can set the options using
juju config <application>, specifying
multiple space-separated key=value pairs if necessary:
juju config mediawiki skin=monoblock name='Juju Wiki'
It is also possible to set the configuration options from a YAML file after the application has been deployed:
juju config mediawiki --file path/to/myconfig.yaml
Setting an option back to its default value is achieved by using the same
command, with the
--reset switch, followed by a comma-separated list of the
values to return to the default setting:
juju config mediawiki --reset admins,name