(Updated) Configuration Management
Introduction
There have been some changes made to how Bacalhau handles configuration:
The bacalhau repo
~/.bacalhau
no longer contains a config file.Bacalhau no longer looks in the repo
~/.bacalhau
for a config file.Bacalhau never writes a config file to disk unless instructed by a user to do so.
A config file is not required to operate Bacalhau.
Bacalhau searches for a default config file. The location is OS-dependent:
Linux:
~/.config/bacalhau/config.yaml
OSX:
~/.config/Application\ Support/bacalhau/config.yaml
Windows:
$AppData\bacalhau\config.yaml
. Usually, this is something likeC:\Users\username\bacalhau\config.yaml
Summary
Bacalhau no longer relies on the ~/.bacalhau
directory for configuration and only creates a config file when instructed. While not required, it will look for a default config file in OS-specific locations.
Inspecting the Current Configuration of Bacalhau
To view the configuration that bacalhau will receive when a command is executed against it, users can run the bacalhau config list command. Users who wish to see Bacalhau’s config represented as YAML may run bacalhau config list --output=yaml
.
Making Changes to the Default Config File
As described above, bacalhau still has the concept of a default config file, which, for the sake of simplicity, we’ll say lives in ~/.config/bacalhau/config.yaml
. There are two ways this file can be modified:
A text editor
vim ~/.config/bacalhau/config.yaml
.The bacalhau config set command.
Using a Non-Default Config File.
The --config
(or -c
) flag allows flexible configuration of bacalhau through various methods. You can use this flag multiple times to combine different configuration sources. To specify a config file to bacalhau, users may use the --config
flag, passing a path to a config file for bacalhau to use. When this flag is provided bacalhau will not search for a default config, and will instead use the configuration provided to it by the --config
flag.
Bacalhau Configuration Keys
In Bacalhau, configuration keys are structured identifiers used to configure and customize the behavior of the application. They represent specific settings that control various aspects of Bacalhau's functionality, such as network parameters, API endpoints, node operations, and user interface options. The configuration file is organized in a tree-like structure using nested mappings (dictionaries) in YAML format. Each level of indentation represents a deeper level in the hierarchy.
Example: part of the config file
In this YAML configuration file:
Top-Level Keys (Categories):
API
,Orchestrator
Sub-Level Keys (Subcategories): Under
API
, we haveHost
andPort
; UnderOrchestrator
we haveHost
,Port
andNodeManager
Leaf Nodes (Settings):
Host
,Port
,NameProvider
,DataDir
,DisconnectTimeout
— these contain the actual configuration values.
Config keys use dot notation to represent the path from the root of the configuration hierarchy down to a specific leaf node. Each segment in the key corresponds to a level in the hierarchy. Syntax is Category.Subcategory(s)...LeafNode
Using Keys With config set
, config list
and --config
config set
, config list
and --config
The bacalhau config list
returns all keys and their corresponding value. The bacalhau config set
command accepts a key and a value to set it to. The --config
flag accepts a key and a value that will be applied to Bacalhau when it runs.
Example Interaction With the Bacalhau Configuration System
How to Modify the API Host
Using bacalhau config set
in the Default Config File:
API Host
Using bacalhau config set
in the Default Config File:Run
bacalhau config list
to find the appropriate key
Run the
bacalhau config set
command
Observe how
bacalhau config list
reflects the new setting
Observe the change has been reflected in the default config file
How to Modify the API Host Using bacalhau config set
a Custom Config File
Run the config set command with the flag
Observe the created config file
Observe the default config and output of bacalhau config list
does not reflect this change.
How to Start Bacalhau With a Custom Config File
Usage of the --config
Flag
--config
Flag The --config
(or -c
) flag allows flexible configuration of bacalhau through various methods. You can use this flag multiple times to combine different configuration sources.
Usage
or using the short form:
Configuration Options
YAML Config Files: Specify paths to YAML configuration files. Example:
Key-Value Pairs: Set specific configuration values using dot notation. Example:
Boolean Flags: Enable boolean options by specifying the key alone. Example:
Precedence
When multiple configuration options are provided, they are applied in the following order of precedence (highest to lowest):
Command-line key-value pairs and boolean flags
YAML configuration files
Default values
Within each category, options specified later override earlier ones.
Examples
Using a single config file:
Merging multiple config files:
Overriding specific values:
Combining file and multiple overrides:
In the last example, WebUI.Enabled
will be set to true
, API.Host
will be 192.168.1.5
, and other values will be loaded from config.yaml
if present.
Remember, later options override earlier ones, allowing for flexible configuration management.
Usage of the bacalhau completion
Command
bacalhau completion
CommandThe bacalhau completion
command will generate shell completion for your shell. You can use the command like:
After running the above command, commands like bacalhau config set
and bacalhau --config
will have auto-completion for all possible configuration values along with their descriptions
Support
If you have questions or need support or guidance, please reach out to the Bacalhau team via Slack (#general channel).
Last updated