Get data from the mine based on the target, function and tgt_type This will actually run the function on all targeted SSH minions (like publish.publish), as salt-ssh clients can't update the mine themselves. We will look for mine_functions in the roster, pillar, and master config,
(
tgt, fun, tgt_type="glob", roster="flat", ssh_minions=True, regular_minions=False
)
| 19 | |
| 20 | |
| 21 | def get( |
| 22 | tgt, fun, tgt_type="glob", roster="flat", ssh_minions=True, regular_minions=False |
| 23 | ): |
| 24 | """ |
| 25 | Get data from the mine based on the target, function and tgt_type |
| 26 | |
| 27 | This will actually run the function on all targeted SSH minions (like |
| 28 | publish.publish), as salt-ssh clients can't update the mine themselves. |
| 29 | |
| 30 | We will look for mine_functions in the roster, pillar, and master config, |
| 31 | in that order, looking for a match for the defined function. |
| 32 | |
| 33 | Targets can be matched based on any standard matching system that can be |
| 34 | matched on the defined roster (in salt-ssh). |
| 35 | |
| 36 | Regular mine data will be fetched as usual and can be targeted as usual. |
| 37 | |
| 38 | CLI Example: |
| 39 | |
| 40 | .. code-block:: bash |
| 41 | |
| 42 | salt-ssh '*' mine.get '*' network.interfaces |
| 43 | salt-ssh '*' mine.get 'myminion' network.interfaces roster=flat |
| 44 | salt-ssh '*' mine.get '192.168.5.0' network.ipaddrs roster=scan |
| 45 | salt-ssh myminion mine.get '*' network.interfaces ssh_minions=False regular_minions=True |
| 46 | salt-ssh myminion mine.get '*' network.interfaces ssh_minions=True regular_minions=True |
| 47 | |
| 48 | tgt |
| 49 | Target whose mine data to get. |
| 50 | |
| 51 | fun |
| 52 | Function to get the mine data of. You can specify multiple functions |
| 53 | to retrieve using either a list or a comma-separated string of functions. |
| 54 | |
| 55 | tgt_type |
| 56 | Target type to use with ``tgt``. Defaults to ``glob``. |
| 57 | See :ref:`targeting` for more information for regular minion targets, above |
| 58 | for SSH ones. |
| 59 | |
| 60 | roster |
| 61 | The roster module to use. Defaults to ``flat``. |
| 62 | |
| 63 | ssh_minions |
| 64 | .. versionadded:: 3007.0 |
| 65 | Target minions from the roster. Defaults to true. |
| 66 | |
| 67 | regular_minions |
| 68 | .. versionadded:: 3007.0 |
| 69 | Target regular minions of the master running salt-ssh. Defaults to false. |
| 70 | """ |
| 71 | rets = {} |
| 72 | if regular_minions: |
| 73 | # Fix OptsDict cachedir issue: ensure we use the master's cachedir, |
| 74 | # not the minion's cachedir that may have been mutated in the parent chain. |
| 75 | # When running in SSH wrapper context, the master_opts OptsDict has a parent |
| 76 | # that was mutated with the minion's cachedir. We construct the correct master |
| 77 | # cachedir from the master's config_dir. |
| 78 | master_opts = __context__["master_opts"] |