progfiguration.sitehelpers.memhosts#

A memory-based inventory store

The store is designed to be persisted to disk, perhaps with a configuration file or by defining the nodes/groups/etc in the site’s root module.

Module Contents#

Classes#

MemoryHostStore

An site's inventory

class progfiguration.sitehelpers.memhosts.MemoryHostStore(groups: Dict[str, List[str]], node_function_map: Dict[str, str], function_role_map: Dict[str, List[str]])#

An site’s inventory

property groups: List[str]#

All groups, in undetermined order

property nodes: List[str]#

All nodes, in undetermined order

property functions: List[str]#

All functions, in undetermined order

property roles: List[str]#

All roles, in undetermined order

property node_groups: Dict[str, List[str]]#

A dict, containing node:grouplist mappings

property function_nodes: Dict[str, List[str]]#

A dict, containing function:nodelist mappings

localhost#

A localhost object

TODO: probably should not use this

node_function#

A dict where keys are node names and values are function names

function_roles#

a dict where keys are function names and value are lists of role names

group_members#

a dict where keys are group names and values are lists of node names

node_rolename_list(nodename: str) List[str]#

A list of all rolenames for a given node

node(name: str) types.ModuleType#

The Python module for a given node

group(name: str) types.ModuleType#

The Python module for a given group

role_module(name: str) types.ModuleType#

The Python module for a given role

node_role(secretstore: progfiguration.inventory.invstores.SecretStore, nodename: str, rolename: str) progfiguration.inventory.roles.ProgfigurationRole#

A dict of {nodename: {rolename: ProgfigurationRole}}

Get an instantiated progfiguration.inventory.roles.ProgfigurationRole object for a given node and role.

We collect all arguments required to instantiate the role, including the superclass arguments like rolepkg and localhost, as well as role-specific arguments accepted by the given ProgfigurationRole subclass and defined as a default argument or in the group or node argument dicts. You can then call .apply() or .calculations() on the role.

Results are cached for subsequent calls.

node_role_list(nodename: str, secretstore: progfiguration.inventory.invstores.SecretStore) list[progfiguration.inventory.roles.ProgfigurationRole]#

A list of all instantiated roles for a given node