salt.runners.resource#

Operator-facing helpers for inspecting Salt Resources state on the master.

New in version 3008.0.

The mmap-backed registry (salt.utils.resource_registry) is the master's authority for which minions manage which resources. The resource_grains cache bank (populated by the master's _register_resources handler from each minion's salt.minion.Minion._collect_resource_grains() payload) is the source of truth for the per-resource grain dicts that drive salt -G / salt -P / salt -C 'G@…' matching.

This runner exposes thin read-only views over both so operators can debug "why didn't salt -G '<key>:<value>' test.ping match my resource?" without spelunking through pickled cache files by hand.

CLI examples:

salt-run resource.show_grains type=dummy id=dummy-01
salt-run resource.list_grains
salt-run resource.refresh minion=resources-minion
salt.runners.resource.list_grains()#

Return every SRN currently in the master's resource_grains cache bank along with a short summary (top-level grain keys, count).

Useful for sanity-checking that a minion's last _register_resources actually landed.

CLI Example:

salt-run resource.list_grains
salt.runners.resource.refresh(minion)#

Ask one minion to re-render its per-resource grains and re-publish them to the master's resource_grains bank.

Fires the resource_refresh event at the minion via the master event bus; the minion's event handler re-runs _discover_resources + _register_resources_with_master.

Use this when a resource's underlying state changed out-of-band (e.g. the operator updated metadata via the resource's connection module) and you need the master's grain bank to reflect it without waiting for the next pillar refresh.

CLI Example:

salt-run resource.refresh minion=resources-minion
Parameters:

minion (str) -- Minion ID to send the event to.

Return type:

bool

salt.runners.resource.show_grains(type, id)#

Return the per-resource grain dict the master has cached for one resource, or None if no entry exists.

The resource is addressed by the same composite SRN the registry uses internally: "<type>:<id>".

CLI Example:

salt-run resource.show_grains type=dummy id=dummy-01
Parameters:
  • type (str) -- The resource type (e.g. "dummy", "ssh").

  • id (str) -- The bare resource id (e.g. "dummy-01").

Return type:

dict or None