INSTRUCTION
stringlengths
1
8.43k
RESPONSE
stringlengths
75
104k
.. versionadded:: 2017. 7. 0
def fcontext_policy_applied(name, recursive=False): ''' .. versionadded:: 2017.7.0 Checks and makes sure the SELinux policies for a given filespec are applied. ''' ret = {'name': name, 'result': False, 'changes': {}, 'comment': ''} changes_text = __salt__['selinux.fcontext_policy_is_applie...
.. versionadded:: 2019. 2. 0
def port_policy_present(name, sel_type, protocol=None, port=None, sel_range=None): ''' .. versionadded:: 2019.2.0 Makes sure an SELinux port policy for a given port, protocol and SELinux context type is present. name The protocol and port spec. Can be formatted as ``(tcp|udp)/(port|port-range)...
.. versionadded:: 2019. 2. 0
def port_policy_absent(name, sel_type=None, protocol=None, port=None): ''' .. versionadded:: 2019.2.0 Makes sure an SELinux port policy for a given port, protocol and SELinux context type is absent. name The protocol and port spec. Can be formatted as ``(tcp|udp)/(port|port-range)``. sel_...
Ensure a value is set in an OpenStack configuration file.
def present(name, filename, section, value, parameter=None): ''' Ensure a value is set in an OpenStack configuration file. filename The full path to the configuration file section The section in which the parameter will be set parameter (optional) The parameter to change. ...
.. versionadded:: 2019. 2. 0
def availability_set_present(name, resource_group, tags=None, platform_update_domain_count=None, platform_fault_domain_count=None, virtual_machines=None, sku=None, connection_auth=None, **kwargs): ''' .. versionadded:: 2019.2.0 Ensure an availabilit...
.. versionadded:: 2019. 2. 0
def availability_set_absent(name, resource_group, connection_auth=None): ''' .. versionadded:: 2019.2.0 Ensure an availability set does not exist in a resource group. :param name: Name of the availability set. :param resource_group: Name of the resource group containing the availa...
Return Fibre Channel port WWNs from a Linux host.
def _linux_wwns(): ''' Return Fibre Channel port WWNs from a Linux host. ''' ret = [] for fc_file in glob.glob('/sys/class/fc_host/*/port_name'): with salt.utils.files.fopen(fc_file, 'r') as _wwn: content = _wwn.read() for line in content.splitlines(): ...
Return Fibre Channel port WWNs from a Windows host.
def _windows_wwns(): ''' Return Fibre Channel port WWNs from a Windows host. ''' ps_cmd = r'Get-WmiObject -ErrorAction Stop ' \ r'-class MSFC_FibrePortHBAAttributes ' \ r'-namespace "root\WMI" | ' \ r'Select -Expandproperty Attributes | ' \ r'%{($_.Por...
Return list of fiber channel HBA WWNs
def fibre_channel_wwns(): ''' Return list of fiber channel HBA WWNs ''' grains = {'fc_wwn': False} if salt.utils.platform.is_linux(): grains['fc_wwn'] = _linux_wwns() elif salt.utils.platform.is_windows(): grains['fc_wwn'] = _windows_wwns() return grains
Returns whether vsan is supported on the vCenter: api version needs to be 6 or higher
def vsan_supported(service_instance): ''' Returns whether vsan is supported on the vCenter: api version needs to be 6 or higher service_instance Service instance to the host or vCenter ''' try: api_version = service_instance.content.about.apiVersion except vim.fault.NoPe...
Returns a vim. cluster. VsanVcClusterConfigSystem object
def get_vsan_cluster_config_system(service_instance): ''' Returns a vim.cluster.VsanVcClusterConfigSystem object service_instance Service instance to the host or vCenter ''' #TODO Replace when better connection mechanism is available #For python 2.7.9 and later, the defaul SSL conext ...
Returns a host s vsan system
def get_host_vsan_system(service_instance, host_ref, hostname=None): ''' Returns a host's vsan system service_instance Service instance to the host or vCenter host_ref Refernce to ESXi host hostname Name of ESXi host. Default value is None. ''' if not hostname: ...
Creates a disk group
def create_diskgroup(service_instance, vsan_disk_mgmt_system, host_ref, cache_disk, capacity_disks): ''' Creates a disk group service_instance Service instance to the host or vCenter vsan_disk_mgmt_system vim.VimClusterVsanVcDiskManagemenetSystem representing the v...
Removes capacity disk ( s ) from a disk group.
def remove_capacity_from_diskgroup(service_instance, host_ref, diskgroup, capacity_disks, data_evacuation=True, hostname=None, host_vsan_system=None): ''' Removes capacity disk(s) from a disk group. ser...
Removes a disk group.
def remove_diskgroup(service_instance, host_ref, diskgroup, hostname=None, host_vsan_system=None, erase_disk_partitions=False, data_accessibility=True): ''' Removes a disk group. service_instance Service instance to the host or vCenter host_ref ...
Returns the extended cluster vsan configuration object ( vim. VsanConfigInfoEx ).
def get_cluster_vsan_info(cluster_ref): ''' Returns the extended cluster vsan configuration object (vim.VsanConfigInfoEx). cluster_ref Reference to the cluster ''' cluster_name = salt.utils.vmware.get_managed_object_name(cluster_ref) log.trace('Retrieving cluster vsan info of clust...
Reconfigures the VSAN system of a cluster.
def reconfigure_cluster_vsan(cluster_ref, cluster_vsan_spec): ''' Reconfigures the VSAN system of a cluster. cluster_ref Reference to the cluster cluster_vsan_spec Cluster VSAN reconfigure spec (vim.vsan.ReconfigSpec). ''' cluster_name = salt.utils.vmware.get_managed_object_nam...
Wait for tasks created via the VSAN API
def _wait_for_tasks(tasks, service_instance): ''' Wait for tasks created via the VSAN API ''' log.trace('Waiting for vsan tasks: {0}', ', '.join([six.text_type(t) for t in tasks])) try: vsanapiutils.WaitForTasks(tasks, service_instance) except vim.fault.NoPermission as exc:...
.. versionadded:: 2017. 7. 0
def decrypt(data, rend, translate_newlines=False, renderers=None, opts=None, valid_rend=None): ''' .. versionadded:: 2017.7.0 Decrypt a data structure using the specified renderer. Written originally as a common codebase to handle decryption o...
Pass in either a raw pem string or the path on disk to the location of a pem file and the type of cryptographic hash to use. The default is SHA256. The fingerprint of the pem will be returned.
def pem_finger(path=None, key=None, sum_type='sha256'): ''' Pass in either a raw pem string, or the path on disk to the location of a pem file, and the type of cryptographic hash to use. The default is SHA256. The fingerprint of the pem will be returned. If neither a key nor a path are passed in, a...
Return the argname value looking up on all possible attributes
def _get_argname_value(self, argname): ''' Return the argname value looking up on all possible attributes ''' # Let's see if there's a private function to get the value argvalue = getattr(self, '__get_{0}__'.format(argname), None) if argvalue is not None and callable(argv...
Return a serializable form of the config instance
def serialize(self): ''' Return a serializable form of the config instance ''' serialized = {'type': self.__type__} for argname in self._attributes: if argname == 'required': # This is handled elsewhere continue argvalue = s...
Adds any missed schema attributes to the _attributes list
def _add_missing_schema_attributes(self): ''' Adds any missed schema attributes to the _attributes list The attributes can be class attributes and they won't be included in the _attributes list automatically ''' for attr in [attr for attr in dir(self) if not attr.startsw...
Returns the definition of the complex item
def get_definition(self): '''Returns the definition of the complex item''' serialized = super(ComplexSchemaItem, self).serialize() # Adjust entries in the serialization del serialized['definition_name'] serialized['title'] = self.definition_name properties = {} ...
Returns a dictionary of the complex attributes
def get_complex_attrs(self): '''Returns a dictionary of the complex attributes''' return [getattr(self, attr_name) for attr_name in self._attributes if isinstance(getattr(self, attr_name), ComplexSchemaItem)]
Check to see if an RDS exists.
def exists(name, tags=None, region=None, key=None, keyid=None, profile=None): ''' Check to see if an RDS exists. CLI example:: salt myminion boto_rds.exists myrds region=us-east-1 ''' conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile) try: rds = conn.descri...
Check to see if an RDS option group exists.
def option_group_exists(name, tags=None, region=None, key=None, keyid=None, profile=None): ''' Check to see if an RDS option group exists. CLI example:: salt myminion boto_rds.option_group_exists myoptiongr region=us-east-1 ''' conn = _get_conn(region=region, key=ke...
Check to see if an RDS parameter group exists.
def parameter_group_exists(name, tags=None, region=None, key=None, keyid=None, profile=None): ''' Check to see if an RDS parameter group exists. CLI example:: salt myminion boto_rds.parameter_group_exists myparametergroup \ region=us-east-1 ''' co...
Check to see if an RDS subnet group exists.
def subnet_group_exists(name, tags=None, region=None, key=None, keyid=None, profile=None): ''' Check to see if an RDS subnet group exists. CLI example:: salt myminion boto_rds.subnet_group_exists my-param-group \ region=us-east-1 ''' try: con...
Create an RDS Instance
def create(name, allocated_storage, db_instance_class, engine, master_username, master_user_password, db_name=None, db_security_groups=None, vpc_security_group_ids=None, vpc_security_groups=None, availability_zone=None, db_subnet_group_name=None, preferred_maintenance_window=...
Create an RDS read replica
def create_read_replica(name, source_name, db_instance_class=None, availability_zone=None, port=None, auto_minor_version_upgrade=None, iops=None, option_group_name=None, publicly_accessible=None, tags=None, db_subnet_group_n...
Create an RDS option group
def create_option_group(name, engine_name, major_engine_version, option_group_description, tags=None, region=None, key=None, keyid=None, profile=None): ''' Create an RDS option group CLI example to create an RDS option group:: salt myminion boto_rds....
Create an RDS parameter group
def create_parameter_group(name, db_parameter_group_family, description, tags=None, region=None, key=None, keyid=None, profile=None): ''' Create an RDS parameter group CLI example to create an RDS parameter group:: salt myminion boto_rds.create...
Create an RDS subnet group
def create_subnet_group(name, description, subnet_ids, tags=None, region=None, key=None, keyid=None, profile=None): ''' Create an RDS subnet group CLI example to create an RDS subnet group:: salt myminion boto_rds.create_subnet_group my-subnet-group \ "group des...
Update an RDS parameter group.
def update_parameter_group(name, parameters, apply_method="pending-reboot", tags=None, region=None, key=None, keyid=None, profile=None): ''' Update an RDS parameter group. CLI example:: salt myminion boto_rds.update_parameter_group my-param-gro...
Return RDS instance details.
def describe(name, tags=None, region=None, key=None, keyid=None, profile=None): ''' Return RDS instance details. CLI example:: salt myminion boto_rds.describe myrds ''' res = __salt__['boto_rds.exists'](name, tags, region, key, keyid, pro...
Return a detailed listing of some or all DB Instances visible in the current scope. Arbitrary subelements or subsections of the returned dataset can be selected by passing in a valid JMSEPath filter as well.
def describe_db_instances(name=None, filters=None, jmespath='DBInstances', region=None, key=None, keyid=None, profile=None): ''' Return a detailed listing of some, or all, DB Instances visible in the current scope. Arbitrary subelements or subsections of the returned dataset c...
Return a detailed listing of some or all DB Subnet Groups visible in the current scope. Arbitrary subelements or subsections of the returned dataset can be selected by passing in a valid JMSEPath filter as well.
def describe_db_subnet_groups(name=None, filters=None, jmespath='DBSubnetGroups', region=None, key=None, keyid=None, profile=None): ''' Return a detailed listing of some, or all, DB Subnet Groups visible in the current scope. Arbitrary subelements or subsections of the returne...
Return the endpoint of an RDS instance.
def get_endpoint(name, tags=None, region=None, key=None, keyid=None, profile=None): ''' Return the endpoint of an RDS instance. CLI example:: salt myminion boto_rds.get_endpoint myrds ''' endpoint = False res = __salt__['boto_rds.exists'](name, tags, region, key, keyi...
Delete an RDS instance.
def delete(name, skip_final_snapshot=None, final_db_snapshot_identifier=None, region=None, key=None, keyid=None, profile=None, tags=None, wait_for_deletion=True, timeout=180): ''' Delete an RDS instance. CLI example:: salt myminion boto_rds.delete myrds skip_final_snapshot=Tr...
Delete an RDS option group.
def delete_option_group(name, region=None, key=None, keyid=None, profile=None): ''' Delete an RDS option group. CLI example:: salt myminion boto_rds.delete_option_group my-opt-group \ region=us-east-1 ''' try: conn = _get_conn(region=region, key=key, keyid=keyid, pr...
Delete an RDS parameter group.
def delete_parameter_group(name, region=None, key=None, keyid=None, profile=None): ''' Delete an RDS parameter group. CLI example:: salt myminion boto_rds.delete_parameter_group my-param-group \ region=us-east-1 ''' try: conn = _get_conn(r...
Delete an RDS subnet group.
def delete_subnet_group(name, region=None, key=None, keyid=None, profile=None): ''' Delete an RDS subnet group. CLI example:: salt myminion boto_rds.delete_subnet_group my-subnet-group \ region=us-east-1 ''' try: conn = _get_conn(region=regio...
Returns a list of DBParameterGroup descriptions. CLI example to description of parameter group::
def describe_parameter_group(name, Filters=None, MaxRecords=None, Marker=None, region=None, key=None, keyid=None, profile=None): ''' Returns a list of `DBParameterGroup` descriptions. CLI example to description of parameter group:: salt myminion boto_rds.describe_parame...
Returns a list of DBParameterGroup parameters. CLI example to description of parameters::
def describe_parameters(name, Source=None, MaxRecords=None, Marker=None, region=None, key=None, keyid=None, profile=None): ''' Returns a list of `DBParameterGroup` parameters. CLI example to description of parameters :: salt myminion boto_rds.describe_parameters parametergro...
Modify settings for a DB instance. CLI example to description of parameters::
def modify_db_instance(name, allocated_storage=None, allow_major_version_upgrade=None, apply_immediately=None, auto_minor_version_upgrade=None, backup_retention_period=None, ca_certi...
Monitor the temperature humidity and pressure using the SenseHat sensors.
def beacon(config): ''' Monitor the temperature, humidity and pressure using the SenseHat sensors. You can either specify a threshold for each value and only emit a beacon if it is exceeded or define a range and emit a beacon when the value is out of range. Units: * humidity: ...
Creates Nova flavor if it does not exist
def flavor_present(name, params=None, **kwargs): ''' Creates Nova flavor if it does not exist :param name: Flavor name :param params: Definition of the Flavor (see Compute API documentation) .. code-block:: yaml nova-flavor-present: nova.flavor_present: - name:...
Grants access of the flavor to a project. Flavor must be private.
def flavor_access_list(name, projects, **kwargs): ''' Grants access of the flavor to a project. Flavor must be private. :param name: non-public flavor name :param projects: list of projects which should have the access to the flavor .. code-block:: yaml nova-flavor-share: nova...
Makes flavor to be absent
def flavor_absent(name, **kwargs): ''' Makes flavor to be absent :param name: flavor name .. code-block:: yaml nova-flavor-absent: nova.flavor_absent: - name: flavor_name ''' dry_run = __opts__['test'] ret = {'name': name, 'result': False, 'comment': ''...
This is a compatibility matcher and is NOT called when using nodegroups for remote execution but is called when the nodegroups matcher is used in states
def match(tgt, nodegroups=None, opts=None): ''' This is a compatibility matcher and is NOT called when using nodegroups for remote execution, but is called when the nodegroups matcher is used in states ''' if not opts: opts = __opts__ if not nodegroups: log.debug('Nodegroup m...
Ensure the existence ( or not ) of LDAP entries and their attributes
def managed(name, entries, connect_spec=None): '''Ensure the existence (or not) of LDAP entries and their attributes Example: .. code-block:: yaml ldapi:///: ldap.managed: - connect_spec: bind: method: sasl - entries: ...
Helper for managed () to process entries and return before/ after views
def _process_entries(l, entries): '''Helper for managed() to process entries and return before/after views Collect the current database state and update it according to the data in :py:func:`managed`'s ``entries`` parameter. Return the current database state and what it will look like after modifi...
Update an entry s attributes using the provided directives
def _update_entry(entry, status, directives): '''Update an entry's attributes using the provided directives :param entry: A dict mapping each attribute name to a set of its values :param status: A dict holding cross-invocation status (whether delete_others is True or not, and the se...
helper to convert various things to a set
def _toset(thing): '''helper to convert various things to a set This enables flexibility in what users provide as the list of LDAP entry attribute values. Note that the LDAP spec prohibits duplicate values in an attribute. RFC 2251 states that: "The order of attribute values within the vals s...
Return information for the specified user
def info(name, root=None): ''' Return information for the specified user name User to get the information for root Directory to chroot into CLI Example: .. code-block:: bash salt '*' shadow.info root ''' if root is not None: getspnam = functools.parti...
Set a parameter in/ etc/ shadow
def _set_attrib(name, key, value, param, root=None, validate=True): ''' Set a parameter in /etc/shadow ''' pre_info = info(name, root=root) # If the user is not present or the attribute is already present, # we return early if not pre_info['name']: return False if value == pre_...
.. versionadded:: 2014. 7. 0
def gen_password(password, crypt_salt=None, algorithm='sha512'): ''' .. versionadded:: 2014.7.0 Generate hashed password .. note:: When called this function is called directly via remote-execution, the password argument may be displayed in the system's process list. This may b...
.. versionadded:: 2014. 7. 0
def del_password(name, root=None): ''' .. versionadded:: 2014.7.0 Delete the password from name user name User to delete root Directory to chroot into CLI Example: .. code-block:: bash salt '*' shadow.del_password username ''' cmd = ['passwd'] if roo...
.. versionadded:: 2016. 11. 0
def unlock_password(name, root=None): ''' .. versionadded:: 2016.11.0 Unlock the password from name user name User to unlock root Directory to chroot into CLI Example: .. code-block:: bash salt '*' shadow.unlock_password username ''' pre_info = info(name...
Set the password for a named user. The password must be a properly defined hash. The password hash can be generated with this command:
def set_password(name, password, use_usermod=False, root=None): ''' Set the password for a named user. The password must be a properly defined hash. The password hash can be generated with this command: ``python -c "import crypt; print crypt.crypt('password', '\\$6\\$SALTsalt')"`` ``SALTsalt``...
Sets the value for the date the password was last changed to days since the epoch ( January 1 1970 ). See man chage.
def set_date(name, date, root=None): ''' Sets the value for the date the password was last changed to days since the epoch (January 1, 1970). See man chage. name User to modify date Date the password was last changed root Directory to chroot into CLI Example: ...
.. versionchanged:: 2014. 7. 0
def set_expire(name, expire, root=None): ''' .. versionchanged:: 2014.7.0 Sets the value for the date the account expires as days since the epoch (January 1, 1970). Using a value of -1 will clear expiration. See man chage. name User to modify date Date the account expires ...
.. versionadded:: 2018. 3. 0
def list_users(root=None): ''' .. versionadded:: 2018.3.0 Return a list of all shadow users root Directory to chroot into CLI Example: .. code-block:: bash salt '*' shadow.list_users ''' if root is not None: getspall = functools.partial(_getspall, root=root) ...
Alternative implementation for getspnam that use only/ etc/ shadow
def _getspnam(name, root=None): ''' Alternative implementation for getspnam, that use only /etc/shadow ''' root = '/' if not root else root passwd = os.path.join(root, 'etc/shadow') with salt.utils.files.fopen(passwd) as fp_: for line in fp_: line = salt.utils.stringutils.to_...
With boto route53 zones can only be matched by name or iterated over in a list. Since the name will be the same for public and private zones in a split DNS situation iterate over the list and match the zone name and public/ private status.
def _get_split_zone(zone, _conn, private_zone): ''' With boto route53, zones can only be matched by name or iterated over in a list. Since the name will be the same for public and private zones in a split DNS situation, iterate over the list and match the zone name and public/private status. ...
Return detailed info about one or all zones in the bound account. If neither zone_id nor domain_name is provided return all zones. Note that the return format is slightly different between the all and single description types.
def describe_hosted_zones(zone_id=None, domain_name=None, region=None, key=None, keyid=None, profile=None): ''' Return detailed info about one, or all, zones in the bound account. If neither zone_id nor domain_name is provided, return all zones. Note that the return format is s...
List by their FQDNs all hosted zones in the bound account.
def list_all_zones_by_name(region=None, key=None, keyid=None, profile=None): ''' List, by their FQDNs, all hosted zones in the bound account. region Region to connect to. key Secret key to be used. keyid Access key to be used. profile A dict with region, key a...
List by their IDs all hosted zones in the bound account.
def list_all_zones_by_id(region=None, key=None, keyid=None, profile=None): ''' List, by their IDs, all hosted zones in the bound account. region Region to connect to. key Secret key to be used. keyid Access key to be used. profile A dict with region, key and k...
Check for the existence of a Route53 hosted zone.
def zone_exists(zone, region=None, key=None, keyid=None, profile=None, retry_on_rate_limit=None, rate_limit_retries=None, retry_on_errors=True, error_retries=5): ''' Check for the existence of a Route53 hosted zone. .. versionadded:: 2015.8.0 CLI Example:: salt...
Create a Route53 hosted zone.
def create_zone(zone, private=False, vpc_id=None, vpc_region=None, region=None, key=None, keyid=None, profile=None): ''' Create a Route53 hosted zone. .. versionadded:: 2015.8.0 zone DNS zone to create private True/False if the zone will be a private zone vpc_...
Create a Route53 healthcheck
def create_healthcheck(ip_addr=None, fqdn=None, region=None, key=None, keyid=None, profile=None, port=53, hc_type='TCP', resource_path='', string_match=None, request_interval=30, failure_threshold=3, retry_on_errors=True, error_retries=5): ''' Create a Route53 healthc...
Delete a Route53 hosted zone.
def delete_zone(zone, region=None, key=None, keyid=None, profile=None): ''' Delete a Route53 hosted zone. .. versionadded:: 2015.8.0 CLI Example:: salt myminion boto_route53.delete_zone example.org ''' if region is None: region = 'universal' conn = _get_conn(region=region...
Get a record from a zone.
def get_record(name, zone, record_type, fetch_all=False, region=None, key=None, keyid=None, profile=None, split_dns=False, private_zone=False, identifier=None, retry_on_rate_limit=None, rate_limit_retries=None, retry_on_errors=True, error_retries=5): ''' Get a record...
Modify a record in a zone.
def delete_record(name, zone, record_type, identifier=None, all_records=False, region=None, key=None, keyid=None, profile=None, wait_for_sync=True, split_dns=False, private_zone=False, retry_on_rate_limit=None, rate_limit_retries=None, retry_on_err...
Create a new Route53 Hosted Zone. Returns a Python data structure with information about the newly created Hosted Zone.
def create_hosted_zone(domain_name, caller_ref=None, comment='', private_zone=False, vpc_id=None, vpc_name=None, vpc_region=None, region=None, key=None, keyid=None, profile=None): ''' Create a new Route53 Hosted Zone. Returns a Python data structure with information...
Fetch secret from pass based on pass_path. If there is any error return back the original pass_path value
def _fetch_secret(pass_path): ''' Fetch secret from pass based on pass_path. If there is any error, return back the original pass_path value ''' cmd = "pass show {0}".format(pass_path.strip()) log.debug('Fetching secret: %s', cmd) proc = Popen(cmd.split(' '), stdout=PIPE, stderr=PIPE) p...
Recursively try to find a pass path ( string ) that can be handed off to pass
def _decrypt_object(obj): ''' Recursively try to find a pass path (string) that can be handed off to pass ''' if isinstance(obj, six.string_types): return _fetch_secret(obj) elif isinstance(obj, dict): for pass_key, pass_path in six.iteritems(obj): obj[pass_key] = _decryp...
Fetch secret from pass based on pass_path
def render(pass_info, saltenv='base', sls='', argline='', **kwargs): ''' Fetch secret from pass based on pass_path ''' try: _get_pass_exec() except SaltRenderError: raise # Make sure environment variable HOME is set, since Pass looks for the # password-store under ~/.passwor...
Show list of available pkg upgrades using a specified format style
def list_upgrades(jid, style='group', outputter='nested', ext_source=None): ''' Show list of available pkg upgrades using a specified format style CLI Example: .. code-block:: bash salt-run pkg.list_upgrades jid=20141120114114417719 style=...
Return the firewall - cmd location
def __firewall_cmd(cmd): ''' Return the firewall-cmd location ''' firewall_cmd = '{0} {1}'.format(salt.utils.path.which('firewall-cmd'), cmd) out = __salt__['cmd.run_all'](firewall_cmd) if out['retcode'] != 0: if not out['stderr']: msg = out['stdout'] else: ...
Perform zone management
def __mgmt(name, _type, action): ''' Perform zone management ''' # It's permanent because the 4 concerned functions need the permanent option, it's wrong without cmd = '--{0}-{1}={2} --permanent'.format(action, _type, name) return __firewall_cmd(cmd)
List everything added for or enabled in all zones
def list_zones(permanent=True): ''' List everything added for or enabled in all zones CLI Example: .. code-block:: bash salt '*' firewalld.list_zones ''' zones = {} cmd = '--list-all-zones' if permanent: cmd += ' --permanent' for i in __firewall_cmd(cmd).splitli...
Add a new zone
def new_zone(zone, restart=True): ''' Add a new zone CLI Example: .. code-block:: bash salt '*' firewalld.new_zone my_zone By default firewalld will be reloaded. However, to avoid reloading you need to specify the restart as False .. code-block:: bash salt '*' firewalld...
Delete an existing zone
def delete_zone(zone, restart=True): ''' Delete an existing zone CLI Example: .. code-block:: bash salt '*' firewalld.delete_zone my_zone By default firewalld will be reloaded. However, to avoid reloading you need to specify the restart as False .. code-block:: bash sal...
Add a new service
def new_service(name, restart=True): ''' Add a new service CLI Example: .. code-block:: bash salt '*' firewalld.new_service my_service By default firewalld will be reloaded. However, to avoid reloading you need to specify the restart as False .. code-block:: bash salt '...
Delete an existing service
def delete_service(name, restart=True): ''' Delete an existing service CLI Example: .. code-block:: bash salt '*' firewalld.delete_service my_service By default firewalld will be reloaded. However, to avoid reloading you need to specify the restart as False .. code-block:: bash ...
List everything added for or enabled in a zone
def list_all(zone=None, permanent=True): ''' List everything added for or enabled in a zone CLI Example: .. code-block:: bash salt '*' firewalld.list_all List a specific zone .. code-block:: bash salt '*' firewalld.list_all my_zone ''' _zone = {} id_ = '' i...
List services added for zone as a space separated list. If zone is omitted default zone will be used.
def list_services(zone=None, permanent=True): ''' List services added for zone as a space separated list. If zone is omitted, default zone will be used. CLI Example: .. code-block:: bash salt '*' firewalld.list_services List a specific zone .. code-block:: bash salt '*'...
Add a service for zone. If zone is omitted default zone will be used.
def add_service(service, zone=None, permanent=True): ''' Add a service for zone. If zone is omitted, default zone will be used. CLI Example: .. code-block:: bash salt '*' firewalld.add_service ssh To assign a service to a specific zone: .. code-block:: bash salt '*' firewal...
Remove a service from zone. This option can be specified multiple times. If zone is omitted default zone will be used.
def remove_service(service, zone=None, permanent=True): ''' Remove a service from zone. This option can be specified multiple times. If zone is omitted, default zone will be used. CLI Example: .. code-block:: bash salt '*' firewalld.remove_service ssh To remove a service from a speci...
Add a new port to the specified service.
def add_service_port(service, port): ''' Add a new port to the specified service. .. versionadded:: 2016.11.0 CLI Example: .. code-block:: bash salt '*' firewalld.add_service_port zone 80 ''' if service not in get_services(permanent=True): raise CommandExecutionError('The...
Show if masquerading is enabled on a zone. If zone is omitted default zone will be used.
def get_masquerade(zone=None, permanent=True): ''' Show if masquerading is enabled on a zone. If zone is omitted, default zone will be used. CLI Example: .. code-block:: bash salt '*' firewalld.get_masquerade zone ''' zone_info = list_all(zone, permanent) if 'no' in [zone_inf...
Enable masquerade on a zone. If zone is omitted default zone will be used.
def add_masquerade(zone=None, permanent=True): ''' Enable masquerade on a zone. If zone is omitted, default zone will be used. .. versionadded:: 2015.8.0 CLI Example: .. code-block:: bash salt '*' firewalld.add_masquerade To enable masquerade on a specific zone .. code-bloc...
Remove masquerade on a zone. If zone is omitted default zone will be used.
def remove_masquerade(zone=None, permanent=True): ''' Remove masquerade on a zone. If zone is omitted, default zone will be used. .. versionadded:: 2015.8.0 CLI Example: .. code-block:: bash salt '*' firewalld.remove_masquerade To remove masquerade on a specific zone .. cod...
Allow specific ports in a zone.
def add_port(zone, port, permanent=True): ''' Allow specific ports in a zone. .. versionadded:: 2015.8.0 CLI Example: .. code-block:: bash salt '*' firewalld.add_port internal 443/tcp ''' cmd = '--zone={0} --add-port={1}'.format(zone, port) if permanent: cmd += ' --p...
Remove a specific port from a zone.
def remove_port(zone, port, permanent=True): ''' Remove a specific port from a zone. .. versionadded:: 2015.8.0 CLI Example: .. code-block:: bash salt '*' firewalld.remove_port internal 443/tcp ''' cmd = '--zone={0} --remove-port={1}'.format(zone, port) if permanent: ...
List all ports in a zone.
def list_ports(zone, permanent=True): ''' List all ports in a zone. .. versionadded:: 2015.8.0 CLI Example: .. code-block:: bash salt '*' firewalld.list_ports ''' cmd = '--zone={0} --list-ports'.format(zone) if permanent: cmd += ' --permanent' return __firewall_...
Add port forwarding.
def add_port_fwd(zone, src, dest, proto='tcp', dstaddr='', permanent=True): ''' Add port forwarding. .. versionadded:: 2015.8.0 CLI Example: .. code-block:: bash salt '*' firewalld.add_port_fwd public 80 443 tcp ''' cmd = '--zone={0} --add-forward-port=port={1}:proto={2}:toport={...
List port forwarding
def list_port_fwd(zone, permanent=True): ''' List port forwarding .. versionadded:: 2015.8.0 CLI Example: .. code-block:: bash salt '*' firewalld.list_port_fwd public ''' ret = [] cmd = '--zone={0} --list-forward-ports'.format(zone) if permanent: cmd += ' --perm...