Search is not available for this dataset
text
stringlengths
75
104k
def cluster_remove(version, name='main', stop=False): ''' Remove a cluster on a Postgres server. By default it doesn't try to stop the cluster. CLI Example: .. code-block:: bash salt '*' postgres.cluster_remove '9.3' salt '*' postgres.cluster...
def _parse_pg_lscluster(output): ''' Helper function to parse the output of pg_lscluster ''' cluster_dict = {} for line in output.splitlines(): version, name, port, status, user, datadir, log = ( line.split()) cluster_dict['{0}/{1}'.format(version, name)] = { ...
def _find_credentials(host): ''' Cycle through all the possible credentials and return the first one that works. ''' user_names = [__pillar__['proxy'].get('username', 'root')] passwords = __pillar__['proxy']['passwords'] for user in user_names: for password in passwords: ...
def _grains(): ''' Get the grains from the proxied device. ''' try: host = __pillar__['proxy']['host'] if host: username, password = _find_credentials(host) protocol = __pillar__['proxy'].get('protocol') port = __pillar__['proxy'].get('port') ...
def ext_pillar(minion_id, pillar, # pylint: disable=W0613 conf): ''' Check etcd for all data ''' comps = conf.split() profile = None if comps[0]: profile = comps[0] client = salt.utils.etcd_util.get_conn(__opts__, profile) path = '/' if len(co...
def rule_absent(name, method, port=None, proto='tcp', direction='in', port_origin='d', ip_origin='s', ttl=None, reload=False): ''' Ensure iptable is not present. name The ...
def ports_open(name, ports, proto='tcp', direction='in'): ''' Ensure ports are open for a protocol, in a direction. e.g. - proto='tcp', direction='in' would set the values for TCP_IN in the csf.conf file. ports A list of ports that should be open. proto The protocol. May be one...
def nics_skip(name, nics, ipv6): ''' Alias for :mod:`csf.nics_skipped <salt.states.csf.nics_skipped>` ''' return nics_skipped(name, nics=nics, ipv6=ipv6)
def nics_skipped(name, nics, ipv6=False): ''' name Meaningless arg, but required for state. nics A list of nics to skip. ipv6 Boolean. Set to true if you want to skip the ipv6 interface. Default false (ipv4). ''' ret = {'name': ','.join(nics), 'change...
def option_present(name, value, reload=False): ''' Ensure the state of a particular option/setting in csf. name The option name in csf.conf value The value it should be set to. reload Boolean. If set to true, csf will be reloaded after. ''' ret = {'name': 'testing ...
def _parse_stack_cfg(content): ''' Allow top level cfg to be YAML ''' try: obj = salt.utils.yaml.safe_load(content) if isinstance(obj, list): return obj except Exception as e: pass return content.splitlines()
def _clear_context(bin_env=None): ''' Remove the cached pip version ''' contextkey = 'pip.version' if bin_env is not None: contextkey = '{0}.{1}'.format(contextkey, bin_env) __context__.pop(contextkey, None)
def _get_pip_bin(bin_env): ''' Locate the pip binary, either from `bin_env` as a virtualenv, as the executable itself, or from searching conventional filesystem locations ''' if not bin_env: logger.debug('pip: Using pip from currently-running Python') return [os.path.normpath(sys.exe...
def _get_cached_requirements(requirements, saltenv): ''' Get the location of a cached requirements file; caching if necessary. ''' req_file, senv = salt.utils.url.parse(requirements) if senv: saltenv = senv if req_file not in __salt__['cp.list_master'](saltenv): # Requirements ...
def _get_env_activate(bin_env): ''' Return the path to the activate binary ''' if not bin_env: raise CommandNotFoundError('Could not find a `activate` binary') if os.path.isdir(bin_env): if salt.utils.platform.is_windows(): activate_bin = os.path.join(bin_env, 'Scripts',...
def _resolve_requirements_chain(requirements): ''' Return an array of requirements file paths that can be used to complete the no_chown==False && user != None conundrum ''' chain = [] if isinstance(requirements, six.string_types): requirements = [requirements] for req_file in requ...
def _process_requirements(requirements, cmd, cwd, saltenv, user): ''' Process the requirements argument ''' cleanup_requirements = [] if requirements is not None: if isinstance(requirements, six.string_types): requirements = [r.strip() for r in requirements.split(',')] e...
def install(pkgs=None, # pylint: disable=R0912,R0913,R0914 requirements=None, bin_env=None, use_wheel=False, no_use_wheel=False, log=None, proxy=None, timeout=None, editable=None, find_links=None, in...
def uninstall(pkgs=None, requirements=None, bin_env=None, log=None, proxy=None, timeout=None, user=None, cwd=None, saltenv='base', use_vt=False): ''' Uninstall packages individually or f...
def freeze(bin_env=None, user=None, cwd=None, use_vt=False, env_vars=None, **kwargs): ''' Return a list of installed packages either globally or in the specified virtualenv bin_env Path to pip (or to a virtualenv). This can be used to speci...
def list_(prefix=None, bin_env=None, user=None, cwd=None, env_vars=None, **kwargs): ''' Filter list of installed apps from ``freeze`` and check to see if ``prefix`` exists in the list of packages installed. .. note:: If the version of pip avail...
def version(bin_env=None): ''' .. versionadded:: 0.17.0 Returns the version of pip. Use ``bin_env`` to specify the path to a virtualenv and get the version of pip in that virtualenv. If unable to detect the pip version, returns ``None``. CLI Example: .. code-block:: bash salt '*...
def list_upgrades(bin_env=None, user=None, cwd=None): ''' Check whether or not an upgrade is available for all packages CLI Example: .. code-block:: bash salt '*' pip.list_upgrades ''' cmd = _get_pip_bin(bin_env) cmd.extend(['list', '--outdated'...
def is_installed(pkgname=None, bin_env=None, user=None, cwd=None): ''' .. versionadded:: 2018.3.0 Filter list of installed apps from ``freeze`` and return True or False if ``pkgname`` exists in the list of packages installed. .. note:: If...
def upgrade_available(pkg, bin_env=None, user=None, cwd=None): ''' .. versionadded:: 2015.5.0 Check whether or not an upgrade is available for a given package CLI Example: .. code-block:: bash salt '*' pip.upgrade_availabl...
def upgrade(bin_env=None, user=None, cwd=None, use_vt=False): ''' .. versionadded:: 2015.5.0 Upgrades outdated pip packages. .. note:: On Windows you can't update salt from pip using salt, so salt will be skipped Returns a dict containing the ch...
def list_all_versions(pkg, bin_env=None, include_alpha=False, include_beta=False, include_rc=False, user=None, cwd=None, index_url=None, extra_i...
def verify_certs(*args): ''' Sanity checking for the specified SSL certificates ''' msg = ("Could not find a certificate: {0}\n" "If you want to quickly generate a self-signed certificate, " "use the tls.create_self_signed_cert function in Salt") for arg in args: if ...
def start(): ''' Start the server loop ''' from . import app root, apiopts, conf = app.get_app(__opts__) if not apiopts.get('disable_ssl', False): if 'ssl_crt' not in apiopts or 'ssl_key' not in apiopts: logger.error("Not starting '%s'. Options 'ssl_crt' and " ...
def get_osarch(): ''' Get the os architecture using rpm --eval ''' if salt.utils.path.which('rpm'): ret = subprocess.Popen( 'rpm --eval "%{_host_cpu}"', shell=True, close_fds=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE).communi...
def check_32(arch, osarch=None): ''' Returns True if both the OS arch and the passed arch are 32-bit ''' if osarch is None: osarch = get_osarch() return all(x in ARCHES_32 for x in (osarch, arch))
def pkginfo(name, version, arch, repoid, install_date=None, install_date_time_t=None): ''' Build and return a pkginfo namedtuple ''' pkginfo_tuple = collections.namedtuple( 'PkgInfo', ('name', 'version', 'arch', 'repoid', 'install_date', 'install_date_time_t') ) return p...
def resolve_name(name, arch, osarch=None): ''' Resolve the package name and arch into a unique name referred to by salt. For example, on a 64-bit OS, a 32-bit package will be pkgname.i386. ''' if osarch is None: osarch = get_osarch() if not check_32(arch, osarch) and arch not in (ARCHMA...
def parse_pkginfo(line, osarch=None): ''' A small helper to parse an rpm/repoquery command's output. Returns a pkginfo namedtuple. ''' try: name, epoch, version, release, arch, repoid, install_time = line.split('_|-') # Handle unpack errors (should never happen with the queryformat we ar...
def combine_comments(comments): ''' Given a list of comments, strings, a single comment or a single string, return a single string of text containing all of the comments, prepending the '#' and joining with newlines as necessary. ''' if not isinstance(comments, list): comments = [comment...
def version_to_evr(verstring): ''' Split the package version string into epoch, version and release. Return this as tuple. The epoch is always not empty. The version and the release can be an empty string if such a component could not be found in the version string. "2:1.0-1.2" => ('2', '1.0',...
def present( name, description, vpc_id=None, vpc_name=None, rules=None, rules_egress=None, delete_ingress_rules=True, delete_egress_rules=True, region=None, key=None, keyid=None, profile=None, tags=None): ''' ...
def _security_group_present(name, description, vpc_id=None, vpc_name=None, region=None, key=None, keyid=None, profile=None): ''' given a group name or a group name and vpc id (or vpc name): 1. determine if the group exists 2. if the group does not exist, creates the group ...
def _split_rules(rules): ''' Split rules with lists into individual rules. We accept some attributes as lists or strings. The data we get back from the execution module lists rules as individual rules. We need to split the provided rules into individual rules to compare them. ''' split = []...
def _check_rule(rule, _rule): ''' Check to see if two rules are the same. Needed to compare rules fetched from boto, since they may not completely match rules defined in sls files but may be functionally equivalent. ''' # We need to alter what Boto returns if no ports are specified # so tha...
def _get_rule_changes(rules, _rules): ''' given a list of desired rules (rules) and existing rules (_rules) return a list of rules to delete (to_delete) and to create (to_create) ''' to_delete = [] to_create = [] # for each rule in state file # 1. validate rule # 2. determine if rule...
def _rules_present(name, rules, delete_ingress_rules=True, vpc_id=None, vpc_name=None, region=None, key=None, keyid=None, profile=None): ''' given a group name or group name and vpc_id (or vpc name): 1. get lists of desired rule changes (using _get_rule_changes) 2. authorize/create ru...
def absent( name, vpc_id=None, vpc_name=None, region=None, key=None, keyid=None, profile=None): ''' Ensure a security group with the specified name does not exist. name Name of the security group. vpc_id The ID of the VPC to remov...
def _tags_present(name, tags, vpc_id=None, vpc_name=None, region=None, key=None, keyid=None, profile=None): ''' helper function to validate tags are correct ''' ret = {'result': True, 'comment': '', 'changes': {}} if tags: sg = __salt__['boto_secgroup.get_config'](name=name...
def _ordereddict2dict(input_ordered_dict): ''' Convert ordered dictionary to a dictionary ''' return salt.utils.json.loads(salt.utils.json.dumps(input_ordered_dict))
def quorum(name, **kwargs): ''' Quorum state This state checks the mon daemons are in quorum. It does not alter the cluster but can be used in formula as a dependency for many cluster operations. Example usage in sls file: .. code-block:: yaml quorum: sesceph.quorum: ...
def ext_pillar(minion_id, pillar, # pylint: disable=W0613 conf): ''' Check consul for all data ''' opts = {} temp = conf target_re = re.compile('target="(.*?)"') match = target_re.search(temp) if match: opts['target'] = match.group(1) temp =...
def consul_fetch(client, path): ''' Query consul for all keys/values within base path ''' # Unless the root path is blank, it needs a trailing slash for # the kv get from Consul to work as expected return client.kv.get('' if not path else path.rstrip('/') + '/', recurse=True)
def fetch_tree(client, path, expand_keys): ''' Grab data from consul, trim base path and remove any keys which are folders. Take the remaining data and send it to be formatted in such a way as to be used as pillar data. ''' _, items = consul_fetch(client, path) ret = {} has_children = re...
def pillar_format(ret, keys, value, expand_keys): ''' Perform data formatting to be used as pillar data and merge it with the current pillar data ''' # if value is empty in Consul then it's None here - skip it if value is None: return ret # If value is not None then it's a string ...
def get_conn(opts, profile): ''' Return a client object for accessing consul ''' opts_pillar = opts.get('pillar', {}) opts_master = opts_pillar.get('master', {}) opts_merged = {} opts_merged.update(opts_master) opts_merged.update(opts_pillar) opts_merged.update(opts) if profil...
def _resolve_datacenter(dc, pillarenv): ''' If ``dc`` is a string - return it as is. If it's a dict then sort it in descending order by key length and try to use keys as RegEx patterns to match against ``pillarenv``. The value for matched pattern should be a string (that can use ``str.format`` ...
def _gather_group_members(group, groups, users): ''' Gather group members ''' _group = __salt__['group.info'](group) if not _group: log.warning('Group %s does not exist, ignoring.', group) return for member in _group['members']: if member not in users: users...
def _check_time_range(time_range, now): ''' Check time range ''' if _TIME_SUPPORTED: _start = dateutil_parser.parse(time_range['start']) _end = dateutil_parser.parse(time_range['end']) return bool(_start <= now <= _end) else: log.error('Dateutil is required.') ...
def beacon(config): ''' Read the last btmp file and return information on the failed logins ''' ret = [] users = {} groups = {} defaults = None for config_item in config: if 'users' in config_item: users = config_item['users'] if 'groups' in config_item: ...
def _sprinkle(config_str): ''' Sprinkle with grains of salt, that is convert 'test {id} test {host} ' types of strings :param config_str: The string to be sprinkled :return: The string sprinkled ''' parts = [x for sub in config_str.split('{') for x in sub.split('}')] for i in range(1, le...
def _generate_payload(author_icon, title, report): ''' Prepare the payload for Slack :param author_icon: The url for the thumbnail to be displayed :param title: The title of the message :param report: A dictionary with the report of the Salt function :return: The payload ready for Slack ''' ...
def _generate_report(ret, show_tasks): ''' Generate a report of the Salt function :param ret: The Salt return :param show_tasks: Flag to show the name of the changed and failed states :return: The report ''' returns = ret.get('return') sorted_data = sorted( returns.items(), ...
def _post_message(webhook, author_icon, title, report): ''' Send a message to a Slack room through a webhook :param webhook: The url of the incoming webhook :param author_icon: The thumbnail image to be displayed on the right side of the message :param title: The title of the message :...
def returner(ret): ''' Send a slack message with the data through a webhook :param ret: The Salt return :return: The result of the post ''' _options = _get_options(ret) webhook = _options.get('webhook', None) show_tasks = _options.get('show_tasks') author_icon = _options.get('autho...
def update_git_repos(clean=False): ''' Checkout git repos containing :ref:`Windows Software Package Definitions <windows-package-manager>`. .. important:: This function requires `Git for Windows`_ to be installed in order to work. When installing, make sure to select an installation opt...
def show_sls(name, saltenv='base'): r''' .. versionadded:: 2015.8.0 Display the rendered software definition from a specific sls file in the local winrepo cache. This will parse all Jinja. Run pkg.refresh_db to pull the latest software definitions from the master. .. note:: This functi...
def version(): ''' Return the actual lxc client version .. versionadded:: 2015.8.0 CLI Example: .. code-block:: bash salt '*' lxc.version ''' k = 'lxc.version' if not __context__.get(k, None): cversion = __salt__['cmd.run_all']('lxc-info --version') if not cv...
def _clear_context(): ''' Clear any lxc variables set in __context__ ''' for var in [x for x in __context__ if x.startswith('lxc.')]: log.trace('Clearing __context__[\'%s\']', var) __context__.pop(var, None)
def _ip_sort(ip): '''Ip sorting''' idx = '001' if ip == '127.0.0.1': idx = '200' if ip == '::1': idx = '201' elif '::' in ip: idx = '100' return '{0}___{1}'.format(idx, ip)
def search_lxc_bridges(): ''' Search which bridges are potentially available as LXC bridges CLI Example: .. code-block:: bash salt '*' lxc.search_lxc_bridges ''' bridges = __context__.get('lxc.bridges', None) # either match not yet called or no bridges were found # to handle ...
def cloud_init_interface(name, vm_=None, **kwargs): ''' Interface between salt.cloud.lxc driver and lxc.init ``vm_`` is a mapping of vm opts in the salt.cloud format as documented for the lxc driver. This can be used either: - from the salt cloud driver - because you find the argument to g...
def _rand_cpu_str(cpu): ''' Return a random subset of cpus for the cpuset config ''' cpu = int(cpu) avail = __salt__['status.nproc']() if cpu < avail: return '0-{0}'.format(avail) to_set = set() while len(to_set) < cpu: choice = random.randint(0, avail - 1) if cho...
def _network_conf(conf_tuples=None, **kwargs): ''' Network configuration defaults network_profile as for containers, we can either call this function either with a network_profile dict or network profile name in the kwargs nic_opts overrides or ex...
def _config_list(conf_tuples=None, only_net=False, **kwargs): ''' Return a list of dicts from the salt level configurations conf_tuples _LXCConfig compatible list of entries which can contain - string line - tuple (lxc config param,value) - dict of one entry: {l...
def _get_veths(net_data): ''' Parse the nic setup inside lxc conf tuples back to a dictionary indexed by network interface ''' if isinstance(net_data, dict): net_data = list(net_data.items()) nics = salt.utils.odict.OrderedDict() current_nic = salt.utils.odict.OrderedDict() no_na...
def _get_base(**kwargs): ''' If the needed base does not exist, then create it, if it does exist create nothing and return the name of the base lxc container so it can be cloned. ''' profile = get_container_profile(copy.deepcopy(kwargs.get('profile'))) kw_overrides = copy.deepcopy(kwargs) ...
def init(name, config=None, cpuset=None, cpushare=None, memory=None, profile=None, network_profile=None, nic_opts=None, cpu=None, autostart=True, password=None, password_encrypted=None, users=None, dnsse...
def cloud_init(name, vm_=None, **kwargs): ''' Thin wrapper to lxc.init to be used from the saltcloud lxc driver name Name of the container may be None and then guessed from saltcloud mapping `vm_` saltcloud mapping defaults for the vm CLI Example: .. code-block:: bash ...
def images(dist=None): ''' .. versionadded:: 2015.5.0 List the available images for LXC's ``download`` template. dist : None Filter results to a single Linux distribution CLI Examples: .. code-block:: bash salt myminion lxc.images salt myminion lxc.images dist=centos...
def templates(): ''' .. versionadded:: 2015.5.0 List the available LXC template scripts installed on the minion CLI Examples: .. code-block:: bash salt myminion lxc.templates ''' try: template_scripts = os.listdir('/usr/share/lxc/templates') except OSError: re...
def create(name, config=None, profile=None, network_profile=None, nic_opts=None, **kwargs): ''' Create a new container. name Name of the container config The config file to use for the container. Defaults to system-wide con...
def clone(name, orig, profile=None, network_profile=None, nic_opts=None, **kwargs): ''' Create a new container as a clone of another container name Name of the container orig Name of the original container to be cloned profile ...
def ls_(active=None, cache=True, path=None): ''' Return a list of the containers available on the minion path path to the container parent directory default: /var/lib/lxc (system) .. versionadded:: 2015.8.0 active If ``True``, return only active (i.e. running) containe...
def list_(extra=False, limit=None, path=None): ''' List containers classified by state extra Also get per-container specific info. This will change the return data. Instead of returning a list of containers, a dictionary of containers and each container's output from :mod:`lxc.info ...
def _ensure_exists(name, path=None): ''' Raise an exception if the container does not exist ''' if not exists(name, path=path): raise CommandExecutionError( 'Container \'{0}\' does not exist'.format(name) )
def _ensure_running(name, no_start=False, path=None): ''' If the container is not currently running, start it. This function returns the state that the container was in before changing path path to the container parent directory default: /var/lib/lxc (system) .. versionadded:: ...
def restart(name, path=None, lxc_config=None, force=False): ''' .. versionadded:: 2015.5.0 Restart the named container. If the container was not running, the container will merely be started. name The name of the container path path to the container parent directory de...
def start(name, **kwargs): ''' Start the named container path path to the container parent directory default: /var/lib/lxc (system) .. versionadded:: 2015.8.0 lxc_config path to a lxc config file config file will be guessed from container name otherwise ...
def stop(name, kill=False, path=None, use_vt=None): ''' Stop the named container path path to the container parent directory default: /var/lib/lxc (system) .. versionadded:: 2015.8.0 kill: False Do not wait for the container to stop, kill all tasks in the container. ...
def freeze(name, **kwargs): ''' Freeze the named container path path to the container parent directory default: /var/lib/lxc (system) .. versionadded:: 2015.8.0 start : False If ``True`` and the container is stopped, the container will be started before attempt...
def unfreeze(name, path=None, use_vt=None): ''' Unfreeze the named container. path path to the container parent directory default: /var/lib/lxc (system) .. versionadded:: 2015.8.0 use_vt run the command through VT .. versionadded:: 2015.8.0 CLI Example: ...
def destroy(name, stop=False, path=None): ''' Destroy the named container. .. warning:: Destroys all data associated with the container. path path to the container parent directory (default: /var/lib/lxc) .. versionadded:: 2015.8.0 stop : False If ``True``, the c...
def exists(name, path=None): ''' Returns whether the named container exists. path path to the container parent directory (default: /var/lib/lxc) .. versionadded:: 2015.8.0 CLI Example: .. code-block:: bash salt '*' lxc.exists name ''' _exists = name in ls_(path...
def state(name, path=None): ''' Returns the state of a container. path path to the container parent directory (default: /var/lib/lxc) .. versionadded:: 2015.8.0 CLI Example: .. code-block:: bash salt '*' lxc.state name ''' # Don't use _ensure_exists() here, it wi...
def get_parameter(name, parameter, path=None): ''' Returns the value of a cgroup parameter for a container path path to the container parent directory default: /var/lib/lxc (system) .. versionadded:: 2015.8.0 CLI Example: .. code-block:: bash salt '*' lxc.get_par...
def set_parameter(name, parameter, value, path=None): ''' Set the value of a cgroup parameter for a container. path path to the container parent directory default: /var/lib/lxc (system) .. versionadded:: 2015.8.0 CLI Example: .. code-block:: bash salt '*' lxc.set...
def info(name, path=None): ''' Returns information about a container path path to the container parent directory default: /var/lib/lxc (system) .. versionadded:: 2015.8.0 CLI Example: .. code-block:: bash salt '*' lxc.info name ''' cachekey = 'lxc.info.{0...
def set_password(name, users, password, encrypted=True, path=None): ''' .. versionchanged:: 2015.5.0 Function renamed from ``set_pass`` to ``set_password``. Additionally, this function now supports (and defaults to using) a password hash instead of a plaintext password. Set the pass...
def update_lxc_conf(name, lxc_conf, lxc_conf_unset, path=None): ''' Edit LXC configuration options path path to the container parent default: /var/lib/lxc (system default) .. versionadded:: 2015.8.0 CLI Example: .. code-block:: bash salt myminion lxc.update_lxc_c...
def set_dns(name, dnsservers=None, searchdomains=None, path=None): ''' .. versionchanged:: 2015.5.0 The ``dnsservers`` and ``searchdomains`` parameters can now be passed as a comma-separated list. Update /etc/resolv.confo path path to the container parent default: /var...
def running_systemd(name, cache=True, path=None): ''' Determine if systemD is running path path to the container parent .. versionadded:: 2015.8.0 CLI Example: .. code-block:: bash salt '*' lxc.running_systemd ubuntu ''' k = 'lxc.systemd.test.{0}{1}'.format(name...
def systemd_running_state(name, path=None): ''' Get the operational state of a systemd based container path path to the container parent default: /var/lib/lxc (system default) .. versionadded:: 2015.8.0 CLI Example: .. code-block:: bash salt myminion lxc.systemd_...
def wait_started(name, path=None, timeout=300): ''' Check that the system has fully inited This is actually very important for systemD based containers see https://github.com/saltstack/salt/issues/23847 path path to the container parent default: /var/lib/lxc (system default) ...
def attachable(name, path=None): ''' Return True if the named container can be attached to via the lxc-attach command path path to the container parent default: /var/lib/lxc (system default) .. versionadded:: 2015.8.0 CLI Example: .. code-block:: bash salt 'm...