config.yaml Setup GuideThe config.yaml file is the central configuration file for the application. It is used to configure database connections, package-specific settings, and other operational parameters. The application reads this file on startup to initialize its configuration.
The config.yaml file has a hierarchical structure. The root of the configuration is determined by the package key. Under the package, the configuration is divided into sections, which in turn contain key-value pairs.
package: "development"
base:
database:
primaryip: "127.0.0.1"
primaryuser: "base_user"
another_section:
key3: "value3"
development:
database:
primaryip: "localhost"
primaryuser: "user"
primarypassword: "password"
primarydb: "axiondb"
connections:
- conn1
- conn2
domain:
dns: "dev.axion.com"
another_section:
key1: "value1"
key2: "value2"
terraform:
database:
primaryip: "10.0.0.1"
Any values under the base: section will be used as defaults if they are not defined in the
active package's section. This allows for a common set of defaults that can be overridden
by specific packages.
The package key at the root of the config.yaml file defines the active configuration package.
The application will load the configuration under the key that matches the value of the package key.
For example, if package is set to "development", the application will load the settings
under the development: section.
The active package can be overridden by setting the AXION_PACKAGE environment variable.
If this environment variable is set, its value will be used to determine the active package,
and the package key in config.yaml will be ignored.
The configuration is organized into sections (e.g., database, domain). The application
loads the sections from the currently active package.
base SectionThere is a special section named base. If a specific configuration option is not found in
the active package's section, the application will look for it in the corresponding section
under base. This allows for defining default values that can be shared across multiple packages.
The configuration supports several dynamic values that are replaced at runtime:
$package$: Replaced with the name of the active package.$dns$: Replaced with the value of the dns key in the domain section of the active package.$terraform$: Replaced with the corresponding value from the terraform section.$environment_KEY$: Replaced with the value of the environment variable AXION_KEY. For example, $environment_USER$ would be replaced by the value of the AXION_USER environment variable.You can define remote connections in the config.yaml file. These connections are used to
connect to remote services, such as databases or message queues. The application will use
the connections defined in the active package's section. From the code the remote connections
connected via the sys_remote_connections table.
connections:
- name: janee
ip: mariadb.netbird.cloud
user: axion
password: |
^llOvFraZP9Rh+pH63RMXfxEsgpS/FH2Erjvfhn9itwV1t/aii3+6EKj44hJZN5O61+mnVZzZUCCctEY9JV4PFlTdAg8ZaH4lM9J
vc5A49eTZy1VcPtJLESCfbb0YqgjJcJbh49vz5Na9rdOxH8lHnV08naM7VZum/ryeusBcGzg01VQahmNcX35YVzD1SdBDbQrCFN3
hVbPvC4ny2TYxvx8MthYur+Kj2JWhraIerumSkJFAXYAXLQfoUr8H1TGe9wamOUdevQWmigERY4Ejczhd1dUWOM1uN6YU3VPi6Mp
HngTYyMkMwkxdXG1ynXzwv5Ql1hgpx9/70d2bTLONWQ==
db: janeedb.axion
type: mysql
If a value starts with ^ is an encrypted value. The application will automatically decrypt it at runtime.
The configuration file can contain encrypted values. These values are encrypted using a
public/private key pair. Encrypted values are identified by a ^ prefix.
To generate the required encryption keys, you can use the following command:
python factory.core/ConfigIni.py genkey <package_name>
Replace <package_name> with the name of the package for which you want to generate the
keys (e.g., development). This command will create _private.pem and _public.pem files in
the data.config/ directory.
To encrypt a value, you can use the encrypt method in the ConfigIni class. To use an encrypted
value in config.yaml, simply prefix it with ^. The application will automatically decrypt it at
runtime.