salt_clear_hcache

Task to clear hosts’ task results cache stored in data. This task plugin does not have much practical applicability outside of SaltStack environment.

salt_clear_hcache sample usage

Sample code to run salt_clear_hcache task:

import pprint
from nornir import InitNornir
from nornir_salt.plugins.tasks import salt_clear_hcache

nr = InitNornir(config_file="config.yaml")

result = NornirObj.run(
    task=salt_clear_hcache,
    cache_keys=["cache_key1", "cache_key2"]
)

result_dictionary = ResultSerializer(result)

pprint.pprint(result_dictionary)

salt_clear_cache returns dictionary of cleared cache keys with status

  • True - cache key deleted

  • False - cache key not found

salt_clear_cache reference

nornir_salt.plugins.tasks.salt_clear_hcache.salt_clear_hcache(task: nornir.core.task.Task, cache_keys: List = None, **kwargs) nornir.core.task.Result

Function to iterate over provided cache keys and delete them from hosts’ data.

Parameters

cache_keys – (list of str) list of cache keys to clean from host’s data, if cache_keys argument not provided removes all cached data

Returns

(dict) dictionary keyed by cache key and True/False status