INSTRUCTION
stringlengths
1
8.43k
RESPONSE
stringlengths
75
104k
Check that the function passed really exists
def verify_fun(lazy_obj, fun): ''' Check that the function passed really exists ''' if not fun: raise salt.exceptions.SaltInvocationError( 'Must specify a function to run!\n' 'ex: manage.up' ) if fun not in lazy_obj: # If the requested function isn't a...
Clear the dict
def clear(self): ''' Clear the dict ''' # create a dict to store loaded values in self._dict = getattr(self, 'mod_dict_class', dict)() # have we already loded everything? self.loaded = False
Check to see if an instance profile exists.
def instance_profile_exists(name, region=None, key=None, keyid=None, profile=None): ''' Check to see if an instance profile exists. CLI Example: .. code-block:: bash salt myminion boto_iam.instance_profile_exists myiprofile ''' conn = _get_conn(region=regio...
Check to see if an IAM role exists.
def role_exists(name, region=None, key=None, keyid=None, profile=None): ''' Check to see if an IAM role exists. CLI Example: .. code-block:: bash salt myminion boto_iam.role_exists myirole ''' conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile) try: conn...
Get information for a role.
def describe_role(name, region=None, key=None, keyid=None, profile=None): ''' Get information for a role. CLI Example: .. code-block:: bash salt myminion boto_iam.describe_role myirole ''' conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile) try: info = c...
Create a user.
def create_user(user_name, path=None, region=None, key=None, keyid=None, profile=None): ''' Create a user. .. versionadded:: 2015.8.0 CLI Example: .. code-block:: bash salt myminion boto_iam.create_user myuser ''' if not path: path = '/' if get_user(us...
Get all access keys from a user.
def get_all_access_keys(user_name, marker=None, max_items=None, region=None, key=None, keyid=None, profile=None): ''' Get all access keys from a user. .. versionadded:: 2015.8.0 CLI Example: .. code-block:: bash salt myminion boto_iam.get_all_access_keys myuser ...
Delete a user.
def delete_user(user_name, region=None, key=None, keyid=None, profile=None): ''' Delete a user. .. versionadded:: 2015.8.0 CLI Example: .. code-block:: bash salt myminion boto_iam.delete_user myuser ''' if not get_user(user_name, region, key, keyid, profile): ...
Get user information.
def get_user(user_name=None, region=None, key=None, keyid=None, profile=None): ''' Get user information. .. versionadded:: 2015.8.0 CLI Example: .. code-block:: bash salt myminion boto_iam.get_user myuser ''' conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile) ...
Get group information.
def get_group(group_name, region=None, key=None, keyid=None, profile=None): ''' Get group information. .. versionadded:: 2015.8.0 CLI Example: .. code-block:: bash salt myminion boto_iam.get_group mygroup ''' conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile) ...
Get group information.
def get_group_members(group_name, region=None, key=None, keyid=None, profile=None): ''' Get group information. .. versionadded:: 2016.3.0 CLI Example: .. code-block:: bash salt myminion boto_iam.get_group mygroup ''' conn = _get_conn(region=region, key=key, keyid=keyid, profile=p...
Add user to group.
def add_user_to_group(user_name, group_name, region=None, key=None, keyid=None, profile=None): ''' Add user to group. .. versionadded:: 2015.8.0 CLI Example: .. code-block:: bash salt myminion boto_iam.add_user_to_group myuser mygroup ''' user = get_user(use...
Check if user exists in group.
def user_exists_in_group(user_name, group_name, region=None, key=None, keyid=None, profile=None): ''' Check if user exists in group. .. versionadded:: 2015.8.0 CLI Example: .. code-block:: bash salt myminion boto_iam.user_exists_in_group myuser mygroup ''' ...
Adds or updates the specified policy document for the specified group.
def put_group_policy(group_name, policy_name, policy_json, region=None, key=None, keyid=None, profile=None): ''' Adds or updates the specified policy document for the specified group. .. versionadded:: 2015.8.0 CLI Example: .. code-block:: bash salt myminion boto_iam...
Delete a group policy.
def delete_group_policy(group_name, policy_name, region=None, key=None, keyid=None, profile=None): ''' Delete a group policy. CLI Example:: .. code-block:: bash salt myminion boto_iam.delete_group_policy mygroup mypolicy ''' conn = _get_conn(region=region, key=...
Retrieves the specified policy document for the specified group.
def get_group_policy(group_name, policy_name, region=None, key=None, keyid=None, profile=None): ''' Retrieves the specified policy document for the specified group. .. versionadded:: 2015.8.0 CLI Example: .. code-block:: bash salt myminion boto_iam.get_group_policy m...
Get and return all IAM group details starting at the optional path.
def get_all_groups(path_prefix='/', region=None, key=None, keyid=None, profile=None): ''' Get and return all IAM group details, starting at the optional path. .. versionadded:: 2016.3.0 CLI Example: salt-call boto_iam.get_all_groups ''' conn = _get_conn(region=region,...
Get and return all IAM instance profiles starting at the optional path.
def get_all_instance_profiles(path_prefix='/', region=None, key=None, keyid=None, profile=None): ''' Get and return all IAM instance profiles, starting at the optional path. .. versionadded:: 2016.11.0 CLI Example: salt-call boto_iam.get_all_instance_profiles ...
List all IAM instance profiles starting at the optional path.
def list_instance_profiles(path_prefix='/', region=None, key=None, keyid=None, profile=None): ''' List all IAM instance profiles, starting at the optional path. .. versionadded:: 2016.11.0 CLI Example: salt-call boto_iam.list_instance_profiles ''' p = get_al...
Get a list of policy names from a group.
def get_all_group_policies(group_name, region=None, key=None, keyid=None, profile=None): ''' Get a list of policy names from a group. CLI Example: .. code-block:: bash salt myminion boto_iam.get_all_group_policies mygroup ''' conn = _get_conn(region=region, ...
Delete a group policy.
def delete_group(group_name, region=None, key=None, keyid=None, profile=None): ''' Delete a group policy. CLI Example:: .. code-block:: bash salt myminion boto_iam.delete_group mygroup ''' conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile) ...
Creates a login profile for the specified user give the user the ability to access AWS services and the AWS Management Console.
def create_login_profile(user_name, password, region=None, key=None, keyid=None, profile=None): ''' Creates a login profile for the specified user, give the user the ability to access AWS services and the AWS Management Console. .. versionadded:: 2015.8.0 CLI Example: ...
Get all MFA devices associated with an IAM user.
def get_all_mfa_devices(user_name, region=None, key=None, keyid=None, profile=None): ''' Get all MFA devices associated with an IAM user. .. versionadded:: 2016.3.0 CLI Example: .. code-block:: bash salt myminion boto_iam.get_all_mfa_devices user_name ''' ...
Deletes the specified virtual MFA device.
def delete_virtual_mfa_device(serial, region=None, key=None, keyid=None, profile=None): ''' Deletes the specified virtual MFA device. CLI Example: .. code-block:: bash salt myminion boto_iam.delete_virtual_mfa_device serial_num ''' conn = __utils__['boto3.get_connection_func']('iam')(...
Update the password policy for the AWS account.
def update_account_password_policy(allow_users_to_change_password=None, hard_expiry=None, max_password_age=None, minimum_password_length=None, password_reuse_prevention=None, requi...
Get account policy for the AWS account.
def get_account_policy(region=None, key=None, keyid=None, profile=None): ''' Get account policy for the AWS account. .. versionadded:: 2015.8.0 CLI Example: .. code-block:: bash salt myminion boto_iam.get_account_policy ''' conn = _get_conn(region=region, key=key, keyid=keyid, pr...
Create an instance role.
def create_role(name, policy_document=None, path=None, region=None, key=None, keyid=None, profile=None): ''' Create an instance role. CLI Example: .. code-block:: bash salt myminion boto_iam.create_role myrole ''' conn = _get_conn(region=region, key=key, keyid=keyid, p...
Delete an IAM role.
def delete_role(name, region=None, key=None, keyid=None, profile=None): ''' Delete an IAM role. CLI Example: .. code-block:: bash salt myminion boto_iam.delete_role myirole ''' conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile) if not role_exists(name, region,...
Check to see if an instance profile is associated with an IAM role.
def profile_associated(role_name, profile_name, region, key, keyid, profile): ''' Check to see if an instance profile is associated with an IAM role. CLI Example: .. code-block:: bash salt myminion boto_iam.profile_associated myirole myiprofile ''' conn = _get_conn(region=region, key=...
Associate an instance profile with an IAM role.
def associate_profile_to_role(profile_name, role_name, region=None, key=None, keyid=None, profile=None): ''' Associate an instance profile with an IAM role. CLI Example: .. code-block:: bash salt myminion boto_iam.associate_profile_to_role myirole myiprofile ...
Get a list of policy names from a role.
def list_role_policies(role_name, region=None, key=None, keyid=None, profile=None): ''' Get a list of policy names from a role. CLI Example: .. code-block:: bash salt myminion boto_iam.list_role_policies myirole ''' conn = _get_conn(region=region, key=key, keyid...
Get a role policy.
def get_role_policy(role_name, policy_name, region=None, key=None, keyid=None, profile=None): ''' Get a role policy. CLI Example: .. code-block:: bash salt myminion boto_iam.get_role_policy myirole mypolicy ''' conn = _get_conn(region=region, key=key, keyid=keyid, ...
Create or modify a role policy.
def create_role_policy(role_name, policy_name, policy, region=None, key=None, keyid=None, profile=None): ''' Create or modify a role policy. CLI Example: .. code-block:: bash salt myminion boto_iam.create_role_policy myirole mypolicy '{"MyPolicy": "Statement": [{"Action...
Delete a role policy.
def delete_role_policy(role_name, policy_name, region=None, key=None, keyid=None, profile=None): ''' Delete a role policy. CLI Example: .. code-block:: bash salt myminion boto_iam.delete_role_policy myirole mypolicy ''' conn = _get_conn(region=region, key=key, k...
Update an assume role policy for a role.
def update_assume_role_policy(role_name, policy_document, region=None, key=None, keyid=None, profile=None): ''' Update an assume role policy for a role. .. versionadded:: 2015.8.0 CLI Example: .. code-block:: bash salt myminion boto_iam.update_assume_role_po...
Build a default assume role policy.
def build_policy(region=None, key=None, keyid=None, profile=None): ''' Build a default assume role policy. .. versionadded:: 2015.8.0 CLI Example: .. code-block:: bash salt myminion boto_iam.build_policy ''' conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile) ...
Get a the AWS account id associated with the used credentials.
def get_account_id(region=None, key=None, keyid=None, profile=None): ''' Get a the AWS account id associated with the used credentials. CLI Example: .. code-block:: bash salt myminion boto_iam.get_account_id ''' cache_key = 'boto_iam.account_id' if cache_key not in __context__: ...
Get and return all IAM role details starting at the optional path.
def get_all_roles(path_prefix=None, region=None, key=None, keyid=None, profile=None): ''' Get and return all IAM role details, starting at the optional path. .. versionadded:: 2016.3.0 CLI Example: salt-call boto_iam.get_all_roles ''' conn = _get_conn(region=region, k...
Get and return all IAM user details starting at the optional path.
def get_all_users(path_prefix='/', region=None, key=None, keyid=None, profile=None): ''' Get and return all IAM user details, starting at the optional path. .. versionadded:: 2016.3.0 CLI Example: salt-call boto_iam.get_all_users ''' conn = _get_conn(region=region, ke...
Get all user policies.
def get_all_user_policies(user_name, marker=None, max_items=None, region=None, key=None, keyid=None, profile=None): ''' Get all user policies. .. versionadded:: 2015.8.0 CLI Example: .. code-block:: bash salt myminion boto_iam.get_all_user_policies myuser ''' conn = _get_conn(reg...
Retrieves the specified policy document for the specified user.
def get_user_policy(user_name, policy_name, region=None, key=None, keyid=None, profile=None): ''' Retrieves the specified policy document for the specified user. .. versionadded:: 2015.8.0 CLI Example: .. code-block:: bash salt myminion boto_iam.get_user_policy myuser mypolicyname ''...
Adds or updates the specified policy document for the specified user.
def put_user_policy(user_name, policy_name, policy_json, region=None, key=None, keyid=None, profile=None): ''' Adds or updates the specified policy document for the specified user. .. versionadded:: 2015.8.0 CLI Example: .. code-block:: bash salt myminion boto_iam.put_user_policy myuser ...
Delete a user policy.
def delete_user_policy(user_name, policy_name, region=None, key=None, keyid=None, profile=None): ''' Delete a user policy. CLI Example: .. code-block:: bash salt myminion boto_iam.delete_user_policy myuser mypolicy ''' conn = _get_conn(region=region, key=key, keyid=keyid, profile=prof...
Upload a certificate to Amazon.
def upload_server_cert(cert_name, cert_body, private_key, cert_chain=None, path=None, region=None, key=None, keyid=None, profile=None): ''' Upload a certificate to Amazon. .. versionadded:: 2015.8.0 CLI Example: .. code-block:: bash salt myminion boto_iam.upload_se...
Lists the server certificates stored in IAM that have the specified path prefix.
def list_server_certificates(path_prefix='/', region=None, key=None, keyid=None, profile=None): ''' Lists the server certificates stored in IAM that have the specified path prefix. .. versionadded:: ??? :param path_prefix: The path prefix for filtering the results. For example: /company/serv...
Deletes a certificate from Amazon.
def delete_server_cert(cert_name, region=None, key=None, keyid=None, profile=None): ''' Deletes a certificate from Amazon. .. versionadded:: 2015.8.0 CLI Example: .. code-block:: bash salt myminion boto_iam.delete_server_cert mycert_name ''' conn = _get_conn(region=region, key=ke...
Get all IAM user details. Produces results that can be used to create an sls file.
def export_users(path_prefix='/', region=None, key=None, keyid=None, profile=None): ''' Get all IAM user details. Produces results that can be used to create an sls file. .. versionadded:: 2016.3.0 CLI Example: salt-call boto_iam.export_users --out=txt | sed "s/local: //"...
Get all IAM role details. Produces results that can be used to create an sls file.
def export_roles(path_prefix='/', region=None, key=None, keyid=None, profile=None): ''' Get all IAM role details. Produces results that can be used to create an sls file. CLI Example: salt-call boto_iam.export_roles --out=txt | sed "s/local: //" > iam_roles.sls ''' conn = _get_conn(reg...
Check to see if policy exists.
def policy_exists(policy_name, region=None, key=None, keyid=None, profile=None): ''' Check to see if policy exists. CLI Example: .. code-block:: bash salt myminion boto_iam.instance_profile_exists myiprofile ''' conn = _get_conn(region=region, key=key, keyid=keyid, p...
Check to see if policy exists.
def get_policy(policy_name, region=None, key=None, keyid=None, profile=None): ''' Check to see if policy exists. CLI Example: .. code-block:: bash salt myminion boto_iam.instance_profile_exists myiprofile ''' conn = _get_conn(region=region, key=key, keyid=keyid, profile...
Create a policy.
def create_policy(policy_name, policy_document, path=None, description=None, region=None, key=None, keyid=None, profile=None): ''' Create a policy. CLI Example: .. code-block:: bash salt myminios boto_iam.create_policy mypolicy '{"Version": "2012-10-17", "Statement": [{ "Effe...
List policies.
def list_policies(region=None, key=None, keyid=None, profile=None): ''' List policies. CLI Example: .. code-block:: bash salt myminion boto_iam.list_policies ''' conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile) try: policies = [] for ret in _...
Check to see if policy exists.
def policy_version_exists(policy_name, version_id, region=None, key=None, keyid=None, profile=None): ''' Check to see if policy exists. CLI Example: .. code-block:: bash salt myminion boto_iam.instance_profile_exists myiprofile ''' conn = _get_conn(region=region, key...
Check to see if policy exists.
def get_policy_version(policy_name, version_id, region=None, key=None, keyid=None, profile=None): ''' Check to see if policy exists. CLI Example: .. code-block:: bash salt myminion boto_iam.instance_profile_exists myiprofile ''' conn = _get_conn(region=region, key=key, ...
Create a policy version.
def create_policy_version(policy_name, policy_document, set_as_default=None, region=None, key=None, keyid=None, profile=None): ''' Create a policy version. CLI Example: .. code-block:: bash salt myminios boto_iam.create_policy_version mypolicy '{"Version": "2012-10-17", "Stat...
Delete a policy version.
def delete_policy_version(policy_name, version_id, region=None, key=None, keyid=None, profile=None): ''' Delete a policy version. CLI Example: .. code-block:: bash salt myminion boto_iam.delete_policy_version mypolicy v1 ''' conn = _get_conn(region=region, key=key, k...
List versions of a policy.
def list_policy_versions(policy_name, region=None, key=None, keyid=None, profile=None): ''' List versions of a policy. CLI Example: .. code-block:: bash salt myminion boto_iam.list_policy_versions mypolicy ''' conn = _get_conn(region=region, key=key, keyid=keyid, pro...
Detach a managed policy to a user.
def detach_user_policy(policy_name, user_name, region=None, key=None, keyid=None, profile=None): ''' Detach a managed policy to a user. CLI Example: .. code-block:: bash salt myminion boto_iam.detach_user_policy mypolicy myuser ''' conn = _get_conn(region=region, key...
List entities that a policy is attached to.
def list_entities_for_policy(policy_name, path_prefix=None, entity_filter=None, region=None, key=None, keyid=None, profile=None): ''' List entities that a policy is attached to. CLI Example: .. code-block:: bash salt myminion boto_iam.list_entities_for_policy mypolicy ''...
List entities attached to the given role.
def list_attached_role_policies(role_name, path_prefix=None, entity_filter=None, region=None, key=None, keyid=None, profile=None): ''' List entities attached to the given role. CLI Example: .. code-block:: bash salt myminion boto_iam.list_entities_for_policy mypolicy '''...
Create SAML provider
def create_saml_provider(name, saml_metadata_document, region=None, key=None, keyid=None, profile=None): ''' Create SAML provider CLI Example: .. code-block:: bash salt myminion boto_iam.create_saml_provider my_saml_provider_name saml_metadata_document ''' conn = _get_conn(region=regi...
Get SAML provider
def get_saml_provider_arn(name, region=None, key=None, keyid=None, profile=None): ''' Get SAML provider CLI Example: .. code-block:: bash salt myminion boto_iam.get_saml_provider_arn my_saml_provider_name ''' conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile) t...
Delete SAML provider
def delete_saml_provider(name, region=None, key=None, keyid=None, profile=None): ''' Delete SAML provider CLI Example: .. code-block:: bash salt myminion boto_iam.delete_saml_provider my_saml_provider_name ''' conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile) ...
List SAML providers.
def list_saml_providers(region=None, key=None, keyid=None, profile=None): ''' List SAML providers. CLI Example: .. code-block:: bash salt myminion boto_iam.list_saml_providers ''' conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile) try: providers = [] ...
Get SAML provider document.
def get_saml_provider(name, region=None, key=None, keyid=None, profile=None): ''' Get SAML provider document. CLI Example: .. code-block:: bash salt myminion boto_iam.get_saml_provider arn ''' conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile) try: prov...
Validate the beacon configuration
def validate(config): ''' Validate the beacon configuration ''' # Configuration for adb beacon should be a dictionary with states array if not isinstance(config, list): log.info('Configuration for adb beacon must be a list.') return False, ('Configuration for adb beacon must be a lis...
Emit the status of all devices returned by adb
def beacon(config): ''' Emit the status of all devices returned by adb Specify the device states that should emit an event, there will be an event for each device with the event type and device specified. .. code-block:: yaml beacons: adb: - states: ...
Add a value to the named set
def set_(name, add, match): ''' Add a value to the named set USAGE: .. code-block:: yaml foo: reg.set: - add: bar - match: my/custom/event ''' ret = {'name': name, 'changes': {}, 'comment': '', 'result': True} if n...
Add the specified values to the named list
def list_(name, add, match, stamp=False, prune=0): ''' Add the specified values to the named list If ``stamp`` is True, then the timestamp from the event will also be added if ``prune`` is set to an integer higher than ``0``, then only the last ``prune`` values will be kept in the list. USAGE:...
Accept a numeric value from the matched events and store a running average of the values in the given register. If the specified value is not numeric it will be skipped
def mean(name, add, match): ''' Accept a numeric value from the matched events and store a running average of the values in the given register. If the specified value is not numeric it will be skipped USAGE: .. code-block:: yaml foo: reg.mean: - add: data_field ...
Clear the namespace from the register
def clear(name): ''' Clear the namespace from the register USAGE: .. code-block:: yaml clearns: reg.clear: - name: myregister ''' ret = {'name': name, 'changes': {}, 'comment': '', 'result': True} if name in __reg__: _...
Delete the namespace from the register
def delete(name): ''' Delete the namespace from the register USAGE: .. code-block:: yaml deletens: reg.delete: - name: myregister ''' ret = {'name': name, 'changes': {}, 'comment': '', 'result': True} if name in __reg__: ...
Set a key in etcd
def set_(name, value, profile=None, **kwargs): ''' Set a key in etcd name The etcd key name, for example: ``/foo/bar/baz``. value The value the key should contain. profile Optional, defaults to ``None``. Sets the etcd profile to use which has been defined in the Sal...
Create a directory in etcd.
def directory(name, profile=None, **kwargs): ''' Create a directory in etcd. name The etcd directory name, for example: ``/foo/bar/baz``. profile Optional, defaults to ``None``. Sets the etcd profile to use which has been defined in the Salt Master config. .. code-block...
Deletes a key from etcd
def rm(name, recurse=False, profile=None, **kwargs): ''' Deletes a key from etcd name The etcd key name to remove, for example ``/foo/bar/baz``. recurse Optional, defaults to ``False``. If ``True`` performs a recursive delete. profile Optional, defaults to ``None``. Sets t...
The etcd watcher called to invoke the watch command. When called execute a etcd function based on a watch call requisite.
def mod_watch(name, **kwargs): ''' The etcd watcher, called to invoke the watch command. When called, execute a etcd function based on a watch call requisite. .. note:: This state exists to support special handling of the ``watch`` :ref:`requisite <requisites>`. It should not be called ...
Determine which packages own the currently running services. By default excludes files whose full path starts with/ dev/ home/ media/ proc/ run/ sys/ tmp and/ var. This can be overridden by passing in a new list to exclude.
def running_service_owners( exclude=('/dev', '/home', '/media', '/proc', '/run', '/sys/', '/tmp', '/var') ): ''' Determine which packages own the currently running services. By default, excludes files whose full path starts with ``/dev``, ``/home``, ``/media``, ``/proc``, ``...
Return which packages own each of the services that are currently enabled.
def enabled_service_owners(): ''' Return which packages own each of the services that are currently enabled. CLI Example: salt myminion introspect.enabled_service_owners ''' error = {} if 'pkg.owner' not in __salt__: error['Unsupported Package Manager'] = ( 'The mod...
Return running and enabled services in a highstate structure. By default also returns package dependencies for those services which means that package definitions must be created outside this function. To drop the package dependencies set requires to False.
def service_highstate(requires=True): ''' Return running and enabled services in a highstate structure. By default also returns package dependencies for those services, which means that package definitions must be created outside this function. To drop the package dependencies, set ``requires`` to F...
Return the targets
def targets(tgt, tgt_type='glob', **kwargs): ''' Return the targets ''' ret = {} ports = __opts__['ssh_scan_ports'] if not isinstance(ports, list): # Comma-separate list of integers ports = list(map(int, six.text_type(ports).split(','))) hosts = list(NodeSet(tgt)) host_a...
Gather some system data and then calculate buffer space.
def _gather_buffer_space(): ''' Gather some system data and then calculate buffer space. Result is in bytes. ''' if HAS_PSUTIL and psutil.version_info >= (0, 6, 0): # Oh good, we have psutil. This will be quick. total_mem = psutil.virtual_memory().total else: # Avoid...
Normalize file or pillar roots.
def _normalize_roots(file_roots): ''' Normalize file or pillar roots. ''' for saltenv, dirs in six.iteritems(file_roots): normalized_saltenv = six.text_type(saltenv) if normalized_saltenv != saltenv: file_roots[normalized_saltenv] = file_roots.pop(saltenv) if not isin...
If the pillar_roots option has a key that is None then we will error out just replace it with an empty list
def _validate_pillar_roots(pillar_roots): ''' If the pillar_roots option has a key that is None then we will error out, just replace it with an empty list ''' if not isinstance(pillar_roots, dict): log.warning('The pillar_roots parameter is not properly formatted,' ' usin...
If the file_roots option has a key that is None then we will error out just replace it with an empty list
def _validate_file_roots(file_roots): ''' If the file_roots option has a key that is None then we will error out, just replace it with an empty list ''' if not isinstance(file_roots, dict): log.warning('The file_roots parameter is not properly formatted,' ' using defaults...
Applies shell globbing to a set of directories and returns the expanded paths
def _expand_glob_path(file_roots): ''' Applies shell globbing to a set of directories and returns the expanded paths ''' unglobbed_path = [] for path in file_roots: try: if glob.has_magic(path): unglobbed_path.extend(glob.glob(path)) else: ...
Check that all of the types of values passed into the config are of the right types
def _validate_opts(opts): ''' Check that all of the types of values passed into the config are of the right types ''' def format_multi_opt(valid_type): try: num_types = len(valid_type) except TypeError: # Bare type name won't have a length, return the name of ...
Ensure we re not using any invalid ssh_minion_opts. We want to make sure that the ssh_minion_opts does not override any pillar or fileserver options inherited from the master config. To add other items modify the if statement in the for loop below.
def _validate_ssh_minion_opts(opts): ''' Ensure we're not using any invalid ssh_minion_opts. We want to make sure that the ssh_minion_opts does not override any pillar or fileserver options inherited from the master config. To add other items, modify the if statement in the for loop below. ''' ...
Append a domain to the existing id if it doesn t already exist
def _append_domain(opts): ''' Append a domain to the existing id if it doesn't already exist ''' # Domain already exists if opts['id'].endswith(opts['append_domain']): return opts['id'] # Trailing dot should mean an FQDN that is terminated, leave it alone. if opts['id'].endswith('.')...
Read in a config file from a given path and process it into a dictionary
def _read_conf_file(path): ''' Read in a config file from a given path and process it into a dictionary ''' log.debug('Reading configuration from %s', path) with salt.utils.files.fopen(path, 'r') as conf_file: try: conf_opts = salt.utils.yaml.safe_load(conf_file) or {} ex...
Return an absolute path. In case relative_to is passed and path is not an absolute path we try to prepend relative_to to path and if that path exists return that one
def _absolute_path(path, relative_to=None): ''' Return an absolute path. In case ``relative_to`` is passed and ``path`` is not an absolute path, we try to prepend ``relative_to`` to ``path``and if that path exists, return that one ''' if path and os.path.isabs(path): return path if ...
Returns configuration dict from parsing either the file described by path or the environment variable described by env_var as YAML.
def load_config(path, env_var, default_path=None, exit_on_config_errors=True): ''' Returns configuration dict from parsing either the file described by ``path`` or the environment variable described by ``env_var`` as YAML. ''' if path is None: # When the passed path is None, we just want the...
Parses extra configuration file ( s ) specified in an include list in the main config file.
def include_config(include, orig_path, verbose, exit_on_config_errors=False): ''' Parses extra configuration file(s) specified in an include list in the main config file. ''' # Protect against empty option if not include: return {} if orig_path is None: # When the passed pat...
Prepends the options that represent filesystem paths with value of the root_dir option.
def prepend_root_dir(opts, path_options): ''' Prepends the options that represent filesystem paths with value of the 'root_dir' option. ''' root_dir = os.path.abspath(opts['root_dir']) def_root_dir = salt.syspaths.ROOT_DIR.rstrip(os.sep) for path_option in path_options: if path_optio...
Inserts path into python path taking into consideration root_dir option.
def insert_system_path(opts, paths): ''' Inserts path into python path taking into consideration 'root_dir' option. ''' if isinstance(paths, six.string_types): paths = [paths] for path in paths: path_options = {'path': path, 'root_dir': opts['root_dir']} prepend_root_dir(path...
Reads in the minion configuration file and sets up special options
def minion_config(path, env_var='SALT_MINION_CONFIG', defaults=None, cache_minion_id=False, ignore_config_errors=True, minion_id=None, role='minion'): ''' Reads in the minion configuration file and sets u...
Recurse for sdb:// links for opts
def apply_sdb(opts, sdb_opts=None): ''' Recurse for sdb:// links for opts ''' # Late load of SDB to keep CLI light import salt.utils.sdb if sdb_opts is None: sdb_opts = opts if isinstance(sdb_opts, six.string_types) and sdb_opts.startswith('sdb://'): return salt.utils.sdb.sdb...
Read in the Salt Cloud config and return the dict
def cloud_config(path=None, env_var='SALT_CLOUD_CONFIG', defaults=None, master_config_path=None, master_config=None, providers_config_path=None, providers_config=None, profiles_config_path=None, profiles_config=None): ''' Read in the Salt Cloud config and retur...
Return a cloud config
def apply_cloud_config(overrides, defaults=None): ''' Return a cloud config ''' if defaults is None: defaults = DEFAULT_CLOUD_OPTS.copy() config = defaults.copy() if overrides: config.update(overrides) # If the user defined providers in salt cloud's main configuration file,...
Read in the salt cloud VM config file
def vm_profiles_config(path, providers, env_var='SALT_CLOUDVM_CONFIG', defaults=None): ''' Read in the salt cloud VM config file ''' if defaults is None: defaults = VM_CONFIG_DEFAULTS overrides = salt.config.load_config( ...
Read in the salt cloud providers configuration file
def cloud_providers_config(path, env_var='SALT_CLOUD_PROVIDERS_CONFIG', defaults=None): ''' Read in the salt cloud providers configuration file ''' if defaults is None: defaults = PROVIDER_CONFIG_DEFAULTS overrides = salt.config.load_con...