INSTRUCTION
stringlengths
1
46.3k
RESPONSE
stringlengths
75
80.2k
Returns the `git-describe(1)`_ string (or the SHA1 hash if there are no tags) for the given revision. cwd The path to the git checkout rev : HEAD The revision to describe user User under which to run the git command. By default, the command is run by the user under whi...
def describe(cwd, rev='HEAD', user=None, password=None, ignore_retcode=False, output_encoding=None): ''' Returns the `git-describe(1)`_ string (or the SHA1 hash if there are no tags) for the given revision. cwd The path to the git...
.. versionadded:: 2015.8.12,2016.3.3,2016.11.0 Interface to `git-diff(1)`_ cwd The path to the git checkout item1 and item2 Revision(s) to pass to the ``git diff`` command. One or both of these arguments may be ignored if some of the options below are set to ``True``. When...
def diff(cwd, item1=None, item2=None, opts='', git_opts='', user=None, password=None, no_index=False, cached=False, paths=None, output_encoding=None): ''' .. versionadded:: 2015.8.12,2016.3.3,2016.11.0 Interface to `g...
.. versionadded:: 2019.2.0 Runs a ``git checkout -- <path>`` from the directory specified by ``cwd``. cwd The path to the git checkout path path relative to cwd (defaults to ``.``) user User under which to run the git command. By default, the command is run by the use...
def discard_local_changes(cwd, path='.', user=None, password=None, ignore_retcode=False, output_encoding=None): ''' .. versionadded:: 2019.2.0 Runs a ``git checkout -- <path>`` ...
.. versionchanged:: 2015.8.2 Return data is now a dictionary containing information on branches and tags that were added/updated Interface to `git-fetch(1)`_ cwd The path to the git checkout remote Optional remote name to fetch. If not passed, then git will use its ...
def fetch(cwd, remote=None, force=False, refspecs=None, opts='', git_opts='', user=None, password=None, identity=None, ignore_retcode=False, saltenv='base', output_encoding=None): ''' .. versionchanged:...
Interface to `git-init(1)`_ cwd The path to the directory to be initialized bare : False If ``True``, init a bare repository .. versionadded:: 2015.8.0 template Set this argument to specify an alternate `template directory`_ .. versionadded:: 2015.8.0 separa...
def init(cwd, bare=False, template=None, separate_git_dir=None, shared=None, opts='', git_opts='', user=None, password=None, ignore_retcode=False, output_encoding=None): ''' Interface to `git-init(1)`_ cwd The...
.. versionadded:: 2015.8.0 This function will attempt to determine if ``cwd`` is part of a worktree by checking its ``.git`` to see if it is a file containing a reference to another gitdir. cwd path to the worktree to be removed user User under which to run the git command. By def...
def is_worktree(cwd, user=None, password=None, output_encoding=None): ''' .. versionadded:: 2015.8.0 This function will attempt to determine if ``cwd`` is part of a worktree by checking its ``.git`` to see if it is a file containing a reference to ano...
.. versionadded:: 2015.8.0 Return a list of branches cwd The path to the git checkout remote : False If ``True``, list remote branches. Otherwise, local branches will be listed. .. warning:: This option will only return remote branches of which the local ...
def list_branches(cwd, remote=False, user=None, password=None, ignore_retcode=False, output_encoding=None): ''' .. versionadded:: 2015.8.0 Return a list of branches cwd The path to the git checkout r...
.. versionadded:: 2015.8.0 Return a list of tags cwd The path to the git checkout user User under which to run the git command. By default, the command is run by the user under which the minion is running. password Windows only. Required when specifying ``user``. This...
def list_tags(cwd, user=None, password=None, ignore_retcode=False, output_encoding=None): ''' .. versionadded:: 2015.8.0 Return a list of tags cwd The path to the git checkout user User under which to run the git command. By ...
.. versionadded:: 2015.8.0 Returns information on worktrees .. versionchanged:: 2015.8.4 Version 2.7.0 added the ``list`` subcommand to `git-worktree(1)`_ which provides a lot of additional information. The return data has been changed to include this information, even for pre-2.7.0 ve...
def list_worktrees(cwd, stale=False, user=None, password=None, output_encoding=None, **kwargs): ''' .. versionadded:: 2015.8.0 Returns information on worktrees .. versionchanged:: 2015.8.4 Version 2....
Interface to `git-ls-remote(1)`_. Returns the upstream hash for a remote reference. cwd The path to the git checkout. Optional (and ignored if present) when ``remote`` is set to a URL instead of a remote name. remote : origin The name of the remote to query. Can be the name of a gi...
def ls_remote(cwd=None, remote='origin', ref=None, opts='', git_opts='', user=None, password=None, identity=None, https_user=None, https_pass=None, ignore_retcode=False, ...
Interface to `git-merge(1)`_ cwd The path to the git checkout rev Revision to merge into the current branch. If not specified, the remote tracking branch will be merged. .. versionadded:: 2015.8.0 opts Any additional options to add to the command line, in a single...
def merge(cwd, rev=None, opts='', git_opts='', user=None, password=None, identity=None, ignore_retcode=False, output_encoding=None, **kwargs): ''' Interface to `git-merge(1)`_ cwd The path to the git checkout ...
.. versionadded:: 2015.8.0 Interface to `git-merge-base(1)`_. cwd The path to the git checkout refs Any refs/commits to check for a merge base. Can be passed as a comma-separated list or a Python list. all : False Return a list of all matching merge bases. Not compati...
def merge_base(cwd, refs=None, octopus=False, is_ancestor=False, independent=False, fork_point=None, opts='', git_opts='', user=None, password=None, ignore_retcode=False,...
.. versionadded:: 2015.8.0 Interface to `git-merge-tree(1)`_, shows the merge results and conflicts from a 3-way merge without touching the index. cwd The path to the git checkout ref1 First ref/commit to compare ref2 Second ref/commit to compare base The bas...
def merge_tree(cwd, ref1, ref2, base=None, user=None, password=None, ignore_retcode=False, output_encoding=None): ''' .. versionadded:: 2015.8.0 Interface to `git-merge-tree(1)`_, shows the merge result...
Interface to `git-push(1)`_ cwd The path to the git checkout remote Name of the remote to which the ref should being pushed .. versionadded:: 2015.8.0 ref : master Name of the ref to push .. note:: Being a refspec_, this argument can include a colon t...
def push(cwd, remote=None, ref=None, opts='', git_opts='', user=None, password=None, identity=None, ignore_retcode=False, saltenv='base', output_encoding=None, **kwargs): ''' Interface to `git-push(1)`_ cwd ...
Interface to `git-rebase(1)`_ cwd The path to the git checkout rev : master The revision to rebase onto the current branch opts Any additional options to add to the command line, in a single string .. note:: On the Salt CLI, if the opts are preceded with a das...
def rebase(cwd, rev='master', opts='', git_opts='', user=None, password=None, ignore_retcode=False, output_encoding=None): ''' Interface to `git-rebase(1)`_ cwd The path to the git checkout rev : master The re...
Get the fetch and push URL for a specific remote cwd The path to the git checkout remote : origin Name of the remote to query user User under which to run the git command. By default, the command is run by the user under which the minion is running. password W...
def remote_get(cwd, remote='origin', user=None, password=None, redact_auth=True, ignore_retcode=False, output_encoding=None): ''' Get the fetch and push URL for a specific remote cwd The path to the git checko...
.. versionadded:: 2015.8.0 Return the remote refs for the specified URL by running ``git ls-remote``. url URL of the remote repository filter Optionally provide a ref name to ``git ls-remote``. This can be useful to make this function run faster on repositories with many b...
def remote_refs(url, heads=False, tags=False, user=None, password=None, identity=None, https_user=None, https_pass=None, ignore_retcode=False, output_encoding=None, ...
cwd The path to the git checkout url Remote URL to set remote : origin Name of the remote to set push_url If unset, the push URL will be identical to the fetch URL. .. versionadded:: 2015.8.0 user User under which to run the git command. By default, t...
def remote_set(cwd, url, remote='origin', user=None, password=None, https_user=None, https_pass=None, push_url=None, push_https_user=None, push_https_pass=None, ignore_re...
Get fetch and push URLs for each remote in a git checkout cwd The path to the git checkout user User under which to run the git command. By default, the command is run by the user under which the minion is running. password Windows only. Required when specifying ``user``. ...
def remotes(cwd, user=None, password=None, redact_auth=True, ignore_retcode=False, output_encoding=None): ''' Get fetch and push URLs for each remote in a git checkout cwd The path to the git checkout user User under which to ...
Interface to `git-reset(1)`_, returns the stdout from the git command cwd The path to the git checkout opts Any additional options to add to the command line, in a single string .. note:: On the Salt CLI, if the opts are preceded with a dash, it is necessary to...
def reset(cwd, opts='', git_opts='', user=None, password=None, identity=None, ignore_retcode=False, output_encoding=None): ''' Interface to `git-reset(1)`_, returns the stdout from the git command cwd The path to the git checkout...
.. versionadded:: 2015.8.0 Interface to `git-rev-parse(1)`_ cwd The path to the git checkout rev Revision to parse. See the `SPECIFYING REVISIONS`_ section of the `git-rev-parse(1)`_ manpage for details on how to format this argument. This argument is optional when using ...
def rev_parse(cwd, rev=None, opts='', git_opts='', user=None, password=None, ignore_retcode=False, output_encoding=None): ''' .. versionadded:: 2015.8.0 Interface to `git-rev-parse(1)`_ cwd The pa...
Returns the SHA1 hash of a given identifier (hash, branch, tag, HEAD, etc.) cwd The path to the git checkout rev : HEAD The revision short : False If ``True``, return an abbreviated SHA1 git hash user User under which to run the git command. By default, the command is...
def revision(cwd, rev='HEAD', short=False, user=None, password=None, ignore_retcode=False, output_encoding=None): ''' Returns the SHA1 hash of a given identifier (hash, branch, tag, HEAD, etc.) cwd The path to the git che...
Interface to `git-rm(1)`_ cwd The path to the git checkout filename The location of the file/directory to remove, relative to ``cwd`` .. note:: To remove a directory, ``-r`` must be part of the ``opts`` parameter. opts Any additional options to add...
def rm_(cwd, filename, opts='', git_opts='', user=None, password=None, ignore_retcode=False, output_encoding=None): ''' Interface to `git-rm(1)`_ cwd The path to the git checkout filename The location of the file/directory to remo...
Interface to `git-stash(1)`_, returns the stdout from the git command cwd The path to the git checkout opts Any additional options to add to the command line, in a single string. Use this to complete the ``git stash`` command by adding the remaining arguments (i.e. ``'save <st...
def stash(cwd, action='save', opts='', git_opts='', user=None, password=None, ignore_retcode=False, output_encoding=None): ''' Interface to `git-stash(1)`_, returns the stdout from the git command cwd The path to the git checkout...
.. versionchanged:: 2015.8.0 Return data has changed from a list of lists to a dictionary Returns the changes to the repository cwd The path to the git checkout user User under which to run the git command. By default, the command is run by the user under which the minion ...
def status(cwd, user=None, password=None, ignore_retcode=False, output_encoding=None): ''' .. versionchanged:: 2015.8.0 Return data has changed from a list of lists to a dictionary Returns the changes to the repository cwd The path to the git...
.. versionchanged:: 2015.8.0 Added the ``command`` argument to allow for operations other than ``update`` to be run on submodules, and deprecated the ``init`` argument. To do a submodule update with ``init=True`` moving forward, use ``command=update opts='--init'`` Interface to `git...
def submodule(cwd, command, opts='', git_opts='', user=None, password=None, identity=None, ignore_retcode=False, saltenv='base', output_encoding=None, **kwargs): ''' .. ver...
.. versionadded:: 2015.8.0 Interface to `git-symbolic-ref(1)`_ cwd The path to the git checkout ref Symbolic ref to read/modify value If passed, then the symbolic ref will be set to this value and an empty string will be returned. If not passed, then the ref ...
def symbolic_ref(cwd, ref, value=None, opts='', git_opts='', user=None, password=None, ignore_retcode=False, output_encoding=None): ''' .. versionadded:: 2015.8.0 Interfac...
.. versionadded:: 2018.3.4 Interface to `git-tag(1)`_, adds and removes tags. cwd The path to the main git checkout or a linked worktree name Name of the tag ref : HEAD Which ref to tag (defaults to local clone's HEAD) .. note:: This argument is ignored w...
def tag(cwd, name, ref='HEAD', message=None, opts='', git_opts='', user=None, password=None, ignore_retcode=False, output_encoding=None): ''' .. versionadded:: 2018.3.4 Interface to `git-tag(1)`_, adds and removes tags. cwd ...
.. versionadded:: 2015.8.0 Returns the version of Git installed on the minion versioninfo : False If ``True``, return the version in a versioninfo list (e.g. ``[2, 5, 0]``) CLI Example: .. code-block:: bash salt myminion git.version
def version(versioninfo=False): ''' .. versionadded:: 2015.8.0 Returns the version of Git installed on the minion versioninfo : False If ``True``, return the version in a versioninfo list (e.g. ``[2, 5, 0]``) CLI Example: .. code-block:: bash salt myminion git.versio...
.. versionadded:: 2015.8.0 Interface to `git-worktree(1)`_, adds a worktree cwd The path to the git checkout worktree_path Path to the new worktree. Can be either absolute, or relative to ``cwd``. branch Name of new branch to create. If omitted, will be set to the bas...
def worktree_add(cwd, worktree_path, ref=None, reset_branch=None, force=None, detach=False, opts='', git_opts='', user=None, password=None, ignore_ret...
.. versionadded:: 2015.8.0 Interface to `git-worktree(1)`_, prunes stale worktree administrative data from the gitdir cwd The path to the main git checkout or a linked worktree dry_run : False If ``True``, then this function will report what would have been pruned, but no chan...
def worktree_prune(cwd, dry_run=False, verbose=True, expire=None, opts='', git_opts='', user=None, password=None, ignore_retcode=False, output_encodi...
.. versionadded:: 2015.8.0 Recursively removes the worktree located at ``cwd``, returning ``True`` if successful. This function will attempt to determine if ``cwd`` is actually a worktree by invoking :py:func:`git.is_worktree <salt.modules.git.is_worktree>`. If the path does not correspond to a wor...
def worktree_rm(cwd, user=None, output_encoding=None): ''' .. versionadded:: 2015.8.0 Recursively removes the worktree located at ``cwd``, returning ``True`` if successful. This function will attempt to determine if ``cwd`` is actually a worktree by invoking :py:func:`git.is_worktree <salt.modu...
Expands a user-provided specification of source files into a list of paths.
def _expand_sources(sources): ''' Expands a user-provided specification of source files into a list of paths. ''' if sources is None: return [] if isinstance(sources, six.string_types): sources = [x.strip() for x in sources.split(',')] elif isinstance(sources, (float, six.integer...
.. note:: This function has changed for version 0.17.0. In prior versions, the ``cwd`` and ``template`` arguments must be specified, with the source directories/files coming as a space-separated list at the end of the command. Beginning with 0.17.0, ``sources`` must be a comma-separated...
def tar(options, tarfile, sources=None, dest=None, cwd=None, template=None, runas=None): ''' .. note:: This function has changed for version 0.17.0. In prior versions, the ``cwd`` and ``template`` arguments must be specified, with the source directories/files coming as a space-s...
Uses the gzip command to create gzip files template : None Can be set to 'jinja' or another supported template engine to render the command arguments before execution: .. code-block:: bash salt '*' archive.gzip template=jinja /tmp/{{grains.id}}.txt runas : None Th...
def gzip(sourcefile, template=None, runas=None, options=None): ''' Uses the gzip command to create gzip files template : None Can be set to 'jinja' or another supported template engine to render the command arguments before execution: .. code-block:: bash salt '*' arch...
Uses the gunzip command to unpack gzip files template : None Can be set to 'jinja' or another supported template engine to render the command arguments before execution: .. code-block:: bash salt '*' archive.gunzip template=jinja /tmp/{{grains.id}}.txt.gz runas : None ...
def gunzip(gzipfile, template=None, runas=None, options=None): ''' Uses the gunzip command to unpack gzip files template : None Can be set to 'jinja' or another supported template engine to render the command arguments before execution: .. code-block:: bash salt '*' ar...
.. versionadded:: 2015.5.0 In versions 2014.7.x and earlier, this function was known as ``archive.zip``. Uses the ``zip`` command to create zip files. This command is part of the `Info-ZIP`_ suite of tools, and is typically packaged as simply ``zip``. .. _`Info-ZIP`: http://www.info-zip.or...
def cmd_zip(zip_file, sources, template=None, cwd=None, runas=None): ''' .. versionadded:: 2015.5.0 In versions 2014.7.x and earlier, this function was known as ``archive.zip``. Uses the ``zip`` command to create zip files. This command is part of the `Info-ZIP`_ suite of tools, and is ...
Uses the ``zipfile`` Python module to create zip files .. versionchanged:: 2015.5.0 This function was rewritten to use Python's native zip file support. The old functionality has been preserved in the new function :mod:`archive.cmd_zip <salt.modules.archive.cmd_zip>`. For versions 2...
def zip_(zip_file, sources, template=None, cwd=None, runas=None, zip64=False): ''' Uses the ``zipfile`` Python module to create zip files .. versionchanged:: 2015.5.0 This function was rewritten to use Python's native zip file support. The old functionality has been preserved in the new fun...
.. versionadded:: 2015.5.0 In versions 2014.7.x and earlier, this function was known as ``archive.unzip``. Uses the ``unzip`` command to unpack zip files. This command is part of the `Info-ZIP`_ suite of tools, and is typically packaged as simply ``unzip``. .. _`Info-ZIP`: http://www.info-...
def cmd_unzip(zip_file, dest, excludes=None, options=None, template=None, runas=None, trim_output=False, password=None): ''' .. versionadded:: 2015.5.0 In versions 2014.7.x and earlier, this function was kn...
Uses the ``zipfile`` Python module to unpack zip files .. versionchanged:: 2015.5.0 This function was rewritten to use Python's native zip file support. The old functionality has been preserved in the new function :mod:`archive.cmd_unzip <salt.modules.archive.cmd_unzip>`. For versions ...
def unzip(zip_file, dest, excludes=None, options=None, template=None, runas=None, trim_output=False, password=None, extract_perms=True): ''' Uses the ``zipfile`` Python module to unpack zip files .. versionchanged:: 2015.5.0 ...
.. versionadded:: 2016.11.0 Returns ``True`` if the zip archive is password-protected, ``False`` if not. If the specified file is not a ZIP archive, an error will be raised. name The path / URL of the archive to check. clean : False Set this value to ``True`` to delete the path referr...
def is_encrypted(name, clean=False, saltenv='base', source_hash=None): ''' .. versionadded:: 2016.11.0 Returns ``True`` if the zip archive is password-protected, ``False`` if not. If the specified file is not a ZIP archive, an error will be raised. name The path / URL of the archive to che...
Uses `rar for Linux`_ to create rar files .. _`rar for Linux`: http://www.rarlab.com/ rarfile Path of rar file to be created sources Comma-separated list of sources to include in the rar file. Sources can also be passed in a Python list. .. versionchanged:: 2017.7.0 ...
def rar(rarfile, sources, template=None, cwd=None, runas=None): ''' Uses `rar for Linux`_ to create rar files .. _`rar for Linux`: http://www.rarlab.com/ rarfile Path of rar file to be created sources Comma-separated list of sources to include in the rar file. Sources can ...
Uses `rar for Linux`_ to unpack rar files .. _`rar for Linux`: http://www.rarlab.com/ rarfile Name of rar file to be unpacked dest The destination directory into which to **unpack** the rar file template : None Can be set to 'jinja' or another supported template engine to ren...
def unrar(rarfile, dest, excludes=None, template=None, runas=None, trim_output=False): ''' Uses `rar for Linux`_ to unpack rar files .. _`rar for Linux`: http://www.rarlab.com/ rarfile Name of rar file to be unpacked dest The destination directory into which to **unpack** the rar ...
Process markup in the :param:`filenames` and :param:`zipfile` variables (NOT the files under the paths they ultimately point to) according to the markup format provided by :param:`template`.
def _render_filenames(filenames, zip_file, saltenv, template): ''' Process markup in the :param:`filenames` and :param:`zipfile` variables (NOT the files under the paths they ultimately point to) according to the markup format provided by :param:`template`. ''' if not template: return (f...
Trim the file list for output.
def _trim_files(files, trim_output): ''' Trim the file list for output. ''' count = 100 if not isinstance(trim_output, bool): count = trim_output if not(isinstance(trim_output, bool) and trim_output is False) and len(files) > count: files = files[:count] files.append("Li...
retrieve the auth_token from nsot :param url: str :param email: str :param secret_key: str :return: str
def _get_token(url, email, secret_key): ''' retrieve the auth_token from nsot :param url: str :param email: str :param secret_key: str :return: str ''' url = urlparse.urljoin(url, 'authenticate') data_dict = {"email": email, "secret_key": secret_key} query = salt.utils.http.quer...
check whether or not this minion should have this external pillar returned :param minion_id: str :param minion_regex: list :return: bool
def _check_regex(minion_id, regex): ''' check whether or not this minion should have this external pillar returned :param minion_id: str :param minion_regex: list :return: bool ''' get_pillar = False for pattern in regex: log.debug('nsot external pillar comparing %s with %s', mi...
if a device is given, query nsot for that specific device, otherwise return all devices :param url: str :param headers: dict :param device: None or str :return:
def _query_nsot(url, headers, device=None): ''' if a device is given, query nsot for that specific device, otherwise return all devices :param url: str :param headers: dict :param device: None or str :return: ''' url = urlparse.urljoin(url, 'devices') ret = {} if not device:...
retrieve a dict of a device that exists in nsot :param minion_id: str :param api_url: str :param email: str :param secret_key: str :param fqdn_separator: str :return: dict
def _proxy_info(minion_id, api_url, email, secret_key, fqdn_separator): ''' retrieve a dict of a device that exists in nsot :param minion_id: str :param api_url: str :param email: str :param secret_key: str :param fqdn_separator: str :return: dict ''' device_info = {} if fqd...
retrieve a list of all devices that exist in nsot :param api_url: str :param email: str :param secret_key: str :return: dict
def _all_nsot_devices(api_url, email, secret_key): ''' retrieve a list of all devices that exist in nsot :param api_url: str :param email: str :param secret_key: str :return: dict ''' token = _get_token(api_url, email, secret_key) all_devices = {} if token: headers = {'A...
Query NSoT API for network devices
def ext_pillar(minion_id, pillar, api_url, email, secret_key, fqdn_separator=None, all_devices_regex=None, minion_regex=None): ''' Query NSoT API for network devices ''' ret = {} if minion_id == ...
Return the changes
def _check_cron(user, path, mask, cmd): ''' Return the changes ''' arg_mask = mask.split(',') arg_mask.sort() lst = __salt__['incron.list_tab'](user) for cron in lst['crons']: if path == cron['path'] and cron['cmd'] == cmd: ...
Verifies that the specified incron job is present for the specified user. For more advanced information about what exactly can be set in the cron timing parameters, check your incron system's documentation. Most Unix-like systems' incron documentation can be found via the incrontab man page: ``man 5 inc...
def present(name, path, mask, cmd, user='root'): ''' Verifies that the specified incron job is present for the specified user. For more advanced information about what exactly can be set in the cron timing parameters, check your incron system's documentati...
Add an item or items to a queue CLI Example: .. code-block:: bash salt-run queue.insert myqueue myitem salt-run queue.insert myqueue "['item1', 'item2', 'item3']" salt-run queue.insert myqueue myitem backend=sqlite salt-run queue.insert myqueue "['item1', 'item2', 'item3']" ba...
def insert(queue, items, backend='sqlite'): ''' Add an item or items to a queue CLI Example: .. code-block:: bash salt-run queue.insert myqueue myitem salt-run queue.insert myqueue "['item1', 'item2', 'item3']" salt-run queue.insert myqueue myitem backend=sqlite salt-r...
Return a list of Salt Queues on the backend CLI Example: .. code-block:: bash salt-run queue.list_queues salt-run queue.list_queues backend=sqlite
def list_queues(backend='sqlite'): ''' Return a list of Salt Queues on the backend CLI Example: .. code-block:: bash salt-run queue.list_queues salt-run queue.list_queues backend=sqlite ''' queue_funcs = salt.loader.queues(__opts__) cmd = '{0}.list_queues'.format(backend) ...
Provide the number of items in a queue CLI Example: .. code-block:: bash salt-run queue.list_length myqueue salt-run queue.list_length myqueue backend=sqlite
def list_length(queue, backend='sqlite'): ''' Provide the number of items in a queue CLI Example: .. code-block:: bash salt-run queue.list_length myqueue salt-run queue.list_length myqueue backend=sqlite ''' queue_funcs = salt.loader.queues(__opts__) cmd = '{0}.list_length...
Pop one or more or all items from a queue CLI Example: .. code-block:: bash salt-run queue.pop myqueue salt-run queue.pop myqueue 6 salt-run queue.pop myqueue all salt-run queue.pop myqueue 6 backend=sqlite salt-run queue.pop myqueue all backend=sqlite
def pop(queue, quantity=1, backend='sqlite', is_runner=False): ''' Pop one or more or all items from a queue CLI Example: .. code-block:: bash salt-run queue.pop myqueue salt-run queue.pop myqueue 6 salt-run queue.pop myqueue all salt-run queue.pop myqueue 6 backend=sq...
Pop items off a queue and create an event on the Salt event bus to be processed by a Reactor. CLI Example: .. code-block:: bash salt-run queue.process_queue myqueue salt-run queue.process_queue myqueue 6 salt-run queue.process_queue myqueue all backend=sqlite
def process_queue(queue, quantity=1, backend='sqlite', is_runner=False): ''' Pop items off a queue and create an event on the Salt event bus to be processed by a Reactor. CLI Example: .. code-block:: bash salt-run queue.process_queue myqueue salt-run queue.process_queue myqueue 6 ...
Get consistent opts for the queued runners
def __get_queue_opts(queue=None, backend=None): ''' Get consistent opts for the queued runners ''' if queue is None: queue = __opts__.get('runner_queue', {}).get('queue') if backend is None: backend = __opts__.get('runner_queue', {}).get('backend', 'pgjsonb') return {'backend': b...
Insert a reference to a runner into the queue so that it can be run later. fun The runner function that is going to be run args list or comma-seperated string of args to send to fun kwargs dictionary of keyword arguments to send to fun queue queue to insert the runner...
def insert_runner(fun, args=None, kwargs=None, queue=None, backend=None): ''' Insert a reference to a runner into the queue so that it can be run later. fun The runner function that is going to be run args list or comma-seperated string of args to send to fun kwargs dictio...
Process queued runners quantity number of runners to process queue queue to insert the runner reference into backend backend that to use for the queue CLI Example: .. code-block:: bash salt-run queue.process_runner salt-run queue.process_runner 5
def process_runner(quantity=1, queue=None, backend=None): ''' Process queued runners quantity number of runners to process queue queue to insert the runner reference into backend backend that to use for the queue CLI Example: .. code-block:: bash salt-ru...
yamlify `arg` and ensure it's outermost datatype is a list
def _parse_args(arg): ''' yamlify `arg` and ensure it's outermost datatype is a list ''' yaml_args = salt.utils.args.yamlify_arg(arg) if yaml_args is None: return [] elif not isinstance(yaml_args, list): return [yaml_args] else: return yaml_args
Publish a command from the minion out to other minions, publications need to be enabled on the Salt master and the minion needs to have permission to publish the command. The Salt master will also prevent a recursive publication loop, this means that a minion cannot command another minion to command ano...
def _publish( tgt, fun, arg=None, tgt_type='glob', returner='', timeout=5, form='clean', wait=False, via_master=None): ''' Publish a command from the minion out to other minions, publications need to be enabled on the Salt master and th...
Publish a command from the minion out to other minions. Publications need to be enabled on the Salt master and the minion needs to have permission to publish the command. The Salt master will also prevent a recursive publication loop, this means that a minion cannot command another minion to command an...
def publish(tgt, fun, arg=None, tgt_type='glob', returner='', timeout=5, via_master=None): ''' Publish a command from the minion out to other minions. Publications need to be enabled on the Salt master and the minion needs to have ...
Return the full data about the publication, this is invoked in the same way as the publish function CLI Example: .. code-block:: bash salt system.example.com publish.full_data '*' cmd.run 'ls -la /tmp' .. admonition:: Attention If you need to pass a value to a function argument and ...
def full_data(tgt, fun, arg=None, tgt_type='glob', returner='', timeout=5): ''' Return the full data about the publication, this is invoked in the same way as the publish function CLI Example: .. code-block:: bash salt ...
Execute a runner on the master and return the data from the runner function CLI Example: .. code-block:: bash salt publish.runner manage.down
def runner(fun, arg=None, timeout=5): ''' Execute a runner on the master and return the data from the runner function CLI Example: .. code-block:: bash salt publish.runner manage.down ''' arg = _parse_args(arg) if 'master_uri' not in __opts__: return 'No access to mas...
Get all principals CLI Example: .. code-block:: bash salt 'kde.example.com' kerberos.list_principals
def list_principals(): ''' Get all principals CLI Example: .. code-block:: bash salt 'kde.example.com' kerberos.list_principals ''' ret = {} cmd = __execute_kadmin('list_principals') if cmd['retcode'] != 0 or cmd['stderr']: ret['comment'] = cmd['stderr'].splitlines()...
Execute kadmin commands
def __execute_kadmin(cmd): ''' Execute kadmin commands ''' ret = {} auth_keytab = __opts__.get('auth_keytab', None) auth_principal = __opts__.get('auth_principal', None) if __salt__['file.file_exists'](auth_keytab) and auth_principal: return __salt__['cmd.run_all']( 'ka...
Get princial details CLI Example: .. code-block:: bash salt 'kdc.example.com' kerberos.get_principal root/admin
def get_principal(name): ''' Get princial details CLI Example: .. code-block:: bash salt 'kdc.example.com' kerberos.get_principal root/admin ''' ret = {} cmd = __execute_kadmin('get_principal {0}'.format(name)) if cmd['retcode'] != 0 or cmd['stderr']: ret['comment'] ...
List policies CLI Example: .. code-block:: bash salt 'kdc.example.com' kerberos.list_policies
def list_policies(): ''' List policies CLI Example: .. code-block:: bash salt 'kdc.example.com' kerberos.list_policies ''' ret = {} cmd = __execute_kadmin('list_policies') if cmd['retcode'] != 0 or cmd['stderr']: ret['comment'] = cmd['stderr'].splitlines()[-1] ...
Current privileges CLI Example: .. code-block:: bash salt 'kdc.example.com' kerberos.get_privs
def get_privs(): ''' Current privileges CLI Example: .. code-block:: bash salt 'kdc.example.com' kerberos.get_privs ''' ret = {} cmd = __execute_kadmin('get_privs') if cmd['retcode'] != 0 or cmd['stderr']: ret['comment'] = cmd['stderr'].splitlines()[-1] ret['...
Create Principal CLI Example: .. code-block:: bash salt 'kdc.example.com' kerberos.create_principal host/example.com
def create_principal(name, enctypes=None): ''' Create Principal CLI Example: .. code-block:: bash salt 'kdc.example.com' kerberos.create_principal host/example.com ''' ret = {} krb_cmd = 'addprinc -randkey' if enctypes: krb_cmd += ' -e {0}'.format(enctypes) krb_...
Delete Principal CLI Example: .. code-block:: bash salt 'kdc.example.com' kerberos.delete_principal host/example.com@EXAMPLE.COM
def delete_principal(name): ''' Delete Principal CLI Example: .. code-block:: bash salt 'kdc.example.com' kerberos.delete_principal host/example.com@EXAMPLE.COM ''' ret = {} cmd = __execute_kadmin('delprinc -force {0}'.format(name)) if cmd['retcode'] != 0 or cmd['stderr']: ...
Create keytab CLI Example: .. code-block:: bash salt 'kdc.example.com' kerberos.create_keytab host/host1.example.com host1.example.com.keytab
def create_keytab(name, keytab, enctypes=None): ''' Create keytab CLI Example: .. code-block:: bash salt 'kdc.example.com' kerberos.create_keytab host/host1.example.com host1.example.com.keytab ''' ret = {} krb_cmd = 'ktadd -k {0}'.format(keytab) if enctypes: krb_cmd...
Ensures that the named host is present with the given ip name The host to assign an ip to ip The ip addr(s) to apply to the host. Can be a single IP or a list of IP addresses. clean : False Remove any entries which don't match those configured in the ``ip`` option....
def present(name, ip, clean=False): # pylint: disable=C0103 ''' Ensures that the named host is present with the given ip name The host to assign an ip to ip The ip addr(s) to apply to the host. Can be a single IP or a list of IP addresses. clean : False Remove any...
Ensure that the named host is absent name The host to remove ip The ip addr(s) of the host to remove
def absent(name, ip): # pylint: disable=C0103 ''' Ensure that the named host is absent name The host to remove ip The ip addr(s) of the host to remove ''' ret = {'name': name, 'changes': {}, 'result': None, 'comment': ''} if not isinstance...
Ensure that only the given hostnames are associated with the given IP address. .. versionadded:: 2016.3.0 name The IP address to associate with the given hostnames. hostnames Either a single hostname or a list of hostnames to associate with the given IP address in the given or...
def only(name, hostnames): ''' Ensure that only the given hostnames are associated with the given IP address. .. versionadded:: 2016.3.0 name The IP address to associate with the given hostnames. hostnames Either a single hostname or a list of hostnames to associate wi...
Returns revision ID of repo
def _rev(repo): ''' Returns revision ID of repo ''' try: repo_info = dict(six.iteritems(CLIENT.info(repo['repo']))) except (pysvn._pysvn.ClientError, TypeError, KeyError, AttributeError) as exc: log.error( 'Error retrieving revision ID for svnfs remote %s ' ...
Return the list of svn remotes and their configuration information
def init(): ''' Return the list of svn remotes and their configuration information ''' bp_ = os.path.join(__opts__['cachedir'], 'svnfs') new_remote = False repos = [] per_remote_defaults = {} for param in PER_REMOTE_OVERRIDES: per_remote_defaults[param] = \ six.text_...
Remove cache directories for remotes no longer configured
def _clear_old_remotes(): ''' Remove cache directories for remotes no longer configured ''' bp_ = os.path.join(__opts__['cachedir'], 'svnfs') try: cachedir_ls = os.listdir(bp_) except OSError: cachedir_ls = [] repos = init() # Remove actively-used remotes from list fo...
Completely clear svnfs cache
def clear_cache(): ''' Completely clear svnfs cache ''' fsb_cachedir = os.path.join(__opts__['cachedir'], 'svnfs') list_cachedir = os.path.join(__opts__['cachedir'], 'file_lists/svnfs') errors = [] for rdir in (fsb_cachedir, list_cachedir): if os.path.exists(rdir): try: ...
Clear update.lk ``remote`` can either be a dictionary containing repo configuration information, or a pattern. If the latter, then remotes for which the URL matches the pattern will be locked.
def clear_lock(remote=None): ''' Clear update.lk ``remote`` can either be a dictionary containing repo configuration information, or a pattern. If the latter, then remotes for which the URL matches the pattern will be locked. ''' def _do_clear_lock(repo): def _add_error(errlist, rep...
Execute an svn update on all of the repos
def update(): ''' Execute an svn update on all of the repos ''' # data for the fileserver event data = {'changed': False, 'backend': 'svnfs'} # _clear_old_remotes runs init(), so use the value from there to avoid a # second init() data['changed'], repos = _clear_old_remotes()...
Check if an environment is exposed by comparing it against a whitelist and blacklist.
def _env_is_exposed(env): ''' Check if an environment is exposed by comparing it against a whitelist and blacklist. ''' if __opts__['svnfs_env_whitelist']: salt.utils.versions.warn_until( 'Neon', 'The svnfs_env_whitelist config option has been renamed to ' ...
Return a list of refs that can be used as environments
def envs(ignore_cache=False): ''' Return a list of refs that can be used as environments ''' if not ignore_cache: env_cache = os.path.join(__opts__['cachedir'], 'svnfs/envs.p') cache_match = salt.fileserver.check_env_cache(__opts__, env_cache) if cache_match is not None: ...
Return the root of the directory corresponding to the desired environment, or None if the environment was not found.
def _env_root(repo, saltenv): ''' Return the root of the directory corresponding to the desired environment, or None if the environment was not found. ''' # If 'base' is desired, look for the trunk if saltenv == 'base': trunk = os.path.join(repo['repo'], repo['trunk']) if os.path...
Find the first file to match the path and ref. This operates similarly to the roots file sever but with assumptions of the directory structure based on svn standard practices.
def find_file(path, tgt_env='base', **kwargs): # pylint: disable=W0613 ''' Find the first file to match the path and ref. This operates similarly to the roots file sever but with assumptions of the directory structure based on svn standard practices. ''' fnd = {'path': '', 'rel': ''}...
Return a file hash, the hash type is set in the master config file
def file_hash(load, fnd): ''' Return a file hash, the hash type is set in the master config file ''' if 'env' in load: # "env" is not supported; Use "saltenv". load.pop('env') if not all(x in load for x in ('path', 'saltenv')): return '' saltenv = load['saltenv'] if ...
Return a dict containing the file lists for files, dirs, emptydirs and symlinks
def _file_lists(load, form): ''' Return a dict containing the file lists for files, dirs, emptydirs and symlinks ''' if 'env' in load: # "env" is not supported; Use "saltenv". load.pop('env') if 'saltenv' not in load or load['saltenv'] not in envs(): return [] list_cach...
Returns True if the given username and password authenticate for the given service. Returns False otherwise ``username``: the username to authenticate ``password``: the password in plain text
def authenticate(username, password): ''' Returns True if the given username and password authenticate for the given service. Returns False otherwise ``username``: the username to authenticate ``password``: the password in plain text ''' service = __opts__.get('auth.pam.service', 'login')...
Retrieves the grains from the network device if not cached already.
def _retrieve_grains_cache(proxy=None): ''' Retrieves the grains from the network device if not cached already. ''' global GRAINS_CACHE if not GRAINS_CACHE: if proxy and salt.utils.napalm.is_proxy(__opts__): # if proxy var passed and is NAPALM-type proxy minion GRAINS...
Loads the network device details if not cached already.
def _retrieve_device_cache(proxy=None): ''' Loads the network device details if not cached already. ''' global DEVICE_CACHE if not DEVICE_CACHE: if proxy and salt.utils.napalm.is_proxy(__opts__): # if proxy var passed and is NAPALM-type proxy minion if 'napalm.get_dev...
Retrieves the grain value from the cached dictionary.
def _get_grain(name, proxy=None): ''' Retrieves the grain value from the cached dictionary. ''' grains = _retrieve_grains_cache(proxy=proxy) if grains.get('result', False) and grains.get('out', {}): return grains.get('out').get(name)
Retrieves device-specific grains.
def _get_device_grain(name, proxy=None): ''' Retrieves device-specific grains. ''' device = _retrieve_device_cache(proxy=proxy) return device.get(name.upper())
Return the username. .. versionadded:: 2017.7.0 CLI Example - select all devices using `foobar` as username for connection: .. code-block:: bash salt -G 'username:foobar' test.ping Output: .. code-block::yaml device1: True device2: True
def username(proxy=None): ''' Return the username. .. versionadded:: 2017.7.0 CLI Example - select all devices using `foobar` as username for connection: .. code-block:: bash salt -G 'username:foobar' test.ping Output: .. code-block::yaml device1: True ...
This grain is set by the NAPALM grain module only when running in a proxy minion. When Salt is installed directly on the network device, thus running a regular minion, the ``host`` grain provides the physical hostname of the network device, as it would be on an ordinary minion server. When runni...
def host(proxy=None): ''' This grain is set by the NAPALM grain module only when running in a proxy minion. When Salt is installed directly on the network device, thus running a regular minion, the ``host`` grain provides the physical hostname of the network device, as it would be on an ordi...
Return the DNS information of the host. This grain is a dictionary having two keys: - ``A`` - ``AAAA`` .. note:: This grain is disabled by default, as the proxy startup may be slower when the lookup fails. The user can enable it using the ``napalm_host_dns_grain`` option (in ...
def host_dns(proxy=None): ''' Return the DNS information of the host. This grain is a dictionary having two keys: - ``A`` - ``AAAA`` .. note:: This grain is disabled by default, as the proxy startup may be slower when the lookup fails. The user can enable it using the `...
Return the connection optional args. .. note:: Sensible data will not be returned. .. versionadded:: 2017.7.0 CLI Example - select all devices connecting via port 1234: .. code-block:: bash salt -G 'optional_args:port:1234' test.ping Output: .. code-block:: yaml ...
def optional_args(proxy=None): ''' Return the connection optional args. .. note:: Sensible data will not be returned. .. versionadded:: 2017.7.0 CLI Example - select all devices connecting via port 1234: .. code-block:: bash salt -G 'optional_args:port:1234' test.ping ...
Return a list of the filenames specified in the ``results`` argument, which are not present in the dest_dir.
def _get_missing_results(results, dest_dir): ''' Return a list of the filenames specified in the ``results`` argument, which are not present in the dest_dir. ''' try: present = set(os.listdir(dest_dir)) except OSError as exc: if exc.errno == errno.ENOENT: log.debug('p...
Make a package repository and optionally sign it and packages present The name is directory to turn into a repo. This state is best used with onchanges linked to your package building states. name The directory to find packages that will be in the repository keyid .. versionchanged:: ...
def repo(name, keyid=None, env=None, use_passphrase=False, gnupghome='/etc/salt/gpgkeys', runas='builder', timeout=15.0): ''' Make a package repository and optionally sign it and packages present The name is directory to turn into a repo. This state is ...