INSTRUCTION
stringlengths
1
46.3k
RESPONSE
stringlengths
75
80.2k
Add a log to the logadm configuration name : string alias for entryname kwargs : boolean|string|int optional additional flags and parameters
def rotate(name, **kwargs): ''' Add a log to the logadm configuration name : string alias for entryname kwargs : boolean|string|int optional additional flags and parameters ''' ret = {'name': name, 'changes': {}, 'result': None, 'comment': ''} ...
Remove a log from the logadm configuration name : string entryname log_file : string (optional) log file path .. note:: If log_file is specified it will be used instead of the entry name.
def remove(name, log_file=None): ''' Remove a log from the logadm configuration name : string entryname log_file : string (optional) log file path .. note:: If log_file is specified it will be used instead of the entry name. ''' ret = {'name': name, 'cha...
Add a new inbound or outbound rule to the firewall policy Args: name (str): The name of the rule. Must be unique and cannot be "all". Required. localport (int): The port the rule applies to. Must be a number between 0 and 65535. Can be a range. Can specify multiple ports s...
def add_rule(name, localport, protocol='tcp', action='allow', dir='in', remoteip='any'): ''' Add a new inbound or outbound rule to the firewall policy Args: name (str): The name of the rule. Must be unique and cannot be "all". ...
Delete an existing firewall rule identified by name and optionally by ports, protocols, direction, and remote IP. .. versionadded:: Neon Args: name (str): The name of the rule to delete. If the name ``all`` is used you must specify additional parameters. localport (Optional[s...
def delete_rule(name, localport=None, protocol=None, dir=None, remoteip=None): ''' Delete an existing firewall rule identified by name and optionally by ports, protocols, direction, and remote IP. .. versionadded:: Neon Args: name (str):...
Enable all the firewall profiles (Windows only) Args: profile (Optional[str]): The name of the profile to enable. Default is ``allprofiles``. Valid options are: - allprofiles - domainprofile - privateprofile - publicprofile Example: .. ...
def enabled(name='allprofiles'): ''' Enable all the firewall profiles (Windows only) Args: profile (Optional[str]): The name of the profile to enable. Default is ``allprofiles``. Valid options are: - allprofiles - domainprofile - privateprofile ...
Send a message to a Mattermost channel. :param channel: The channel name, either will work. :param username: The username of the poster. :param message: The message to send to the Mattermost channel. :param api_url: The Mattermost api url, if not specified in the configuration. :param...
def post_message(message, channel=None, username=None, api_url=None, hook=None): ''' Send a message to a Mattermost channel. :param channel: The channel name, either will work. :param username: The username of the poster. :pa...
Send an event to a Mattermost channel. :param channel: The channel name, either will work. :param username: The username of the poster. :param event: The event to send to the Mattermost channel. :param api_url: The Mattermost api url, if not specified in the configuration. :param ho...
def post_event(event, channel=None, username=None, api_url=None, hook=None): ''' Send an event to a Mattermost channel. :param channel: The channel name, either will work. :param username: The username of the poster. :param event: ...
Return the value of key at path in vault, or entire secret Jinja Example: .. code-block:: jinja my-secret: {{ salt['vault'].read_secret('secret/my/secret', 'some-key') }} .. code-block:: jinja {% set supersecret = salt['vault'].read_secret('secret/my/secret') %} secrets: ...
def read_secret(path, key=None): ''' Return the value of key at path in vault, or entire secret Jinja Example: .. code-block:: jinja my-secret: {{ salt['vault'].read_secret('secret/my/secret', 'some-key') }} .. code-block:: jinja {% set supersecret = salt['vault'].read_secret('s...
Set secret at the path in vault. The vault policy used must allow this. CLI Example: .. code-block:: bash salt '*' vault.write_secret "secret/my/secret" user="foo" password="bar"
def write_secret(path, **kwargs): ''' Set secret at the path in vault. The vault policy used must allow this. CLI Example: .. code-block:: bash salt '*' vault.write_secret "secret/my/secret" user="foo" password="bar" ''' log.debug('Writing vault secrets for %s at %s', __grains__['...
Set raw data at the path in vault. The vault policy used must allow this. CLI Example: .. code-block:: bash salt '*' vault.write_raw "secret/my/secret" '{"user":"foo","password": "bar"}'
def write_raw(path, raw): ''' Set raw data at the path in vault. The vault policy used must allow this. CLI Example: .. code-block:: bash salt '*' vault.write_raw "secret/my/secret" '{"user":"foo","password": "bar"}' ''' log.debug('Writing vault secrets for %s at %s', __grains__['...
Verify that the raid is present .. versionchanged:: 2014.7.0 name The name of raid device to be created level The RAID level to use when creating the raid. devices A list of devices used to build the array. kwargs Optional arguments to be passed to mdadm....
def present(name, level, devices, **kwargs): ''' Verify that the raid is present .. versionchanged:: 2014.7.0 name The name of raid device to be created level The RAID level to use when creating the raid. devices A list of d...
Accepts HJSON as a string or as a file object and runs it through the HJSON parser. :rtype: A Python data structure
def render(hjson_data, saltenv='base', sls='', **kws): ''' Accepts HJSON as a string or as a file object and runs it through the HJSON parser. :rtype: A Python data structure ''' if not isinstance(hjson_data, six.string_types): hjson_data = hjson_data.read() if hjson_data.startswit...
Ensure function exists. name The name of the state definition FunctionName Name of the Function. Runtime The Runtime environment for the function. One of 'nodejs', 'java8', or 'python2.7' Role The name or ARN of the IAM role that the function assumes when it e...
def function_present(name, FunctionName, Runtime, Role, Handler, ZipFile=None, S3Bucket=None, S3Key=None, S3ObjectVersion=None, Description='', Timeout=3, MemorySize=128, Permissions=None, RoleRetries=5, region=None, key=None, keyid=Non...
Ensure alias exists. name The name of the state definition. FunctionName Name of the function for which you want to create an alias. Name The name of the alias to be created. FunctionVersion Function version for which you are creating the alias. Description ...
def alias_present(name, FunctionName, Name, FunctionVersion, Description='', region=None, key=None, keyid=None, profile=None): ''' Ensure alias exists. name The name of the state definition. FunctionName Name of the function for which you want to create an alias. ...
Ensure event source mapping exists. name The name of the state definition. EventSourceArn The Amazon Resource Name (ARN) of the Amazon Kinesis or the Amazon DynamoDB stream that is the event source. FunctionName The Lambda function to invoke when AWS Lambda detects an even...
def event_source_mapping_present(name, EventSourceArn, FunctionName, StartingPosition, Enabled=True, BatchSize=100, region=None, key=None, keyid=None, profile=None): ''' Ensure event source mapping exists. na...
Ensure event source mapping with passed properties is absent. name The name of the state definition. EventSourceArn ARN of the event source. FunctionName Name of the lambda function. region Region to connect to. key Secret key to be used. keyid ...
def event_source_mapping_absent(name, EventSourceArn, FunctionName, region=None, key=None, keyid=None, profile=None): ''' Ensure event source mapping with passed properties is absent. name The name of the state definition. EventSourceArn ARN of the event...
Return a list of load balancers. :param profile: The profile key :type profile: ``str`` :param libcloud_kwargs: Extra arguments for the driver's list_balancers method :type libcloud_kwargs: ``dict`` CLI Example: .. code-block:: bash salt myminion libcloud_storage.list_balancers pr...
def list_balancers(profile, **libcloud_kwargs): ''' Return a list of load balancers. :param profile: The profile key :type profile: ``str`` :param libcloud_kwargs: Extra arguments for the driver's list_balancers method :type libcloud_kwargs: ``dict`` CLI Example: .. code-block:: ba...
Return a list of supported protocols. :param profile: The profile key :type profile: ``str`` :param libcloud_kwargs: Extra arguments for the driver's list_protocols method :type libcloud_kwargs: ``dict`` :return: a list of supported protocols :rtype: ``list`` of ``str`` CLI Example: ...
def list_protocols(profile, **libcloud_kwargs): ''' Return a list of supported protocols. :param profile: The profile key :type profile: ``str`` :param libcloud_kwargs: Extra arguments for the driver's list_protocols method :type libcloud_kwargs: ``dict`` :return: a list of supported pr...
Create a new load balancer instance :param name: Name of the new load balancer (required) :type name: ``str`` :param port: Port the load balancer should listen on, defaults to 80 :type port: ``str`` :param protocol: Loadbalancer protocol, defaults to http. :type protocol: ``str`` :par...
def create_balancer(name, port, protocol, profile, algorithm=None, members=None, **libcloud_kwargs): ''' Create a new load balancer instance :param name: Name of the new load balancer (required) :type name: ``str`` :param port: Port the load balancer should listen on, defaults to 80 :type po...
Destroy a load balancer :param balancer_id: LoadBalancer ID which should be used :type balancer_id: ``str`` :param profile: The profile key :type profile: ``str`` :param libcloud_kwargs: Extra arguments for the driver's destroy_balancer method :type libcloud_kwargs: ``dict`` :return: ...
def destroy_balancer(balancer_id, profile, **libcloud_kwargs): ''' Destroy a load balancer :param balancer_id: LoadBalancer ID which should be used :type balancer_id: ``str`` :param profile: The profile key :type profile: ``str`` :param libcloud_kwargs: Extra arguments for the driver's ...
Get the details for a load balancer by name :param name: Name of a load balancer you want to fetch :type name: ``str`` :param profile: The profile key :type profile: ``str`` :param libcloud_kwargs: Extra arguments for the driver's list_balancers method :type libcloud_kwargs: ``dict`` ...
def get_balancer_by_name(name, profile, **libcloud_kwargs): ''' Get the details for a load balancer by name :param name: Name of a load balancer you want to fetch :type name: ``str`` :param profile: The profile key :type profile: ``str`` :param libcloud_kwargs: Extra arguments for the d...
Add a new member to the load balancer :param balancer_id: id of a load balancer you want to fetch :type balancer_id: ``str`` :param ip: IP address for the new member :type ip: ``str`` :param port: Port for the new member :type port: ``int`` :param profile: The profile key :type p...
def balancer_attach_member(balancer_id, ip, port, profile, extra=None, **libcloud_kwargs): ''' Add a new member to the load balancer :param balancer_id: id of a load balancer you want to fetch :type balancer_id: ``str`` :param ip: IP address for the new member :type ip: ``str`` :param p...
Add a new member to the load balancer :param balancer_id: id of a load balancer you want to fetch :type balancer_id: ``str`` :param ip: IP address for the new member :type ip: ``str`` :param port: Port for the new member :type port: ``int`` :param profile: The profile key :type p...
def balancer_detach_member(balancer_id, member_id, profile, **libcloud_kwargs): ''' Add a new member to the load balancer :param balancer_id: id of a load balancer you want to fetch :type balancer_id: ``str`` :param ip: IP address for the new member :type ip: ``str`` :param port: Port f...
List the members of a load balancer :param balancer_id: id of a load balancer you want to fetch :type balancer_id: ``str`` :param profile: The profile key :type profile: ``str`` :param libcloud_kwargs: Extra arguments for the driver's list_balancer_members method :type libcloud_kwargs: ``d...
def list_balancer_members(balancer_id, profile, **libcloud_kwargs): ''' List the members of a load balancer :param balancer_id: id of a load balancer you want to fetch :type balancer_id: ``str`` :param profile: The profile key :type profile: ``str`` :param libcloud_kwargs: Extra argumen...
Call an extended method on the driver :param method: Driver's method name :type method: ``str`` :param profile: The profile key :type profile: ``str`` :param libcloud_kwargs: Extra arguments for the driver's method :type libcloud_kwargs: ``dict`` CLI Example: .. code-block:: bash...
def extra(method, profile, **libcloud_kwargs): ''' Call an extended method on the driver :param method: Driver's method name :type method: ``str`` :param profile: The profile key :type profile: ``str`` :param libcloud_kwargs: Extra arguments for the driver's method :type libcloud_k...
Install new alternative for defined <name> name is the master name for this link group (e.g. pager) link is the symlink pointing to /etc/alternatives/<name>. (e.g. /usr/bin/pager) path is the location of the new alternative target. NB: This file / directory...
def install(name, link, path, priority): ''' Install new alternative for defined <name> name is the master name for this link group (e.g. pager) link is the symlink pointing to /etc/alternatives/<name>. (e.g. /usr/bin/pager) path is the location of the new ...
Removes installed alternative for defined <name> and <path> or fallback to default alternative, if some defined before. name is the master name for this link group (e.g. pager) path is the location of one of the alternative target files. (e.g. /usr/bin/less)
def remove(name, path): ''' Removes installed alternative for defined <name> and <path> or fallback to default alternative, if some defined before. name is the master name for this link group (e.g. pager) path is the location of one of the alternative target files. ...
.. versionadded:: 0.17.0 Instruct alternatives to use the highest priority path for <name> name is the master name for this link group (e.g. pager)
def auto(name): ''' .. versionadded:: 0.17.0 Instruct alternatives to use the highest priority path for <name> name is the master name for this link group (e.g. pager) ''' ret = {'name': name, 'result': True, 'comment': '', 'changes': {}} ...
.. versionadded:: 0.17.0 Sets alternative for <name> to <path>, if <path> is defined as an alternative for <name>. name is the master name for this link group (e.g. pager) path is the location of one of the alternative target files. (e.g. /usr/bin/less) .. code-bl...
def set_(name, path): ''' .. versionadded:: 0.17.0 Sets alternative for <name> to <path>, if <path> is defined as an alternative for <name>. name is the master name for this link group (e.g. pager) path is the location of one of the alternative target files. (e...
Ensure that a data source is present. name Name of the data source. type Type of the datasource ('graphite', 'influxdb' etc.). access Use proxy or direct. Default: proxy url The URL to the data source API. user Optional - user to authenticate with the dat...
def present(name, type, url, access=None, user=None, password=None, database=None, basic_auth=None, basic_auth_user=None, basic_auth_password=None, tls_auth=None, json_data=None, ...
Ensure that a data source is present. name Name of the data source to remove. orgname Name of the organization from which the data source should be absent. profile Configuration profile used to connect to the Grafana instance. Default is 'grafana'.
def absent(name, orgname=None, profile='grafana'): ''' Ensure that a data source is present. name Name of the data source to remove. orgname Name of the organization from which the data source should be absent. profile Configuration profile used to connect to the Grafana i...
Return the primary name associate with the load, if an empty string is returned then the load does not match the function
def load_name(self, load): ''' Return the primary name associate with the load, if an empty string is returned then the load does not match the function ''' if 'eauth' not in load: return '' fstr = '{0}.auth'.format(load['eauth']) if fstr not in self.a...
Return the token and set the cache data for use Do not call this directly! Use the time_auth method to overcome timing attacks
def __auth_call(self, load): ''' Return the token and set the cache data for use Do not call this directly! Use the time_auth method to overcome timing attacks ''' if 'eauth' not in load: return False fstr = '{0}.auth'.format(load['eauth']) if...
Make sure that all failures happen in the same amount of time
def time_auth(self, load): ''' Make sure that all failures happen in the same amount of time ''' start = time.time() ret = self.__auth_call(load) if ret: return ret f_time = time.time() - start if f_time > self.max_fail: self.max_fa...
Returns ACL for a specific user. Returns None if eauth doesn't provide any for the user. I. e. None means: use acl declared in master config.
def __get_acl(self, load): ''' Returns ACL for a specific user. Returns None if eauth doesn't provide any for the user. I. e. None means: use acl declared in master config. ''' if 'eauth' not in load: return None mod = self.opts['eauth_acl_module'] ...
Allows eauth module to modify the access list right before it'll be applied to the request. For example ldap auth module expands entries
def __process_acl(self, load, auth_list): ''' Allows eauth module to modify the access list right before it'll be applied to the request. For example ldap auth module expands entries ''' if 'eauth' not in load: return auth_list fstr = '{0}.process_acl'.format(...
Read in a load and return the groups a user is a member of by asking the appropriate provider
def get_groups(self, load): ''' Read in a load and return the groups a user is a member of by asking the appropriate provider ''' if 'eauth' not in load: return False fstr = '{0}.groups'.format(load['eauth']) if fstr not in self.auth: retur...
Return bool if requesting user is allowed to set custom expire
def _allow_custom_expire(self, load): ''' Return bool if requesting user is allowed to set custom expire ''' expire_override = self.opts.get('token_expire_user_override', False) if expire_override is True: return True if isinstance(expire_override, collectio...
Run time_auth and create a token. Return False or the token
def mk_token(self, load): ''' Run time_auth and create a token. Return False or the token ''' if not self.authenticate_eauth(load): return {} if self._allow_custom_expire(load): token_expire = load.pop('token_expire', self.opts['token_expire']) el...
Return the name associated with the token, or False if the token is not valid
def get_tok(self, tok): ''' Return the name associated with the token, or False if the token is not valid ''' tdata = self.tokens["{0}.get_token".format(self.opts['eauth_tokens'])](self.opts, tok) if not tdata: return {} rm_tok = False if 'exp...
Remove the given token from token storage.
def rm_token(self, tok): ''' Remove the given token from token storage. ''' self.tokens["{0}.rm_token".format(self.opts['eauth_tokens'])](self.opts, tok)
Authenticate a user by the token specified in load. Return the token object or False if auth failed.
def authenticate_token(self, load): ''' Authenticate a user by the token specified in load. Return the token object or False if auth failed. ''' token = self.get_tok(load['token']) # Bail if the token is empty or if the eauth type specified is not allowed if not ...
Authenticate a user by the external auth module specified in load. Return True on success or False on failure.
def authenticate_eauth(self, load): ''' Authenticate a user by the external auth module specified in load. Return True on success or False on failure. ''' if 'eauth' not in load: log.warning('Authentication failure of type "eauth" occurred.') return False ...
Authenticate a user by the key passed in load. Return the effective user id (name) if it's different from the specified one (for sudo). If the effective user id is the same as the passed one, return True on success or False on failure.
def authenticate_key(self, load, key): ''' Authenticate a user by the key passed in load. Return the effective user id (name) if it's different from the specified one (for sudo). If the effective user id is the same as the passed one, return True on success or False on failure. ...
Retrieve access list for the user specified in load. The list is built by eauth module or from master eauth configuration. Return None if current configuration doesn't provide any ACL for the user. Return an empty list if the user has no rights to execute anything on this master and returns non-...
def get_auth_list(self, load, token=None): ''' Retrieve access list for the user specified in load. The list is built by eauth module or from master eauth configuration. Return None if current configuration doesn't provide any ACL for the user. Return an empty list if the user ha...
.. versionadded:: 2018.3.0 Go through various checks to see if the token/eauth/user can be authenticated. Returns a dictionary containing the following keys: - auth_list - username - error If an error is encountered, return immediately with the relevant error dictiona...
def check_authentication(self, load, auth_type, key=None, show_username=False): ''' .. versionadded:: 2018.3.0 Go through various checks to see if the token/eauth/user can be authenticated. Returns a dictionary containing the following keys: - auth_list - username ...
Gather and create the authorization data sets We're looking at several constructs here. Standard eauth: allow jsmith to auth via pam, and execute any command on server web1 external_auth: pam: jsmith: - web1: - .* Django eaut...
def auth_data(self): ''' Gather and create the authorization data sets We're looking at several constructs here. Standard eauth: allow jsmith to auth via pam, and execute any command on server web1 external_auth: pam: jsmith: - web1: ...
Determine if token auth is valid and yield the adata
def token(self, adata, load): ''' Determine if token auth is valid and yield the adata ''' try: token = self.loadauth.get_tok(load['token']) except Exception as exc: log.error('Exception occurred when generating auth token: %s', exc) yield {} ...
Determine if the given eauth is valid and yield the adata
def eauth(self, adata, load): ''' Determine if the given eauth is valid and yield the adata ''' for sub_auth in [adata]: if load['eauth'] not in sub_auth: continue try: name = self.loadauth.load_name(load) if not ((n...
Read in the access system to determine if the validated user has requested rights
def rights_check(self, form, sub_auth, name, load, eauth=None): ''' Read in the access system to determine if the validated user has requested rights ''' if load.get('eauth'): sub_auth = sub_auth[load['eauth']] good = self.ckminions.any_auth( f...
Determine what type of authentication is being requested and pass authorization Note: this will check that the user has at least one right that will let the user execute "load", this does not deal with conflicting rules
def rights(self, form, load): ''' Determine what type of authentication is being requested and pass authorization Note: this will check that the user has at least one right that will let the user execute "load", this does not deal with conflicting rules ''' adat...
Execute the CLI options to fill in the extra data needed for the defined eauth system
def cli(self, eauth): ''' Execute the CLI options to fill in the extra data needed for the defined eauth system ''' ret = {} if not eauth: print('External authentication system has not been specified') return ret fstr = '{0}.auth'.format(ea...
Create the token from the CLI and request the correct data to authenticate via the passed authentication mechanism
def token_cli(self, eauth, load): ''' Create the token from the CLI and request the correct data to authenticate via the passed authentication mechanism ''' load['cmd'] = 'mk_token' load['eauth'] = eauth tdata = self._send_token_request(load) if 'token' no...
Request a token from the master
def get_token(self, token): ''' Request a token from the master ''' load = {} load['token'] = token load['cmd'] = 'get_token' tdata = self._send_token_request(load) return tdata
Returns a list of the requester's topics CLI example:: salt myminion boto3_sns.list_topics
def list_topics(region=None, key=None, keyid=None, profile=None): ''' Returns a list of the requester's topics CLI example:: salt myminion boto3_sns.list_topics ''' conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile) res = {} NextToken = '' while NextToken is...
Returns details about a specific SNS topic, specified by name or ARN. CLI example:: salt my_favorite_client boto3_sns.describe_topic a_sns_topic_of_my_choice
def describe_topic(name, region=None, key=None, keyid=None, profile=None): ''' Returns details about a specific SNS topic, specified by name or ARN. CLI example:: salt my_favorite_client boto3_sns.describe_topic a_sns_topic_of_my_choice ''' topics = list_topics(region=region, key=key, keyi...
Check to see if an SNS topic exists. CLI example:: salt myminion boto3_sns.topic_exists mytopic region=us-east-1
def topic_exists(name, region=None, key=None, keyid=None, profile=None): ''' Check to see if an SNS topic exists. CLI example:: salt myminion boto3_sns.topic_exists mytopic region=us-east-1 ''' topics = list_topics(region=region, key=key, keyid=keyid, profile=profile) return name in li...
Create an SNS topic. CLI example:: salt myminion boto3_sns.create_topic mytopic region=us-east-1
def create_topic(Name, region=None, key=None, keyid=None, profile=None): ''' Create an SNS topic. CLI example:: salt myminion boto3_sns.create_topic mytopic region=us-east-1 ''' conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile) try: ret = conn.create_topic(...
Delete an SNS topic. CLI example:: salt myminion boto3_sns.delete_topic mytopic region=us-east-1
def delete_topic(TopicArn, region=None, key=None, keyid=None, profile=None): ''' Delete an SNS topic. CLI example:: salt myminion boto3_sns.delete_topic mytopic region=us-east-1 ''' conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile) try: conn.delete_topic(To...
Returns all of the properties of a topic. Topic properties returned might differ based on the authorization of the user. CLI example:: salt myminion boto3_sns.get_topic_attributes someTopic region=us-west-1
def get_topic_attributes(TopicArn, region=None, key=None, keyid=None, profile=None): ''' Returns all of the properties of a topic. Topic properties returned might differ based on the authorization of the user. CLI example:: salt myminion boto3_sns.get_topic_attributes someTopic region=us-west...
Set an attribute of a topic to a new value. CLI example:: salt myminion boto3_sns.set_topic_attributes someTopic DisplayName myDisplayNameValue
def set_topic_attributes(TopicArn, AttributeName, AttributeValue, region=None, key=None, keyid=None, profile=None): ''' Set an attribute of a topic to a new value. CLI example:: salt myminion boto3_sns.set_topic_attributes someTopic DisplayName myDisplayNameValue ''' ...
Returns a list of the subscriptions to a specific topic CLI example:: salt myminion boto3_sns.list_subscriptions_by_topic mytopic region=us-east-1
def list_subscriptions_by_topic(TopicArn, region=None, key=None, keyid=None, profile=None): ''' Returns a list of the subscriptions to a specific topic CLI example:: salt myminion boto3_sns.list_subscriptions_by_topic mytopic region=us-east-1 ''' conn = _get_conn(region=region, key=key, ke...
Returns all of the properties of a subscription. CLI example:: salt myminion boto3_sns.get_subscription_attributes somesubscription region=us-west-1
def get_subscription_attributes(SubscriptionArn, region=None, key=None, keyid=None, profile=None): ''' Returns all of the properties of a subscription. CLI example:: salt myminion boto3_sns.get_subscription_attributes somesubscription region=us-west-1 ''' conn = _get_conn(region=region, ke...
Subscribe to a Topic. CLI example:: salt myminion boto3_sns.subscribe mytopic https https://www.example.com/sns-endpoint
def subscribe(TopicArn=None, Protocol=None, Endpoint=None, region=None, key=None, keyid=None, profile=None, **kwargs): ''' Subscribe to a Topic. CLI example:: salt myminion boto3_sns.subscribe mytopic https https://www.example.com/sns-endpoint ''' conn = _get_conn(region=regi...
Unsubscribe a specific SubscriptionArn of a topic. CLI Example: .. code-block:: bash salt myminion boto3_sns.unsubscribe my_subscription_arn region=us-east-1
def unsubscribe(SubscriptionArn, region=None, key=None, keyid=None, profile=None): ''' Unsubscribe a specific SubscriptionArn of a topic. CLI Example: .. code-block:: bash salt myminion boto3_sns.unsubscribe my_subscription_arn region=us-east-1 ''' if not SubscriptionArn.startswith('a...
Determines if the system needs to be rebooted. Returns: bool: True if the system requires a reboot, False if not CLI Examples: .. code-block:: bash import salt.utils.win_update salt.utils.win_update.needs_reboot()
def needs_reboot(): ''' Determines if the system needs to be rebooted. Returns: bool: True if the system requires a reboot, False if not CLI Examples: .. code-block:: bash import salt.utils.win_update salt.utils.win_update.needs_reboot() ''' # Initialize the Py...
Create a dictionary with the details for the updates in the collection. Returns: dict: Details about each update .. code-block:: cfg List of Updates: {'<GUID>': {'Title': <title>, 'KB': <KB>, 'GUID': <the globally uni...
def list(self): ''' Create a dictionary with the details for the updates in the collection. Returns: dict: Details about each update .. code-block:: cfg List of Updates: {'<GUID>': {'Title': <title>, 'KB': <KB>, ...
Create a dictionary with a summary of the updates in the collection. Returns: dict: Summary of the contents of the collection .. code-block:: cfg Summary of Updates: {'Total': <total number of updates returned>, 'Available': <updates that are not downl...
def summary(self): ''' Create a dictionary with a summary of the updates in the collection. Returns: dict: Summary of the contents of the collection .. code-block:: cfg Summary of Updates: {'Total': <total number of updates returned>, '...
Get the contents of ``_updates`` (all updates) and puts them in an Updates class to expose the list and summary functions. Returns: Updates: An instance of the Updates class with all updates for the system. .. code-block:: python import salt.utils.win_updat...
def updates(self): ''' Get the contents of ``_updates`` (all updates) and puts them in an Updates class to expose the list and summary functions. Returns: Updates: An instance of the Updates class with all updates for the system. .. code-block:: python ...
Refresh the contents of the ``_updates`` collection. This gets all updates in the Windows Update system and loads them into the collection. This is the part that is slow. Code Example: .. code-block:: python import salt.utils.win_update wua = salt.utils.win_upd...
def refresh(self): ''' Refresh the contents of the ``_updates`` collection. This gets all updates in the Windows Update system and loads them into the collection. This is the part that is slow. Code Example: .. code-block:: python import salt.utils.win_upda...
Gets a list of all updates available on the system that match the passed criteria. Args: skip_hidden (bool): Skip hidden updates. Default is True skip_installed (bool): Skip installed updates. Default is True skip_mandatory (bool): Skip mandatory updates. Default ...
def available(self, skip_hidden=True, skip_installed=True, skip_mandatory=False, skip_reboot=False, software=True, drivers=True, categories=None, severities=None): ''' ...
Search for either a single update or a specific list of updates. GUIDs are searched first, then KB numbers, and finally Titles. Args: search_string (str, list): The search string to use to find the update. This can be the GUID or KB of the update (preferred). It can ...
def search(self, search_string): ''' Search for either a single update or a specific list of updates. GUIDs are searched first, then KB numbers, and finally Titles. Args: search_string (str, list): The search string to use to find the update. This can be the GUI...
Download the updates passed in the updates collection. Load the updates collection using ``search`` or ``available`` Args: updates (Updates): An instance of the Updates class containing a the updates to be downloaded. Returns: dict: A dictionary containing ...
def download(self, updates): ''' Download the updates passed in the updates collection. Load the updates collection using ``search`` or ``available`` Args: updates (Updates): An instance of the Updates class containing a the updates to be downloaded. Re...
Install the updates passed in the updates collection. Load the updates collection using the ``search`` or ``available`` functions. If the updates need to be downloaded, use the ``download`` function. Args: updates (Updates): An instance of the Updates class containing a ...
def install(self, updates): ''' Install the updates passed in the updates collection. Load the updates collection using the ``search`` or ``available`` functions. If the updates need to be downloaded, use the ``download`` function. Args: updates (Updates): An instan...
Uninstall the updates passed in the updates collection. Load the updates collection using the ``search`` or ``available`` functions. .. note:: Starting with Windows 10 the Windows Update Agent is unable to uninstall updates. An ``Uninstall Not Allowed`` error is returned. If this error ...
def uninstall(self, updates): ''' Uninstall the updates passed in the updates collection. Load the updates collection using the ``search`` or ``available`` functions. .. note:: Starting with Windows 10 the Windows Update Agent is unable to uninstall updates. An ``Uninstall Not A...
Internal function for running commands. Used by the uninstall function. Args: cmd (str, list): The command to run Returns: str: The stdout of the command
def _run(self, cmd): ''' Internal function for running commands. Used by the uninstall function. Args: cmd (str, list): The command to run Returns: str: The stdout of the command ''' if isinstance(cmd, six.string_types): cmd = salt.u...
Accepts YAML as a string or as a file object and runs it through the YAML parser. :rtype: A Python data structure
def render(yaml_data, saltenv='base', sls='', argline='', **kws): ''' Accepts YAML as a string or as a file object and runs it through the YAML parser. :rtype: A Python data structure ''' if not isinstance(yaml_data, string_types): yaml_data = yaml_data.read() with warnings.catch_wa...
Write a default to the system CLI Example: .. code-block:: bash salt '*' macdefaults.write com.apple.CrashReporter DialogType Server salt '*' macdefaults.write NSGlobalDomain ApplePersistence True type=bool domain The name of the domain to write to key The key of th...
def write(domain, key, value, type='string', user=None): ''' Write a default to the system CLI Example: .. code-block:: bash salt '*' macdefaults.write com.apple.CrashReporter DialogType Server salt '*' macdefaults.write NSGlobalDomain ApplePersistence True type=bool domain ...
Write a default to the system CLI Example: .. code-block:: bash salt '*' macdefaults.read com.apple.CrashReporter DialogType salt '*' macdefaults.read NSGlobalDomain ApplePersistence domain The name of the domain to read from key The key of the given domain to read ...
def read(domain, key, user=None): ''' Write a default to the system CLI Example: .. code-block:: bash salt '*' macdefaults.read com.apple.CrashReporter DialogType salt '*' macdefaults.read NSGlobalDomain ApplePersistence domain The name of the domain to read from ke...
Delete a default from the system CLI Example: .. code-block:: bash salt '*' macdefaults.delete com.apple.CrashReporter DialogType salt '*' macdefaults.delete NSGlobalDomain ApplePersistence domain The name of the domain to delete from key The key of the given domain...
def delete(domain, key, user=None): ''' Delete a default from the system CLI Example: .. code-block:: bash salt '*' macdefaults.delete com.apple.CrashReporter DialogType salt '*' macdefaults.delete NSGlobalDomain ApplePersistence domain The name of the domain to delete f...
Manage the computer's description field name The desired computer description
def computer_desc(name): ''' Manage the computer's description field name The desired computer description ''' # Just in case someone decides to enter a numeric description name = six.text_type(name) ret = {'name': name, 'changes': {}, 'result': True, ...
Manage the computer's name name The desired computer name
def computer_name(name): ''' Manage the computer's name name The desired computer name ''' # Just in case someone decides to enter a numeric description name = six.text_type(name) ret = {'name': name, 'changes': {}, 'result': True, 'comment': 'Compu...
.. versionadded:: 2016.3.0 Manage the hostname of the computer name The hostname to set
def hostname(name): ''' .. versionadded:: 2016.3.0 Manage the hostname of the computer name The hostname to set ''' ret = { 'name': name, 'changes': {}, 'result': True, 'comment': '' } current_hostname = __salt__['system.get_hostname']() if...
.. 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 computer name The workgroup to set Example: .. code-block:: yaml set workgroup: system.workgroup: - name: local ''' ret = {'name': name.upper(), 'result': False, 'ch...
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...
def join_domain(name, username=None, password=None, account_ou=None, account_exists=False, restart=False): ''' Checks if a computer is joined to the Domain. If the computer is not in the Domain, it will be joined. Args: ...
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...
def reboot(name, message=None, timeout=5, force_close=True, in_seconds=False, only_on_pending_reboot=True): ''' 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...
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...
def shutdown(name, message=None, timeout=5, force_close=True, reboot=False, in_seconds=False, only_on_pending_reboot=False): ''' 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. ...
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...
def post_message(name, channel, from_name, message, api_key=None, icon=None): ''' Send a message to a Slack channel. .. code-block:: yaml slack-message: slack.post_message: - channel: '#gener...
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 tkn in line.split("uuid:")] ...
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']("blkid -o export") salt.utils.fsutils._verify_run(out) return salt.utils.fsutils._blkid_output(out['stdout'], fs_type...
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 filesystem show {0}".format(device)) salt.utils.fsutils._verify_run(out) return _parse_btrfs_info(out['stdout'])
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'], 'log': out['stderr'] or False, ...
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: ...
def defragment(path): ''' 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 de...
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']("mkfs.btrfs -O list-all") salt.utils.fsutils._verify_run(out) ret = {} for line in [re.sub(r"\s+", " ", line) for ...
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]).replace(" ", "_").lower()...
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] = {} for val in [size...
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 = __salt__['cmd.run_all']("btrfs filesystem usage {0}".format(path)) salt.utils.fsutils._verify_run(out) ret = {} for section ...
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...
def mkfs(*devices, **kwargs): ''' 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. ...
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...
def resize(mountpoint, size): ''' 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 ...