Werk #10199: Bakery plugins must save the configuration into yml_store parameter

Component Checks & agents
Title Bakery plugins must save the configuration into yml_store parameter
Date Nov 14, 2019
Checkmk Edition Checkmk Raw (CRE)
Checkmk Version 2.0.0i1
Level Trivial Change
Class New Feature
Compatibility Compatible - no manual interaction needed

Previously the Bakery configured Windows Agent using check_mk.ini configuration file: every script in enterprise/agents/bakery directory could write own configuration data into the own file. All those files had been later gathered into one check_mk.ini configuration file.

Since this release the Bakery configures Windows Agent using only check_mk.bakery.yml. All data located in the ini file will be ignored.

To correctly configure Windows Agent you must use new parameter in your bake_*** function named yml_store. This parameter has type YamlStore and imported automatically from agent_bakery_plugins.py.

Now the configuration data of all plugins are stored in a standard Python dictionary, which replicates the structure of the Windows Agent's configuration file.

The following sample bake function sets the agent port setting for the Yaml file. It receives the configured port for the agent configuration and creates two entries, "enabled" and "port" in the "global" section.

def bake_agent_port(opsys, conf, conf_dir, plugins_dir, yml_store):
  #                                                     ^^^^^^^^^
  global_section = yml_store.make_section["global"] # mandatory to get dict
  #                                        ^^^^^^
  global_section["enabled"] = True  # mandatory also

  global_section["port"] = conf  # configures the Agent port
  #               ^^^^     ^^^^

The function above creates the following definitions in the check_mk.bakery.yml:

global:
  enabled: True
  port: 6551

To the list of all Werks