The function cache system allows for data to be stored on the master so it can be easily read by other minions
salt.modules.mine.
delete
(fun)¶Remove specific function contents of minion.
CLI Example:
salt '*' mine.delete 'network.interfaces'
salt.modules.mine.
flush
()¶Remove all mine contents of minion.
True on success
CLI Example:
salt '*' mine.flush
salt.modules.mine.
get
(tgt, fun, tgt_type='glob', exclude_minion=False)¶Get data from the mine.
tgt (str) -- Target whose mine data to get.
fun (str or list) -- Function to get the mine data of. You can specify multiple functions to retrieve using either a list or a comma-separated string of functions.
tgt_type (str) -- Default glob
. Target type to use with tgt
.
See Targeting Minions for more information.
Note that all pillar matches, whether using the compound matching system or
the pillar matching system, will be exact matches, with globbing disabled.
exclude_minion (bool) -- Excludes the current minion from the result set.
CLI Example:
salt '*' mine.get '*' network.interfaces
salt '*' mine.get 'os:Fedora' network.interfaces grain
salt '*' mine.get 'G@os:Fedora and S@192.168.5.0/24' network.ipaddrs compound
See also
Retrieving Mine data from Pillar and Orchestrate
This execution module is intended to be executed on minions.
Master-side operations such as Pillar or Orchestrate that require Mine
data should use the Mine Runner module
instead; it can be invoked from a Pillar SLS file using the
saltutil.runner
module. For
example:
{% set minion_ips = salt.saltutil.runner('mine.get',
tgt='*',
fun='network.ip_addrs',
tgt_type='glob') %}
salt.modules.mine.
get_docker
(interfaces=None, cidrs=None, with_container_id=False)¶Changed in version 2017.7.8,2018.3.3: When docker.update_mine
is set to False
for a given
minion, no mine data will be populated for that minion, and thus none
will be returned for it.
Changed in version 2019.2.0: docker.update_mine
now defaults to False
Get all mine data for docker.ps
and
run an aggregation routine. The interfaces
parameter allows for
specifying the network interfaces from which to select IP addresses. The
cidrs
parameter allows for specifying a list of subnets which the IP
address must match.
Boolean, to expose container_id in the list of results
New in version 2015.8.2.
CLI Example:
salt '*' mine.get_docker
salt '*' mine.get_docker interfaces='eth0'
salt '*' mine.get_docker interfaces='["eth0", "eth1"]'
salt '*' mine.get_docker cidrs='107.170.147.0/24'
salt '*' mine.get_docker cidrs='["107.170.147.0/24", "172.17.42.0/24"]'
salt '*' mine.get_docker interfaces='["eth0", "eth1"]' cidrs='["107.170.147.0/24", "172.17.42.0/24"]'
salt.modules.mine.
send
(name, *args, **kwargs)¶Send a specific function and its result to the salt mine. This gets stored in either the local cache, or the salt master's cache.
name (str) -- Name of the function to add to the mine.
The following pameters are extracted from kwargs if present:
mine_function (str) -- The name of the execution_module.function to run
and whose value will be stored in the salt mine. Defaults to name
.
allow_tgt (str) -- Targeting specification for ACL. Specifies which minions are allowed to access this function. Please note both your master and minion need to be on, at least, version 3000 for this to work properly.
allow_tgt_type (str) -- Type of the targeting specification. This value will
be ignored if allow_tgt
is not specified. Please note both your
master and minion need to be on, at least, version 3000 for this to work
properly.
Remaining args and kwargs will be passed on to the function to run.
Whether executing the function and storing the information was successful.
Changed in version 3000: Added allow_tgt
- and allow_tgt_type
-parameters to specify which
minions are allowed to access this function.
See Targeting Minions for more information about targeting.
CLI Example:
salt '*' mine.send network.ip_addrs eth0
salt '*' mine.send eth0_ip_addrs mine_function=network.ip_addrs eth0
salt '*' mine.send eth0_ip_addrs mine_function=network.ip_addrs eth0 allow_tgt='G@grain:value' allow_tgt_type=compound
salt.modules.mine.
update
(clear=False, mine_functions=None)¶Call the configured functions and send the data back up to the master. The functions to be called are merged from the master config, pillar and minion config under the option mine_functions:
mine_functions:
network.ip_addrs:
- eth0
disk.usage: []
This function accepts the following arguments:
clear (bool) -- Default: False
Specifies whether updating will clear the existing values (True
), or
whether it will update them (False
).
mine_functions (dict) --
Update (or clear, see clear
) the mine data on these functions only.
This will need to have the structure as defined on
https://docs.saltstack.com/en/latest/topics/mine/index.html#mine-functions
This feature can be used when updating the mine for functions that require a refresh at different intervals than the rest of the functions specified under mine_functions in the minion/master config or pillar. A potential use would be together with the scheduler, for example:
schedule:
lldp_mine_update:
function: mine.update
kwargs:
mine_functions:
net.lldp: []
hours: 12
In the example above, the mine for net.lldp would be refreshed every 12 hours, while network.ip_addrs would continue to be updated as specified in mine_interval.
The function cache will be populated with information from executing these functions
CLI Example:
salt '*' mine.update
salt.modules.mine.
valid
()¶List valid entries in mine configuration.
CLI Example:
salt '*' mine.valid