text
stringlengths
81
112k
Install a p12 certificate file into the macOS keychain name The certificate to install password The password for the certificate being installed formatted in the way described for openssl command in the PASS PHRASE ARGUMENTS section keychain The keychain to install the cer...
Uninstall a p12 certificate file from the macOS keychain name The certificate to uninstall, this can be a path for a .p12 or the friendly name password The password for the certificate being installed formatted in the way described for openssl command in the PASS PHRASE ARGUMEN...
Set the default keychain to use name The chain in which to use as the default domain The domain to use valid values are user|system|common|dynamic, the default is user user The user to run as def default_keychain(name, domain="user", user=None): ''' Set the default keycha...
Grab the opts dict of the master config by trying to import Salt def bootstrap_app(): ''' Grab the opts dict of the master config by trying to import Salt ''' from salt.netapi.rest_cherrypy import app import salt.config __opts__ = salt.config.client_config( os.environ.get('SALT_MAS...
Returns a WSGI application function. If you supply the WSGI app and config it will use that, otherwise it will try to obtain them from a local Salt installation def get_application(*args): ''' Returns a WSGI application function. If you supply the WSGI app and config it will use that, otherwise it ...
Return a sqlite3 database connection def _get_conn(ret=None): ''' Return a sqlite3 database connection ''' # Possible todo: support detect_types, isolation_level, check_same_thread, # factory, cached_statements. Do we really need to though? _options = _get_options(ret) database = _options.g...
Insert minion return data into the sqlite3 database def returner(ret): ''' Insert minion return data into the sqlite3 database ''' log.debug('sqlite3 returner <returner> called with data: %s', ret) conn = _get_conn(ret) cur = conn.cursor() sql = '''INSERT INTO salt_returns (fun...
Save the load to the specified jid def save_load(jid, load, minions=None): ''' Save the load to the specified jid ''' log.debug('sqlite3 returner <save_load> called jid: %s load: %s', jid, load) conn = _get_conn(ret=None) cur = conn.cursor() sql = '''INSERT INTO jids (jid, load) VALUES (:ji...
Return the load from a specified jid def get_load(jid): ''' Return the load from a specified jid ''' log.debug('sqlite3 returner <get_load> called jid: %s', jid) conn = _get_conn(ret=None) cur = conn.cursor() sql = '''SELECT load FROM jids WHERE jid = :jid''' cur.execute(sql, ...
Return the information returned from a specified jid def get_jid(jid): ''' Return the information returned from a specified jid ''' log.debug('sqlite3 returner <get_jid> called jid: %s', jid) conn = _get_conn(ret=None) cur = conn.cursor() sql = '''SELECT id, full_ret FROM salt_returns WHERE...
Return a dict of the last function called for all minions def get_fun(fun): ''' Return a dict of the last function called for all minions ''' log.debug('sqlite3 returner <get_fun> called fun: %s', fun) conn = _get_conn(ret=None) cur = conn.cursor() sql = '''SELECT s.id, s.full_ret, s.jid ...
Return a list of minions def get_minions(): ''' Return a list of minions ''' log.debug('sqlite3 returner <get_minions> called') conn = _get_conn(ret=None) cur = conn.cursor() sql = '''SELECT DISTINCT id FROM salt_returns''' cur.execute(sql) data = cur.fetchall() ret = [] for...
Ensure that we don't try to operate on worktrees in git < 2.5.0. def _check_worktree_support(failhard=True): ''' Ensure that we don't try to operate on worktrees in git < 2.5.0. ''' git_version = version(versioninfo=False) if _LooseVersion(git_version) < _LooseVersion('2.5.0'): if failhard:...
Common code for config.get_* functions, builds and runs the git CLI command and returns the result dict for the calling function to parse. def _config_getter(get_opt, key, value_regex=None, cwd=None, user=None, password=...
Expand home directory def _expand_path(cwd, user): ''' Expand home directory ''' try: to_expand = '~' + user if user else '~' except TypeError: # Users should never be numeric but if we don't account for this then # we're going to get a traceback if someone passes this inval...
Check every part of path for executable permission def _path_is_executable_others(path): ''' Check every part of path for executable permission ''' prevpath = None while path and path != prevpath: try: if not os.stat(path).st_mode & stat.S_IXOTH: return False ...
Common code to inspect opts and split them if necessary def _format_opts(opts): ''' Common code to inspect opts and split them if necessary ''' if opts is None: return [] elif isinstance(opts, list): new_opts = [] for item in opts: if isinstance(item, six.string_...
Do a version check and make sure that the installed version of git can support git -c def _format_git_opts(opts): ''' Do a version check and make sure that the installed version of git can support git -c ''' if opts: version_ = version(versioninfo=False) if _LooseVersion(version...
Windows only: search for Git's bundled ssh.exe in known locations def _find_ssh_exe(): ''' Windows only: search for Git's bundled ssh.exe in known locations ''' # Known locations for Git's ssh.exe in Windows globmasks = [os.path.join(os.getenv('SystemDrive'), os.sep, '...
simple, throw an exception with the error message on an error return code. this function may be moved to the command module, spliced with 'cmd.run_all', and used as an alternative to 'cmd.run_all'. Some commands don't return proper retcodes, so this can't replace 'cmd.run_all'. def _git_run(command, cwd=N...
Use git rev-parse to return the top level of a repo def _get_toplevel(path, user=None, password=None, output_encoding=None): ''' Use git rev-parse to return the top level of a repo ''' return _git_run( ['git', 'rev-parse', '--show-toplevel'], cwd=path, user=user, passwor...
Helper to retrieve git config options def _git_config(cwd, user, password, output_encoding=None): ''' Helper to retrieve git config options ''' contextkey = 'git.config.' + cwd if contextkey not in __context__: git_dir = rev_parse(cwd, opts=['--git-dir'], ...
Based on whether global or local config is desired, return a list of CLI args to include in the git config command. def _which_git_config(global_, cwd, user, password, output_encoding=None): ''' Based on whether global or local config is desired, return a list of CLI args to include in the git config c...
.. versionchanged:: 2015.8.0 The ``--verbose`` command line argument is now implied Interface to `git-add(1)`_ cwd The path to the git checkout filename The location of the file/directory to add, relative to ``cwd`` opts Any additional options to add to the command li...
.. versionchanged:: 2015.8.0 Returns ``True`` if successful, raises an error if not. Interface to `git-archive(1)`_, exports a tarball/zip file of the repository cwd The path to be archived .. note:: ``git archive`` permits a partial archive to be created. Thus, this ...
Interface to `git-branch(1)`_ cwd The path to the git checkout name Name of the branch on which to operate. If not specified, the current branch will be assumed. opts Any additional options to add to the command line, in a single string .. note:: To cr...
Interface to `git-checkout(1)`_ 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 precede them with ``opts=`` (as in th...
Interface to `git-clone(1)`_ cwd Location of git clone .. versionchanged:: 2015.8.0 If ``name`` is passed, then the clone will be made *within* this directory. url The URL of the repository to be cloned .. versionchanged:: 2015.8.0 Argument...
Interface to `git-commit(1)`_ cwd The path to the git checkout message Commit message opts Any additional options to add to the command line, in a single string. These opts will be added to the end of the git command being run. .. note:: On the Salt CL...
Get the value of a key in the git configuration file key The name of the configuration key to get .. versionchanged:: 2015.8.0 Argument renamed from ``setting_name`` to ``key`` cwd The path to the git checkout .. versionchanged:: 2015.8.0 Now optional ...
r''' .. versionadded:: 2015.8.0 Get the value of a key or keys in the git configuration file using regexes for more flexible matching. The return data is a dictionary mapping keys to lists of values matching the ``value_regex``. If no values match, an empty dictionary will be returned. key ...
.. versionchanged:: 2015.8.0 Return the value(s) of the key being set Set a key in the git configuration file cwd The path to the git checkout. Must be an absolute path, or the word ``global`` to indicate that a global key should be set. .. versionchanged:: 2014.7.0 ...
.. versionadded:: 2015.8.0 Unset a key in the git configuration file cwd The path to the git checkout. Must be an absolute path, or the word ``global`` to indicate that a global key should be unset. key The name of the configuration key to unset value_regex Regular ex...
Returns the current branch name of a local checkout. If HEAD is detached, return the SHA1 of the revision which is currently checked out. 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...
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...
.. 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...
.. 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...
.. 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 ...
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...
.. 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...
.. 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 ...
.. 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...
.. 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...
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...
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...
.. 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...
.. 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...
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...
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...
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...
.. 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...
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...
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``. ...
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...
.. 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 ...
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...
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...
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...
.. 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 ...
.. 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...
.. 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 ...
.. 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...
.. 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 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...
.. 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...
.. 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...
.. versionadded:: 2016.11.0 .. versionchanged:: 2016.11.2 The rarfile_ Python module is now supported for listing the contents of rar archives. This is necessary on minions with older releases of the ``rar`` CLI tool, which do not support listing the contents in a parsable format. ...
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() ...
.. 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...
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...
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 ...
.. 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...
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...
.. 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-...
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 ...
.. 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...
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 ...
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...
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 ...
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[...
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 = urlpars...
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_r...
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 a...
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 exist...
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...
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 '...
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']...
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...
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...
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 s...
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:: ba...
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, ...
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(qu...
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('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...
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 pr...
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_ar...
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...
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...
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 ...