minions interface — VMware Salt API

minions interface — VMware Salt API

minions interface

The LoadedMod class allows for the module loaded onto the sub to return custom sequencing, for instance it can be iterated over to return all functions

delete_minion_cache(master_id: str | None, minion_id: str | None)

Flush the minion's cache on a master.

Parameters

master_id:ID (not UUID) of master
minion_id:ID of minion for which the cache should be flushed.
delete_minion_key_state(master_id: str | None)

Remove all minion key state data from a particular master.

Parameters

master_id:ID (not UUID) of master.
deploy_minion(master_id: <class 'str'>, host_name_ip: <class 'str'>, os: <class 'str'>, username: <class 'str'>, minion_id: str | None, password: str | None, private_key: str | None, private_key_path: str | None, saltenv: str | None, pillarenv: str | None, installer_file_name: str | None, state_files: list[str] | None, variables: dict | None, additional_minion_params: dict | None, additional_auth_params: dict | None)
Returns: <class 'uuid.UUID'>

Deploy a Salt minion on a target host

Parameters

master_id:

Salt master id to which the Salt minion is to be connected.

host_name_ip:

Host name or IP address of the target system on which minion is to be deployed

os:

Operating System of the target host on which salt minion is to be deployed

minion_id:

Salt minion ID to be assigned to the deployed minion. Optional.

username:

User name to connect to the target system through SSH. Required during minion deployment. Optional during state file run.

password:

Password to connect to the target system through SSH. One of password / private_key / private_key_path is required during minion deployment. Optional during state file run.

private_key:

Private key to connect to the target system through SSH. One of password / private_key / private_key_path is required during minion deployment. Optional during state file run.

private_key_path:

Private key to connect to the target system through SSH. One of password / private_key / private_key_path is required during minion deployment. Optional during state file run.

saltenv:

Saltenv to use when running state files. Optional.

pillarenv:

Pillarenv to use when running state files. Optional.

installer_file_name:

Salt minion installer file name on the master. Optional.

state_files:

List of state files to run on the deployed minion. Optional.

variables:

Parameters required by the state file to run on the deployed minion. Optional.

additional_minion_params:

Additional configuration parameters for the salt minion, to be passed in as dictionary. Refer: https://docs.saltproject.io/en/latest/ref/configuration/minion.html

additional_auth_params:

Additional auth params that can be passed in for provisioning the salt minion. This API uses saltify driver of salt-cloud under the hood. Custom values for provider and profile can be passed under keys provider and profile respectively. These will be merged/override the default salt-cloud configuration for saltify driver. Example: {'provider': {'driver': 'digitalocean', 'personal_access_token': 'xxx', 'location': 'NY'},

'profile': {'image': 'fedora 17', 'size': '256 server'}}

Refer: https://docs.saltproject.io/en/master/topics/cloud/profiles.html

get_minion_cache(master_id: str | None, minion_id: str | None, tgt_uuid: uuid.UUID | None, sort_by: str | None = alter_time, page: int | None, limit: int | None = 100, reverse: bool | None)
Returns: <class 'dict'>

Retrieve the minion cache for a particular master.

Parameters

master_id:ID for master.
minion_id:ID for minion.

Example:

client.api.minions.get_minion_cache(master_id='saltmaster1_master',
                                    minion_id='s01-m01')

RPCResponse(riq=28, ret=
    {u'saltmaster1_master':
        {u's01-m01':
            {u'grains':
               {u'biosversion': u'4.2.amazon',
                u'kernel': u'Linux',
                u'domain': u'us-west-1.compute.internal', ..... }}}},
    error=None, warnings=[])
get_minion_deployments(deploy_uuid: uuid.UUID | None, minion_id: str | None, master_id: str | None, page: int | None, limit: int | None = 50)
Returns: <class 'dict'>

Get minion deployments done using VMware Salt.

Parameters

deploy_uuid:Filter by deployment uuid. Optional.
master_id:Filter by Salt master id. Optional.
minion_id:Filter by Salt minion ID. Optional.
page:Return data from this page number.
limit:Set page size (maximum number of minion deployment records to return).
get_minion_details(master_id: str | None, minion_id: str | None, tgt_uuid: uuid.UUID | None, grains: dict | None, sort_by: str | None, reverse: bool | None, page: int | None, limit: int | None = 50, response_file: str | None, exact_match: bool | None)
Returns: <class 'dict'>

Get minion details.

Parameters

master_id:Filter minions by master id.
minion_id:Filter minions by minion id.
tgt_uuid:Limit the query to minions matching this target group.
grains:Filter the minions by matching grains.
sort_by:Sort results by this minion grain.
reverse:Pass True to sort results in descending order.
page:Return data from this page number.
limit:Set page size (maximum number of minions to return).
response_file:Pass 'filename.csv' or .json to return a file.
exact_match:Match the exact master_id and minion_id. Default: False
get_minion_grain_keys(master_id: str | None, minion_id: str | None, tgt_uuid: uuid.UUID | None)
Returns: list[str]

Get a list of unique minion grain keys, optionally filtering by master id, minion id, or target group.

Parameters

master_id:Limit the query to minion grains reported by this master
minion_id:Limit the query to grains from this minion
tgt_uuid:Limit the query to minions matching this target group

Note

when enable_grains_indexing: False this will always return an empty list.

get_minion_grain_values(key: <class 'str'>, master_id: str | None, minion_id: str | None, tgt_uuid: uuid.UUID | None)
Returns: list[Any]

Get a list of unique minion grain values for a particular key, optionally filtering by master id, minion id, or target group.

Parameters

key:Get possible minion grain values for this minion grain key
master_id:Limit the query to minion grains reported by this master
minion_id:Limit the query to grains from this minion
tgt_uuid:Limit the query to minions matching this target group

Note

when enable_grains_indexing: False this will always return an empty list.

get_minion_key_state(master_id: str | None, minion_id: str | None, key_state: str | None, sort_by: str | None, reverse: bool | None, page: int | None, limit: int | None = 50)
Returns: <class 'dict'>

Get minion key states

Parameters

master_id:Filter results by master id.
minion_id:Filter results by minion id.
key_state:Limit results to this minion key state (accepted, rejected, pending, or denied).
sort_by:Sort results by this field (master_id, minion_id, or key_state).
reverse:Pass True to sort results in descending order.
page:Return data from this page number.
limit:Set page size (maximum number of results to return).
get_minion_presence(master_id: str | None, minion_id: str | None, status: str | None, ipv4: str | None, host: str | None, separate_master_cluster_ids: bool | None, sort_by: str | None, reverse: bool | None, page: int | None, limit: int | None = 100)
Returns: <class 'dict'>

Retrieve presence status for all minions in the infrastructure.

Example:

client.api.minions.get_minion_presence()

RPCResponse(riq=6543, ret={
      'results': [
              {'minion': 's01-m01', 'master': 'saltmaster1_master', 'status': 'present', 'timestamp': u'2017-11-27T23:06:12.674176'},
              {'minion': 's01-m02', 'master': 'saltmaster1_master', 'status': 'lost', 'timestamp': u'2017-11-27T23:06:12.674176'}
          ],
      'count': 2
    },
    error=None, warnings=[])
save_minion_cache(master_id: <class 'str'>, minions_delta: <class 'dict'>)

Update the minion data cache for a given master. Note that data about minions with unaccepted keys will be ignored. This function should be called only by a salt-master.

Parameters

master_id:ID (not UUID) of master
minions_delta:A dictionary specifying changes to minion grains data to be made in RaaS. The top-level key update contains a dictionary keyed by minion id where each value contains the grains to save for that minion. Any existing grains data for a particular minion will be discarded before the new grains are saved. The top-level key delete contains a list of minion ids identifying grains data to remove from RaaS.
save_minion_key_state(master_id: <class 'str'>, keys: <class 'dict'>)

Save minion key state for a given master.

This function should only be called by a salt-master.

Parameters

master_id:ID (not UUID) for the master to update.
keys:Dictionary containing key state for minions. This dictionary needs to be in this format:
set_minion_key_state(state: <class 'str'>, minions: list[list[str]], include_accepted: bool | None, include_rejected: bool | None, include_denied: bool | None)
Returns: <class 'dict'>

Set the minion key state on the provided master id/cluster id.

Parameters

state:accept, delete, or reject
minions:list of [master_id, minion_id] pairs to set
include_accepted:include accepted keys along with pending keys, works with reject state only
include_rejected:include rejected keys along with pending keys, works with accept state only
include_denied:include denied keys along with pending keys, works with accept and reject state only