Tom Donohue Tom Donohue

Editing Karaf configuration using Fabric profiles

When you run JBoss Fuse in a Fabric, the configuration of each Karaf container can be managed using profiles.

Profiles are useful, because they allow you to make a configuration setting just once, and have that setting applied across all containers in your Fabric that share the same profile. This saves you having to copy files between containers yourself.

Here are some other fun facts about profiles:

  • A container can have one or more profiles assigned to it.
  • Profiles are arranged in a hierarchy. That is, a child profile will inherit settings from its parent.
  • The profile that defines all the main stuff for Fabric to run is called default.

To edit configuration values in a profile, use the fabric:profile-edit command, which you type into the Karaf console.

When you change a configuration value in a profile, it will then be applied to all containers that have that profile.

To list all of your containers, and see the profiles assigned to each, use the command fabric:container-list.

Setting OSGi Config Admin Persistent ID (PID) properties

OSGi Config Admin Persistent ID (PID) properties are the properties that you normally see in etc/. These include things like the org.ops4j... sets of properties, which control things like logging, the Jetty web server, and so on.

These OSGi PIDs can be set using the fabric:profile-edit command, with the --pid argument:

fabric:profile-edit --pid <PID>/<Property>=<Value> <Profile> [<Version>]

Where PID is the OSGi Persistent ID to edit (e.g. org.ops4j.pax.logging).

For example, to increase the logging on your class com.example.myclass, you can use:

fabric:profile-edit --pid org.ops4j.pax.logging/log4j.logger.com.example.myclass=DEBUG karaf

Setting Java properties (config.properties and system.properties)

You can also use Fabric to change settings in your config.properties and system.properties files, too. These files are also under the control of Fabric.

To make changes to these files, you can still use fabric:profile-edit, but the syntax is a little different.

For settings in config.properties, you use the --system argument:

fabric:profile-edit --system <Property>=<Value> <Profile> [<Version>]

And for settings in config.properties, you use the --config argument:

fabric:profile-edit --config <Property>=<Value> <Profile> [<Version>]

For example, to set a system property and then a config property, you would do something like the following (see how I’m applying these settings to the karaf profile):

fabric:profile-edit --system my.config.parameter=1234 karaf
fabric:profile-edit --config another.config.parameter=1234 karaf

Then, these values will be added into the system.properties and config.properties files respectively.

Don’t forget, first check out profile-list to see the available profiles that you can edit.

For more information check out the fabric8 docs!

Comments

What do you think? You can use Markdown in your comment.

To write code, indent each line with 4 spaces. Or, to paste a lot of code, you can put it in pastebin.com and share the link in your comment.