salt.modules.mine

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. Returns True on success.

CLI 范例:

salt '*' mine.delete 'network.interfaces'
salt.modules.mine.flush()

Remove all mine contents of minion. Returns True on success.

CLI 范例:

salt '*' mine.flush
salt.modules.mine.get(tgt, fun, expr_form='glob', exclude_minion=False)

Get data from the mine based on the target, function and expr_form

Targets can be matched based on any standard matching system that can be matched on the master via these keywords:

glob
pcre
grain
grain_pcre
compound
pillar
pillar_pcre

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
Excludes the current minion from the result set

CLI 范例:

salt '*' mine.get '*' network.interfaces
salt '*' mine.get 'os:Fedora' network.interfaces grain
salt '*' mine.get 'os:Fedora and S@192.168.5.0/24' network.ipaddrs compound

参见

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 an 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)

Get all mine data for 'docker.get_containers' and run an aggregation routine. The "interfaces" parameter allows for specifying which network interfaces to select ip addresses from. The "cidrs" parameter allows for specifying a list of cidrs which the ip address must match.

with_container_id

Boolean, to expose container_id in the list of results

2015.8.2 新版功能.

CLI 范例:

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(func, *args, **kwargs)

Send a specific function to the mine.

CLI 范例:

salt '*' mine.send network.ip_addrs eth0
salt '*' mine.send eth0_ip_addrs mine_function=network.ip_addrs eth0
salt.modules.mine.update(clear=False)

Execute the configured functions and send the data back up to the master The functions to be executed are merged from the master config, pillar and minion config under the option "function_cache":

mine_functions:
  network.ip_addrs:
    - eth0
  disk.usage: []

The function cache will be populated with information from executing these functions

CLI 范例:

salt '*' mine.update