text
stringlengths
81
112k
.. versionadded:: 2019.2.0 Manage the workgroup of the computer name The workgroup to set Example: .. code-block:: yaml set workgroup: system.workgroup: - name: local def workgroup(name): ''' .. versionadded:: 2019.2.0 Manage the workgroup of the ...
Checks if a computer is joined to the Domain. If the computer is not in the Domain, it will be joined. Args: name (str): The name of the Domain. username (str): Username of an account which is authorized to join computers to the specified domain. Need to be...
Reboot the computer :param str message: An optional message to display to users. It will also be used as a comment in the event log entry. The default value is None. :param int timeout: The number of minutes or seconds before a reboot will occur. Whether this number re...
Shutdown the computer :param str message: An optional message to display to users. It will also be used as a comment in the event log entry. The default value is None. :param int timeout: The number of minutes or seconds before a shutdown will occur. Whether this numbe...
Send a message to a Slack channel. .. code-block:: yaml slack-message: slack.post_message: - channel: '#general' - from_name: SuperAdmin - message: 'This state was executed successfully.' - api_key: peWcBiMOS9HrZG15peWcBiMOS9HrZG15 The followi...
Parse BTRFS device info data. def _parse_btrfs_info(data): ''' Parse BTRFS device info data. ''' ret = {} for line in [line for line in data.split("\n") if line][:-1]: if line.startswith("Label:"): line = re.sub(r"Label:\s+", "", line) label, uuid_ = [tkn.strip() for...
Get BTRFS filesystem information. CLI Example: .. code-block:: bash salt '*' btrfs.info /dev/sda1 def info(device): ''' Get BTRFS filesystem information. CLI Example: .. code-block:: bash salt '*' btrfs.info /dev/sda1 ''' out = __salt__['cmd.run_all']("btrfs filesy...
Get known BTRFS formatted devices on the system. CLI Example: .. code-block:: bash salt '*' btrfs.devices def devices(): ''' Get known BTRFS formatted devices on the system. CLI Example: .. code-block:: bash salt '*' btrfs.devices ''' out = __salt__['cmd.run_all'](...
Defragment only one BTRFS mountpoint. def _defragment_mountpoint(mountpoint): ''' Defragment only one BTRFS mountpoint. ''' out = __salt__['cmd.run_all']("btrfs filesystem defragment -f {0}".format(mountpoint)) return { 'mount_point': mountpoint, 'passed': not out['stderr'], ...
Defragment mounted BTRFS filesystem. In order to defragment a filesystem, device should be properly mounted and writable. If passed a device name, then defragmented whole filesystem, mounted on in. If passed a moun tpoint of the filesystem, then only this mount point is defragmented. CLI Example: ...
List currently available BTRFS features. CLI Example: .. code-block:: bash salt '*' btrfs.mkfs_features def features(): ''' List currently available BTRFS features. CLI Example: .. code-block:: bash salt '*' btrfs.mkfs_features ''' out = __salt__['cmd.run_all']("mk...
Parse usage/overall. def _usage_overall(raw): ''' Parse usage/overall. ''' data = {} for line in raw.split("\n")[1:]: keyset = [item.strip() for item in re.sub(r"\s+", " ", line).split(":", 1) if item.strip()] if len(keyset) == 2: key = re.sub(r"[()]", "", keyset[0]).rep...
Parse usage/specific. def _usage_specific(raw): ''' Parse usage/specific. ''' get_key = lambda val: dict([tuple(val.split(":")), ]) raw = raw.split("\n") section, size, used = raw[0].split(" ") section = section.replace(",", "_").replace(":", "").lower() data = {} data[section] = {...
Parse usage/unallocated. def _usage_unallocated(raw): ''' Parse usage/unallocated. ''' ret = {} for line in raw.split("\n")[1:]: keyset = re.sub(r"\s+", " ", line.strip()).split(" ") if len(keyset) == 2: ret[keyset[0]] = keyset[1] return ret
Show in which disk the chunks are allocated. CLI Example: .. code-block:: bash salt '*' btrfs.usage /your/mountpoint def usage(path): ''' Show in which disk the chunks are allocated. CLI Example: .. code-block:: bash salt '*' btrfs.usage /your/mountpoint ''' out = ...
Create a file system on the specified device. By default wipes out with force. General options: * **allocsize**: Specify the BTRFS offset from the start of the device. * **bytecount**: Specify the size of the resultant filesystem. * **nodesize**: Node size. * **leafsize**: Specify the nodesize, th...
Resize filesystem. General options: * **mountpoint**: Specify the BTRFS mountpoint to resize. * **size**: ([+/-]<newsize>[kKmMgGtTpPeE]|max) Specify the new size of the target. CLI Example: .. code-block:: bash salt '*' btrfs.resize /mountpoint size=+1g salt '*' btrfs.resize /de...
Convert ext2/3/4 to BTRFS. Device should be mounted. Filesystem can be converted temporarily so the further processing and rollback is possible, or permanently, where previous extended filesystem image gets deleted. Please note, permanent conversion takes a while as BTRFS filesystem needs to be properly re...
Restripe BTRFS: add or remove devices from the particular mounted filesystem. def _restripe(mountpoint, direction, *devices, **kwargs): ''' Restripe BTRFS: add or remove devices from the particular mounted filesystem. ''' fs_log = [] if salt.utils.fsutils._is_device(mountpoint): raise Comm...
Parse properties list. def _parse_proplist(data): ''' Parse properties list. ''' out = {} for line in data.split("\n"): line = re.split(r"\s+", line, 1) if len(line) == 2: out[line[0]] = line[1] return out
List properties for given btrfs object. The object can be path of BTRFS device, mount point, or any directories/files inside the BTRFS filesystem. General options: * **type**: Possible types are s[ubvol], f[ilesystem], i[node] and d[evice]. * **force**: Force overwrite existing filesystem on the disk ...
Create subvolume `name` in `dest`. Return True if the subvolume is created, False is the subvolume is already there. name Name of the new subvolume dest If not given, the subvolume will be created in the current directory, if given will be in /dest/name qgroupids ...
Delete the subvolume(s) from the filesystem The user can remove one single subvolume (name) or multiple of then at the same time (names). One of the two parameters needs to specified. Please, refer to the documentation to understand the implication on the transactions, and when the subvolume is re...
List the recently modified files in a subvolume name Name of the subvolume last_gen Last transid marker from where to compare CLI Example: .. code-block:: bash salt '*' btrfs.subvolume_find_new /var/volumes/tmp 1024 def subvolume_find_new(name, last_gen): ''' List t...
Get the default subvolume of the filesystem path path Mount point for the subvolume CLI Example: .. code-block:: bash salt '*' btrfs.subvolume_get_default /var/volumes/tmp def subvolume_get_default(path): ''' Get the default subvolume of the filesystem path path Mou...
Helper for the line parser. If key is a prefix of line, will remove ir from the line and will extract the value (space separation), and the rest of the line. If use_rest is True, the value will be the rest of the line. Return a tuple with the value and the rest of the line. def _pop(line, key, use_r...
List the subvolumes present in the filesystem. path Mount point for the subvolume parent_id Print parent ID absolute Print all the subvolumes in the filesystem and distinguish between absolute and relative path with respect to the given <path> ogeneration ...
Set the subvolume as default subvolid ID of the new default subvolume path Mount point for the filesystem CLI Example: .. code-block:: bash salt '*' btrfs.subvolume_set_default 257 /var/volumes/tmp def subvolume_set_default(subvolid, path): ''' Set the subvolume as ...
Show information of a given subvolume path Mount point for the filesystem CLI Example: .. code-block:: bash salt '*' btrfs.subvolume_show /var/volumes/tmp def subvolume_show(path): ''' Show information of a given subvolume path Mount point for the filesystem CL...
Create a snapshot of a source subvolume source Source subvolume from where to create the snapshot dest If only dest is given, the subvolume will be named as the basename of the source name Name of the snapshot read_only Create a read only snapshot CLI Exam...
Wait until given subvolume are completely removed from the filesystem after deletion. path Mount point for the filesystem subvolids List of IDs of subvolumes to wait for sleep Sleep N seconds betwenn checks (default: 1) CLI Example: .. code-block:: bash salt...
Add a user to the minion. Args: name (str): User name password (str, optional): User's password in plain text. fullname (str, optional): The user's full name. description (str, optional): A brief description of the user account. groups (str, optional): A list of groups t...
Updates settings for the windows user. Name is the only required parameter. Settings will only be changed if the parameter is passed a value. .. versionadded:: 2015.8.0 Args: name (str): The user name to update. password (str, optional): New user password in plain text. fullname ...
Remove a user from the minion Args: name (str): The name of the user to delete purge (bool, optional): Boolean value indicating that the user profile should also be removed when the user account is deleted. If set to True the profile will be removed. Default is False. ...
Get the Security ID for the user Args: username (str): The user name for which to look up the SID Returns: str: The user SID CLI Example: .. code-block:: bash salt '*' user.getUserSid jsnuffy def getUserSid(username): ''' Get the Security ID for the user Args: ...
Add user to a group Args: name (str): The user name to add to the group group (str): The name of the group to which to add the user Returns: bool: True if successful, otherwise False CLI Example: .. code-block:: bash salt '*' user.addgroup jsnuffy 'Power Users' def...
Change the home directory of the user, pass True for persist to move files to the new home directory if the old home directory exist. Args: name (str): The name of the user whose home directory you wish to change home (str): The new location of the home directory Returns: bool: Tr...
Change the groups this user belongs to, add append=False to make the user a member of only the specified groups Args: name (str): The user name for which to change groups groups (str, list): A single group or a list of groups to assign to the user. For multiple groups this can be a...
Return user information Args: name (str): Username for which to display information Returns: dict: A dictionary containing user information - fullname - username - SID - passwd (will always return None) - comment (same as description,...
In case net user doesn't return the userprofile we can get it from the registry Args: user (str): The user name, used in debug message sid (str): The sid to lookup in the registry Returns: str: Profile directory def _get_userprofile_from_registry(user, sid): ''' In case n...
Return a list of groups the named user belongs to Args: name (str): The user name for which to list groups Returns: list: A list of groups to which the user belongs CLI Example: .. code-block:: bash salt '*' user.list_groups foo def list_groups(name): ''' Return a l...
Return the list of all info for all users Args: refresh (bool, optional): Refresh the cached user information. Useful when used from within a state function. Default is False. Returns: dict: A dictionary containing information about all users on the system CLI Example: .....
Return a list of all users on Windows Returns: list: A list of all users on the system CLI Example: .. code-block:: bash salt '*' user.list_users def list_users(): ''' Return a list of all users on Windows Returns: list: A list of all users on the system CLI Ex...
Change the username for a named user Args: name (str): The user name to change new_name (str): The new name for the current user Returns: bool: True if successful, otherwise False CLI Example: .. code-block:: bash salt '*' user.rename jsnuffy jshmoe def rename(name...
Get the username that salt-minion is running under. If salt-minion is running as a service it should return the Local System account. If salt is running from a command prompt it should return the username that started the command prompt. .. versionadded:: 2015.5.6 Args: sam (bool, optional...
Validates a mac address def mac(addr): ''' Validates a mac address ''' valid = re.compile(r''' (^([0-9A-F]{1,2}[-]){5}([0-9A-F]{1,2})$ |^([0-9A-F]{1,2}[:]){5}([0-9A-F]{1,2})$ |^([0-9A-F]{1,2}[.]){5}([0-9A-F]{1,2})$) ...
Returns True if the IP address (and optional subnet) are valid, otherwise returns False. def __ip_addr(addr, address_family=socket.AF_INET): ''' Returns True if the IP address (and optional subnet) are valid, otherwise returns False. ''' mask_max = '32' if address_family == socket.AF_INET6:...
Returns True if the value passed is a valid netmask, otherwise return False def netmask(mask): ''' Returns True if the value passed is a valid netmask, otherwise return False ''' if not isinstance(mask, string_types): return False octets = mask.split('.') if not len(octets) == 4: ...
Returns a tuple of (user, host, port) with config, pillar, or default values assigned to missing values. def _connect(host=DEFAULT_HOST, port=DEFAULT_PORT): ''' Returns a tuple of (user, host, port) with config, pillar, or default values assigned to missing values. ''' if six.text_type(port).is...
Get memcached status CLI Example: .. code-block:: bash salt '*' memcached.status def status(host=DEFAULT_HOST, port=DEFAULT_PORT): ''' Get memcached status CLI Example: .. code-block:: bash salt '*' memcached.status ''' conn = _connect(host, port) try: ...
Retrieve value for a key CLI Example: .. code-block:: bash salt '*' memcached.get <key> def get(key, host=DEFAULT_HOST, port=DEFAULT_PORT): ''' Retrieve value for a key CLI Example: .. code-block:: bash salt '*' memcached.get <key> ''' conn = _connect(host, port) ...
Set a key on the memcached server, overwriting the value if it exists. CLI Example: .. code-block:: bash salt '*' memcached.set <key> <value> def set_(key, value, host=DEFAULT_HOST, port=DEFAULT_PORT, time=DEFAULT_TIME, min_compress_len=DEFAULT_MIN_COMPRE...
Delete a key from memcache server CLI Example: .. code-block:: bash salt '*' memcached.delete <key> def delete(key, host=DEFAULT_HOST, port=DEFAULT_PORT, time=DEFAULT_TIME): ''' Delete a key from memcache server CLI Example: .. code-block:: bash ...
Replace a key on the memcached server. This only succeeds if the key already exists. This is the opposite of :mod:`memcached.add <salt.modules.memcached.add>` CLI Example: .. code-block:: bash salt '*' memcached.replace <key> <value> def replace(key, value, host=DEFAU...
Increment the value of a key CLI Example: .. code-block:: bash salt '*' memcached.increment <key> salt '*' memcached.increment <key> 2 def increment(key, delta=1, host=DEFAULT_HOST, port=DEFAULT_PORT): ''' Increment the value of a key CLI Example: .. code-block:: bash ...
Publish a command "from the minion out to other minions". In reality, the minion does not execute this function, it is executed by the master. Thus, no access control is enabled, as minions cannot initiate publishes themselves. Salt-ssh publishes will default to whichever roster was used for the in...
Publish a command "from the minion out to other minions". In reality, the minion does not execute this function, it is executed by the master. Thus, no access control is enabled, as minions cannot initiate publishes themselves. Salt-ssh publishes will default to whichever roster was used for the i...
Execute a runner on the master and return the data from the runnr function CLI Example: .. code-block:: bash salt-ssh '*' publish.runner jobs.lookup_jid 20140916125524463507 def runner(fun, arg=None, timeout=5): ''' Execute a runner on the master and return the data from the runnr function ...
Create RackSpace Queue. def create(self, qname): ''' Create RackSpace Queue. ''' try: if self.exists(qname): log.error('Queues "%s" already exists. Nothing done.', qname) return True self.conn.create(qname) return Tru...
Delete an existings RackSpace Queue. def delete(self, qname): ''' Delete an existings RackSpace Queue. ''' try: q = self.exists(qname) if not q: return False queue = self.show(qname) if queue: queue.delete()...
Check to see if a Queue exists. def exists(self, qname): ''' Check to see if a Queue exists. ''' try: # First if not exists() -> exit if self.conn.queue_exists(qname): return True return False except pyrax.exceptions as err_msg...
Show information about Queue def show(self, qname): ''' Show information about Queue ''' try: # First if not exists() -> exit if not self.conn.queue_exists(qname): return {} # If exist, search the queue to return the Queue Object ...
Return a list of startup dirs def _get_dirs(user_dir, startup_dir): ''' Return a list of startup dirs ''' try: users = os.listdir(user_dir) except WindowsError: # pylint: disable=E0602 users = [] full_dirs = [] for user in users: full_dir = os.path.join(user_dir, u...
Get a list of automatically running programs CLI Example: .. code-block:: bash salt '*' autoruns.list def list_(): ''' Get a list of automatically running programs CLI Example: .. code-block:: bash salt '*' autoruns.list ''' autoruns = {} # Find autoruns in re...
Get pillar data from Vault for the configuration ``conf``. def ext_pillar(minion_id, # pylint: disable=W0613 pillar, # pylint: disable=W0613 conf, nesting_key=None): ''' Get pillar data from Vault for the configuration ``conf``. ''' comps = conf.split() ...
Export a file or directory from an SVN repository name Address and path to the file or directory to be exported. target Name of the target directory where the checkout will put the working directory rev : None The name revision number to checkout. Enable "force" if the dir...
Determine if the working directory has been changed. def dirty(name, target, user=None, username=None, password=None, ignore_unversioned=False): ''' Determine if the working directory has been changed. ''' ret = {'name': name, 'result': True, 'comment':...
Compile pillar data def ext_pillar(minion_id, pillar, *args, **kwargs): ''' Compile pillar data ''' # Node definitions path will be retrieved from args (or set to default), # then added to 'salt_data' dict that is passed to the 'get_pillars' # function. The dictionary contains: # - __op...
Ensures a container is present. :param name: Container name :type name: ``str`` :param profile: The profile key :type profile: ``str`` def container_present(name, profile): ''' Ensures a container is present. :param name: Container name :type name: ``str`` :param profile: The...
Ensures a object is presnt. :param container: Container name :type container: ``str`` :param name: Object name in cloud :type name: ``str`` :param path: Local path to file :type path: ``str`` :param profile: The profile key :type profile: ``str`` def object_present(container, na...
Ensures a object is absent. :param container: Container name :type container: ``str`` :param name: Object name in cloud :type name: ``str`` :param profile: The profile key :type profile: ``str`` def object_absent(container, name, profile): ''' Ensures a object is absent. :par...
Ensures a object is downloaded locally. :param container: Container name :type container: ``str`` :param name: Object name in cloud :type name: ``str`` :param path: Local path to file :type path: ``str`` :param profile: The profile key :type profile: ``str`` :param overwrite...
Required. Initialize device connection using ssh or nxapi connection type. def init(opts=None): ''' Required. Initialize device connection using ssh or nxapi connection type. ''' global CONNECTION if __opts__.get('proxy').get('connection') is not None: CONNECTION = __opts__.get('pro...
Get grains for minion. .. code-block: bash salt '*' nxos.cmd grains def grains(**kwargs): ''' Get grains for minion. .. code-block: bash salt '*' nxos.cmd grains ''' import __main__ as main # pylint: disable=unused-import if not DEVICE_DETAILS['grains_cache']: d...
Send arbitrary show or config commands to the NX-OS device. command The command to be sent. method: ``cli_show_ascii``: Return raw test or unstructured output. ``cli_show``: Return structured output. ``cli_conf``: Send configuration commands to the device. Defaults to `...
Send configuration commands over SSH or NX-API commands List of configuration commands no_save_config If True, don't save configuration commands to startup configuration. If False, save configuration to startup configuration. Default: False .. code-block: bash sal...
Open a connection to the NX-OS switch over SSH. def _init_ssh(opts): ''' Open a connection to the NX-OS switch over SSH. ''' if opts is None: opts = __opts__ try: this_prompt = None if 'prompt_regex' in opts['proxy']: this_prompt = opts['proxy']['prompt_regex'] ...
Helper method to parse command output for error information def _parse_output_for_errors(data, command, **kwargs): ''' Helper method to parse command output for error information ''' if re.search('% Invalid', data): raise CommandExecutionError({ 'rejected_input': command, ...
Open a connection to the NX-OS switch over NX-API. As the communication is HTTP(S) based, there is no connection to maintain, however, in order to test the connectivity and make sure we are able to bring up this Minion, we are executing a very simple command (``show clock``) which doesn't come with muc...
Executes an nxapi_request request over NX-API. commands The exec or config commands to be sent. method: ``cli_show`` ``cli_show_ascii``: Return raw test or unstructured output. ``cli_show``: Return structured output. ``cli_conf``: Send configuration commands to the device. ...
.. versionadded:: 2019.2.0 Create or update an availability set. :param name: The availability set to create. :param resource_group: The resource group name assigned to the availability set. CLI Example: .. code-block:: bash salt-call azurearm_compute.availability_set_create_or...
.. versionadded:: 2019.2.0 Delete an availability set. :param name: The availability set to delete. :param resource_group: The resource group name assigned to the availability set. CLI Example: .. code-block:: bash salt-call azurearm_compute.availability_set_delete testset test...
.. versionadded:: 2019.2.0 Get a dictionary representing an availability set's properties. :param name: The availability set to get. :param resource_group: The resource group name assigned to the availability set. CLI Example: .. code-block:: bash salt-call azurearm_compute.ava...
.. versionadded:: 2019.2.0 List all availability sets within a resource group. :param resource_group: The resource group name to list availability sets within. CLI Example: .. code-block:: bash salt-call azurearm_compute.availability_sets_list testgroup def availability_sets_list(r...
.. versionadded:: 2019.2.0 List all available virtual machine sizes that can be used to to create a new virtual machine in an existing availability set. :param name: The availability set name to list available virtual machine sizes within. :param resource_group: The resource group name to lis...
.. versionadded:: 2019.2.0 Captures the VM by copying virtual hard disks of the VM and outputs a template that can be used to create similar VMs. :param name: The name of the virtual machine. :param destination_name: The destination container name. :param resource_group: The resource group name ...
.. versionadded:: 2019.2.0 Retrieves information about the model view or the instance view of a virtual machine. :param name: The name of the virtual machine. :param resource_group: The resource group name assigned to the virtual machine. CLI Example: .. code-block:: bash s...
.. versionadded:: 2019.2.0 Converts virtual machine disks from blob-based to managed disks. Virtual machine must be stop-deallocated before invoking this operation. :param name: The name of the virtual machine to convert. :param resource_group: The resource group name assigned to the virtual ...
.. versionadded:: 2019.2.0 Set the state of a virtual machine to 'generalized'. :param name: The name of the virtual machine. :param resource_group: The resource group name assigned to the virtual machine. CLI Example: .. code-block:: bash salt-call azurearm_compute.virtual_mac...
.. versionadded:: 2019.2.0 List all virtual machines within a resource group. :param resource_group: The resource group name to list virtual machines within. CLI Example: .. code-block:: bash salt-call azurearm_compute.virtual_machines_list testgroup def virtual_machines_list(resou...
.. versionadded:: 2019.2.0 List all virtual machines within a subscription. CLI Example: .. code-block:: bash salt-call azurearm_compute.virtual_machines_list_all def virtual_machines_list_all(**kwargs): ''' .. versionadded:: 2019.2.0 List all virtual machines within a subscription...
.. versionadded:: 2019.2.0 Lists all available virtual machine sizes to which the specified virtual machine can be resized. :param name: The name of the virtual machine. :param resource_group: The resource group name assigned to the virtual machine. CLI Example: .. code-block:: bash...
Print out YAML using the block mode def output(data, **kwargs): # pylint: disable=unused-argument ''' Print out YAML using the block mode ''' params = {} if 'output_indent' not in __opts__: # default indentation params.update(default_flow_style=False) elif __opts__['output_ind...
Convert an AutoYAST file to an SLS file def mksls(src, dst=None): ''' Convert an AutoYAST file to an SLS file ''' with salt.utils.files.fopen(src, 'r') as fh_: ps_opts = xml.to_dict(ET.fromstring(fh_.read())) if dst is not None: with salt.utils.files.fopen(dst, 'w') as fh_: ...
Return the color theme to use def get_color_theme(theme): ''' Return the color theme to use ''' # Keep the heavy lifting out of the module space import salt.utils.data import salt.utils.files import salt.utils.yaml if not os.path.isfile(theme): log.warning('The named theme %s if...
Return the colors as an easy to use dict. Pass `False` to deactivate all colors by setting them to empty strings. Pass a string containing only the name of a single color to be used in place of all colors. Examples: .. code-block:: python colors = get_colors() # enable all colors no_color...
Creates new user group. NOTE: This function accepts all standard user group properties: keyword argument names differ depending on your zabbix version, see: https://www.zabbix.com/documentation/2.0/manual/appendix/api/usergroup/definitions#user_group .. versionadded:: 2016.3.0 :param name: name of...
Ensures that the user group does not exist, eventually delete user group. .. versionadded:: 2016.3.0 :param name: name of the user group :param _connection_user: Optional - zabbix user (can also be set in opts or pillar, see module's docstring) :param _connection_password: Optional - zabbix password (...
Return configuration def _get_config(**kwargs): ''' Return configuration ''' config = { 'filter_id_regex': ['.*!doc_skip'], 'filter_function_regex': [], 'replace_text_regex': {}, 'proccesser': 'highstate_doc.proccesser_markdown', 'max_render_file_size': 10000, ...
output the contents of a file: this is a workaround if the cp.push module does not work. https://github.com/saltstack/salt/issues/37133 help the master output the contents of a document that might be saved on the minions filesystem. .. code-block:: python #!/bin/python import os ...