INSTRUCTION
stringlengths
1
46.3k
RESPONSE
stringlengths
75
80.2k
Ensure VPC with passed properties is absent. name Name of the VPC. tags A list of tags. All tags must match. region Region to connect to. key Secret key to be used. keyid Access key to be used. profile A dict with region, key and keyid, or a ...
def absent(name, tags=None, region=None, key=None, keyid=None, profile=None): ''' Ensure VPC with passed properties is absent. name Name of the VPC. tags A list of tags. All tags must match. region Region to connect to. key Secret key to be used. keyid ...
Ensure a set of DHCP options with the given settings exist. Note that the current implementation only SETS values during option set creation. It is unable to update option sets in place, and thus merely verifies the set exists via the given name and/or dhcp_options_id param. name (string) ...
def dhcp_options_present(name, dhcp_options_id=None, vpc_name=None, vpc_id=None, domain_name=None, domain_name_servers=None, ntp_servers=None, netbios_name_servers=None, netbios_node_type=None, tags=None, region=None, key=None, keyid=None, profi...
Ensure a set of DHCP options with the given settings exist. name (string) Name of the DHCP options set. dhcp_options_id (string) Id of the DHCP options set. region (string) Region to connect to. key (string) Secret key to be used. ...
def dhcp_options_absent(name=None, dhcp_options_id=None, region=None, key=None, keyid=None, profile=None): ''' Ensure a set of DHCP options with the given settings exist. name (string) Name of the DHCP options set. dhcp_options_id (string) Id of the DHCP options set. ...
Helper function verify a subnet's route table association route_table_desc the description of a route table, as returned from boto_vpc.describe_route_table subnet_id the subnet id to verify .. versionadded:: 2016.11.0
def _verify_subnet_association(route_table_desc, subnet_id): ''' Helper function verify a subnet's route table association route_table_desc the description of a route table, as returned from boto_vpc.describe_route_table subnet_id the subnet id to verify .. versionadded:: 2016.11....
Ensure a subnet exists. name Name of the subnet. cidr_block The range if IPs for the subnet, in CIDR format. For example: 10.0.0.0/24. Block size must be between /16 and /28 netmask. vpc_name Name of the VPC in which the subnet should be placed. Either vpc_name or ...
def subnet_present(name, cidr_block, vpc_name=None, vpc_id=None, availability_zone=None, tags=None, region=None, key=None, keyid=None, profile=None, route_table_id=None, route_table_name=None, auto_assign_public_ipv4=False): ''' Ensure...
Ensure subnet with passed properties is absent. name Name of the subnet. region Region to connect to. key Secret key to be used. keyid Access key to be used. profile A dict with region, key and keyid, or a pillar key (string) that contains a dict ...
def subnet_absent(name=None, subnet_id=None, region=None, key=None, keyid=None, profile=None): ''' Ensure subnet with passed properties is absent. name Name of the subnet. region Region to connect to. key Secret key to be used. keyid Access key to be used. ...
Ensure an internet gateway exists. name Name of the internet gateway. vpc_name Name of the VPC to which the internet gateway should be attached. vpc_id Id of the VPC to which the internet_gateway should be attached. Only one of vpc_name or vpc_id may be provided. tags...
def internet_gateway_present(name, vpc_name=None, vpc_id=None, tags=None, region=None, key=None, keyid=None, profile=None): ''' Ensure an internet gateway exists. name Name of the internet gateway. vpc_name Name of the VPC to wh...
Ensure the named internet gateway is absent. name Name of the internet gateway. detach First detach the internet gateway from a VPC, if attached. region Region to connect to. key Secret key to be used. keyid Access key to be used. profile A d...
def internet_gateway_absent(name, detach=False, region=None, key=None, keyid=None, profile=None): ''' Ensure the named internet gateway is absent. name Name of the internet gateway. detach First detach the internet gateway from a VPC, if attached. regio...
Ensure route table with routes exists and is associated to a VPC. This function requires boto3 to be installed if nat gatewyas are specified. Example: .. code-block:: yaml boto_vpc.route_table_present: - name: my_route_table - vpc_id: vpc-123456 - routes: ...
def route_table_present(name, vpc_name=None, vpc_id=None, routes=None, subnet_ids=None, subnet_names=None, tags=None, region=None, key=None, keyid=None, profile=None): ''' Ensure route table with routes exists and is associated to a VPC. This function require...
Ensure the named route table is absent. name Name of the route table. region Region to connect to. key Secret key to be used. keyid Access key to be used. profile A dict with region, key and keyid, or a pillar key (string) that contains a dict wit...
def route_table_absent(name, region=None, key=None, keyid=None, profile=None): ''' Ensure the named route table is absent. name Name of the route table. region Region to connect to. key Secret key to be used. keyid Access key to be used....
Ensure a nat gateway exists within the specified subnet This function requires boto3. .. versionadded:: 2016.11.0 Example: .. code-block:: yaml boto_vpc.nat_gateway_present: - subnet_name: my-subnet name Name of the state subnet_name Name of the subnet wi...
def nat_gateway_present(name, subnet_name=None, subnet_id=None, region=None, key=None, keyid=None, profile=None, allocation_id=None): ''' Ensure a nat gateway exists within the specified subnet This function requires boto3. .. versionadded:: 2016.11.0 Example: .. code...
Ensure the nat gateway in the named subnet is absent. This function requires boto3. .. versionadded:: 2016.11.0 name Name of the state. subnet_name Name of the subnet within which the nat gateway should exist subnet_id Id of the subnet within which the nat gateway should...
def nat_gateway_absent(name=None, subnet_name=None, subnet_id=None, region=None, key=None, keyid=None, profile=None, wait_for_delete_retries=0): ''' Ensure the nat gateway in the named subnet is absent. This function requires boto3. .. versionadded:: 2016....
Accept a VPC pending requested peering connection between two VPCs. name Name of this state conn_id The connection ID to accept. Exclusive with conn_name. String type. conn_name The name of the VPC peering connection to accept. Exclusive with conn_id. String type. region ...
def accept_vpc_peering_connection(name=None, conn_id=None, conn_name=None, region=None, key=None, keyid=None, profile=None): ''' Accept a VPC pending requested peering connection between two VPCs. name Name of this state conn_id The connection ID to ac...
name Name of the state requester_vpc_id ID of the requesting VPC. Exclusive with requester_vpc_name. String type. requester_vpc_name Name tag of the requesting VPC. Exclusive with requester_vpc_id. String type. peer_vpc_id ID of the VPC tp crete VPC peering connection wi...
def request_vpc_peering_connection(name, requester_vpc_id=None, requester_vpc_name=None, peer_vpc_id=None, peer_vpc_name=None, conn_name=None, peer_owner_id=None, peer_region=None, region=None, key=None, keyid=None,...
name Name of the state requester_vpc_id ID of the requesting VPC. Exclusive with requester_vpc_name. requester_vpc_name Name tag of the requesting VPC. Exclusive with requester_vpc_id. peer_vpc_id ID of the VPC tp crete VPC peering connection with. This can be a VPC in ...
def vpc_peering_connection_present(name, requester_vpc_id=None, requester_vpc_name=None, peer_vpc_id=None, peer_vpc_name=None, conn_name=None, peer_owner_id=None, peer_region=None, region=None, key=None, keyid=None,...
name Name of the state conn_id ID of the peering connection to delete. Exclusive with conn_name. conn_name The name of the peering connection to delete. Exclusive with conn_id. region Region to connect to. key Secret key to be used. keyid Access...
def delete_vpc_peering_connection(name, conn_id=None, conn_name=None, region=None, key=None, keyid=None, profile=None): ''' name Name of the state conn_id ID of the peering connection to delete. Exclusive with conn_name. conn_name The name of ...
Destroy the partition table and content of a given disk. .. code-block:: bash salt '*' ceph.osd_prepare 'dev'='/dev/vdc' \\ 'cluster_name'='ceph' \\ 'cluster_uuid'='cluster_uuid' dev The block device to format. cluster_name The cluster name. Defaul...
def zap(target=None, **kwargs): ''' Destroy the partition table and content of a given disk. .. code-block:: bash salt '*' ceph.osd_prepare 'dev'='/dev/vdc' \\ 'cluster_name'='ceph' \\ 'cluster_uuid'='cluster_uuid' dev The block device to format. c...
Create a virtual server CLI Examples: .. code-block:: bash salt-run f5.create_vs lbalancer vs_name 10.0.0.1 80 tcp http poolname
def create_vs(lb, name, ip, port, protocol, profile, pool_name): ''' Create a virtual server CLI Examples: .. code-block:: bash salt-run f5.create_vs lbalancer vs_name 10.0.0.1 80 tcp http poolname ''' if __opts__['load_balancers'].get(lb, None): (username, password) = list(__...
Create a pool on the F5 load balancer CLI Examples: .. code-block:: bash salt-run f5.create_pool load_balancer pool_name loadbalance_method salt-run f5.create_pool load_balancer my_pool ROUND_ROBIN
def create_pool(lb, name, method='ROUND_ROBIN'): ''' Create a pool on the F5 load balancer CLI Examples: .. code-block:: bash salt-run f5.create_pool load_balancer pool_name loadbalance_method salt-run f5.create_pool load_balancer my_pool ROUND_ROBIN ''' if __opts__['load_bala...
Add a node to a pool CLI Examples: .. code-block:: bash salt-run f5.add_pool_member load_balancer 10.0.0.1 80 my_pool
def add_pool_member(lb, name, port, pool_name): ''' Add a node to a pool CLI Examples: .. code-block:: bash salt-run f5.add_pool_member load_balancer 10.0.0.1 80 my_pool ''' if __opts__['load_balancers'].get(lb, None): (username, password) = list(__opts__['load_balancers'][lb]...
Check to see if a pool exists CLI Examples: .. code-block:: bash salt-run f5.check_pool load_balancer pool_name
def check_pool(lb, name): ''' Check to see if a pool exists CLI Examples: .. code-block:: bash salt-run f5.check_pool load_balancer pool_name ''' if __opts__['load_balancers'].get(lb, None): (username, password) = list(__opts__['load_balancers'][lb].values()) else: ...
Check a pool member exists in a specific pool CLI Examples: .. code-block:: bash salt-run f5.check_member_pool load_balancer 10.0.0.1 my_pool
def check_member_pool(lb, member, pool_name): ''' Check a pool member exists in a specific pool CLI Examples: .. code-block:: bash salt-run f5.check_member_pool load_balancer 10.0.0.1 my_pool ''' if __opts__['load_balancers'].get(lb, None): (username, password) = list(__opts__...
Connect to F5
def _connect(self): ''' Connect to F5 ''' try: self.bigIP = f5.BIGIP(hostname=self.lb, username=self.username, password=self.password, fromurl=True, ...
Create a virtual server
def create_vs(self, name, ip, port, protocol, profile, pool_name): ''' Create a virtual server ''' vs = self.bigIP.LocalLB.VirtualServer vs_def = vs.typefactory.create('Common.VirtualServerDefinition') vs_def.name = name vs_def.address = ip vs_def.port = ...
Create a pool on the F5 load balancer
def create_pool(self, name, method='ROUND_ROBIN'): ''' Create a pool on the F5 load balancer ''' lbmethods = self.bigIP.LocalLB.Pool.typefactory.create( 'LocalLB.LBMethod' ) supported_method = [i[0] for i in lbmethods if ( i[0].split('_', 2)[-1] =...
Add a node to a pool
def add_pool_member(self, name, port, pool_name): ''' Add a node to a pool ''' if not self.check_pool(pool_name): raise CommandExecutionError( '{0} pool does not exists'.format(pool_name) ) members_seq = self.bigIP.LocalLB.Pool.typefactory...
Check to see if a pool exists
def check_pool(self, name): ''' Check to see if a pool exists ''' pools = self.bigIP.LocalLB.Pool for pool in pools.get_list(): if pool.split('/')[-1] == name: return True return False
Check to see if a virtual server exists
def check_virtualserver(self, name): ''' Check to see if a virtual server exists ''' vs = self.bigIP.LocalLB.VirtualServer for v in vs.get_list(): if v.split('/')[-1] == name: return True return False
Check a pool member exists in a specific pool
def check_member_pool(self, member, pool_name): ''' Check a pool member exists in a specific pool ''' members = self.bigIP.LocalLB.Pool.get_member(pool_names=[pool_name])[0] for mem in members: if member == mem.address: return True return False
List all the load balancer methods
def lbmethods(self): ''' List all the load balancer methods ''' methods = self.bigIP.LocalLB.Pool.typefactory.create( 'LocalLB.LBMethod' ) return [method[0].split('_', 2)[-1] for method in methods]
Return a conn object for the passed VM data
def get_conn(service='SoftLayer_Virtual_Guest'): ''' Return a conn object for the passed VM data ''' client = SoftLayer.Client( username=config.get_cloud_config_value( 'user', get_configured_provider(), __opts__, search_global=False ), api_key=config.get_cloud_config_...
List all available locations
def avail_locations(call=None): ''' List all available locations ''' if call == 'action': raise SaltCloudSystemExit( 'The avail_locations function must be called with ' '-f or --function, or with the --list-locations option' ) ret = {} conn = get_conn() ...
Return a dict of all available VM sizes on the cloud provider with relevant data. This data is provided in three dicts.
def avail_sizes(call=None): ''' Return a dict of all available VM sizes on the cloud provider with relevant data. This data is provided in three dicts. ''' if call == 'action': raise SaltCloudSystemExit( 'The avail_sizes function must be called with ' '-f or --functio...
Return a dict of all available VM images on the cloud provider.
def avail_images(call=None): ''' Return a dict of all available VM images on the cloud provider. ''' if call == 'action': raise SaltCloudSystemExit( 'The avail_images function must be called with ' '-f or --function, or with the --list-images option' ) ret = ...
Return a dict of all custom VM images on the cloud provider.
def list_custom_images(call=None): ''' Return a dict of all custom VM images on the cloud provider. ''' if call != 'function': raise SaltCloudSystemExit( 'The list_vlans function must be called with -f or --function.' ) ret = {} conn = get_conn('SoftLayer_Account') ...
Create a single VM from a data dict
def create(vm_): ''' Create a single VM from a data dict ''' try: # Check for required profile parameters before sending any API calls. if vm_['profile'] and config.is_profile_configured(__opts__, __active_provider_name__ or 'sof...
Return a list of the VMs that are on the provider
def list_nodes_full(mask='mask[id]', call=None): ''' Return a list of the VMs that are on the provider ''' if call == 'action': raise SaltCloudSystemExit( 'The list_nodes_full function must be called with -f or --function.' ) ret = {} conn = get_conn(service='SoftLay...
Return a list of the VMs that are on the provider
def list_nodes(call=None): ''' Return a list of the VMs that are on the provider ''' if call == 'action': raise SaltCloudSystemExit( 'The list_nodes function must be called with -f or --function.' ) ret = {} nodes = list_nodes_full() if 'error' in nodes: ...
Destroy a node. CLI Example: .. code-block:: bash salt-cloud --destroy mymachine
def destroy(name, call=None): ''' Destroy a node. CLI Example: .. code-block:: bash salt-cloud --destroy mymachine ''' if call == 'function': raise SaltCloudSystemExit( 'The destroy action must be called with -d, --destroy, ' '-a or --action.' )...
.. versionadded:: 2014.7.0 Create new custom set CLI Example: .. code-block:: bash salt '*' ipset.new_set custom_set list:set salt '*' ipset.new_set custom_set list:set comment=True IPv6: salt '*' ipset.new_set custom_set list:set family=ipv6
def new_set(set=None, set_type=None, family='ipv4', comment=False, **kwargs): ''' .. versionadded:: 2014.7.0 Create new custom set CLI Example: .. code-block:: bash salt '*' ipset.new_set custom_set list:set salt '*' ipset.new_set custom_set list:set comment=True IPv6: ...
.. versionadded:: 2014.7.0 Delete ipset set. CLI Example: .. code-block:: bash salt '*' ipset.delete_set custom_set IPv6: salt '*' ipset.delete_set custom_set family=ipv6
def delete_set(set=None, family='ipv4'): ''' .. versionadded:: 2014.7.0 Delete ipset set. CLI Example: .. code-block:: bash salt '*' ipset.delete_set custom_set IPv6: salt '*' ipset.delete_set custom_set family=ipv6 ''' if not set: return 'Error: Set nee...
.. versionadded:: 2014.7.0 Delete ipset set. CLI Example: .. code-block:: bash salt '*' ipset.rename_set custom_set new_set=new_set_name IPv6: salt '*' ipset.rename_set custom_set new_set=new_set_name family=ipv6
def rename_set(set=None, new_set=None, family='ipv4'): ''' .. versionadded:: 2014.7.0 Delete ipset set. CLI Example: .. code-block:: bash salt '*' ipset.rename_set custom_set new_set=new_set_name IPv6: salt '*' ipset.rename_set custom_set new_set=new_set_name family=ipv6...
.. versionadded:: 2014.7.0 List all ipset sets. CLI Example: .. code-block:: bash salt '*' ipset.list_sets
def list_sets(family='ipv4'): ''' .. versionadded:: 2014.7.0 List all ipset sets. CLI Example: .. code-block:: bash salt '*' ipset.list_sets ''' cmd = '{0} list -t'.format(_ipset_cmd()) out = __salt__['cmd.run'](cmd, python_shell=False) _tmp = out.split('\n') count...
Check that given ipset set exists. .. versionadded:: 2014.7.0 CLI Example: .. code-block:: bash salt '*' ipset.check_set setname
def check_set(set=None, family='ipv4'): ''' Check that given ipset set exists. .. versionadded:: 2014.7.0 CLI Example: .. code-block:: bash salt '*' ipset.check_set setname ''' if not set: return 'Error: Set needs to be specified' setinfo = _find_set_info(set) i...
Append an entry to the specified set. CLI Example: .. code-block:: bash salt '*' ipset.add setname 192.168.1.26 salt '*' ipset.add setname 192.168.0.3,AA:BB:CC:DD:EE:FF
def add(setname=None, entry=None, family='ipv4', **kwargs): ''' Append an entry to the specified set. CLI Example: .. code-block:: bash salt '*' ipset.add setname 192.168.1.26 salt '*' ipset.add setname 192.168.0.3,AA:BB:CC:DD:EE:FF ''' if not setname: return 'Error:...
Check that an entry exists in the specified set. set The ipset name entry An entry in the ipset. This parameter can be a single IP address, a range of IP addresses, or a subnet block. Example: .. code-block:: cfg 192.168.0.1 192.168.0.2-192.168.0.19 ...
def check(set=None, entry=None, family='ipv4'): ''' Check that an entry exists in the specified set. set The ipset name entry An entry in the ipset. This parameter can be a single IP address, a range of IP addresses, or a subnet block. Example: .. code-block:: cfg ...
Flush entries in the specified set, Flush all sets if set is not specified. CLI Example: .. code-block:: bash salt '*' ipset.flush salt '*' ipset.flush set IPv6: salt '*' ipset.flush salt '*' ipset.flush set
def flush(set=None, family='ipv4'): ''' Flush entries in the specified set, Flush all sets if set is not specified. CLI Example: .. code-block:: bash salt '*' ipset.flush salt '*' ipset.flush set IPv6: salt '*' ipset.flush salt '*' ipset.flush set ''...
Return list of members for a set
def _find_set_members(set): ''' Return list of members for a set ''' cmd = '{0} list {1}'.format(_ipset_cmd(), set) out = __salt__['cmd.run_all'](cmd, python_shell=False) if out['retcode'] > 0: # Set doesn't exist return false return False _tmp = out['stdout'].split('\n') ...
Return information about the set
def _find_set_info(set): ''' Return information about the set ''' cmd = '{0} list -t {1}'.format(_ipset_cmd(), set) out = __salt__['cmd.run_all'](cmd, python_shell=False) if out['retcode'] > 0: # Set doesn't exist return false return False setinfo = {} _tmp = out['stdo...
Query a resource, and decode the return data Passes through all the parameters described in the :py:func:`utils.http.query function <salt.utils.http.query>`: CLI Example: .. code-block:: bash salt-run http.query http://somelink.com/ salt-run http.query http://somelink.com/ method=POS...
def query(url, output=True, **kwargs): ''' Query a resource, and decode the return data Passes through all the parameters described in the :py:func:`utils.http.query function <salt.utils.http.query>`: CLI Example: .. code-block:: bash salt-run http.query http://somelink.com/ ...
Update the local CA bundle file from a URL .. versionadded:: 2015.5.0 CLI Example: .. code-block:: bash salt-run http.update_ca_bundle salt-run http.update_ca_bundle target=/path/to/cacerts.pem salt-run http.update_ca_bundle source=https://example.com/cacerts.pem If the ``ta...
def update_ca_bundle(target=None, source=None, merge_files=None): ''' Update the local CA bundle file from a URL .. versionadded:: 2015.5.0 CLI Example: .. code-block:: bash salt-run http.update_ca_bundle salt-run http.update_ca_bundle target=/path/to/cacerts.pem salt-run...
Ensure that a user is present. name Name of the user. password Password of the user. email Optional - Email of the user. is_admin Optional - Set user as admin user. Default: False fullname Optional - Full name of the user. theme Optional - Se...
def present(name, password, email=None, is_admin=False, fullname=None, theme=None, default_organization=None, organizations=None, profile='grafana'): ''' Ensure that a user is present. name Name of the u...
Ensure that a user is present. name Name of the user to remove. profile Configuration profile used to connect to the Grafana instance. Default is 'grafana'.
def absent(name, profile='grafana'): ''' Ensure that a user is present. name Name of the user to remove. profile Configuration profile used to connect to the Grafana instance. Default is 'grafana'. ''' if isinstance(profile, string_types): profile = __salt__['co...
Create the named vm CLI Example: .. code-block:: bash salt <minion-id> saltcloud.create webserver rackspace_centos_512
def create(name, profile): ''' Create the named vm CLI Example: .. code-block:: bash salt <minion-id> saltcloud.create webserver rackspace_centos_512 ''' cmd = 'salt-cloud --out json -p {0} {1}'.format(profile, name) out = __salt__['cmd.run_stdout'](cmd, python_shell=False) tr...
Ensure that the named database is present with the specified properties. For more information about all of these options see man createdb(1) name The name of the database to manage tablespace Default tablespace for the database encoding The character encoding scheme to be used...
def present(name, tablespace=None, encoding=None, lc_collate=None, lc_ctype=None, owner=None, owner_recurse=False, template=None, user=None, maintenance_db=None, db_password=None, db_host=...
List all available profiles default_only : boolean return only default profile CLI Example: .. code-block:: bash salt '*' rbac.profile_list
def profile_list(default_only=False): ''' List all available profiles default_only : boolean return only default profile CLI Example: .. code-block:: bash salt '*' rbac.profile_list ''' profiles = {} default_profiles = ['All'] ## lookup default profile(s) wit...
List profiles for user user : string username default_hidden : boolean hide default profiles CLI Example: .. code-block:: bash salt '*' rbac.profile_get leo salt '*' rbac.profile_get leo default_hidden=False
def profile_get(user, default_hidden=True): ''' List profiles for user user : string username default_hidden : boolean hide default profiles CLI Example: .. code-block:: bash salt '*' rbac.profile_get leo salt '*' rbac.profile_get leo default_hidden=False ...
Add profile to user user : string username profile : string profile name CLI Example: .. code-block:: bash salt '*' rbac.profile_add martine 'Primary Administrator' salt '*' rbac.profile_add martine 'User Management,User Security'
def profile_add(user, profile): ''' Add profile to user user : string username profile : string profile name CLI Example: .. code-block:: bash salt '*' rbac.profile_add martine 'Primary Administrator' salt '*' rbac.profile_add martine 'User Management,User Sec...
List all available roles CLI Example: .. code-block:: bash salt '*' rbac.role_list
def role_list(): ''' List all available roles CLI Example: .. code-block:: bash salt '*' rbac.role_list ''' roles = {} ## read user_attr file (user:qualifier:res1:res2:attr) with salt.utils.files.fopen('/etc/user_attr', 'r') as user_attr: for role in user_attr: ...
List roles for user user : string username CLI Example: .. code-block:: bash salt '*' rbac.role_get leo
def role_get(user): ''' List roles for user user : string username CLI Example: .. code-block:: bash salt '*' rbac.role_get leo ''' user_roles = [] ## read user_attr file (user:qualifier:res1:res2:attr) with salt.utils.files.fopen('/etc/user_attr', 'r') as user_a...
Add role to user user : string username role : string role name CLI Example: .. code-block:: bash salt '*' rbac.role_add martine netcfg salt '*' rbac.role_add martine netcfg,zfssnap
def role_add(user, role): ''' Add role to user user : string username role : string role name CLI Example: .. code-block:: bash salt '*' rbac.role_add martine netcfg salt '*' rbac.role_add martine netcfg,zfssnap ''' ret = {} ## validate roles ...
List all available authorization CLI Example: .. code-block:: bash salt '*' rbac.auth_list
def auth_list(): ''' List all available authorization CLI Example: .. code-block:: bash salt '*' rbac.auth_list ''' auths = {} ## read auth_attr file (name:res1:res2:short_desc:long_desc:attr) with salt.utils.files.fopen('/etc/security/auth_attr', 'r') as auth_attr: f...
List authorization for user user : string username computed : boolean merge results from `auths` command into data from user_attr CLI Example: .. code-block:: bash salt '*' rbac.auth_get leo
def auth_get(user, computed=True): ''' List authorization for user user : string username computed : boolean merge results from `auths` command into data from user_attr CLI Example: .. code-block:: bash salt '*' rbac.auth_get leo ''' user_auths = [] ## re...
Add authorization to user user : string username auth : string authorization name CLI Example: .. code-block:: bash salt '*' rbac.auth_add martine solaris.zone.manage salt '*' rbac.auth_add martine solaris.zone.manage,solaris.mail.mailq
def auth_add(user, auth): ''' Add authorization to user user : string username auth : string authorization name CLI Example: .. code-block:: bash salt '*' rbac.auth_add martine solaris.zone.manage salt '*' rbac.auth_add martine solaris.zone.manage,solaris.mail...
Manage the configuration of a specific policy term. filter_name The name of the policy filter. term_name The name of the term. filter_options Additional filter options. These options are platform-specific. See the complete list of options_. .. _options: https://gi...
def term(name, filter_name, term_name, filter_options=None, pillar_key='acl', pillarenv=None, saltenv=None, merge_pillar=False, revision_id=None, revision_no=None, revision_date=True, revision_date_format='%Y/%m/%d', ...
Get current system keyboard setting CLI Example: .. code-block:: bash salt '*' keyboard.get_sys
def get_sys(): ''' Get current system keyboard setting CLI Example: .. code-block:: bash salt '*' keyboard.get_sys ''' cmd = '' if salt.utils.path.which('localectl'): cmd = 'localectl | grep Keymap | sed -e"s/: /=/" -e"s/^[ \t]*//"' elif 'RedHat' in __grains__['os_fami...
Set current system keyboard setting CLI Example: .. code-block:: bash salt '*' keyboard.set_sys dvorak
def set_sys(layout): ''' Set current system keyboard setting CLI Example: .. code-block:: bash salt '*' keyboard.set_sys dvorak ''' if salt.utils.path.which('localectl'): __salt__['cmd.run']('localectl set-keymap {0}'.format(layout)) elif 'RedHat' in __grains__['os_family'...
Generate a secure password.
def secure_password(length=20, use_random=True): ''' Generate a secure password. ''' try: length = int(length) pw = '' while len(pw) < length: if HAS_RANDOM and use_random: while True: try: char = salt.utils....
Generate /etc/shadow hash
def gen_hash(crypt_salt=None, password=None, algorithm='sha512'): ''' Generate /etc/shadow hash ''' if not HAS_CRYPT: raise SaltInvocationError('No crypt module for windows') hash_algorithms = dict( md5='$1$', blowfish='$2a$', sha256='$5$', sha512='$6$' ) if algorithm not in...
Jenkins One-At-A-Time Hash Function More Info: http://en.wikipedia.org/wiki/Jenkins_hash_function#one-at-a-time
def _get_hash(): ''' Jenkins One-At-A-Time Hash Function More Info: http://en.wikipedia.org/wiki/Jenkins_hash_function#one-at-a-time ''' # Using bitmask to emulate rollover behavior of C unsigned 32 bit int bitmask = 0xffffffff h = 0 for i in bytearray(salt.utils.stringutils.to_bytes(__...
Splay a salt function call execution time across minions over a number of seconds (default: 300) .. note:: You *probably* want to use --async here and look up the job results later. If you're dead set on getting the output from the CLI command, then make sure to set the timeout (with th...
def execute(opts, data, func, args, kwargs): ''' Splay a salt function call execution time across minions over a number of seconds (default: 300) .. note:: You *probably* want to use --async here and look up the job results later. If you're dead set on getting the output from the CLI co...
Ensure that the named index is absent. name Name of the index to remove
def absent(name): ''' Ensure that the named index is absent. name Name of the index to remove ''' ret = {'name': name, 'changes': {}, 'result': True, 'comment': ''} try: index = __salt__['elasticsearch.index_get'](index=name) if index and name in index: if ...
.. versionadded:: 2015.8.0 .. versionchanged:: 2017.3.0 Marked ``definition`` as optional. Ensure that the named index is present. name Name of the index to add definition Optional dict for creation parameters as per https://www.elastic.co/guide/en/elasticsearch/reference/curr...
def present(name, definition=None): ''' .. versionadded:: 2015.8.0 .. versionchanged:: 2017.3.0 Marked ``definition`` as optional. Ensure that the named index is present. name Name of the index to add definition Optional dict for creation parameters as per https://www....
Return full path to service command .. versionchanged:: 2016.3.4 Support for jail (representing jid or jail name) keyword argument in kwargs
def _cmd(jail=None): ''' Return full path to service command .. versionchanged:: 2016.3.4 Support for jail (representing jid or jail name) keyword argument in kwargs ''' service = salt.utils.path.which('service') if not service: raise CommandNotFoundError('\'service\' command not f...
.. versionadded:: 2016.3.4 Return the jail's root directory (path) as shown in jls jail The jid or jail name
def _get_jail_path(jail): ''' .. versionadded:: 2016.3.4 Return the jail's root directory (path) as shown in jls jail The jid or jail name ''' jls = salt.utils.path.which('jls') if not jls: raise CommandNotFoundError('\'jls\' command not found') jails = __salt__['cmd.ru...
Return full path to service rc script .. versionchanged:: 2016.3.4 Support for jail (representing jid or jail name) keyword argument in kwargs
def _get_rcscript(name, jail=None): ''' Return full path to service rc script .. versionchanged:: 2016.3.4 Support for jail (representing jid or jail name) keyword argument in kwargs ''' cmd = '{0} -r'.format(_cmd(jail)) prf = _get_jail_path(jail) if jail else '' for line in __salt__['...
Return rcvar .. versionchanged:: 2016.3.4 Support for jail (representing jid or jail name) keyword argument in kwargs
def _get_rcvar(name, jail=None): ''' Return rcvar .. versionchanged:: 2016.3.4 Support for jail (representing jid or jail name) keyword argument in kwargs ''' if not available(name, jail): log.error('Service %s not found', name) return False cmd = '{0} {1} rcvar'.format(_c...
Return what services are set to run on boot .. versionchanged:: 2016.3.4 Support for jail (representing jid or jail name) keyword argument in kwargs CLI Example: .. code-block:: bash salt '*' service.get_enabled
def get_enabled(jail=None): ''' Return what services are set to run on boot .. versionchanged:: 2016.3.4 Support for jail (representing jid or jail name) keyword argument in kwargs CLI Example: .. code-block:: bash salt '*' service.get_enabled ''' ret = [] service = _cmd...
Return what services are available but not enabled to start at boot .. versionchanged:: 2016.3.4 Support for jail (representing jid or jail name) keyword argument in kwargs CLI Example: .. code-block:: bash salt '*' service.get_disabled
def get_disabled(jail=None): ''' Return what services are available but not enabled to start at boot .. versionchanged:: 2016.3.4 Support for jail (representing jid or jail name) keyword argument in kwargs CLI Example: .. code-block:: bash salt '*' service.get_disabled ''' e...
Switch on/off service start at boot. .. versionchanged:: 2016.3.4 Support for jail (representing jid or jail name) and chroot keyword argument in kwargs. chroot should be used when jail's /etc is mounted read-only and should point to a root directory where jail's /etc is mounted read-write.
def _switch(name, # pylint: disable=C0103 on, # pylint: disable=C0103 **kwargs): ''' Switch on/off service start at boot. .. versionchanged:: 2016.3.4 Support for jail (representing jid or jail name) and chroot keyword argument in kwarg...
Return True if the named service is enabled, false otherwise name Service name .. versionchanged:: 2016.3.4 Support for jail (representing jid or jail name) keyword argument in kwargs CLI Example: .. code-block:: bash salt '*' service.enabled <service name>
def enabled(name, **kwargs): ''' Return True if the named service is enabled, false otherwise name Service name .. versionchanged:: 2016.3.4 Support for jail (representing jid or jail name) keyword argument in kwargs CLI Example: .. code-block:: bash salt '*' service.en...
Return a list of all available services .. versionchanged:: 2016.3.4 jail: optional jid or jail name CLI Example: .. code-block:: bash salt '*' service.get_all
def get_all(jail=None): ''' Return a list of all available services .. versionchanged:: 2016.3.4 jail: optional jid or jail name CLI Example: .. code-block:: bash salt '*' service.get_all ''' ret = [] service = _cmd(jail) for srv in __salt__['cmd.run']('{0} -l'.forma...
Start the specified service .. versionchanged:: 2016.3.4 jail: optional jid or jail name CLI Example: .. code-block:: bash salt '*' service.start <service name>
def start(name, jail=None): ''' Start the specified service .. versionchanged:: 2016.3.4 jail: optional jid or jail name CLI Example: .. code-block:: bash salt '*' service.start <service name> ''' cmd = '{0} {1} onestart'.format(_cmd(jail), name) return not __salt__['cmd...
Check to see if given python is installed.
def _python_installed(ret, python, user=None): ''' Check to see if given python is installed. ''' default = __salt__['pyenv.default'](runas=user) for version in __salt__['pyenv.versions'](user): if version == python: ret['result'] = True ret['comment'] = 'Requested py...
Verify that python is installed, install if unavailable
def _check_and_install_python(ret, python, default=False, user=None): ''' Verify that python is installed, install if unavailable ''' ret = _python_installed(ret, python, user=user) if not ret['result']: if __salt__['pyenv.install_python'](python, runas=user): ret['result'] = Tru...
Verify that the specified python is installed with pyenv. pyenv is installed if necessary. name The version of python to install default : False Whether to make this python the default. user: None The user to run pyenv as. .. versionadded:: 0.17.0 .. versionadded...
def installed(name, default=False, user=None): ''' Verify that the specified python is installed with pyenv. pyenv is installed if necessary. name The version of python to install default : False Whether to make this python the default. user: None The user to run pyenv...
Verify that python is uninstalled
def _check_and_uninstall_python(ret, python, user=None): ''' Verify that python is uninstalled ''' ret = _python_installed(ret, python, user=user) if ret['result']: if ret['default']: __salt__['pyenv.default']('system', runas=user) if __salt__['pyenv.uninstall_python'](p...
Verify that the specified python is not installed with pyenv. pyenv is installed if necessary. name The version of python to uninstall user: None The user to run pyenv as. .. versionadded:: 0.17.0 .. versionadded:: 0.16.0
def absent(name, user=None): ''' Verify that the specified python is not installed with pyenv. pyenv is installed if necessary. name The version of python to uninstall user: None The user to run pyenv as. .. versionadded:: 0.17.0 .. versionadded:: 0.16.0 ''' r...
Install pyenv if not installed. Allows you to require pyenv be installed prior to installing the plugins. Useful if you want to install pyenv plugins via the git or file modules and need them installed before installing any rubies. Use the pyenv.root configuration option to set the path for pyenv if yo...
def install_pyenv(name, user=None): ''' Install pyenv if not installed. Allows you to require pyenv be installed prior to installing the plugins. Useful if you want to install pyenv plugins via the git or file modules and need them installed before installing any rubies. Use the pyenv.root conf...
Send a message via SMTP .. code-block:: yaml server-warning-message: smtp.send_msg: - name: 'This is a server warning message' - profile: my-smtp-account - subject: 'Message from Salt' - recipient: admin@example.com - sender: admin@exam...
def send_msg(name, recipient, subject, sender=None, profile=None, use_ssl='True', attachments=None): ''' Send a message via SMTP .. code-block:: yaml server-warning-message: smtp.send_msg: - name: '...
Set answers to debconf questions for a package. CLI Example: .. code-block:: bash salt '*' debconf.set <package> <question> <type> <value> [<value> ...]
def set_(package, question, type, value, *extra): ''' Set answers to debconf questions for a package. CLI Example: .. code-block:: bash salt '*' debconf.set <package> <question> <type> <value> [<value> ...] ''' if extra: value = ' '.join((value,) + tuple(extra)) fd_, fna...
Answers to debconf questions for all packages in the following format:: {'package': [['question', 'type', 'value'], ...]} CLI Example: .. code-block:: bash salt '*' debconf.get_selections
def get_selections(fetchempty=True): ''' Answers to debconf questions for all packages in the following format:: {'package': [['question', 'type', 'value'], ...]} CLI Example: .. code-block:: bash salt '*' debconf.get_selections ''' selections = {} cmd = 'debconf-get-sele...
Set answers to debconf questions from a template. path location of the file containing the package selections template template format context variables to add to the template environment default default values for the template environment CLI Example: .. co...
def set_template(path, template, context, defaults, saltenv='base', **kwargs): ''' Set answers to debconf questions from a template. path location of the file containing the package selections template template format context variables to add to the template environment ...
Set answers to debconf questions from a file. CLI Example: .. code-block:: bash salt '*' debconf.set_file salt://pathto/pkg.selections
def set_file(path, saltenv='base', **kwargs): ''' Set answers to debconf questions from a file. CLI Example: .. code-block:: bash salt '*' debconf.set_file salt://pathto/pkg.selections ''' if '__env__' in kwargs: # "env" is not supported; Use "saltenv". kwargs.pop('__e...
Call both with prep_jid on all returners in multi_returner TODO: finish this, what do do when you get different jids from 2 returners... since our jids are time based, this make this problem hard, because they aren't unique, meaning that we have to make sure that no one else got the jid and if they did...
def prep_jid(nocache=False, passed_jid=None): ''' Call both with prep_jid on all returners in multi_returner TODO: finish this, what do do when you get different jids from 2 returners... since our jids are time based, this make this problem hard, because they aren't unique, meaning that we have to ...
Write return to all returners in multi_returner
def returner(load): ''' Write return to all returners in multi_returner ''' for returner_ in __opts__[CONFIG_KEY]: _mminion().returners['{0}.returner'.format(returner_)](load)
Write load to all returners in multi_returner
def save_load(jid, clear_load, minions=None): ''' Write load to all returners in multi_returner ''' for returner_ in __opts__[CONFIG_KEY]: _mminion().returners['{0}.save_load'.format(returner_)](jid, clear_load)
Merge the load data from all returners
def get_load(jid): ''' Merge the load data from all returners ''' ret = {} for returner_ in __opts__[CONFIG_KEY]: ret.update(_mminion().returners['{0}.get_load'.format(returner_)](jid)) return ret
Clean out the old jobs from all returners (if you have it)
def clean_old_jobs(): ''' Clean out the old jobs from all returners (if you have it) ''' for returner_ in __opts__[CONFIG_KEY]: fstr = '{0}.clean_old_jobs'.format(returner_) if fstr in _mminion().returners: _mminion().returners[fstr]()
Return all job data from all returners
def get_jids(): ''' Return all job data from all returners ''' ret = {} for returner_ in __opts__[CONFIG_KEY]: ret.update(_mminion().returners['{0}.get_jids'.format(returner_)]()) return ret