mc_macros / macros helpers¶
-
mc_states.modules.mc_macros.autoinclude(reg, additional_includes=None)¶ Helper to autoload & (un)register services in a top file
-
mc_states.modules.mc_macros.construct_registry_configuration(name, defaults=None)¶ Helper to factorise registry mappings
-
mc_states.modules.mc_macros.filecache_fun(func, args=None, kwargs=None, registry='disk_cache', prefix=None, ttl=1)¶ Execute a function and store the result in a filebased cache
- func
- func to execute
- args
- positional args to func
- kwargs
- kwargs to func
- registry
- name of the file inside /etc/makina-states
- prefix
- cache key
- ttl
- if 0: do not use cache
-
mc_states.modules.mc_macros.get_registry(registry_configuration)¶ Mangle a registry of activated/unactived states to be run as part of the automatic highstate inclusion.
{ 'kind': 'foo', 'bases': ['localsettings'], 'defaults': { 'mastersalt_minion': {'active': False}, 'mastersalt_master': {'active': False}, 'salt_minion': {'active': False}, 'salt_master': {'active': True} } } }Will activate the ‘makina-states.controllers.salt_master’ and deactivate all other states to be automaticly run
EG, for automatic activation of firewalld, lookup in Configs for this key (pillar, grains, reg):
makina-states.services.is.firewall.firewalld: true makina-states.services.firewall.firewalld: true
Idea why for the dict containing ‘active’, i did not choosed a simple boolean is to support other data in the near future.
We return here a registry in the form:
{ 'kind': 'foo', 'bases': ['localsettings'], 'states_pref': 'makina-states.foo', 'grains_pref': 'makina-states.foo', 'activated': {'salt_master': {'active': True}}, 'unactivated': { 'mastersalt_minion': {'active': False}, 'mastersalt_master': {'active': False}, 'salt_minion': {'active': False}, }, 'defaults': { 'mastersalt_minion': {'active': False}, 'mastersalt_master': {'active': False}, 'salt_minion': {'active': False}, 'salt_master': {'active': True} } } }
-
mc_states.modules.mc_macros.is_active(registry, name)¶ Is the queried service active in the registry
-
mc_states.modules.mc_macros.is_item_active(registry_name, item, default_status=False, grains_pref=None, force=False)¶ Look in pillar/grains/localconfig for registry activation status
-
mc_states.modules.mc_macros.pack_dump_local_registry(registry)¶ encode in a file using msgpack backend
-
mc_states.modules.mc_macros.register(kind, slss, data=None, suf='')¶ Register a/some service(s) in the local registry
-
mc_states.modules.mc_macros.unregister(kind, slss, data=None, suf='')¶ Unregister a/some service(s) in the local registry
-
mc_states.modules.mc_macros.update_local_registry(registry_name, params, registry_format='yaml')¶ Alias to update_local_registry
-
mc_states.modules.mc_macros.update_registry_params(registry_name, params, registry_format='yaml')¶ Update the desired local registry