salt.resources.dummy#

Dummy resource module for testing the Salt resource subsystem.

This module implements the dummy resource type. It is the resource analogue of salt.proxy.dummy — a self-contained, file-backed implementation that exercises the full resource lifecycle without requiring any real managed devices.

Unlike a proxy module, a resource module is loaded once per resource type per minion. A single instance of this module handles all dummy resources managed by the minion. The current resource context is conveyed via the __resource__ dunder rather than as a function parameter, keeping the interface consistent with all other Salt module systems.

Configuration (via Pillar):

resources:
  dummy:
    resource_ids:
      - dummy-01
      - dummy-02
      - dummy-03
salt.resources.dummy.discover(opts)#

Return the list of resource IDs of type dummy that this minion manages.

Called by saltutil.refresh_resources to populate the master's Resource Registry. For the dummy module the list of IDs is read from resource_ids under the dummy type in the configured resource pillar subtree.

Returns a list of bare resource IDs (not full SRNs) — e.g. ["dummy-01", "dummy-02"].

Parameters:

opts (dict) -- The Salt opts dict.

Return type:

list[str]

salt.resources.dummy.grains()#

Return the grains dict for the current resource.

The current resource context is available via __resource__. Each dummy resource reports a small set of static grains for use in targeting and state execution.

Return type:

dict

salt.resources.dummy.grains_refresh()#

Invalidate the cached grains for the current resource and return a freshly generated grains dict.

Return type:

dict

salt.resources.dummy.init(opts)#

Initialize the dummy resource type for this minion.

Called once when the resource type is loaded, before any per-resource operations are performed. Reads the resource type configuration from the dummy entry under the pillar subtree selected by resource_pillar_key (see salt.utils.resources.pillar_resources_tree()) and sets up shared type-level state in __context__["dummy_resource"].

Parameters:

opts (dict) -- The Salt opts dict.

salt.resources.dummy.initialized()#

Return True if init() has been called successfully for this resource type.

Checked by the loader before dispatching per-resource operations, in the same way salt.proxy.dummy.initialized() is used today.

Return type:

bool

salt.resources.dummy.package_install(name, **kwargs)#

Install a "package" on the current dummy resource.

salt.resources.dummy.package_list()#

List "packages" installed on the current dummy resource.

salt.resources.dummy.package_remove(name)#

Remove a "package" from the current dummy resource.

salt.resources.dummy.package_status(name)#

Return the installation status of a package on the current dummy resource.

salt.resources.dummy.ping()#

Return True if the current resource is reachable and responsive.

For the dummy module this always returns True; no real connection is made.

salt.resources.dummy.service_list()#

List "services" on the current dummy resource.

salt.resources.dummy.service_restart(name)#

Restart a "service" on the current dummy resource.

salt.resources.dummy.service_start(name)#

Start a "service" on the current dummy resource.

salt.resources.dummy.service_status(name)#

Return the status of a service on the current dummy resource.

salt.resources.dummy.service_stop(name)#

Stop a "service" on the current dummy resource.

salt.resources.dummy.shutdown(opts)#

Tear down the dummy resource type.

Called when the minion shuts down or the resource type is unloaded. Cleans up shared type-level state from __context__.

Parameters:

opts (dict) -- The Salt opts dict.

salt.resources.dummy.test_from_state()#

Test function so we have something to call from a state.

salt.resources.dummy.upgrade()#

"Upgrade" all packages on the current dummy resource.

salt.resources.dummy.uptodate()#

Report whether packages on the current dummy resource are up to date.