text
stringlengths
81
112k
Sets global variables _OS_IDENTITY_API_VERSION and _TENANT_ID depending on API version. def _api_version(profile=None, **connection_args): ''' Sets global variables _OS_IDENTITY_API_VERSION and _TENANT_ID depending on API version. ''' global _TENANT_ID global _OS_IDENTITY_API_VERSION tr...
Ensure that the keystone user is present with the specified properties. name The name of the user to manage password The password to use for this user. .. note:: If the user already exists and a different password was set for the user than the one specified he...
Ensure that the keystone user is absent. name The name of the user that should not exist def user_absent(name, profile=None, **connection_args): ''' Ensure that the keystone user is absent. name The name of the user that should not exist ''' ret = {'name': name, 'ch...
Ensures that the keystone tenant exists name The name of the tenant to manage description The description to use for this tenant enabled Availability state for this tenant def tenant_present(name, description=None, enabled=True, profile=None, **connection_args)...
Ensure that the keystone tenant is absent. name The name of the tenant that should not exist def tenant_absent(name, profile=None, **connection_args): ''' Ensure that the keystone tenant is absent. name The name of the tenant that should not exist ''' ret = {'name': name, ...
Ensures that the keystone project exists Alias for tenant_present from V2 API to fulfill V3 API naming convention. .. versionadded:: 2016.11.0 name The name of the project to manage description The description to use for this project enabled Availability state for thi...
Ensures that the keystone role exists name The name of the role that should be present def role_present(name, profile=None, **connection_args): '''' Ensures that the keystone role exists name The name of the role that should be present ''' ret = {'name': name, 'chan...
Ensure service present in Keystone catalog name The name of the service service_type The type of Openstack Service description (optional) Description of the service def service_present(name, service_type, description=None, profile=None, **connection_args): ...
Ensure the specified endpoints exists for service name The Service name publicurl The public url of service endpoint (for V2 API) internalurl The internal url of service endpoint (for V2 API) adminurl The admin url of the service endpoint (for V2 API) region ...
Ensure that the endpoint for a service doesn't exist in Keystone catalog name The name of the service whose endpoints should not exist region (optional) The region of the endpoint. Defaults to ``RegionOne``. interface The interface type, which describes the visibility of ...
Run 'chkconfig --add' for a service whose script is installed in /etc/init.d. The service is initially configured to be disabled at all run-levels. def _chkconfig_add(name): ''' Run 'chkconfig --add' for a service whose script is installed in /etc/init.d. The service is initially configured to be...
Return True if the service is a System V service (includes those managed by chkconfig); otherwise return False. def _service_is_sysv(name): ''' Return True if the service is a System V service (includes those managed by chkconfig); otherwise return False. ''' try: # Look for user-execut...
Return True if the service is managed by chkconfig. def _service_is_chkconfig(name): ''' Return True if the service is managed by chkconfig. ''' cmdline = '/sbin/chkconfig --list {0}'.format(name) return __salt__['cmd.retcode'](cmdline, python_shell=False, ignore_retcode=True) == 0
Return True if the sysv (or chkconfig) service is enabled for the specified runlevel; otherwise return False. If `runlevel` is None, then use the current runlevel. def _sysv_is_enabled(name, runlevel=None): ''' Return True if the sysv (or chkconfig) service is enabled for the specified runlevel; o...
Return ``True`` if the service is enabled according to chkconfig; otherwise return ``False``. If ``runlevel`` is ``None``, then use the current runlevel. def _chkconfig_is_enabled(name, runlevel=None): ''' Return ``True`` if the service is enabled according to chkconfig; otherwise return ``False``...
Enable the named sysv service to start at boot. The service will be enabled using chkconfig with default run-levels if the service is chkconfig compatible. If chkconfig is not available, then this will fail. def _sysv_enable(name): ''' Enable the named sysv service to start at boot. The service will...
Delete the named sysv service from the system. The service will be deleted using chkconfig. def _sysv_delete(name): ''' Delete the named sysv service from the system. The service will be deleted using chkconfig. ''' if not _service_is_chkconfig(name): return False cmd = '/sbin/chkco...
Delete an upstart service. This will only rename the .conf file def _upstart_delete(name): ''' Delete an upstart service. This will only rename the .conf file ''' if HAS_UPSTART: if os.path.exists('/etc/init/{0}.conf'.format(name)): os.rename('/etc/init/{0}.conf'.format(name), ...
Return list of sysv services. def _sysv_services(): ''' Return list of sysv services. ''' _services = [] output = __salt__['cmd.run'](['chkconfig', '--list'], python_shell=False) for line in output.splitlines(): comps = line.split() try: if comps[1].startswith('0:'):...
Return the enabled services. Use the ``limit`` param to restrict results to services of that type. CLI Examples: .. code-block:: bash salt '*' service.get_enabled salt '*' service.get_enabled limit=upstart salt '*' service.get_enabled limit=sysvinit def get_enabled(limit=''): ...
Return all installed services. Use the ``limit`` param to restrict results to services of that type. CLI Example: .. code-block:: bash salt '*' service.get_all salt '*' service.get_all limit=upstart salt '*' service.get_all limit=sysvinit def get_all(limit=''): ''' Return...
Return True if the named service is available. Use the ``limit`` param to restrict results to services of that type. CLI Examples: .. code-block:: bash salt '*' service.available sshd salt '*' service.available sshd limit=upstart salt '*' service.available sshd limit=sysvinit de...
The inverse of service.available. Return True if the named service is not available. Use the ``limit`` param to restrict results to services of that type. CLI Examples: .. code-block:: bash salt '*' service.missing sshd salt '*' service.missing sshd limit=upstart salt '*' ser...
Start the specified service CLI Example: .. code-block:: bash salt '*' service.start <service name> def start(name): ''' Start the specified service CLI Example: .. code-block:: bash salt '*' service.start <service name> ''' if _service_is_upstart(name): cm...
Stop the specified service CLI Example: .. code-block:: bash salt '*' service.stop <service name> def stop(name): ''' Stop the specified service CLI Example: .. code-block:: bash salt '*' service.stop <service name> ''' if _service_is_upstart(name): cmd = '...
Restart the named service CLI Example: .. code-block:: bash salt '*' service.restart <service name> def restart(name): ''' Restart the named service CLI Example: .. code-block:: bash salt '*' service.restart <service name> ''' if _service_is_upstart(name): ...
Reload the named service CLI Example: .. code-block:: bash salt '*' service.reload <service name> def reload_(name): ''' Reload the named service CLI Example: .. code-block:: bash salt '*' service.reload <service name> ''' if _service_is_upstart(name): cmd ...
Check for specified command name in search path def _check_repo_sign_utils_support(name): ''' Check for specified command name in search path ''' if salt.utils.path.which(name): return True else: raise CommandExecutionError( 'utility \'{0}\' needs to be installed or made...
Get build environment overrides dictionary to use in build process def _get_build_env(env): ''' Get build environment overrides dictionary to use in build process ''' env_override = '' if env is None: return env_override if not isinstance(env, dict): raise SaltInvocationError( ...
Get repo environment overrides dictionary to use in repo options process env A dictionary of variables to define the repository options Example: .. code-block:: yaml - env: - OPTIONS : 'ask-passphrase' .. warning:: The above illustrates a ...
Get repo environment overrides dictionary to use in repo distributions process env A dictionary of variables to define the repository distributions Example: .. code-block:: yaml - env: - ORIGIN : 'jessie' - LABEL : 'salt debian' ...
Create the .pbuilder family of files in user's home directory env A list or dictionary of environment variables to be set prior to execution. Example: .. code-block:: yaml - env: - DEB_BUILD_OPTIONS: 'nocheck' .. warning:: The above illus...
Get the named sources and place them into the tree_base def _get_src(tree_base, source, saltenv='base'): ''' Get the named sources and place them into the tree_base ''' parsed = _urlparse(source) sbase = os.path.basename(source) dest = os.path.join(tree_base, sbase) if parsed.scheme: ...
Create a platform specific source package from the given platform spec/control file and sources CLI Example: **Debian** .. code-block:: bash salt '*' pkgbuild.make_src_pkg /var/www/html/ https://raw.githubusercontent.com/saltstack/libnacl/master/pkg/deb/python-libnacl.control.tar...
Given the package destination directory, the tarball containing debian files (e.g. control) and package sources, use pbuilder to safely build the platform package CLI Example: **Debian** .. code-block:: bash salt '*' pkgbuild.make_src_pkg deb-8-x86_64 /var/www/html https://ra...
Make a package repository and optionally sign it and packages present Given the repodir (directory to create repository in), create a Debian repository and optionally sign it and packages present. This state is best used with onchanges linked to your package building states. repodir The direct...
Generate a Vault token for minion minion_id minion_id The id of the minion that requests a token signature Cryptographic signature which validates that the request is indeed sent by the minion (or the master, see impersonated_by_master). impersonated_by_master If the maste...
Unseal Vault server This function uses the 'keys' from the 'vault' configuration to unseal vault server vault: keys: - n63/TbrQuL3xaIW7ZZpuXj/tIfnK1/MbVxO4vT3wYD2A - S9OwCvMRhErEA4NVVELYBs6w/Me6+urgUr24xGK44Uy3 - F1j4b7JKq850NS6Kboiy5laJ0xY8dWJvB3fcwA+SraYl - 1cYtvjKJNDVa...
Validate that either minion with id minion_id, or the master, signed the request def _validate_signature(minion_id, signature, impersonated_by_master): ''' Validate that either minion with id minion_id, or the master, signed the request ''' pki_dir = __opts__['pki_dir'] if impersonated_by_m...
Get the policies that should be applied to a token for minion_id def _get_policies(minion_id, config): ''' Get the policies that should be applied to a token for minion_id ''' _, grains, _ = salt.utils.minions.get_minion_data(minion_id, __opts__) policy_patterns = config.get( ...
Expands the pattern for any list-valued mappings, such that for any list of length N in the mappings present in the pattern, N copies of the pattern are returned, each with an element of the list substituted. pattern: A pattern to expand, for example ``by-role/{grains[roles]}`` mappings: ...
Validate the current token exists and is still valid def _selftoken_expired(): ''' Validate the current token exists and is still valid ''' try: verify = __opts__['vault'].get('verify', None) url = '{0}/v1/auth/token/lookup-self'.format(__opts__['vault']['url']) if 'token' not i...
Create Vault url for token creation def _get_token_create_url(config): ''' Create Vault url for token creation ''' role_name = config.get('role_name', None) auth_path = '/v1/auth/token/create' base_url = config['url'] return '/'.join(x.strip('/') for x in (base_url, auth_path, role_name) if...
Given function name, find and return matching Lambda information. def _find_function(name, region=None, key=None, keyid=None, profile=None): ''' Given function name, find and return matching Lambda information. ''' conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile...
Given a function name, check to see if the given function name exists. Returns True if the given function exists and returns False if the given function does not exist. CLI Example: .. code-block:: bash salt myminion boto_lambda.function_exists myfunction def function_exists(FunctionName, r...
.. versionadded:: 2017.7.0 Given a valid config, create a function. Environment The parent object that contains your environment's configuration settings. This is a dictionary of the form: .. code-block:: python { 'Variables': { 'Variab...
Given a function name and optional version qualifier, delete it. Returns {deleted: true} if the function was deleted and returns {deleted: false} if the function was not deleted. CLI Example: .. code-block:: bash salt myminion boto_lambda.delete_function myfunction def delete_function(Funct...
Given a function name describe its properties. Returns a dictionary of interesting properties. CLI Example: .. code-block:: bash salt myminion boto_lambda.describe_function myfunction def describe_function(FunctionName, region=None, key=None, keyid=None, profile=None): ...
.. versionadded:: 2017.7.0 Update the named lambda function to the configuration. Environment The parent object that contains your environment's configuration settings. This is a dictionary of the form: .. code-block:: python { 'Variables': { ...
Upload the given code to the named lambda function. Returns {updated: true} if the function was updated and returns {updated: False} if the function was not updated. CLI Example: .. code-block:: bash salt myminion boto_lamba.update_function_code my_function ZipFile=function.zip def update_f...
Add a permission to a lambda function. Returns {added: true} if the permission was added and returns {added: False} if the permission was not added. CLI Example: .. code-block:: bash salt myminion boto_lamba.add_permission my_function my_id "lambda:*" \\ s3.amazona...
Remove a permission from a lambda function. Returns {removed: true} if the permission was removed and returns {removed: False} if the permission was not removed. CLI Example: .. code-block:: bash salt myminion boto_lamba.remove_permission my_function my_id def remove_permission(FunctionName...
Get resource permissions for the given lambda function Returns dictionary of permissions, by statement ID CLI Example: .. code-block:: bash salt myminion boto_lamba.get_permissions my_function permissions: {...} def get_permissions(FunctionName, Qualifier=None, regi...
List all Lambda functions visible in the current scope. CLI Example: .. code-block:: bash salt myminion boto_lambda.list_functions def list_functions(region=None, key=None, keyid=None, profile=None): ''' List all Lambda functions visible in the current scope. CLI Example: .. code-b...
List the versions available for the given function. Returns list of function versions CLI Example: .. code-block:: yaml versions: - {...} - {...} def list_function_versions(FunctionName, region=None, key=None, keyid=None, profile=None): ''' ...
Given a valid config, create an alias to a function. Returns {created: true} if the alias was created and returns {created: False} if the alias was not created. CLI Example: .. code-block:: bash salt myminion boto_lamba.create_alias my_function my_alias $LATEST "An alias" def create_alias(F...
Given function name and alias name, find and return matching alias information. def _find_alias(FunctionName, Name, FunctionVersion=None, region=None, key=None, keyid=None, profile=None): ''' Given function name and alias name, find and return matching alias information. ''' conn = _get...
Given a function name and alias name, check to see if the given alias exists. Returns True if the given alias exists and returns False if the given alias does not exist. CLI Example: .. code-block:: bash salt myminion boto_lambda.alias_exists myfunction myalias def alias_exists(FunctionName...
Given a function name and alias name describe the properties of the alias. Returns a dictionary of interesting properties. CLI Example: .. code-block:: bash salt myminion boto_lambda.describe_alias myalias def describe_alias(FunctionName, Name, region=None, key=None, keyid=No...
Update the named alias to the configuration. Returns {updated: true} if the alias was updated and returns {updated: False} if the alias was not updated. CLI Example: .. code-block:: bash salt myminion boto_lamba.update_alias my_lambda my_alias $LATEST def update_alias(FunctionName, Name, Fu...
Identifies a stream as an event source for a Lambda function. It can be either an Amazon Kinesis stream or an Amazon DynamoDB stream. AWS Lambda invokes the specified function when records are posted to the stream. Returns {created: true} if the event source mapping was created and returns {created: Fa...
Given an event source and function name, return a list of mapping IDs CLI Example: .. code-block:: bash salt myminion boto_lambda.get_event_source_mapping_ids arn:::: myfunction def get_event_source_mapping_ids(EventSourceArn, FunctionName, region=None, key=None, key...
Given an event source mapping ID or an event source ARN and FunctionName, delete the event source mapping Returns {deleted: true} if the mapping was deleted and returns {deleted: false} if the mapping was not deleted. CLI Example: .. code-block:: bash salt myminion boto_lambda.delete_eve...
Given an event source mapping ID or an event source ARN and FunctionName, check whether the mapping exists. Returns True if the given alias exists and returns False if the given alias does not exist. CLI Example: .. code-block:: bash salt myminion boto_lambda.alias_exists myfunction myal...
Given an event source mapping ID or an event source ARN and FunctionName, obtain the current settings of that mapping. Returns a dictionary of interesting properties. CLI Example: .. code-block:: bash salt myminion boto_lambda.describe_event_source_mapping uuid def describe_event_source_map...
Update the event source mapping identified by the UUID. Returns {updated: true} if the alias was updated and returns {updated: False} if the alias was not updated. CLI Example: .. code-block:: bash salt myminion boto_lamba.update_event_source_mapping uuid FunctionName=new_function def updat...
Update the cache file for the bucket. def update(): ''' Update the cache file for the bucket. ''' metadata = _init() if S3_SYNC_ON_UPDATE: # sync the buckets to the local cache log.info('Syncing local cache from S3...') for saltenv, env_meta in six.iteritems(metadata): ...
Look through the buckets cache file for a match. If the field is found, it is retrieved from S3 only if its cached version is missing, or if the MD5 does not match. def find_file(path, saltenv='base', **kwargs): ''' Look through the buckets cache file for a match. If the field is found, it is retri...
Return an MD5 file hash def file_hash(load, fnd): ''' Return an MD5 file hash ''' if 'env' in load: # "env" is not supported; Use "saltenv". load.pop('env') ret = {} if 'saltenv' not in load: return ret if 'path' not in fnd or 'bucket' not in fnd or not fnd['path'...
Return a chunk from a file based on the data received def serve_file(load, fnd): ''' Return a chunk from a file based on the data received ''' if 'env' in load: # "env" is not supported; Use "saltenv". load.pop('env') ret = {'data': '', 'dest': ''} if 'path' not in ...
Return a list of all files on the file server in a specified environment def file_list(load): ''' Return a list of all files on the file server in a specified environment ''' if 'env' in load: # "env" is not supported; Use "saltenv". load.pop('env') ret = [] if 'saltenv' not i...
Return a list of all directories on the master def dir_list(load): ''' Return a list of all directories on the master ''' if 'env' in load: # "env" is not supported; Use "saltenv". load.pop('env') ret = [] if 'saltenv' not in load: return ret saltenv = load['salte...
Get AWS keys from pillar or config def _get_s3_key(): ''' Get AWS keys from pillar or config ''' key = __opts__['s3.key'] if 's3.key' in __opts__ else None keyid = __opts__['s3.keyid'] if 's3.keyid' in __opts__ else None service_url = __opts__['s3.service_url'] \ if 's3.service_url' in...
Connect to S3 and download the metadata for each file in all buckets specified and cache the data to disk. def _init(): ''' Connect to S3 and download the metadata for each file in all buckets specified and cache the data to disk. ''' cache_file = _get_buckets_cache_filename() exp = time.ti...
Return the cached file name for a bucket path file def _get_cached_file_name(bucket_name, saltenv, path): ''' Return the cached file name for a bucket path file ''' file_path = os.path.join(_get_cache_dir(), saltenv, bucket_name, path) # make sure bucket and saltenv directories exist if not o...
Return the filename of the cache for bucket contents. Create the path if it does not exist. def _get_buckets_cache_filename(): ''' Return the filename of the cache for bucket contents. Create the path if it does not exist. ''' cache_dir = _get_cache_dir() if not os.path.exists(cache_dir): ...
Retrieve the content of all buckets and cache the metadata to the buckets cache file def _refresh_buckets_cache_file(cache_file): ''' Retrieve the content of all buckets and cache the metadata to the buckets cache file ''' log.debug('Refreshing buckets cache file') key, keyid, service_url...
Return the contents of the buckets cache file def _read_buckets_cache_file(cache_file): ''' Return the contents of the buckets cache file ''' log.debug('Reading buckets cache file') with salt.utils.files.fopen(cache_file, 'rb') as fp_: try: data = pickle.load(fp_) exce...
Looks for all the files in the S3 bucket cache metadata def _find_files(metadata): ''' Looks for all the files in the S3 bucket cache metadata ''' ret = [] found = {} for bucket_dict in metadata: for bucket_name, data in six.iteritems(bucket_dict): filepaths = [k['Key'] fo...
Looks for all the directories in the S3 bucket cache metadata. Supports trailing '/' keys (as created by S3 console) as well as directories discovered in the path of file keys. def _find_dirs(metadata): ''' Looks for all the directories in the S3 bucket cache metadata. Supports trailing '/' keys ...
Looks for a file's metadata in the S3 bucket cache file def _find_file_meta(metadata, bucket_name, saltenv, path): ''' Looks for a file's metadata in the S3 bucket cache file ''' env_meta = metadata[saltenv] if saltenv in metadata else {} bucket_meta = {} for bucket in env_meta: if buck...
Checks the local cache for the file, if it's old or missing go grab the file from S3 and update the cache def _get_file_from_s3(metadata, saltenv, bucket_name, path, cached_file_path): ''' Checks the local cache for the file, if it's old or missing go grab the file from S3 and update the cache ''' ...
Return a list of file paths with the saltenv directory removed def _trim_env_off_path(paths, saltenv, trim_slash=False): ''' Return a list of file paths with the saltenv directory removed ''' env_len = None if _is_env_per_bucket() else len(saltenv) + 1 slash_len = -1 if trim_slash else None re...
Return the configuration mode, either buckets per environment or a list of buckets that have environment dirs in their root def _is_env_per_bucket(): ''' Return the configuration mode, either buckets per environment or a list of buckets that have environment dirs in their root ''' buckets = _g...
Find a hosted zone with the given characteristics. Id The unique Zone Identifier for the Hosted Zone. Exclusive with Name. Name The domain name associated with the Hosted Zone. Exclusive with Id. Note this has the potential to match more then one hosted zone (e.g. a public and a priv...
Return detailed info about the given zone. Id The unique Zone Identifier for the Hosted Zone. region Region to connect to. key Secret key to be used. keyid Access key to be used. profile Dict, or pillar key pointing to a dict, containing AWS region/key/ke...
Find any zones with the given domain name and return detailed info about them. Note that this can return multiple Route53 zones, since a domain name can be used in both public and private zones. Name The domain name associated with the Hosted Zone(s). region Region to connect to. ...
Return detailed info about all zones in the bound account. DelegationSetId If you're using reusable delegation sets and you want to list all of the hosted zones that are associated with a reusable delegation set, specify the ID of that delegation set. region Region to connect to. ...
Create a new Route53 Hosted Zone. Returns a Python data structure with information about the newly created Hosted Zone. Name The name of the domain. This should be a fully-specified domain, and should terminate with a period. This is the name you have registered with your DNS registrar. It is a...
Update the comment on an existing Route 53 hosted zone. Id The unique Zone Identifier for the Hosted Zone. Name The domain name associated with the Hosted Zone(s). Comment Any comments you want to include about the hosted zone. PrivateZone Boolean - Set to True if cha...
Associates an Amazon VPC with a private hosted zone. To perform the association, the VPC and the private hosted zone must already exist. You can't convert a public hosted zone into a private hosted zone. If you want to associate a VPC from one AWS account with a zone from a another, the AWS account owning...
Delete a Route53 hosted zone. CLI Example:: salt myminion boto3_route53.delete_hosted_zone Z1234567890 def delete_hosted_zone(Id, region=None, key=None, keyid=None, profile=None): ''' Delete a Route53 hosted zone. CLI Example:: salt myminion boto3_route53.delete_hosted_zone Z1234567...
Delete a Route53 hosted zone by domain name, and PrivateZone status if provided. CLI Example:: salt myminion boto3_route53.delete_hosted_zone_by_domain example.org. def delete_hosted_zone_by_domain(Name, PrivateZone=None, region=None, key=None, keyid=None, profile=None): ...
An implementation of the encoding required to suport AWS's domain name rules defined here__: .. __: http://docs.aws.amazon.com/Route53/latest/DeveloperGuide/DomainNameFormat.html While AWS's documentation specifies individual ASCII characters which need to be encoded, we instead just try to force the ...
helper method to process a change batch & encode the bits which need encoding. def _aws_encode_changebatch(o): ''' helper method to process a change batch & encode the bits which need encoding. ''' change_idx = 0 while change_idx < len(o['Changes']): o['Changes'][change_idx]['ResourceRecord...
Get all resource records from a given zone matching the provided StartRecordName (if given) or all records in the zone (if not), optionally filtered by a specific StartRecordType. This will return any and all RRs matching, regardless of their special AWS flavors (weighted, geolocation, alias, etc.) so your...
See the `AWS Route53 API docs`__ as well as the `Boto3 documentation`__ for all the details... .. __: https://docs.aws.amazon.com/Route53/latest/APIReference/API_ChangeResourceRecordSets.html .. __: http://boto3.readthedocs.io/en/latest/reference/services/route53.html#Route53.Client.change_resource_record_sets...
Mask a line in the data, which matches "mask". This can be used for cases where values in your roster file may contain sensitive data such as IP addresses, passwords, user names, etc. Note that this works only when ``data`` is a single string (i.e. when the data in the roster is formatted as ``key: va...
Raise an exception if value is empty. Otherwise strip it down. :param value: :return: def trim(value): ''' Raise an exception if value is empty. Otherwise strip it down. :param value: :return: ''' value = (value or '').strip() if not value: ...
Remove everything that would affect paths in the filename :param value: :return: def filename(value): ''' Remove everything that would affect paths in the filename :param value: :return: ''' return re.sub('[^a-zA-Z0-9.-_ ]', '', os.path.basename(InputSa...