neulab/tldr huggingface dataset:
In order to run state and highstate saltcheck tests, a sub-folder in the state directory must be created and named saltcheck-tests. Tests for a state should be created in files ending in *.tst and placed in the saltcheck-tests folder. tst files are run through the salt rendering system, enabling tests to be written in yaml (or renderer of choice), and include jinja, as well as the usual grain and pillar information. Like states, multiple tests can be specified in a tst file. Multiple tst files can be created in the saltcheck-tests folder, and should be named the same as the associated state. The id of a test works in the same manner as in salt state files and should be unique and descriptive.
New in version 3000: The saltcheck-tests folder can be customized using the saltcheck_test_location minion configuration setting.  This setting is a relative path from the formula's salt:// path to the test files.
Usage Example Default file system layout:
/srv/salt/apache/ init.sls config.sls saltcheck-tests/ init.tst config.tst deployment_validation.tst
Alternative example file system layout with custom saltcheck_test_location:
Minion configuration: saltcheck_test_location: tests/integration/saltcheck
Filesystem layout: /srv/salt/apache/ init.sls config.sls tests/integration/saltcheck/ init.tst config.tst deployment_validation.tst
Tests can be run for each state by name, for all apache/saltcheck/*.tst files, or for all states assigned to the minion in top.sls. Tests may also be created with no associated state. These tests will be run through the use of saltcheck.run_state_tests, but will not be automatically run by saltcheck.run_highstate_tests.
salt '*' saltcheck.run_state_tests apache,apache.config salt '*' saltcheck.run_state_tests apache check_all=True salt '*' saltcheck.run_highstate_tests salt '*' saltcheck.run_state_tests apache.deployment_validation
Saltcheck Keywords module_and_function: (str) This is the salt module which will be run locally, the same as salt-call --local <module>. The saltcheck.state_apply module name is special as it bypasses the local option in order to resolve state names when run in a master/minion environment.
args:  (list) Optional arguments passed to the salt module
kwargs: (dict) Optional keyword arguments to be passed to the salt module
assertion: (str) One of the supported assertions and required except for saltcheck.state_apply Tests which fail the assertion and expected_return, cause saltcheck to exit which a non-zero exit code.
expected_return: (str) Required except by assertEmpty, assertNotEmpty, assertTrue, assertFalse. The return of module_and_function is compared to this value in the assertion.
assertion_section: (str) Optional keyword used to parse the module_and_function return. If a salt module returns a dictionary as a result, the assertion_section value is used to lookup a specific value in that return for the assertion comparison.
assertion_section_delimiter: (str) Optional delimiter to use when splitting a nested structure. Defaults to ':'
print_result: (bool) Optional keyword to show results in the assertEqual, assertNotEqual, assertIn, and assertNotIn output. Defaults to True.
output_details: (bool) Optional keyword to display module_and_function, args, assertion_section, and assertion results text in the output. If print_result is False, assertion results will be hidden.  This is a per test setting, but can be set globally for all tests by adding saltcheck_output_details: True in the minion configuration file.  Defaults to False
pillar_data: (dict) Optional keyword for passing in pillar data. Intended for use in potential test setup or teardown with the saltcheck.state_apply function.
skip:  (bool) Optional keyword to skip running the individual test
New in version 3000: Multiple assertions can be run against the output of a single module_and_function call. The assertion, expected_return, assertion_section, and assertion_section_delimiter keys can be placed in a list under an assertions key. See the multiple assertions example below.
Sample Cases/Examples Basic Example echo_test_hello: module_and_function: test.echo args: - "hello" kwargs: assertion: assertEqual expected_return:  'hello'
Example with jinja {% for package in ["apache2", "openssh"] %} {# or another example #} {# for package in salt['pillar.get']("packages") #} test_{{ package }}_latest: module_and_function: pkg.upgrade_available args: - {{ package }} assertion: assertFalse {% endfor %}
Example with setup state including pillar setup_test_environment: module_and_function: saltcheck.state_apply args: - common pillar_data: data: value
verify_vim: module_and_function: pkg.version args: - vim assertion: assertNotEmpty
Example with setup state including pillar setup_test_environment: module_and_function: saltcheck.state_apply args: - common pillar-data: data: value
Example with skip package_latest: module_and_function: pkg.upgrade_available args: - apache2 assertion: assertFalse skip: True
Example with assertion_section validate_shell: module_and_function: user.info args: - root assertion: assertEqual expected_return: /bin/bash assertion_section: shell
Example with a nested assertion_section validate_smb_signing: module_and_function: lgpo.get args: - 'Machine' kwargs: return_full_policy_names: True assertion: assertEqual expected_return: Enabled assertion_section: 'Computer Configuration|Microsoft network client: Digitally sign communications (always)' assertion_section_delimiter: '|'
Example suppressing print results validate_env_nameNode: module_and_function: hadoop.dfs args: - text - /oozie/common/env.properties expected_return: nameNode = hdfs://nameservice2 assertion: assertNotIn print_result: False
Example with multiple assertions and output_details multiple_validations: module_and_function: network.netstat assertions: - assertion: assertEqual assertion_section: "0:program" expected_return: "systemd-resolve" - assertion: assertEqual assertion_section: "0:proto" expected_return: "udp" output_details: True
Supported assertions • assertEqual
• assertNotEqual
• assertTrue
• assertFalse
• assertIn
• assertNotIn
• assertGreater
• assertGreaterEqual
• assertLess
• assertLessEqual
• assertEmpty
• assertNotEmpty
WARNING: The saltcheck.state_apply function is an alias for state.apply. If using the ACL system saltcheck.* might provide more capability than intended if only saltcheck.run_state_tests and saltcheck.run_highstate_tests are needed.
class salt.modules.saltcheck.SaltCheck(saltenv='base') This class validates and runs the saltchecks
run_test(test_dict) Run a single saltcheck test
class salt.modules.saltcheck.StateTestLoader(saltenv='base') Class loads in test files for a state e.g. state_dir/saltcheck-tests/[1.tst, 2.tst, 3.tst]
add_test_files_for_sls(sls_name, check_all=False) Detects states used, caches needed files, and adds to test list
load_test_suite() Load tests either from one file, or a set of files
salt.modules.saltcheck.parallel_scheck(data) triggers salt-call in parallel
salt.modules.saltcheck.report_highstate_tests(saltenv=None) Report on tests for states assigned to the minion through highstate.  Quits with the exit code for the number of missing tests.
salt '*' saltcheck.report_highstate_tests
salt.modules.saltcheck.run_highstate_tests(saltenv=None, only_fails=False) Execute all tests for states assigned to the minion through highstate and return results
• saltenv (str) -- optional saltenv. Defaults to base
• only_fails (bool) -- boolean to only print failure results
salt '*' saltcheck.run_highstate_tests
salt.modules.saltcheck.run_state_tests(state, saltenv=None, check_all=False, only_fails=False) Execute tests for a salt state and return results Nested states will also be tested
• state (str) -- state name for which to run associated .tst test files
• check_all (bool) -- boolean to run all tests in state/saltcheck-tests directory
salt '*' saltcheck.run_state_tests postfix,common
Tests will be run in parallel by adding "saltcheck_parallel: True" in minion config.  When enabled, saltcheck will use up to the number of cores detected. This can be limited by setting the "saltcheck_processes" value to an integer to set the maximum number of parallel processes.
salt.modules.saltcheck.run_state_tests_ssh(state, saltenv=None, check_all=False, only_fails=False) This function is an alias of run_state_tests. Execute tests for a salt state and return results Nested states will also be tested
param str state state name for which to run associated .tst test files
param str saltenv optional saltenv. Defaults to base
param bool check_all boolean to run all tests in state/saltcheck-tests directory
param bool only_fails boolean to only print failure results
salt.modules.saltcheck.run_test(**kwargs) Execute one saltcheck test and return result
Parameters arg test (keyword) --
salt '*' saltcheck.run_test test='{"module_and_function": "test.echo", "assertion": "assertEqual", "expected_return": "This works!", "args":["This works!"] }'
salt.modules.saltcheck.state_apply(state_name, **kwargs) Runs state.apply with given options to set up test data.  Intended to be used for optional test setup or teardown
Reference the state.apply module documentation for arguments and usage options
salt '*' saltcheck.state_apply postfix
salt.modules.saltcloudmod Control a salt cloud system
salt.modules.saltcloudmod.create(name, profile) Create the named vm
salt <minion-id> saltcloud.create webserver rackspace_centos_512
salt.modules.saltutil The Saltutil module is used to manage the state of the salt minion itself. It is used to manage minion modules as well as automate updates to the salt minion.
• esky Python module for update functionality
salt.modules.saltutil.clear_cache() Forcibly removes all caches on a minion.
WARNING: The safest way to clear a minion cache is by first stopping the minion and then deleting the cache files before restarting it.
salt '*' saltutil.clear_cache
salt.modules.saltutil.clear_job_cache(hours=24) Forcibly removes job cache folders and files on a minion.
salt '*' saltutil.clear_job_cache hours=12
salt.modules.saltutil.cmd(tgt, fun, arg=(), timeout=None, tgt_type='glob', ret='', kwarg=None, ssh=False, **kwargs) Changed in version 2017.7.0: The expr_form argument has been renamed to tgt_type, earlier releases must use expr_form.
Assuming this minion is a master, execute a salt command
salt '*' saltutil.cmd
salt.modules.saltutil.cmd_iter(tgt, fun, arg=(), timeout=None, tgt_type='glob', ret='', kwarg=None, ssh=False, **kwargs) Changed in version 2017.7.0: The expr_form argument has been renamed to tgt_type, earlier releases must use expr_form.
salt '*' saltutil.cmd_iter
salt.modules.saltutil.find_cached_job(jid) Return the data for a specific cached job id. Note this only works if cache_jobs has previously been set to True on the minion.
salt '*' saltutil.find_cached_job <job id>
salt.modules.saltutil.find_job(jid) Return the data for a specific job id that is currently running.
jid    The job id to search for and return data.
salt '*' saltutil.find_job <job id>
Note that the find_job function only returns job information when the job is still running. If the job is currently running, the output looks something like this:
# salt my-minion saltutil.find_job 20160503150049487736 my-minion: ---------- arg: - 30 fun: test.sleep jid: 20160503150049487736 pid: 9601 ret: tgt: my-minion tgt_type: glob user: root
If the job has already completed, the job cannot be found and therefore the function returns an empty dictionary, which looks like this on the CLI:
# salt my-minion saltutil.find_job 20160503150049487736 my-minion: ----------
salt.modules.saltutil.is_running(fun) If the named function is running return the data associated with it/them.  The argument can be a glob
salt '*' saltutil.is_running state.highstate
salt.modules.saltutil.kill_all_jobs() Sends a kill signal (SIGKILL 9) to all currently running jobs
salt '*' saltutil.kill_all_jobs
salt.modules.saltutil.kill_job(jid) Sends a kill signal (SIGKILL 9) to the named salt job's process
salt '*' saltutil.kill_job <job id>
salt.modules.saltutil.list_extmods() New in version 2017.7.0.
List Salt modules which have been synced externally
salt '*' saltutil.list_extmods
salt.modules.saltutil.mmodule(saltenv, fun, *args, **kwargs) Loads minion modules from an environment so that they can be used in pillars for that environment
salt '*' saltutil.mmodule base test.ping
salt.modules.saltutil.pillar_refresh(wait=False, timeout=30) This function is an alias of refresh_pillar. Signal the minion to refresh the in-memory pillar data. See pillar-in-memory.
param wait Wait for pillar refresh to complete, defaults to False.
type wait bool, optional
param timeout How long to wait in seconds, only used when wait is True, defaults to 30.
type timeout int, optional
return Boolean status, True when the pillar_refresh event was fired successfully.
salt '*' saltutil.refresh_pillar salt '*' saltutil.refresh_pillar wait=True timeout=60
salt.modules.saltutil.refresh_beacons() Signal the minion to refresh the beacons.
salt '*' saltutil.refresh_beacons
salt.modules.saltutil.refresh_grains(**kwargs) New in version 2016.3.6,2016.11.4,2017.7.0.
Refresh the minion's grains without syncing custom grains modules from salt://_grains.
NOTE: The available execution modules will be reloaded as part of this proceess, as grains can affect which modules are available.
refresh_pillar True Set to False to keep pillar data from being refreshed.
salt '*' saltutil.refresh_grains
salt.modules.saltutil.refresh_matchers() Signal the minion to refresh its matchers.
salt '*' saltutil.refresh_matchers
salt.modules.saltutil.refresh_modules(**kwargs) Signal the minion to refresh the module and grain data
The default is to refresh module asynchronously. To block until the module refresh is complete, set the 'async' flag to False.
salt '*' saltutil.refresh_modules
salt.modules.saltutil.refresh_pillar(wait=False, timeout=30) Signal the minion to refresh the in-memory pillar data. See pillar-in-memory.
• wait (bool, optional) -- Wait for pillar refresh to complete, defaults to False.
• timeout (int, optional) -- How long to wait in seconds, only used when wait is True, defaults to 30.
Returns Boolean status, True when the pillar_refresh event was fired successfully.
salt.modules.saltutil.regen_keys() Used to regenerate the minion keys.
salt '*' saltutil.regen_keys
salt.modules.saltutil.revoke_auth(preserve_minion_cache=False) The minion sends a request to the master to revoke its own key. Note that the minion session will be revoked and the minion may not be able to return the result of this command back to the master.
If the 'preserve_minion_cache' flag is set to True, the master cache for this minion will not be removed.
salt '*' saltutil.revoke_auth
salt.modules.saltutil.runner(name, arg=None, kwarg=None, full_return=False, saltenv='base', jid=None, **kwargs) Execute a runner function. This function must be run on the master, either by targeting a minion running on a master or by using salt-call on a master.
name   The name of the function to run
kwargs Any keyword arguments to pass to the runner function
In this example, assume that master_minion is a minion running on a master.
salt master_minion saltutil.runner jobs.list_jobs salt master_minion saltutil.runner test.arg arg="['baz']" kwarg="{'foo': 'bar'}"
salt.modules.saltutil.running() Return the data on all running salt processes on the minion
salt '*' saltutil.running
salt.modules.saltutil.signal_job(jid, sig) Sends a signal to the named salt job's process
salt '*' saltutil.signal_job <job id> 15
salt.modules.saltutil.sync_all(saltenv=None, refresh=True, extmod_whitelist=None, extmod_blacklist=None) Changed in version 2015.8.11,2016.3.2: On masterless minions, pillar modules are now synced, and refreshed when refresh is set to True.
Sync down all of the dynamic modules from the file server for a specific environment. This function synchronizes custom modules, states, beacons, grains, returners, output modules, renderers, and utils.
refresh True Also refresh the execution modules and recompile pillar data available to the minion. This refresh will be performed even if no new dynamic modules are synced. Set to False to prevent this refresh.
IMPORTANT: If this function is executed using a module.run state, the SLS file will not have access to newly synced execution modules unless a refresh argument is added to the state, like so:
load_my_custom_module: module.run: - name: saltutil.sync_all - refresh: True
See here for a more detailed explanation of why this is necessary.
extmod_whitelist None dictionary of modules to sync based on type
extmod_blacklist None dictionary of modules to blacklist based on type
salt '*' saltutil.sync_all salt '*' saltutil.sync_all saltenv=dev salt '*' saltutil.sync_all saltenv=base,dev salt '*' saltutil.sync_all extmod_whitelist={'modules': ['custom_module']}
salt.modules.saltutil.sync_beacons(saltenv=None, refresh=True, extmod_whitelist=None, extmod_blacklist=None) New in version 2015.5.1.
Sync beacons from salt://_beacons to the minion
saltenv The fileserver environment from which to sync. To sync from more than one environment, pass a comma-separated list.
If not passed, then all environments configured in the top files will be checked for beacons to sync. If no top files are found, then the base environment will be synced.
refresh True If True, refresh the available beacons on the minion. This refresh will be performed even if no new beacons are synced. Set to False to prevent this refresh.
extmod_whitelist None comma-separated list of modules to sync
extmod_blacklist None comma-separated list of modules to blacklist based on type
salt '*' saltutil.sync_beacons salt '*' saltutil.sync_beacons saltenv=dev salt '*' saltutil.sync_beacons saltenv=base,dev
salt.modules.saltutil.sync_clouds(saltenv=None, refresh=True, extmod_whitelist=None, extmod_blacklist=None) New in version 2017.7.0.
Sync cloud modules from salt://_cloud to the minion
saltenv base The fileserver environment from which to sync. To sync from more than one environment, pass a comma-separated list.
refresh True If True, refresh the available execution modules on the minion.  This refresh will be performed even if no new utility modules are synced. Set to False to prevent this refresh.
salt '*' saltutil.sync_clouds salt '*' saltutil.sync_clouds saltenv=dev salt '*' saltutil.sync_clouds saltenv=base,dev
salt.modules.saltutil.sync_engines(saltenv=None, refresh=False, extmod_whitelist=None, extmod_blacklist=None) New in version 2016.3.0.
Sync engine modules from salt://_engines to the minion
If not passed, then all environments configured in the top files will be checked for engines to sync. If no top files are found, then the base environment will be synced.
refresh True If True, refresh the available execution modules on the minion.  This refresh will be performed even if no new engine modules are synced.  Set to False to prevent this refresh.
salt '*' saltutil.sync_engines salt '*' saltutil.sync_engines saltenv=base,dev
salt.modules.saltutil.sync_executors(saltenv=None, refresh=True, extmod_whitelist=None, extmod_blacklist=None) New in version 3000.
Sync executors from salt://_executors to the minion
If not passed, then all environments configured in the top files will be checked for log handlers to sync. If no top files are found, then the base environment will be synced.
refresh True If True, refresh the available execution modules on the minion.  This refresh will be performed even if no new log handlers are synced.  Set to False to prevent this refresh.
extmod_whitelist None comma-seperated list of modules to sync
extmod_blacklist None comma-seperated list of modules to blacklist based on type
salt '*' saltutil.sync_executors salt '*' saltutil.sync_executors saltenv=dev salt '*' saltutil.sync_executors saltenv=base,dev
salt.modules.saltutil.sync_grains(saltenv=None, refresh=True, extmod_whitelist=None, extmod_blacklist=None) New in version 0.10.0.
Sync grains modules from salt://_grains to the minion
If not passed, then all environments configured in the top files will be checked for grains modules to sync. If no top files are found, then the base environment will be synced.
refresh True If True, refresh the available execution modules and recompile pillar data for the minion. This refresh will be performed even if no new grains modules are synced. Set to False to prevent this refresh.
salt '*' saltutil.sync_grains salt '*' saltutil.sync_grains saltenv=dev salt '*' saltutil.sync_grains saltenv=base,dev
salt.modules.saltutil.sync_log_handlers(saltenv=None, refresh=True, extmod_whitelist=None, extmod_blacklist=None) New in version 2015.8.0.
Sync log handlers from salt://_log_handlers to the minion
salt '*' saltutil.sync_log_handlers salt '*' saltutil.sync_log_handlers saltenv=dev salt '*' saltutil.sync_log_handlers saltenv=base,dev
salt.modules.saltutil.sync_matchers(saltenv=None, refresh=False, extmod_whitelist=None, extmod_blacklist=None) New in version 2019.2.0.
Sync engine modules from salt://_matchers to the minion
refresh True If True, refresh the available execution modules on the minion.  This refresh will be performed even if no new matcher modules are synced.  Set to False to prevent this refresh.
salt '*' saltutil.sync_matchers salt '*' saltutil.sync_matchers saltenv=base,dev
salt.modules.saltutil.sync_modules(saltenv=None, refresh=True, extmod_whitelist=None, extmod_blacklist=None) New in version 0.10.0.
Sync execution modules from salt://_modules to the minion
If not passed, then all environments configured in the top files will be checked for execution modules to sync. If no top files are found, then the base environment will be synced.
refresh True If True, refresh the available execution modules on the minion.  This refresh will be performed even if no new execution modules are synced. Set to False to prevent this refresh.
load_my_custom_module: module.run: - name: saltutil.sync_modules - refresh: True
salt '*' saltutil.sync_modules salt '*' saltutil.sync_modules saltenv=dev salt '*' saltutil.sync_modules saltenv=base,dev
salt.modules.saltutil.sync_output(saltenv=None, refresh=True, extmod_whitelist=None, extmod_blacklist=None) Sync outputters from salt://_output to the minion
If not passed, then all environments configured in the top files will be checked for outputters to sync. If no top files are found, then the base environment will be synced.
refresh True If True, refresh the available execution modules on the minion.  This refresh will be performed even if no new outputters are synced.  Set to False to prevent this refresh.
salt '*' saltutil.sync_output salt '*' saltutil.sync_output saltenv=dev salt '*' saltutil.sync_output saltenv=base,dev
salt.modules.saltutil.sync_outputters(saltenv=None, refresh=True, extmod_whitelist=None, extmod_blacklist=None) This function is an alias of sync_output. Sync outputters from salt://_output to the minion
salt.modules.saltutil.sync_pillar(saltenv=None, refresh=True, extmod_whitelist=None, extmod_blacklist=None) New in version 2015.8.11,2016.3.2.
Sync pillar modules from the salt://_pillar directory on the Salt fileserver. This function is environment-aware, pass the desired environment to grab the contents of the _pillar directory from that environment. The default environment, if none is specified, is base.
refresh True Also refresh the execution modules available to the minion, and refresh pillar data.
NOTE: This function will raise an error if executed on a traditional (i.e.  not masterless) minion
salt '*' saltutil.sync_pillar salt '*' saltutil.sync_pillar saltenv=dev
salt.modules.saltutil.sync_proxymodules(saltenv=None, refresh=False, extmod_whitelist=None, extmod_blacklist=None) New in version 2015.8.2.
Sync proxy modules from salt://_proxy to the minion
If not passed, then all environments configured in the top files will be checked for proxy modules to sync. If no top files are found, then the base environment will be synced.
refresh True If True, refresh the available execution modules on the minion.  This refresh will be performed even if no new proxy modules are synced.  Set to False to prevent this refresh.
salt '*' saltutil.sync_proxymodules salt '*' saltutil.sync_proxymodules saltenv=dev salt '*' saltutil.sync_proxymodules saltenv=base,dev
salt.modules.saltutil.sync_renderers(saltenv=None, refresh=True, extmod_whitelist=None, extmod_blacklist=None) New in version 0.10.0.
Sync renderers from salt://_renderers to the minion
If not passed, then all environments configured in the top files will be checked for renderers to sync. If no top files are found, then the base environment will be synced.
refresh True If True, refresh the available execution modules on the minion.  This refresh will be performed even if no new renderers are synced.  Set to False to prevent this refresh. Set to False to prevent this refresh.
salt '*' saltutil.sync_renderers salt '*' saltutil.sync_renderers saltenv=dev salt '*' saltutil.sync_renderers saltenv=base,dev
salt.modules.saltutil.sync_returners(saltenv=None, refresh=True, extmod_whitelist=None, extmod_blacklist=None) New in version 0.10.0.
Sync returners from salt://_returners to the minion
If not passed, then all environments configured in the top files will be checked for returners to sync. If no top files are found, then the base environment will be synced.
refresh True If True, refresh the available execution modules on the minion.  This refresh will be performed even if no new returners are synced. Set to False to prevent this refresh.
salt '*' saltutil.sync_returners salt '*' saltutil.sync_returners saltenv=dev
salt.modules.saltutil.sync_sdb(saltenv=None, extmod_whitelist=None, extmod_blacklist=None) New in version 2015.5.8,2015.8.3.
Sync sdb modules from salt://_sdb to the minion
If not passed, then all environments configured in the top files will be checked for sdb modules to sync. If no top files are found, then the base environment will be synced.
refresh False This argument has no affect and is included for consistency with the other sync functions.
salt '*' saltutil.sync_sdb salt '*' saltutil.sync_sdb saltenv=dev salt '*' saltutil.sync_sdb saltenv=base,dev
salt.modules.saltutil.sync_serializers(saltenv=None, refresh=True, extmod_whitelist=None, extmod_blacklist=None) New in version 2019.2.0.
Sync serializers from salt://_serializers to the minion
If not passed, then all environments configured in the top files will be checked for serializer modules to sync. If no top files are found, then the base environment will be synced.
refresh True If True, refresh the available execution modules on the minion.  This refresh will be performed even if no new serializer modules are synced. Set to False to prevent this refresh.
salt '*' saltutil.sync_serializers salt '*' saltutil.sync_serializers saltenv=dev salt '*' saltutil.sync_serializers saltenv=base,dev
salt.modules.saltutil.sync_states(saltenv=None, refresh=True, extmod_whitelist=None, extmod_blacklist=None) New in version 0.10.0.
Sync state modules from salt://_states to the minion
If not passed, then all environments configured in the top files will be checked for state modules to sync. If no top files are found, then the base environment will be synced.
refresh True If True, refresh the available states on the minion. This refresh will be performed even if no new state modules are synced. Set to False to prevent this refresh.
salt '*' saltutil.sync_states salt '*' saltutil.sync_states saltenv=dev salt '*' saltutil.sync_states saltenv=base,dev
salt.modules.saltutil.sync_thorium(saltenv=None, refresh=False, extmod_whitelist=None, extmod_blacklist=None) New in version 2018.3.0.
Sync Thorium modules from salt://_thorium to the minion
refresh: True If True, refresh the available execution modules on the minion.  This refresh will be performed even if no new Thorium modules are synced.  Set to False to prevent this refresh.
extmod_whitelist comma-separated list of modules to sync
extmod_blacklist comma-separated list of modules to blacklist based on type
salt '*' saltutil.sync_thorium salt '*' saltutil.sync_thorium saltenv=base,dev
salt.modules.saltutil.sync_utils(saltenv=None, refresh=True, extmod_whitelist=None, extmod_blacklist=None) New in version 2014.7.0.
Sync utility modules from salt://_utils to the minion
If not passed, then all environments configured in the top files will be checked for utility modules to sync. If no top files are found, then the base environment will be synced.
salt '*' saltutil.sync_utils salt '*' saltutil.sync_utils saltenv=dev salt '*' saltutil.sync_utils saltenv=base,dev
salt.modules.saltutil.term_all_jobs() Sends a termination signal (SIGTERM 15) to all currently running jobs
salt '*' saltutil.term_all_jobs
salt.modules.saltutil.term_job(jid) Sends a termination signal (SIGTERM 15) to the named salt job's process
salt '*' saltutil.term_job <job id>
salt.modules.saltutil.update(version=None) Update the salt minion from the URL defined in opts['update_url'] SaltStack, Inc provides the latest builds here: update_url: https://repo.saltproject.io/windows/
Be aware that as of 2014-8-11 there's a bug in esky such that only the latest version available in the update_url can be downloaded and installed.
This feature requires the minion to be running a bdist_esky build.
The version number is optional and will default to the most recent version available at opts['update_url'].
Returns details about the transaction upon completion.
salt '*' saltutil.update salt '*' saltutil.update 0.10.3
salt.modules.saltutil.wheel(name, *args, **kwargs) Execute a wheel module and function. This function must be run against a minion that is local to the master.
args   Any positional arguments to pass to the wheel function. A common example of this would be the match arg needed for key functions.
New in version 2015.8.11.
kwargs Any keyword arguments to pass to the wheel function
salt my-local-minion saltutil.wheel key.accept jerry salt my-local-minion saltutil.wheel minions.connected
NOTE: Since this function must be run against a minion that is running locally on the master in order to get accurate returns, if this function is run against minions that are not local to the master, "empty" returns are expected. The remote minion does not have access to wheel functions and their return data.
salt.modules.schedule Module for managing the Salt schedule on a minion
salt.modules.schedule.add(name, **kwargs) Add a job to the schedule
salt '*' schedule.add job1 function='test.ping' seconds=3600 # If function have some arguments, use job_args salt '*' schedule.add job2 function='cmd.run' job_args="['date >> /tmp/date.log']" seconds=60
salt.modules.schedule.build_schedule_item(name, **kwargs) Build a schedule job
salt '*' schedule.build_schedule_item job1 function='test.ping' seconds=3600
salt.modules.schedule.copy(name, target, **kwargs) Copy scheduled job to another minion or minions.
salt '*' schedule.copy jobname target
salt.modules.schedule.delete(name, **kwargs) Delete a job from the minion's schedule
salt '*' schedule.delete job1
salt.modules.schedule.disable(**kwargs) Disable all scheduled jobs on the minion
salt '*' schedule.disable
salt.modules.schedule.disable_job(name, **kwargs) Disable a job in the minion's schedule
salt '*' schedule.disable_job job1
salt.modules.schedule.enable(**kwargs) Enable all scheduled jobs on the minion
salt '*' schedule.enable
salt.modules.schedule.enable_job(name, **kwargs) Enable a job in the minion's schedule
salt '*' schedule.enable_job job1
salt.modules.schedule.is_enabled(name=None) List a Job only if its enabled
If job is not specified, indicate if the scheduler is enabled or disabled.
salt '*' schedule.is_enabled name=job_name
salt '*' schedule.is_enabled
salt.modules.schedule.job_status(name) Show the information for a particular job.
salt '*' schedule.job_status
salt.modules.schedule.list_(show_all=False, show_disabled=True, where=None, return_yaml=True) List the jobs currently scheduled on the minion
salt '*' schedule.list
# Show all jobs including hidden internal jobs salt '*' schedule.list show_all=True
# Hide disabled jobs from list of jobs salt '*' schedule.list show_disabled=False
salt.modules.schedule.modify(name, **kwargs) Modify an existing job in the schedule
salt '*' schedule.modify job1 function='test.ping' seconds=3600
salt.modules.schedule.move(name, target, **kwargs) Move scheduled job to another minion or minions.
salt '*' schedule.move jobname target
salt.modules.schedule.postpone_job(name, current_time, new_time, **kwargs) Postpone a job in the minion's schedule
Current time and new time should be in date string format, default value is %Y-%m-%dT%H:%M:%S.
salt '*' schedule.postpone_job job current_time new_time
salt '*' schedule.postpone_job job current_time new_time time_fmt='%Y-%m-%dT%H:%M:%S'
salt.modules.schedule.purge(**kwargs) Purge all the jobs currently scheduled on the minion
salt '*' schedule.purge
salt.modules.schedule.reload_() Reload saved scheduled jobs on the minion
salt '*' schedule.reload
salt.modules.schedule.run_job(name, force=False) Run a scheduled job on the minion immediately
salt '*' schedule.run_job job1
salt '*' schedule.run_job job1 force=True Force the job to run even if it is disabled.
salt.modules.schedule.save(**kwargs) Save all scheduled jobs on the minion
salt '*' schedule.save
salt.modules.schedule.show_next_fire_time(name, **kwargs) Show the next fire time for scheduled job
salt '*' schedule.show_next_fire_time job_name
salt.modules.schedule.skip_job(name, current_time, **kwargs) Skip a job in the minion's schedule at specified time.
Time to skip should be specified as date string format, default value is %Y-%m-%dT%H:%M:%S.
salt '*' schedule.skip_job job time
salt.modules.scp SCP Module New in version 2019.2.0.
Module to copy files via SCP
salt.modules.scp_mod.get(remote_path, local_path='', recursive=False, preserve_times=False, **kwargs) Transfer files and directories from remote host to the localhost of the Minion.
salt '*' scp.get /var/tmp/file /tmp/file hostname=10.10.10.1 auto_add_policy=True
salt.modules.scp_mod.put(files, remote_path=None, recursive=False, preserve_times=False, saltenv='base', **kwargs) Transfer files and directories to remote host.
salt '*' scp.put /path/to/file /var/tmp/file hostname=server1 auto_add_policy=True
salt.modules.scsi SCSI administration module
salt.modules.scsi.ls_(get_size=True) List SCSI devices, with details
salt '*' scsi.ls salt '*' scsi.ls get_size=False
get_size True Get the size information for scsi devices.  This option should be set to False for older OS distributions (RHEL6 and older) due to lack of support for the '-s' option in lsscsi.
New in version 2015.5.10.
salt.modules.scsi.rescan_all(host) List scsi devices
salt '*' scsi.rescan_all 0
salt.modules.sdb Module for Manipulating Data via the Salt DB API salt.modules.sdb.delete(uri) Delete a value from a db, using a uri in the form of sdb://<profile>/<key>.  If the uri provided does not start with sdb:// or the value is not successfully deleted, return False.
salt '*' sdb.delete sdb://mymemcached/foo
salt.modules.sdb.get(uri, strict=False) Get a value from a db, using a uri in the form of sdb://<profile>/<key>. If the uri provided is not valid, then it will be returned as-is, unless strict=True was passed.
salt '*' sdb.get sdb://mymemcached/foo strict=True
salt.modules.sdb.get_or_set_hash(uri, length=8, chars='abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)') Perform a one-time generation of a hash and write it to sdb.  If that value has already been set return the value instead.
This is useful for generating passwords or keys that are specific to multiple minions that need to be stored somewhere centrally.
some_mysql_user: mysql_user: - present - host: localhost - password: '{{ salt['sdb.get_or_set_hash']('some_mysql_user_pass') }}'
salt '*' sdb.get_or_set_hash 'SECRET_KEY' 50
salt.modules.sdb.set_(uri, value) Set a value in a db, using a uri in the form of sdb://<profile>/<key>.  If the uri provided does not start with sdb:// or the value is not successfully set, return False.
salt '*' sdb.set sdb://mymemcached/foo bar
salt.modules.seed Virtual machine image management tools
salt.modules.seed.apply_(path, id_=None, config=None, approve_key=True, install=True, prep_install=False, pub_key=None, priv_key=None, mount_point=None) Seed a location (disk image, directory, or block device) with the minion config, approve the minion's key, and/or install salt-minion.
salt 'minion' seed.apply path id [config=config_data] \ [gen_key=(true|false)] [approve_key=(true|false)] \ [install=(true|false)]
path   Full path to the directory, device, or disk image  on the target minion's file system.
id     Minion id with which to seed the path.
config Minion configuration options. By default, the 'master' option is set to the target host's 'master'.
approve_key Request a pre-approval of the generated minion key. Requires that the salt-master be configured to either auto-accept all keys or expect a signing request from the target host. Default: true.
install Install salt-minion, if absent. Default: true.
prep_install Prepare the bootstrap script, but don't run it. Default: false
salt.modules.seed.mkconfig(config=None, tmp=None, id_=None, approve_key=True, pub_key=None, priv_key=None) Generate keys and config and put them in a tmp directory.
pub_key absolute path or file content of an optional preseeded salt key
priv_key absolute path or file content of an optional preseeded salt key
salt 'minion' seed.mkconfig [config=config_data] [tmp=tmp_dir] \ [id_=minion_id] [approve_key=(true|false)]
salt.modules.seed.prep_bootstrap(mpt) Update and get the random script to a random place
salt '*' seed.prep_bootstrap /tmp
salt.modules.selinux Execute calls on selinux
NOTE: This module requires the semanage, setsebool, and semodule commands to be available on the minion. On RHEL-based distributions, ensure that the policycoreutils and policycoreutils-python packages are installed. If not on a Fedora or RHEL-based distribution, consult the selinux documentation for your distribution to ensure that the proper packages are installed.
salt.modules.selinux.fcontext_add_policy(name, filetype=None, sel_type=None, sel_user=None, sel_level=None) New in version 2019.2.0.
Adds the SELinux policy for a given filespec and other optional parameters.
Returns the result of the call to semanage.
Note that you don't have to remove an entry before setting a new one for a given filespec and filetype, as adding one with semanage automatically overwrites a previously configured SELinux context.
name   filespec of the file or directory. Regex syntax is allowed.
file_type The SELinux filetype specification. Use one of [a, f, d, c, b, s, l, p]. See also man semanage-fcontext. Defaults to 'a' (all files).
sel_type SELinux context type. There are many.
sel_user SELinux user. Use semanage login -l to determine which ones are available to you.
sel_level The MLS range of the SELinux context.
salt '*' selinux.fcontext_add_policy my-policy
salt.modules.selinux.fcontext_apply_policy(name, recursive=False) New in version 2017.7.0.
Applies SElinux policies to filespec using restorecon [-R] filespec. Returns dict with changes if successful, the output of the restorecon command otherwise.
recursive Recursively apply SELinux policies.
salt '*' selinux.fcontext_apply_policy my-policy
salt.modules.selinux.fcontext_delete_policy(name, filetype=None, sel_type=None, sel_user=None, sel_level=None) New in version 2019.2.0.
Deletes the SELinux policy for a given filespec and other optional parameters.
salt '*' selinux.fcontext_delete_policy my-policy
salt.modules.selinux.fcontext_get_policy(name, filetype=None, sel_type=None, sel_user=None, sel_level=None) New in version 2017.7.0.
Returns the current entry in the SELinux policy list as a dictionary. Returns None if no exact match was found.
Returned keys are:
• filespec (the name supplied and matched)
• filetype (the descriptive name of the filetype supplied)
• sel_user, sel_role, sel_type, sel_level (the selinux context)
For a more in-depth explanation of the selinux context, go to https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/6/html/Security-Enhanced_Linux/chap-Security-Enhanced_Linux-SELinux_Contexts.html
filetype The SELinux filetype specification. Use one of [a, f, d, c, b, s, l, p]. See also man semanage-fcontext. Defaults to 'a' (all files).
salt '*' selinux.fcontext_get_policy my-policy
salt.modules.selinux.fcontext_policy_is_applied(name, recursive=False) New in version 2017.7.0.
Returns an empty string if the SELinux policy for a given filespec is applied, returns string with differences in policy and actual situation otherwise.
salt '*' selinux.fcontext_policy_is_applied my-policy
salt.modules.selinux.filetype_id_to_string(filetype='a') New in version 2017.7.0.
Translates SELinux filetype single-letter representation to a more human-readable version (which is also used in semanage fcontext -l).
salt.modules.selinux.getconfig() Return the selinux mode from the config file
salt '*' selinux.getconfig
salt.modules.selinux.getenforce() Return the mode selinux is running in
salt '*' selinux.getenforce
salt.modules.selinux.getsebool(boolean) Return the information on a specific selinux boolean
salt '*' selinux.getsebool virt_use_usb
salt.modules.selinux.getsemod(module) Return the information on a specific selinux module
salt '*' selinux.getsemod mysql
salt.modules.selinux.install_semod(module_path) Install custom SELinux module from file
salt '*' selinux.install_semod [salt://]path/to/module.pp
salt.modules.selinux.list_sebool() Return a structure listing all of the selinux booleans on the system and what state they are in
salt '*' selinux.list_sebool
salt.modules.selinux.list_semod() Return a structure listing all of the selinux modules on the system and what state they are in
salt '*' selinux.list_semod
salt.modules.selinux.port_add_policy(name, sel_type=None, protocol=None, port=None, sel_range=None) New in version 2019.2.0.
Adds the SELinux policy for a given protocol and port.
name   The protocol and port spec. Can be formatted as (tcp|udp)/(port|port-range).
sel_type The SELinux Type. Required.
protocol The protocol for the port, tcp or udp. Required if name is not formatted.
port   The port or port range. Required if name is not formatted.
sel_range The SELinux MLS/MCS Security Range.
salt '*' selinux.port_add_policy add tcp/8080 http_port_t salt '*' selinux.port_add_policy add foobar http_port_t protocol=tcp port=8091
salt.modules.selinux.port_delete_policy(name, protocol=None, port=None) New in version 2019.2.0.
Deletes the SELinux policy for a given protocol and port.
salt '*' selinux.port_delete_policy tcp/8080 salt '*' selinux.port_delete_policy foobar protocol=tcp port=8091
salt.modules.selinux.port_get_policy(name, sel_type=None, protocol=None, port=None) New in version 2019.2.0.
• sel_type (the selinux type)
• proto (the protocol)
• port (the port(s) and/or port range(s))
sel_type The SELinux Type.
salt '*' selinux.port_get_policy tcp/80 salt '*' selinux.port_get_policy foobar protocol=tcp port=80
salt.modules.selinux.remove_semod(module) Remove SELinux module
salt '*' selinux.remove_semod module_name
salt.modules.selinux.selinux_fs_path() Return the location of the SELinux VFS directory
salt '*' selinux.selinux_fs_path
salt.modules.selinux.setenforce(mode) Set the SELinux enforcing mode
salt '*' selinux.setenforce enforcing
salt.modules.selinux.setsebool(boolean, value, persist=False) Set the value for a boolean
salt '*' selinux.setsebool virt_use_usb off
salt.modules.selinux.setsebools(pairs, persist=False) Set the value of multiple booleans
salt '*' selinux.setsebools '{virt_use_usb: on, squid_use_tproxy: off}'
salt.modules.selinux.setsemod(module, state) Enable or disable an SELinux module.
salt '*' selinux.setsemod nagios Enabled
salt.modules.sensehat Module for controlling the LED matrix or reading environment data on the SenseHat of a Raspberry Pi.
maintainer Benedikt Werner <1benediktwerner@gmail.com>, Joachim Werner <‐ joe@suse.com>
The rotation of the Pi can be specified in a pillar.  This is useful if the Pi is used upside down or sideways to correct the orientation of the image being shown.
sensehat: rotation: 90
salt.modules.sensehat.clear(color=None) Sets the LED matrix to a single color or turns all LEDs off.
salt 'raspberry' sensehat.clear salt 'raspberry' sensehat.clear '[255, 0, 0]'
salt.modules.sensehat.get_humidity() Get the percentage of relative humidity from the humidity sensor.
salt.modules.sensehat.get_pixel(x, y) Returns the color of a single pixel on the LED matrix.
x      The x coordinate of the pixel. Ranges from 0 on the left to 7 on the right.
y      The y coordinate of the pixel. Ranges from 0 at the top to 7 at the bottom.
NOTE: Please read the note for get_pixels
salt.modules.sensehat.get_pixels() Returns a list of 64 smaller lists of [R, G, B] pixels representing the the currently displayed image on the LED matrix.
NOTE: When using set_pixels the pixel values can sometimes change when you read them again using get_pixels. This is because we specify each pixel element as 8 bit numbers (0 to 255) but when they're passed into the Linux frame buffer for the LED matrix the numbers are bit shifted down to fit into RGB 565. 5 bits for red, 6 bits for green and 5 bits for blue.  The loss of binary precision when performing this conversion (3 bits lost for red, 2 for green and 3 for blue) accounts for the discrepancies you see.
The get_pixels method provides an accurate representation of how the pixels end up in frame buffer memory after you have called set_pixels.
salt.modules.sensehat.get_pressure() Gets the current pressure in Millibars from the pressure sensor.
salt.modules.sensehat.get_temperature() Gets the temperature in degrees Celsius from the humidity sensor. Equivalent to calling get_temperature_from_humidity.
If you get strange results try using get_temperature_from_pressure.
salt.modules.sensehat.get_temperature_from_humidity() Gets the temperature in degrees Celsius from the humidity sensor.
salt.modules.sensehat.get_temperature_from_pressure() Gets the temperature in degrees Celsius from the pressure sensor.
salt.modules.sensehat.low_light(low_light=True) Sets the LED matrix to low light mode. Useful in a dark environment.
salt 'raspberry' sensehat.low_light salt 'raspberry' sensehat.low_light False
salt.modules.sensehat.set_pixel(x, y, color) Sets a single pixel on the LED matrix to a specified color.
color  The new color of the pixel as a list of [R, G, B] values.
salt 'raspberry' sensehat.set_pixel 0 0 '[255, 0, 0]'
salt.modules.sensehat.set_pixels(pixels) Sets the entire LED matrix based on a list of 64 pixel values
pixels A list of 64 [R, G, B] color values.
salt.modules.sensehat.show_image(image) Displays an 8 x 8 image on the LED matrix.
image  The path to the image to display. The image must be 8 x 8 pixels in size.
salt 'raspberry' sensehat.show_image /tmp/my_image.png
salt.modules.sensehat.show_letter(letter, text_color=None, back_color=None) Displays a single letter on the LED matrix.
letter The letter to display
text_color The color in which the letter is shown. Defaults to '[255, 255, 255]' (white).
back_color The background color of the display. Defaults to '[0, 0, 0]' (black).
salt 'raspberry' sensehat.show_letter O salt 'raspberry' sensehat.show_letter X '[255, 0, 0]' salt 'raspberry' sensehat.show_letter B '[0, 0, 255]' '[255, 255, 0]'
salt.modules.sensehat.show_message(message, msg_type=None, text_color=None, back_color=None, scroll_speed=0.1) Displays a message on the LED matrix.
message The message to display
msg_type The type of the message. Changes the appearance of the message.
error:      red text warning:    orange text success:    green text info:       blue text
scroll_speed The speed at which the message moves over the LED matrix. This value represents the time paused for between shifting the text to the left by one column of pixels. Defaults to '0.1'.
text_color The color in which the message is shown. Defaults to '[255, 255, 255]' (white).
salt 'raspberry' sensehat.show_message 'Status ok' salt 'raspberry' sensehat.show_message 'Something went wrong' error salt 'raspberry' sensehat.show_message 'Red' text_color='[255, 0, 0]' salt 'raspberry' sensehat.show_message 'Hello world' None '[0, 0, 255]' '[255, 255, 0]' 0.2
salt.modules.sensors Read lm-sensors
New in version 2014.1.3.
salt.modules.sensors.sense(chip, fahrenheit=False) Gather lm-sensors data from a given chip
To determine the chip to query, use the 'sensors' command and see the leading line in the block.
/usr/bin/sensors