text
stringlengths
81
112k
Install custom SELinux module from file CLI Example: .. code-block:: bash salt '*' selinux.install_semod [salt://]path/to/module.pp .. versionadded:: 2016.11.6 def install_semod(module_path): ''' Install custom SELinux module from file CLI Example: .. code-block:: bash ...
Return a structure listing all of the selinux modules on the system and what state they are in CLI Example: .. code-block:: bash salt '*' selinux.list_semod .. versionadded:: 2016.3.0 def list_semod(): ''' Return a structure listing all of the selinux modules on the system and w...
.. versionadded:: 2019.2.0 Validates and parses the protocol and port/port range from the name if both protocol and port are not provided. If the name is in a valid format, the protocol and port are ignored if provided Examples: tcp/8080 or udp/20-21 def _parse_protocol_port(name, protocol, port): ...
.. versionadded:: 2017.7.0 Converts an SELinux file context from string to dict. def _context_string_to_dict(context): ''' .. versionadded:: 2017.7.0 Converts an SELinux file context from string to dict. ''' if not re.match('[^:]+:[^:]+:[^:]+:[^:]+$', context): raise SaltInvocationErr...
.. versionadded:: 2017.7.0 Returns the current entry in the SELinux policy list as a dictionary. Returns None if no exact match was found. Returned keys are: * filespec (the name supplied and matched) * filetype (the descriptive name of the filetype supplied) * sel_user, sel_role, sel_type, s...
.. versionadded:: 2019.2.0 Adds the SELinux policy for a given filespec and other optional parameters. Returns the result of the call to semanage. Note that you don't have to remove an entry before setting a new one for a given filespec and filetype, as adding one with semanage automatically over...
.. versionadded:: 2019.2.0 Deletes the SELinux policy for a given filespec and other optional parameters. Returns the result of the call to semanage. Note that you don't have to remove an entry before setting a new one for a given filespec and filetype, as adding one with semanage automatically o...
.. versionadded:: 2017.7.0 Adds or deletes the SELinux policy for a given filespec and other optional parameters. Returns the result of the call to semanage. Note that you don't have to remove an entry before setting a new one for a given filespec and filetype, as adding one with semanage automat...
.. versionadded:: 2019.2.0 Performs the action as called from ``fcontext_add_policy`` or ``fcontext_delete_policy``. Returns the result of the call to semanage. def _fcontext_add_or_delete_policy(action, name, filetype=None, sel_type=None, sel_user=None, sel_level=None): ''' .. versionadded:: 2019.2....
.. versionadded:: 2017.7.0 Returns an empty string if the SELinux policy for a given filespec is applied, returns string with differences in policy and actual situation otherwise. name filespec of the file or directory. Regex syntax is allowed. CLI Example: .. code-block:: bash ...
.. versionadded:: 2017.7.0 Applies SElinux policies to filespec using `restorecon [-R] filespec`. Returns dict with changes if successful, the output of the restorecon command otherwise. name filespec of the file or directory. Regex syntax is allowed. recursive Recursively apply S...
.. versionadded:: 2019.2.0 Returns the current entry in the SELinux policy list as a dictionary. Returns None if no exact match was found. Returned keys are: * sel_type (the selinux type) * proto (the protocol) * port (the port(s) and/or port range(s)) name The protocol and port ...
.. versionadded:: 2019.2.0 Adds the SELinux policy for a given protocol and port. Returns the result of the call to semanage. name The protocol and port spec. Can be formatted as ``(tcp|udp)/(port|port-range)``. sel_type The SELinux Type. Required. protocol The protocol ...
.. versionadded:: 2019.2.0 Performs the action as called from ``port_add_policy`` or ``port_delete_policy``. Returns the result of the call to semanage. def _port_add_or_delete_policy(action, name, sel_type=None, protocol=None, port=None, sel_range=None): ''' .. versionadded:: 2019.2.0 Performs ...
Establish a connection to etcd def _get_conn(opts, profile=None): ''' Establish a connection to etcd ''' if profile is None: profile = opts.get('etcd.returner') path = opts.get('etcd.returner_root', '/salt/return') return salt.utils.etcd_util.get_conn(opts, profile), path
Return data to an etcd server or cluster def returner(ret): ''' Return data to an etcd server or cluster ''' write_profile = __opts__.get('etcd.returner_write_profile') if write_profile: ttl = __opts__.get(write_profile, {}).get('etcd.ttl') else: ttl = __opts__.get('etcd.ttl') ...
Save the load to the specified jid def save_load(jid, load, minions=None): ''' Save the load to the specified jid ''' log.debug('sdstack_etcd returner <save_load> called jid: %s', jid) write_profile = __opts__.get('etcd.returner_write_profile') client, path = _get_conn(__opts__, write_profile) ...
Return the load data that marks a specified jid def get_load(jid): ''' Return the load data that marks a specified jid ''' log.debug('sdstack_etcd returner <get_load> called jid: %s', jid) read_profile = __opts__.get('etcd.returner_read_profile') client, path = _get_conn(__opts__, read_profile)...
Return the information returned when the specified job id was executed def get_jid(jid): ''' Return the information returned when the specified job id was executed ''' log.debug('sdstack_etcd returner <get_jid> called jid: %s', jid) ret = {} client, path = _get_conn(__opts__) items = client...
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('sdstack_etcd returner <get_fun> called fun: %s', fun) ret = {} client, path = _get_conn(__opts__) items = client.get('/'.join((path, 'mini...
Return a list of all job ids def get_jids(): ''' Return a list of all job ids ''' log.debug('sdstack_etcd returner <get_jids> called') ret = [] client, path = _get_conn(__opts__) items = client.get('/'.join((path, 'jobs'))) for item in items.children: if item.dir is True: ...
Return a list of minions def get_minions(): ''' Return a list of minions ''' log.debug('sdstack_etcd returner <get_minions> called') ret = [] client, path = _get_conn(__opts__) items = client.get('/'.join((path, 'minions'))) for item in items.children: comps = str(item.key).spli...
Ensure a Linux ACL is present name The acl path acl_type The type of the acl is used for it can be 'user' or 'group' acl_name The user or group perms Set the permissions eg.: rwx recurse Set the permissions recursive in the path force Wipe o...
Ensure a Linux ACL does not exist name The acl path acl_type The type of the acl is used for, it can be 'user' or 'group' acl_names The user or group perms Remove the permissions eg.: rwx recurse Set the permissions recursive in the path def absent(name,...
Ensure a Linux ACL list is present Takes a list of acl names and add them to the given path name The acl path acl_type The type of the acl is used for it can be 'user' or 'group' acl_names The list of users or groups perms Set the permissions eg.: rwx recurs...
Ensure a Linux ACL list does not exist Takes a list of acl names and remove them from the given path name The acl path acl_type The type of the acl is used for, it can be 'user' or 'group' acl_names The list of users or groups perms Remove the permissions eg.: rw...
Helper function to retrieve objtype from pillars if objname is string_types, used for SupportedLoginProviders and OpenIdConnectProviderARNs. def _get_object(objname, objtype): ''' Helper function to retrieve objtype from pillars if objname is string_types, used for SupportedLoginProviders and O...
Helper function to set the Roles to the identity pool def _role_present(ret, IdentityPoolId, AuthenticatedRole, UnauthenticatedRole, conn_params): ''' Helper function to set the Roles to the identity pool ''' r = __salt__['boto_cognitoidentity.get_identity_pool_roles'](IdentityPoolName='', ...
Ensure Cognito Identity Pool exists. name The name of the state definition IdentityPoolName Name of the Cognito Identity Pool AuthenticatedRole An IAM role name or ARN that will be associated with temporary AWS credentials for an authenticated cognito identity. AllowU...
Ensure cognito identity pool with passed properties is absent. name The name of the state definition. IdentityPoolName Name of the Cognito Identity Pool. Please note that this may match multiple pools with the same given name, in which case, all will be removed. RemoveAll...
Returns true if the passed pcre regex matches def match(tgt, opts=None): ''' Returns true if the passed pcre regex matches ''' if not opts: return bool(re.match(tgt, __opts__['id'])) else: return bool(re.match(tgt, opts['id']))
Return the running jobs on this minion def running(opts): ''' Return the running jobs on this minion ''' ret = [] proc_dir = os.path.join(opts['cachedir'], 'proc') if not os.path.isdir(proc_dir): return ret for fn_ in os.listdir(proc_dir): path = os.path.join(proc_dir, fn_)...
Write job information to cache def cache_jobs(opts, jid, ret): ''' Write job information to cache ''' serial = salt.payload.Serial(opts=opts) fn_ = os.path.join( opts['cachedir'], 'minion_jobs', jid, 'return.p') jdir = os.path.dirname(fn_) if not os.path.isd...
Return a dict of JID metadata, or None def _read_proc_file(path, opts): ''' Return a dict of JID metadata, or None ''' serial = salt.payload.Serial(opts) current_thread = threading.currentThread().name pid = os.getpid() with salt.utils.files.fopen(path, 'rb') as fp_: buf = fp_.read(...
In some cases where there are an insane number of processes being created on a system a PID can get recycled or assigned to a non-Salt process. On Linux this fn checks to make sure the PID we are checking on is actually a Salt process. For non-Linux systems we punt and just return True def _check_cmdl...
Return a boolean stating whether or not a file's trailing newline should be removed. To figure this out, first check if keep_newline is a boolean and if so, return its opposite. Otherwise, iterate over keep_newline and check if any of the patterns match the file path. If a match is found, return False, ...
Construct pillar from file tree. def _construct_pillar(top_dir, follow_dir_links, keep_newline=False, render_default=None, renderer_blacklist=None, renderer_whitelist=None, template=False...
Compile pillar data from the given ``root_dir`` specific to Nodegroup names and Minion IDs. If a Minion's ID is not found at ``<root_dir>/host/<minion_id>`` or if it is not included in any Nodegroups named at ``<root_dir>/nodegroups/<node_group>``, no pillar data provided by this pillar module will...
Compile pillar data for a single root_dir for the specified minion ID def _ext_pillar(minion_id, root_dir, follow_dir_links, debug, keep_newline, render_default, renderer_blacklist, renderer_whitelist, ...
.. versionchanged:: 2017.7.0 Add a job to queue. job : string Command to run. timespec : string The 'timespec' follows the format documented in the at(1) manpage. tag : string Make a tag for the job. user : string The user to run the at job .. versionadde...
.. versionchanged:: 2017.7.0 Remove a job from queue jobid: string|int Specific jobid to remove tag : string Job's tag runas : string Runs user-specified jobs kwargs Addition kwargs can be provided to filter jobs. See output of `at.jobcheck` for more. ...
.. versionadded:: 2017.7.0 Add an at job if trigger by watch job : string Command to run. timespec : string The 'timespec' follows the format documented in the at(1) manpage. tag : string Make a tag for the job. user : string The user to run the at job .....
The at watcher, called to invoke the watch command. .. note:: This state exists to support special handling of the ``watch`` :ref:`requisite <requisites>`. It should not be called directly. Parameters for this function should be set by the state being triggered. name The name ...
Return args as a list of strings def _normalize_args(args): ''' Return args as a list of strings ''' if isinstance(args, six.string_types): return shlex.split(args) if isinstance(args, (tuple, list)): return [six.text_type(arg) for arg in args] else: return [six.text_ty...
Return the set of GUIDs found in guid_string :param str guid_string: String containing zero or more GUIDs. Each GUID may or may not be enclosed in {} Example data (this string contains two distinct GUIDs): PARENT_SNAPSHOT_ID SNAPSHOT_ID ...
Execute a prlsrvctl command .. versionadded:: 2016.11.0 :param str sub_cmd: prlsrvctl subcommand to execute :param str args: The arguments supplied to ``prlsrvctl <sub_cmd>`` :param str runas: The user that the prlsrvctl command will be run as Example: .. code-block...
List information about the VMs :param str name: Name/ID of VM to list .. versionchanged:: 2016.11.0 No longer implies ``info=True`` :param str info: List extra information :param bool all: List all non-template VMs :param tuple args: Additional a...
Clone a VM .. versionadded:: 2016.11.0 :param str name: Name/ID of VM to clone :param str new_name: Name of the new VM :param bool linked: Create a linked virtual machine. :param bool template: Create a virtual machine template instead of a real virtual machine. ...
Delete a VM .. versionadded:: 2016.11.0 :param str name: Name/ID of VM to clone :param str runas: The user that the prlctl command will be run as Example: .. code-block:: bash salt '*' parallels.exec macvm 'find /etc/paths.d' runas=macdev def delete(name, runas=None): ...
Query whether a VM exists .. versionadded:: 2016.11.0 :param str name: Name/ID of VM :param str runas: The user that the prlctl command will be run as Example: .. code-block:: bash salt '*' parallels.exists macvm runas=macdev def exists(name, runas=None): ''' Q...
Start a VM :param str name: Name/ID of VM to start :param str runas: The user that the prlctl command will be run as Example: .. code-block:: bash salt '*' parallels.start macvm runas=macdev def start(name, runas=None): ''' Start a VM :param str name: N...
Stop a VM :param str name: Name/ID of VM to stop :param bool kill: Perform a hard shutdown :param str runas: The user that the prlctl command will be run as Example: .. code-block:: bash salt '*' parallels.stop macvm runas=macdev salt '*' parallels.stop ...
Restart a VM by gracefully shutting it down and then restarting it :param str name: Name/ID of VM to restart :param str runas: The user that the prlctl command will be run as Example: .. code-block:: bash salt '*' parallels.restart macvm runas=macdev def restart(name, r...
Reset a VM by performing a hard shutdown and then a restart :param str name: Name/ID of VM to reset :param str runas: The user that the prlctl command will be run as Example: .. code-block:: bash salt '*' parallels.reset macvm runas=macdev def reset(name, runas=None): '...
Status of a VM :param str name: Name/ID of VM whose status will be returned :param str runas: The user that the prlctl command will be run as Example: .. code-block:: bash salt '*' parallels.status macvm runas=macdev def status(name, runas=None): ''' Status of a VM ...
Run a command on a VM :param str name: Name/ID of VM whose exec will be returned :param str command: Command to run on the VM :param str runas: The user that the prlctl command will be run as Example: .. code-block:: bash salt '*' parallels.exec macvm 'find /etc...
Attempt to convert a snapshot ID to a snapshot name. If the snapshot has no name or if the ID is not found or invalid, an empty string will be returned :param str name: Name/ID of VM whose snapshots are inspected :param str snap_id: ID of the snapshot :param bool strict: Rais...
Attempt to convert a snapshot name to a snapshot ID. If the name is not found an empty string is returned. If multiple snapshots share the same name, a list will be returned :param str name: Name/ID of VM whose snapshots are inspected :param str snap_name: Name of the snapshot :...
Validate snapshot name and convert to snapshot ID :param str name: Name/ID of VM whose snapshot name is being validated :param str snap_name: Name/ID of snapshot :param bool strict: Raise an exception if multiple snapshot IDs are found :param str runas: The user that ...
List the snapshots :param str name: Name/ID of VM whose snapshots will be listed :param str snap_id: Name/ID of snapshot to display information about. If ``tree=True`` is also specified, display the snapshot subtree having this snapshot as the root snapshot :param bool tr...
Create a snapshot :param str name: Name/ID of VM to take a snapshot of :param str snap_name: Name of snapshot :param str desc: Description of snapshot :param str runas: The user that the prlctl command will be run as Example: .. code-block:: bash sa...
Delete a snapshot .. note:: Deleting a snapshot from which other snapshots are dervied will not delete the derived snapshots :param str name: Name/ID of VM whose snapshot will be deleted :param str snap_name: Name/ID of snapshot to delete :param str runas: Th...
Revert a VM to a snapshot :param str name: Name/ID of VM to revert to a snapshot :param str snap_name: Name/ID of snapshot to revert to :param str runas: The user that the prlctl command will be run as Example: .. code-block:: bash salt '*' parallels.revert_snap...
Executes the given rpc. The returned data can be stored in a file by specifying the destination path with dest as an argument .. code-block:: yaml get-interface-information: junos: - rpc - dest: /home/user/rpc.log - interface_name: lo0 Parame...
Changes the hostname of the device. .. code-block:: yaml device_name: junos: - set_hostname - comment: "Host-name set via saltstack." Parameters: Required * hostname: The name to be set. (default = None) Optional * kwargs: K...
Commits the changes loaded into the candidate configuration. .. code-block:: yaml commit the changes: junos: - commit - confirm: 10 Parameters: Optional * kwargs: Keyworded arguments which can be provided like- * timeout: ...
Rollbacks the committed changes. .. code-block:: yaml rollback the changes: junos: - rollback - id: 5 Parameters: Optional * id: The rollback id value [0-49]. (default = 0) * kwargs: Keyworded arguments which can be pro...
Gets the difference between the candidate and the current configuration. .. code-block:: yaml get the diff: junos: - diff - id: 10 Parameters: Optional * id: The rollback id value [0-49]. (default = 0) def diff(name, **kwargs)...
Executes the CLI commands and reuturns the text output. .. code-block:: yaml show version: junos: - cli - format: xml Parameters: Required * command: The command that need to be executed on Junos CLI. (default = None) Opt...
Shuts down the device. .. code-block:: yaml shut the device: junos: - shutdown - in_min: 10 Parameters: Optional * kwargs: * reboot: Whether to reboot instead of shutdown. (default=False) * at: ...
Loads and commits the configuration provided. .. code-block:: yaml Install the mentioned config: junos: - install_config - path: salt//configs/interface.set - timeout: 100 - diffs_file: 'var/log/diff' .. code-block:: y...
Installs the given image on the device. After the installation is complete the device is rebooted, if reboot=True is given as a keyworded argument. .. code-block:: yaml salt://images/junos_image.tgz: junos: - install_os - timeout: 100 -...
Copies the file from the local device to the junos device. .. code-block:: yaml /home/m2/info.txt: junos: - file_copy - dest: info_copy.txt Parameters: Required * src: The sorce path where the file is kept. * dest: ...
Loads the configuration provided onto the junos device. .. code-block:: yaml Install the mentioned config: junos: - load - path: salt//configs/interface.set .. code-block:: yaml Install the mentioned config: junos: ...
Retrieve data from a Junos device using Tables/Views name (required) task definition table (required) Name of PyEZ Table file YAML file that has the table specified in table parameter path: Path of location of the YAML file. defaults to op directory in jnpr.ju...
Create a file system on the specified device CLI Example: .. code-block:: bash salt '*' extfs.mkfs /dev/sda1 fs_type=ext4 opts='acl,noexec' Valid options are: * **block_size**: 1024, 2048 or 4096 * **check**: check for bad blocks * **direct**: use direct IO * **ext_opts**: exten...
Set attributes for the specified device (using tune2fs) CLI Example: .. code-block:: bash salt '*' extfs.tune /dev/sda1 force=True label=wildstallyns opts='acl,noexec' Valid options are: * **max**: max mount count * **count**: mount count * **error**: error behavior * **extended...
Return all contents of dumpe2fs for a specified device CLI Example: .. code-block:: bash salt '*' extfs.dump /dev/sda1 def dump(device, args=None): ''' Return all contents of dumpe2fs for a specified device CLI Example: .. code-block:: bash salt '*' extfs.dump /dev/sda1 ...
ZeroMQ python bindings >= 2.1.9 are required def zmq_version(): ''' ZeroMQ python bindings >= 2.1.9 are required ''' try: import zmq except Exception: # Return True for local mode return True ver = zmq.__version__ # The last matched group can be None if the version ...
Lookup a hostname and determine its address family. The first address returned will be AF_INET6 if the system is IPv6-enabled, and AF_INET otherwise. def lookup_family(hostname): ''' Lookup a hostname and determine its address family. The first address returned will be AF_INET6 if the system is IPv6-en...
Attempt to bind to the sockets to verify that they are available def verify_socket(interface, pub_port, ret_port): ''' Attempt to bind to the sockets to verify that they are available ''' addr_family = lookup_family(interface) for port in pub_port, ret_port: sock = socket.socket(addr_famil...
Verify that the named files exist and are owned by the named user def verify_files(files, user): ''' Verify that the named files exist and are owned by the named user ''' if salt.utils.platform.is_windows(): return True import pwd # after confirming not running Windows try: pwn...
Verify that the named directories are in place and that the environment can shake the salt def verify_env( dirs, user, permissive=False, pki_dir='', skip_extra=False, root_dir=ROOT_DIR): ''' Verify that the named directories are in place and that the environm...
Check user and assign process uid/gid. def check_user(user): ''' Check user and assign process uid/gid. ''' if salt.utils.platform.is_windows(): return True if user == salt.utils.user.get_user(): return True import pwd # after confirming not running Windows try: pwu...
Returns a full list of directories leading up to, and including, a path. So list_path_traversal('/path/to/salt') would return: ['/', '/path', '/path/to', '/path/to/salt'] in that order. This routine has been tested on Windows systems as well. list_path_traversal('c:\\path\\to\\salt') on Window...
Walk from the root up to a directory and verify that the current user has access to read each directory. This is used for making sure a user can read all parent directories of the minion's key before trying to go and generate a new key and raising an IOError def check_path_traversal(path, user='root', sk...
Check the number of max allowed open files and adjust if needed def check_max_open_files(opts): ''' Check the number of max allowed open files and adjust if needed ''' mof_c = opts.get('max_open_files', 100000) if sys.platform.startswith('win'): # Check the Windows API for more detail on th...
Accepts the root the path needs to be under and verifies that the path is under said root. Pass in subdir=True if the path can result in a subdirectory of the root instead of having to reside directly in the root def clean_path(root, path, subdir=False): ''' Accepts the root the path needs to be under ...
Returns if the passed id is valid def valid_id(opts, id_): ''' Returns if the passed id is valid ''' try: if any(x in id_ for x in ('/', '\\', str('\0'))): return False return bool(clean_path(opts['pki_dir'], id_)) except (AttributeError, KeyError, TypeError, UnicodeDeco...
Check a string to see if it has any potentially unsafe routines which could be executed via python, this routine is used to improve the safety of modules suct as virtualenv def safe_py_code(code): ''' Check a string to see if it has any potentially unsafe routines which could be executed via python...
If an insecre logging configuration is found, show a warning def verify_log(opts): ''' If an insecre logging configuration is found, show a warning ''' level = LOG_LEVELS.get(str(opts.get('log_level')).lower(), logging.NOTSET) if level < logging.INFO: log.warning('Insecure logging configur...
Verify that the named directories are in place and that the environment can shake the salt def win_verify_env( path, dirs, permissive=False, pki_dir='', skip_extra=False): ''' Verify that the named directories are in place and that the environment can shake the s...
List all available package upgrades on this system CLI Example: .. code-block:: bash salt '*' pkg.list_upgrades def list_upgrades(refresh=False, root=None, **kwargs): # pylint: disable=W0613 ''' List all available package upgrades on this system CLI Example: .. code-block:: bash ...
List the packages currently installed as a dict:: {'<package_name>': '<version>'} CLI Example: .. code-block:: bash salt '*' pkg.list_pkgs def list_pkgs(versions_as_list=False, **kwargs): ''' List the packages currently installed as a dict:: {'<package_name>': '<version>'} ...
.. versionadded:: 2016.11.0 Lists all groups known by pacman on this system CLI Example: .. code-block:: bash salt '*' pkg.group_list def group_list(): ''' .. versionadded:: 2016.11.0 Lists all groups known by pacman on this system CLI Example: .. code-block:: bash ...
.. versionadded:: 2016.11.0 Lists all packages in the specified group CLI Example: .. code-block:: bash salt '*' pkg.group_info 'xorg' def group_info(name): ''' .. versionadded:: 2016.11.0 Lists all packages in the specified group CLI Example: .. code-block:: bash ...
.. versionadded:: 2016.11.0 Lists which of a group's packages are installed and which are not installed Compatible with yumpkg.group_diff for easy support of state.pkg.group_installed CLI Example: .. code-block:: bash salt '*' pkg.group_diff 'xorg' def group_diff(name): ''' .....
Just run a ``pacman -Sy``, return a dict:: {'<database name>': Bool} CLI Example: .. code-block:: bash salt '*' pkg.refresh_db def refresh_db(root=None, **kwargs): ''' Just run a ``pacman -Sy``, return a dict:: {'<database name>': Bool} CLI Example: .. code-block:...
.. 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 pacman commands spawned by Sa...
.. 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 pacman commands spawned by Sa...