Integration with fabric#

class minke.fabrictools.FabricConfig(host, session_cls, runtime_config)#

A minke specific implementation of fabric’s Config.

The Connection which is used within a session to run commands on the remote host will be initialized with an object of Config. This object holds all configuration parameters which are collected and applied from different places in a predefined order:

  • Project configuration file placed within django’s BASE_DIR. See fabric’s documentation about configuration files for more informations about filename conventions.

  • Configurations from django’s settings file.

  • Configurations from config() of hostgroups associated with the session’s host.

  • Configurations from config() of the host itself.

  • Configurations from the session’s invoke_config.

  • Configurations coming from forms like MINKE_FABRIC_FORM and get_form() that were rendered for the session.

  • Required defaults to make fabric work well in the deamonized context of minke.

load_global_config()#

Global configuration parameters could be defined within django’s settings file. Therefore the parameters must be prefixed with FABRIC_. To support nested configuration attributes we apply them using the _load_snake_case_config() method with the lower case parameter names without the prefix.

A settings parameter like:

FABRIC_RUN_PTY = True

becomes:

config.run.pty = True
load_hostgroup_config(host)#

Each HostGroup can hold its own fabric configuration within the config field. The configuration must be a yaml formatted associative array.

The configuration of each hostgroup associated with the host to work on will be applied.

Note

The order in which configurations from multiple hostgroups are applied is not defined.

Parameters

host (host) – host object

load_host_config(host)#

Each Host can hold its own fabric configuration within the config field. The configuration must be a yaml formatted associative array.

The configuration of the host to work on will be applied.

Parameters

host (host) – host object

load_session_config(session_cls)#

Load config from session class

Parameters

session_cls (Session) – session class to work with

load_runtime_config(runtime_config)#

Load the data that was coming from forms. Form fields starting with ‘fabric_’ are applied as configuration. The other fields are added in an extra section named ‘session_data’.

Parameters

runtime_config (dict) – collected data from forms

set_required_defaults()#

To properly work with fabric in a deamon based context we need some defaults that must not be overwritten.

_load_snake_case_config(config)#

Load a plane config dictonary as a nested one using a simple convention: The snake case structure of a key represents the nested logic of the config object: A key like run_pty becomes config.run.pty.

Since some config attributes have underscores themselves we use a simple rule to prevent ambiguities:

The first part of the snake case key must already exists on the config object. The remaining part of the snake case key will be used as a second level key: Something like connect_kwargs_my_special_key will become config.connect_kwargs.my_special_key on the config object.

Parameters

config (dict) – a plane snake case key configuration

Raises

InvalidMinkeSetup – If a key does not match an existing configuration attribute.