INSTRUCTION
stringlengths
1
8.43k
RESPONSE
stringlengths
75
104k
Ensure that an item is created
def _item_present(name, item, item_id, item_type, show='show', create='create', extra_args=None, cibname=None): ''' Ensure that an item is created name Irrelevant, not used item config, property, resource, constraint etc. item_id id of the item item_type item typ...
Ensure all nodes are authorized to the cluster
def auth(name, nodes, pcsuser='hacluster', pcspasswd='hacluster', extra_args=None): ''' Ensure all nodes are authorized to the cluster name Irrelevant, not used (recommended: pcs_auth__auth) nodes a list of nodes which should be authorized to the cluster pcsuser user for com...
Setup Pacemaker cluster on nodes. Should be run on one cluster node only ( there may be races )
def cluster_setup(name, nodes, pcsclustername='pcscluster', extra_args=None): ''' Setup Pacemaker cluster on nodes. Should be run on one cluster node only (there may be races) name Irrelevant, not used (recommended: pcs_setup__setup) nodes a list of nodes which should be set up ...
Add a node to the Pacemaker cluster via PCS Should be run on one cluster node only ( there may be races ) Can only be run on a already setup/ added node
def cluster_node_present(name, node, extra_args=None): ''' Add a node to the Pacemaker cluster via PCS Should be run on one cluster node only (there may be races) Can only be run on a already setup/added node name Irrelevant, not used (recommended: pcs_setup__node_add_{{node}}) node...
Ensure that a CIB - file with the content of the current live CIB is created
def cib_present(name, cibname, scope=None, extra_args=None): ''' Ensure that a CIB-file with the content of the current live CIB is created Should be run on one cluster node only (there may be races) name Irrelevant, not used (recommended: {{formulaname}}__cib_present_{{cibname}}) cibn...
Ensure that a CIB - file is pushed if it is changed since the creation of it with pcs. cib_present
def cib_pushed(name, cibname, scope=None, extra_args=None): ''' Ensure that a CIB-file is pushed if it is changed since the creation of it with pcs.cib_present Should be run on one cluster node only (there may be races) name Irrelevant, not used (recommended: {{formulaname}}__cib_pushed_{{...
Ensure that a property in the cluster is set to a given value
def prop_has_value(name, prop, value, extra_args=None, cibname=None): ''' Ensure that a property in the cluster is set to a given value Should be run on one cluster node only (there may be races) name Irrelevant, not used (recommended: pcs_properties__prop_has_value_{{prop}}) prop ...
Ensure a resource default in the cluster is set to a given value
def resource_defaults_to(name, default, value, extra_args=None, cibname=None): ''' Ensure a resource default in the cluster is set to a given value Should be run on one cluster node only (there may be races) Can only be run on a node with a functional pacemaker/corosync name Irrelevant...
Ensure a resource operation default in the cluster is set to a given value
def resource_op_defaults_to(name, op_default, value, extra_args=None, cibname=None): ''' Ensure a resource operation default in the cluster is set to a given value Should be run on one cluster node only (there may be races) Can only be run on a node with a functional pacemaker/corosync name ...
Ensure that a fencing resource is created
def stonith_present(name, stonith_id, stonith_device_type, stonith_device_options=None, cibname=None): ''' Ensure that a fencing resource is created Should be run on one cluster node only (there may be races) Can only be run on a node with a functional pacemaker/corosync name Irrelevan...
Ensure that a resource is created
def resource_present(name, resource_id, resource_type, resource_options=None, cibname=None): ''' Ensure that a resource is created Should be run on one cluster node only (there may be races) Can only be run on a node with a functional pacemaker/corosync name Irrelevant, not used (recom...
Ensure that a constraint is created
def constraint_present(name, constraint_id, constraint_type, constraint_options=None, cibname=None): ''' Ensure that a constraint is created Should be run on one cluster node only (there may be races) Can only be run on a node with a functional pacemaker/corosync name Irrelevant, not u...
Allow top_cfg to be YAML
def _parse_top_cfg(content, filename): ''' Allow top_cfg to be YAML ''' try: obj = salt.utils.yaml.safe_load(content) if isinstance(obj, list): log.debug('MakoStack cfg `%s` parsed as YAML', filename) return obj except Exception as err: pass log.de...
See if jail service is actually enabled on boot
def is_enabled(): ''' See if jail service is actually enabled on boot CLI Example: .. code-block:: bash salt '*' jail.is_enabled <jail name> ''' cmd = 'service -e' services = __salt__['cmd.run'](cmd, python_shell=False) for service in services.split('\\n'): if re.searc...
Return which jails are set to be run
def get_enabled(): ''' Return which jails are set to be run CLI Example: .. code-block:: bash salt '*' jail.get_enabled ''' ret = [] for rconf in ('/etc/rc.conf', '/etc/rc.conf.local'): if os.access(rconf, os.R_OK): with salt.utils.files.fopen(rconf, 'r') as _f...
Display specified jail s configuration
def show_config(jail): ''' Display specified jail's configuration CLI Example: .. code-block:: bash salt '*' jail.show_config <jail name> ''' ret = {} if subprocess.call(["jls", "-nq", "-j", jail]) == 0: jls = subprocess.check_output(["jls", "-nq", "-j", jail]) # pylint: ...
Display contents of a fstab ( 5 ) file defined in specified jail s configuration. If no file is defined return False.
def fstab(jail): ''' Display contents of a fstab(5) file defined in specified jail's configuration. If no file is defined, return False. CLI Example: .. code-block:: bash salt '*' jail.fstab <jail name> ''' ret = [] config = show_config(jail) if 'fstab' in config: ...
See if specified jail is currently running
def status(jail): ''' See if specified jail is currently running CLI Example: .. code-block:: bash salt '*' jail.status <jail name> ''' cmd = 'jls' found_jails = __salt__['cmd.run'](cmd, python_shell=False) for found_jail in found_jails.split('\\n'): if re.search(jail,...
Dump all jail related kernel states ( sysctl )
def sysctl(): ''' Dump all jail related kernel states (sysctl) CLI Example: .. code-block:: bash salt '*' jail.sysctl ''' ret = {} sysctl_jail = __salt__['cmd.run']('sysctl security.jail') for line in sysctl_jail.splitlines(): key, value = line.split(':', 1) re...
Execute the command passed with pecl
def _pecl(command, defaults=False): ''' Execute the command passed with pecl ''' cmdline = 'pecl {0}'.format(command) if salt.utils.data.is_true(defaults): cmdline = 'yes ' "''" + ' | ' + cmdline ret = __salt__['cmd.run_all'](cmdline, python_shell=True) if ret['retcode'] == 0: ...
.. versionadded:: 0. 17. 0
def install(pecls, defaults=False, force=False, preferred_state='stable'): ''' .. versionadded:: 0.17.0 Installs one or several pecl extensions. pecls The pecl extensions to install. defaults Use default answers for extensions such as pecl_http which ask questions before i...
Uninstall one or several pecl extensions.
def uninstall(pecls): ''' Uninstall one or several pecl extensions. pecls The pecl extensions to uninstall. CLI Example: .. code-block:: bash salt '*' pecl.uninstall fuse ''' if isinstance(pecls, six.string_types): pecls = [pecls] return _pecl('uninstall {0}'....
List installed pecl extensions.
def list_(channel=None): ''' List installed pecl extensions. CLI Example: .. code-block:: bash salt '*' pecl.list ''' pecl_channel_pat = re.compile('^([^ ]+)[ ]+([^ ]+)[ ]+([^ ]+)') pecls = {} command = 'list' if channel: command = '{0} -c {1}'.format(command, _cmd...
Return cloud client
def _get_client(): ''' Return cloud client ''' client = salt.cloud.CloudClient( os.path.join(os.path.dirname(__opts__['conf_file']), 'cloud') ) return client
Create a cloud vm with the given profile and instances instances can be a list or comma - delimited string
def profile(prof=None, instances=None, opts=None, **kwargs): ''' Create a cloud vm with the given profile and instances, instances can be a list or comma-delimited string CLI Example: .. code-block:: bash salt-run cloud.profile prof=my-ec2 instances=node1,node2,node3 ''' if prof i...
Execute a salt cloud map file
def map_run(path=None, opts=None, **kwargs): ''' Execute a salt cloud map file ''' client = _get_client() if isinstance(opts, dict): client.opts.update(opts) info = client.map_run(path, **salt.utils.args.clean_kwargs(**kwargs)) return info
Destroy the named vm ( s )
def destroy(instances, opts=None): ''' Destroy the named vm(s) ''' client = _get_client() if isinstance(opts, dict): client.opts.update(opts) info = client.destroy(instances) return info
Execute a single action on the given map/ provider/ instance
def action(func=None, cloudmap=None, instances=None, provider=None, instance=None, opts=None, **kwargs): ''' Execute a single action on the given map/provider/instance CLI Example: .. code-block:: bash salt-run cloud.action sta...
Create an instance using Salt Cloud
def create(provider, instances, opts=None, **kwargs): ''' Create an instance using Salt Cloud CLI Example: .. code-block:: bash salt-run cloud.create my-ec2-config myinstance \ image=ami-1624987f size='t1.micro' ssh_username=ec2-user \ securitygroup=default delvol_on_d...
Get splunk search properties from an object
def _get_splunk_search_props(search): ''' Get splunk search properties from an object ''' props = search.content props["app"] = search.access.app props["sharing"] = search.access.sharing return props
Get a splunk search
def get(name, profile="splunk"): ''' Get a splunk search CLI Example: splunk_search.get 'my search name' ''' client = _get_splunk(profile) search = None # uglyness of splunk lib try: search = client.saved_searches[name] except KeyError: pass return searc...
Update a splunk search
def update(name, profile="splunk", **kwargs): ''' Update a splunk search CLI Example: splunk_search.update 'my search name' sharing=app ''' client = _get_splunk(profile) search = client.saved_searches[name] props = _get_splunk_search_props(search) updates = kwargs update_ne...
Create a splunk search
def create(name, profile="splunk", **kwargs): ''' Create a splunk search CLI Example: splunk_search.create 'my search name' search='error msg' ''' client = _get_splunk(profile) search = client.saved_searches.create(name, **kwargs) # use the REST API to set owner and permissions ...
Delete a splunk search
def delete(name, profile="splunk"): ''' Delete a splunk search CLI Example: splunk_search.delete 'my search name' ''' client = _get_splunk(profile) try: client.saved_searches.delete(name) return True except KeyError: return None
List splunk searches ( names only )
def list_(profile="splunk"): ''' List splunk searches (names only) CLI Example: splunk_search.list ''' client = _get_splunk(profile) searches = [x['name'] for x in client.saved_searches] return searches
Get all splunk search details. Produces results that can be used to create an sls file.
def list_all(prefix=None, app=None, owner=None, description_contains=None, name_not_contains=None, profile="splunk"): ''' Get all splunk search details. Produces results that can be used to create an sls file. if app or owner are specified, results will be limited to matching saved sea...
.. versionadded:: 2014. 7. 0
def set_present(name, set_type, family='ipv4', **kwargs): ''' .. versionadded:: 2014.7.0 Verify the set exists. name A user-defined set name. set_type The type for the set. family Networking family, either ipv4 or ipv6 ''' ret = {'name': name, 'cha...
.. versionadded:: 2014. 7. 0
def set_absent(name, family='ipv4', **kwargs): ''' .. versionadded:: 2014.7.0 Verify the set is absent. family Networking family, either ipv4 or ipv6 ''' ret = {'name': name, 'changes': {}, 'result': None, 'comment': ''} set_check = __salt__['ipse...
.. versionadded:: 2014. 7. 0
def absent(name, entry=None, entries=None, family='ipv4', **kwargs): ''' .. versionadded:: 2014.7.0 Remove a entry or entries from a chain name A user-defined name to call this entry by in another part of a state or formula. This should not be an actual entry. family Netwo...
.. versionadded:: 2014. 7. 0
def flush(name, family='ipv4', **kwargs): ''' .. versionadded:: 2014.7.0 Flush current ipset set family Networking family, either ipv4 or ipv6 ''' ret = {'name': name, 'changes': {}, 'result': None, 'comment': ''} set_check = __salt__['ipset.check...
Make sure that a gem is installed.
def installed(name, # pylint: disable=C0103 ruby=None, gem_bin=None, user=None, version=None, rdoc=False, ri=False, pre_releases=False, proxy=None, source=None): # pylint: disable=C...
Make sure that a gem is not installed.
def removed(name, ruby=None, user=None, gem_bin=None): ''' Make sure that a gem is not installed. name The name of the gem to uninstall gem_bin : None Full path to ``gem`` binary to use. ruby : None If RVM or rbenv are installed, the ruby version and gemset to use. ...
Make sure that a gem source is added.
def sources_add(name, ruby=None, user=None): ''' Make sure that a gem source is added. name The URL of the gem source to be added ruby: None For RVM or rbenv installations: the ruby version and gemset to target. user: None The user under which to run the ``gem`` command ...
Make sure that a gem source is removed.
def sources_remove(name, ruby=None, user=None): ''' Make sure that a gem source is removed. name The URL of the gem source to be removed ruby: None For RVM or rbenv installations: the ruby version and gemset to target. user: None The user under which to run the ``gem`` com...
Ensure the current node joined to a cluster with node user@host
def joined(name, host, user='rabbit', ram_node=None, runas='root'): ''' Ensure the current node joined to a cluster with node user@host name Irrelevant, not used (recommended: user@host) user The user of node to join to (default: rabbit) host The host of node to join to ...
Create an image
def image_create(auth=None, **kwargs): ''' Create an image CLI Example: .. code-block:: bash salt '*' glanceng.image_create name=cirros file=cirros.raw disk_format=raw salt '*' glanceng.image_create name=cirros file=cirros.raw disk_format=raw hw_scsi_model=virtio-scsi hw_disk_bus=scsi...
Delete an image
def image_delete(auth=None, **kwargs): ''' Delete an image CLI Example: .. code-block:: bash salt '*' glanceng.image_delete name=image1 salt '*' glanceng.image_delete name=0e4febc2a5ab4f2c8f374b054162506d ''' cloud = get_operator_cloud(auth) kwargs = _clean_kwargs(**kwargs...
List images
def image_list(auth=None, **kwargs): ''' List images CLI Example: .. code-block:: bash salt '*' glanceng.image_list salt '*' glanceng.image_list ''' cloud = get_operator_cloud(auth) kwargs = _clean_kwargs(**kwargs) return cloud.list_images(**kwargs)
Search for images
def image_search(auth=None, **kwargs): ''' Search for images CLI Example: .. code-block:: bash salt '*' glanceng.image_search name=image1 salt '*' glanceng.image_search ''' cloud = get_operator_cloud(auth) kwargs = _clean_kwargs(**kwargs) return cloud.search_images(**k...
Get a single image
def image_get(auth=None, **kwargs): ''' Get a single image CLI Example: .. code-block:: bash salt '*' glanceng.image_get name=image1 salt '*' glanceng.image_get name=0e4febc2a5ab4f2c8f374b054162506d ''' cloud = get_operator_cloud(auth) kwargs = _clean_kwargs(**kwargs) ...
Update properties for an image
def update_image_properties(auth=None, **kwargs): ''' Update properties for an image CLI Example: .. code-block:: bash salt '*' glanceng.update_image_properties name=image1 hw_scsi_model=virtio-scsi hw_disk_bus=scsi salt '*' glanceng.update_image_properties name=0e4febc2a5ab4f2c8f374b...
Deletes a device from Vistara based on DNS name or partial name. By default delete_device will only perform the delete if a single host is returned. Set safety_on = False to delete all matches ( up to default API search page size )
def delete_device(name, safety_on=True): ''' Deletes a device from Vistara based on DNS name or partial name. By default, delete_device will only perform the delete if a single host is returned. Set safety_on=False to delete all matches (up to default API search page size) CLI Example: .. code...
Query the vistara API and get an access_token
def _get_oath2_access_token(client_key, client_secret): ''' Query the vistara API and get an access_token ''' if not client_key and not client_secret: log.error( "client_key and client_secret have not been specified " "and are required parameters." ) retu...
Return server version ( apachectl - v )
def version(): ''' Return server version (``apachectl -v``) CLI Example: .. code-block:: bash salt '*' apache.version ''' cmd = '{0} -v'.format(_detect_os()) out = __salt__['cmd.run'](cmd).splitlines() ret = out[0].split(': ') return ret[1]
Return server version ( apachectl - V )
def fullversion(): ''' Return server version (``apachectl -V``) CLI Example: .. code-block:: bash salt '*' apache.fullversion ''' cmd = '{0} -V'.format(_detect_os()) ret = {} ret['compiled_with'] = [] out = __salt__['cmd.run'](cmd).splitlines() # Example # -D APR_...
Return list of static and shared modules ( apachectl - M )
def modules(): ''' Return list of static and shared modules (``apachectl -M``) CLI Example: .. code-block:: bash salt '*' apache.modules ''' cmd = '{0} -M'.format(_detect_os()) ret = {} ret['static'] = [] ret['shared'] = [] out = __salt__['cmd.run'](cmd).splitlines() ...
Return list of modules compiled into the server ( apachectl - l )
def servermods(): ''' Return list of modules compiled into the server (``apachectl -l``) CLI Example: .. code-block:: bash salt '*' apache.servermods ''' cmd = '{0} -l'.format(_detect_os()) ret = [] out = __salt__['cmd.run'](cmd).splitlines() for line in out: if no...
Return list of directives together with expected arguments and places where the directive is valid ( apachectl - L )
def directives(): ''' Return list of directives together with expected arguments and places where the directive is valid (``apachectl -L``) CLI Example: .. code-block:: bash salt '*' apache.directives ''' cmd = '{0} -L'.format(_detect_os()) ret = {} out = __salt__['cmd.run...
Show the settings as parsed from the config file ( currently only shows the virtualhost settings ) ( apachectl - S ). Because each additional virtual host adds to the execution time this command may require a long timeout be specified by using - t 10.
def vhosts(): ''' Show the settings as parsed from the config file (currently only shows the virtualhost settings) (``apachectl -S``). Because each additional virtual host adds to the execution time, this command may require a long timeout be specified by using ``-t 10``. CLI Example: ...
Signals httpd to start restart or stop.
def signal(signal=None): ''' Signals httpd to start, restart, or stop. CLI Example: .. code-block:: bash salt '*' apache.signal restart ''' no_extra_args = ('configtest', 'status', 'fullstatus') valid_signals = ('start', 'stop', 'restart', 'graceful', 'graceful-stop') if sign...
Add HTTP user using the htpasswd command. If the htpasswd file does not exist it will be created. Valid options that can be passed are:
def useradd(pwfile, user, password, opts=''): ''' Add HTTP user using the ``htpasswd`` command. If the ``htpasswd`` file does not exist, it will be created. Valid options that can be passed are: .. code-block:: text n Don't update file; display results on stdout. m Force MD5 hashing ...
Get Information from the Apache server - status handler
def server_status(profile='default'): ''' Get Information from the Apache server-status handler .. note:: The server-status handler is disabled by default. In order for this function to work it needs to be enabled. See http://httpd.apache.org/docs/2.2/mod/mod_status.html The f...
Recursively goes through config structure and builds final Apache configuration
def _parse_config(conf, slot=None): ''' Recursively goes through config structure and builds final Apache configuration :param conf: defined config structure :param slot: name of section container if needed ''' ret = cStringIO() if isinstance(conf, six.string_types): if slot: ...
Create VirtualHost configuration files
def config(name, config, edit=True): ''' Create VirtualHost configuration files name File for the virtual host config VirtualHost configurations .. note:: This function is not meant to be used from the command line. Config is meant to be an ordered dict of all of t...
Ensure the SQS queue exists.
def present( name, attributes=None, region=None, key=None, keyid=None, profile=None, ): ''' Ensure the SQS queue exists. name Name of the SQS queue. attributes A dict of key/value SQS attributes. region Region to connect to. ...
Ensure the named sqs queue is deleted.
def absent( name, region=None, key=None, keyid=None, profile=None, ): ''' Ensure the named sqs queue is deleted. name Name of the SQS queue. region Region to connect to. key Secret key to be used. keyid Access key to be ...
Determine if the groups need to be changed
def _group_changes(cur, wanted, remove=False): ''' Determine if the groups need to be changed ''' old = set(cur) new = set(wanted) if (remove and old != new) or (not remove and not new.issubset(old)): return True return False
Return a dict of the changes required for a user if the user is present otherwise return False.
def _changes(name, uid=None, gid=None, groups=None, optional_groups=None, remove_groups=True, home=None, createhome=True, password=None, enforce_password=True, empty_password=False, ...
Ensure that the named user is present with the specified properties
def present(name, uid=None, gid=None, usergroup=None, groups=None, optional_groups=None, remove_groups=True, home=None, createhome=True, password=None, hash_password=False, enforce_passwor...
Ensure that the named user is absent
def absent(name, purge=False, force=False): ''' Ensure that the named user is absent name The name of the user to remove purge Set purge to True to delete all of the user's files as well as the user, Default is ``False``. force If the user is logged in, the absent ...
Parse a salt:// URL ; return the path and a possible saltenv query.
def parse(url): ''' Parse a salt:// URL; return the path and a possible saltenv query. ''' if not url.startswith('salt://'): return url, None # urlparse will split on valid filename chars such as '?' and '&' resource = url.split('salt://', 1)[-1] if '?env=' in resource: # "...
join path and saltenv into a salt:// URL.
def create(path, saltenv=None): ''' join `path` and `saltenv` into a 'salt://' URL. ''' if salt.utils.platform.is_windows(): path = salt.utils.path.sanitize_win_path(path) path = salt.utils.data.decode(path) query = 'saltenv={0}'.format(saltenv) if saltenv else '' url = salt.utils.d...
test whether url is escaped with |
def is_escaped(url): ''' test whether `url` is escaped with `|` ''' scheme = urlparse(url).scheme if not scheme: return url.startswith('|') elif scheme == 'salt': path, saltenv = parse(url) if salt.utils.platform.is_windows() and '|' in url: return path.starts...
add escape character | to url
def escape(url): ''' add escape character `|` to `url` ''' if salt.utils.platform.is_windows(): return url scheme = urlparse(url).scheme if not scheme: if url.startswith('|'): return url else: return '|{0}'.format(url) elif scheme == 'salt': ...
remove escape character | from url
def unescape(url): ''' remove escape character `|` from `url` ''' scheme = urlparse(url).scheme if not scheme: return url.lstrip('|') elif scheme == 'salt': path, saltenv = parse(url) if salt.utils.platform.is_windows() and '|' in url: return create(path.lstri...
append saltenv to url as a query parameter to a salt:// url
def add_env(url, saltenv): ''' append `saltenv` to `url` as a query parameter to a 'salt://' url ''' if not url.startswith('salt://'): return url path, senv = parse(url) return create(path, saltenv)
remove the saltenv query parameter from a salt:// url
def split_env(url): ''' remove the saltenv query parameter from a 'salt://' url ''' if not url.startswith('salt://'): return url, None path, senv = parse(url) return create(path), senv
Return a string with http basic auth incorporated into it
def add_http_basic_auth(url, user=None, password=None, https_only=False): ''' Return a string with http basic auth incorporated into it ''' if user is None and password is None: return url else: urltuple = urlpar...
Remove HTTP user and password
def redact_http_basic_auth(output): ''' Remove HTTP user and password ''' # We can't use re.compile because re.compile(someregex).sub() doesn't # support flags even in Python 2.7. url_re = '(https?)://.*@' redacted = r'\1://<redacted>@' if sys.version_info >= (2, 7): # re.sub() s...
Resolve a package name from a line containing the hold expression. If the regex is not matched None is returned.
def _get_hold(line, pattern=__HOLD_PATTERN, full=True): ''' Resolve a package name from a line containing the hold expression. If the regex is not matched, None is returned. yum ==> 2:vim-enhanced-7.4.629-5.el6.* dnf ==> vim-enhanced-2:7.4.827-1.fc22.* ''' if full: if _yum() == 'dnf...
Determine package manager name ( yum or dnf ) depending on the system version.
def _yum(): ''' Determine package manager name (yum or dnf), depending on the system version. ''' contextkey = 'yum_bin' if contextkey not in __context__: if ('fedora' in __grains__['os'].lower() and int(__grains__['osrelease']) >= 22): __context__[contextkey] = 'd...
Call yum/ dnf.
def _call_yum(args, **kwargs): ''' Call yum/dnf. ''' params = {'output_loglevel': 'trace', 'python_shell': False, 'env': salt.utils.environment.get_module_environment(globals())} params.update(kwargs) cmd = [] if salt.utils.systemd.has_scope(__context__) and __sal...
Parse yum/ dnf output ( which could contain irregular line breaks if package names are long ) retrieving the name version etc. and return a list of pkginfo namedtuples.
def _yum_pkginfo(output): ''' Parse yum/dnf output (which could contain irregular line breaks if package names are long) retrieving the name, version, etc., and return a list of pkginfo namedtuples. ''' cur = {} keys = itertools.cycle(('name', 'version', 'repoid')) values = salt.utils.it...
Ensure that the appropriate versionlock plugin is present
def _check_versionlock(): ''' Ensure that the appropriate versionlock plugin is present ''' if _yum() == 'dnf': if int(__grains__.get('osmajorrelease')) >= 26: if six.PY3: vl_plugin = 'python3-dnf-plugin-versionlock' else: vl_plugin = 'pyth...
Returns a list of options to be used in the yum/ dnf command based on the kwargs passed.
def _get_options(**kwargs): ''' Returns a list of options to be used in the yum/dnf command, based on the kwargs passed. ''' # Get repo options from the kwargs fromrepo = kwargs.pop('fromrepo', '') repo = kwargs.pop('repo', '') disablerepo = kwargs.pop('disablerepo', '') enablerepo =...
Returns a dict representing the yum config options and values.
def _get_yum_config(): ''' Returns a dict representing the yum config options and values. We try to pull all of the yum config options into a standard dict object. This is currently only used to get the reposdir settings, but could be used for other things if needed. If the yum python library ...
Look for a specific config variable and return its value
def _get_yum_config_value(name): ''' Look for a specific config variable and return its value ''' conf = _get_yum_config() if name in conf.keys(): return conf.get(name) return None
Takes a basedir argument as a string or a list. If the string or list is empty then look up the default from the reposdir option in the yum config.
def _normalize_basedir(basedir=None): ''' Takes a basedir argument as a string or a list. If the string or list is empty, then look up the default from the 'reposdir' option in the yum config. Returns a list of directories. ''' # if we are passed a string (for backward compatibility), conve...
Strips the architecture from the specified package name if necessary. Circumstances where this would be done include:
def normalize_name(name): ''' Strips the architecture from the specified package name, if necessary. Circumstances where this would be done include: * If the arch is 32 bit and the package name ends in a 32-bit arch. * If the arch matches the OS arch, or is ``noarch``. CLI Example: .. cod...
.. versionadded:: 2015. 5. 4
def version_cmp(pkg1, pkg2, ignore_epoch=False, **kwargs): ''' .. versionadded:: 2015.5.4 Do a cmp-style comparison on two packages. Return -1 if pkg1 < pkg2, 0 if pkg1 == pkg2, and 1 if pkg1 > pkg2. Return None if there was a problem making the comparison. ignore_epoch : False Set to ...
List the packages currently installed as a dict. By default the dict contains versions as a comma separated string::
def list_pkgs(versions_as_list=False, **kwargs): ''' List the packages currently installed as a dict. By default, the dict contains versions as a comma separated string:: {'<package_name>': '<version>[,<version>...]'} versions_as_list: If set to true, the versions are provided as a lis...
.. versionadded:: 2014. 1. 0.. versionchanged:: 2014. 7. 0 All available versions of each package are now returned. This required a slight modification to the structure of the return dict. The return data shown below reflects the updated return dict structure. Note that packages which are version - locked using: py: mo...
def list_repo_pkgs(*args, **kwargs): ''' .. versionadded:: 2014.1.0 .. versionchanged:: 2014.7.0 All available versions of each package are now returned. This required a slight modification to the structure of the return dict. The return data shown below reflects the updated return d...
Check whether or not an upgrade is available for all packages
def list_upgrades(refresh=True, **kwargs): ''' Check whether or not an upgrade is available for all packages The ``fromrepo``, ``enablerepo``, and ``disablerepo`` arguments are supported, as used in pkg states, and the ``disableexcludes`` option is also supported. .. versionadded:: 2014.7.0 ...
.. versionadded:: 2017. 7. 0
def list_downloaded(**kwargs): ''' .. versionadded:: 2017.7.0 List prefetched packages downloaded by Yum in the local disk. CLI example: .. code-block:: bash salt '*' pkg.list_downloaded ''' CACHE_DIR = os.path.join('/var/cache/', _yum()) ret = {} for root, dirnames, fil...
.. versionadded:: 2015. 8. 1
def info_installed(*names, **kwargs): ''' .. versionadded:: 2015.8.1 Return the information of the named package(s), installed on the system. :param all_versions: Include information for all versions of the packages installed on the minion. CLI example: .. code-block:: bash ...
Check the yum repos for updated packages
def refresh_db(**kwargs): ''' Check the yum repos for updated packages Returns: - ``True``: Updates are available - ``False``: An error occurred - ``None``: No updates are available repo Refresh just the specified repo disablerepo Do not refresh the specified repo ...
.. versionchanged:: 2015. 8. 12 2016. 3. 3 2016. 11. 0 On minions running systemd > = 205 systemd - run ( 1 ) _ is now used to isolate commands which modify installed packages from the salt - minion daemon s control group. This is done to keep systemd from killing any yum/ dnf commands spawned by Salt when the salt - m...
def install(name=None, refresh=False, skip_verify=False, pkgs=None, sources=None, downloadonly=False, reinstall=False, normalize=True, update_holds=False, saltenv='base', ignore_epoch=False, ...
Run a full system upgrade ( a yum upgrade or dnf upgrade ) or upgrade specified packages. If the packages aren t installed they will not be installed.
def upgrade(name=None, pkgs=None, refresh=True, skip_verify=False, normalize=True, minimal=False, obsoletes=True, **kwargs): ''' Run a full system upgrade (a ``yum upgrade`` or ``dnf upgrade``), or upgrade specified packages...
.. versionadded:: 2019. 2. 0
def update(name=None, pkgs=None, refresh=True, skip_verify=False, normalize=True, minimal=False, obsoletes=False, **kwargs): ''' .. versionadded:: 2019.2.0 Calls :py:func:`pkg.upgrade <salt.modules.yumpkg.upgrade>` with ``obso...
.. versionchanged:: 2015. 8. 12 2016. 3. 3 2016. 11. 0 On minions running systemd > = 205 systemd - run ( 1 ) _ is now used to isolate commands which modify installed packages from the salt - minion daemon s control group. This is done to keep systemd from killing any yum/ dnf commands spawned by Salt when the salt - m...
def remove(name=None, pkgs=None, **kwargs): # pylint: disable=W0613 ''' .. versionchanged:: 2015.8.12,2016.3.3,2016.11.0 On minions running systemd>=205, `systemd-run(1)`_ is now used to isolate commands which modify installed packages from the ``salt-minion`` daemon's control group. Th...