text
stringlengths
81
112k
Get the IPGrant list for the SMTP virtual server. :param bool as_wmi_format: Returns the connection IPs as a list in the format WMI expects. :param str server: The SMTP server name. :return: A dictionary of the IP and subnet pairs. :rtype: dict CLI Example: .. code-block:: bash salt...
Set the IPGrant list for the SMTP virtual server. :param str addresses: A dictionary of IP + subnet pairs. :param bool grant_by_default: Whether the addresses should be a blacklist or whitelist. :param str server: The SMTP server name. :return: A boolean representing whether the change succeeded. ...
Get the RelayIpList list for the SMTP virtual server. :param str server: The SMTP server name. :return: A list of the relay IPs. :rtype: list .. note:: A return value of None corresponds to the restrictive 'Only the list below' GUI parameter with an empty access list, and setting an ...
Set the RelayIpList list for the SMTP virtual server. Due to the unusual way that Windows stores the relay IPs, it is advisable to retrieve the existing list you wish to set from a pre-configured server. For example, setting '127.0.0.1' as an allowed relay IP through the GUI would generate an actual r...
Prepare the connection with the remote network device, and clean up the key value pairs, removing the args used for the connection init. def _prepare_connection(**kwargs): ''' Prepare the connection with the remote network device, and clean up the key value pairs, removing the args used for the connect...
Invoke multiple Netmiko methods at once, and return their output, as list. methods A list of dictionaries with the following keys: - ``name``: the name of the Netmiko method to be executed. - ``args``: list of arguments to be sent to the Netmiko method. - ``kwargs``: dictionary of ...
Send configuration commands down the SSH channel. Return the configuration lines sent to the device. The function is flexible to send the configuration from a local or remote file, or simply the commands as list. config_file The source file with the configuration commands to be sent to the ...
Activate nbd for an image file. CLI Example: .. code-block:: bash salt '*' qemu_nbd.connect /tmp/image.raw def connect(image): ''' Activate nbd for an image file. CLI Example: .. code-block:: bash salt '*' qemu_nbd.connect /tmp/image.raw ''' if not os.path.isfile(i...
Pass in the nbd connection device location, mount all partitions and return a dict of mount points CLI Example: .. code-block:: bash salt '*' qemu_nbd.mount /dev/nbd0 def mount(nbd, root=None): ''' Pass in the nbd connection device location, mount all partitions and return a dict of ...
Mount the named image via qemu-nbd and return the mounted roots CLI Example: .. code-block:: bash salt '*' qemu_nbd.init /srv/image.qcow2 def init(image, root=None): ''' Mount the named image via qemu-nbd and return the mounted roots CLI Example: .. code-block:: bash salt ...
Pass in the mnt dict returned from nbd_mount to unmount and disconnect the image from nbd. If all of the partitions are unmounted return an empty dict, otherwise return a dict containing the still mounted partitions CLI Example: .. code-block:: bash salt '*' qemu_nbd.clear '{"/mnt/foo": "...
if hardfailing: If we got the original stacktrace, log it If all cases, raise the original exception but this is logically part the initial stack. else just let salt exit gracefully def _handle_interrupt(exc, original_exc, hardfail=False, trace=''): ''' if hardfailing: ...
Start the salt master. def salt_master(): ''' Start the salt master. ''' import salt.cli.daemons # REMOVEME after Python 2.7 support is dropped (also the six import) if six.PY2: from salt.utils.versions import warn_until # Message borrowed from pip's deprecation warning warn...
Start a minion process def minion_process(): ''' Start a minion process ''' import salt.utils.platform import salt.utils.process import salt.cli.daemons # salt_minion spawns this function in a new process salt.utils.process.appendproctitle('KeepAlive') def handle_hup(manager, sig...
Start the salt minion in a subprocess. Auto restart minion on error. def salt_minion(): ''' Start the salt minion in a subprocess. Auto restart minion on error. ''' import signal import salt.utils.platform import salt.utils.process salt.utils.process.notify_systemd() import sa...
Start a proxy minion process def proxy_minion_process(queue): ''' Start a proxy minion process ''' import salt.cli.daemons import salt.utils.platform # salt_minion spawns this function in a new process lock = threading.RLock() def suicide_when_without_parent(parent_pid): ''' ...
Start a proxy minion. def salt_proxy(): ''' Start a proxy minion. ''' import salt.cli.daemons import salt.utils.platform import multiprocessing if '' in sys.path: sys.path.remove('') if salt.utils.platform.is_windows(): proxyminion = salt.cli.daemons.ProxyMinion() ...
Start the salt syndic. def salt_syndic(): ''' Start the salt syndic. ''' import salt.utils.process salt.utils.process.notify_systemd() import salt.cli.daemons pid = os.getpid() try: syndic = salt.cli.daemons.Syndic() syndic.start() except KeyboardInterrupt: ...
Manage the authentication keys with salt-key. def salt_key(): ''' Manage the authentication keys with salt-key. ''' import salt.cli.key try: client = salt.cli.key.SaltKey() _install_signal_handlers(client) client.run() except Exception as err: sys.stderr.write("E...
Publish commands to the salt system from the command line on the master. def salt_cp(): ''' Publish commands to the salt system from the command line on the master. ''' import salt.cli.cp client = salt.cli.cp.SaltCPCli() _install_signal_handlers(client) client.run()
Directly call a salt command in the modules, does not require a running salt minion to run. def salt_call(): ''' Directly call a salt command in the modules, does not require a running salt minion to run. ''' import salt.cli.call if '' in sys.path: sys.path.remove('') client = s...
Execute a salt convenience routine. def salt_run(): ''' Execute a salt convenience routine. ''' import salt.cli.run if '' in sys.path: sys.path.remove('') client = salt.cli.run.SaltRun() _install_signal_handlers(client) client.run()
Execute the salt-ssh system def salt_ssh(): ''' Execute the salt-ssh system ''' import salt.cli.ssh if '' in sys.path: sys.path.remove('') try: client = salt.cli.ssh.SaltSSH() _install_signal_handlers(client) client.run() except SaltClientError as err: ...
The main function for salt-cloud def salt_cloud(): ''' The main function for salt-cloud ''' # Define 'salt' global so we may use it after ImportError. Otherwise, # UnboundLocalError will be raised. global salt # pylint: disable=W0602 try: # Late-imports for CLI performance ...
The main function for salt-api def salt_api(): ''' The main function for salt-api ''' import salt.utils.process salt.utils.process.notify_systemd() import salt.cli.api sapi = salt.cli.api.SaltAPI() # pylint: disable=E1120 sapi.start()
Publish commands to the salt system from the command line on the master. def salt_main(): ''' Publish commands to the salt system from the command line on the master. ''' import salt.cli.salt if '' in sys.path: sys.path.remove('') client = salt.cli.salt.SaltCMD() _install_si...
The main function for spm, the Salt Package Manager .. versionadded:: 2015.8.0 def salt_spm(): ''' The main function for spm, the Salt Package Manager .. versionadded:: 2015.8.0 ''' import salt.cli.spm spm = salt.cli.spm.SPM() # pylint: disable=E1120 spm.run()
Quickstart for developing on the saltstack installation .. versionadded:: 2016.11.0 def salt_extend(extension, name, description, salt_dir, merge): ''' Quickstart for developing on the saltstack installation .. versionadded:: 2016.11.0 ''' import salt.utils.extend salt.utils.extend.run(ex...
Run Salt Support that collects system data, logs etc for debug and support purposes. :return: def salt_support(): ''' Run Salt Support that collects system data, logs etc for debug and support purposes. :return: ''' import salt.cli.support.collector if '' in sys.path: sys.path.remo...
Execute an unmodified puppet_node_classifier and read the output as YAML def ext_pillar(minion_id, pillar, # pylint: disable=W0613 command): ''' Execute an unmodified puppet_node_classifier and read the output as YAML ''' try: data = salt.utils.yaml.safe_load(__sa...
Execute the desired powershell command and ensure that it returns data in JSON format and load that into python def _pshell_json(cmd, cwd=None): ''' Execute the desired powershell command and ensure that it returns data in JSON format and load that into python ''' if 'convertto-json' not in cmd...
Install a KB from a .msu file. Args: path (str): The full path to the msu file to install restart (bool): ``True`` to force a restart if required by the installation. Adds the ``/forcerestart`` switch to the ``wusa.exe`` command. ``False`` will add ...
Uninstall a specific KB. Args: path (str): The full path to the msu file to uninstall. This can also be just the name of the KB to uninstall restart (bool): ``True`` to force a restart if required by the installation. Adds the ``/forcerestart`` swit...
Get a list of updates installed on the machine Returns: list: A list of installed updates CLI Example: .. code-block:: bash salt '*' wusa.list def list(): ''' Get a list of updates installed on the machine Returns: list: A list of installed updates CLI Example:...
Manage the device configuration given the input data structured according to the YANG models. data YANG structured data. models A list of models to be used when generating the config. profiles: ``None`` Use certain profiles to generate the config. If not specified, wi...
Configure the network device, given the input data structured according to the YANG models. .. note:: The main difference between this function and ``managed`` is that the later generates and loads the configuration only when there are differences between the existing configurat...
Returns the datacenter name configured on the proxy Supported proxies: esxcluster, esxdatacenter def _get_datacenter_name(): ''' Returns the datacenter name configured on the proxy Supported proxies: esxcluster, esxdatacenter ''' proxy_type = __salt__['vsphere.get_proxy_type']() details ...
Configures a DVS. Creates a new DVS, if it doesn't exist in the provided datacenter or reconfigures it if configured differently. dvs DVS dict representations (see module sysdocs) def dvs_configured(name, dvs): ''' Configures a DVS. Creates a new DVS, if it doesn't exist in the provi...
Returns a dictionary with the diffs between two dictionaries It will ignore any key that doesn't exist in dict2 def _get_diff_dict(dict1, dict2): ''' Returns a dictionary with the diffs between two dictionaries It will ignore any key that doesn't exist in dict2 ''' ret_dict = {} for p in ...
Returns a dictionaries with the values stored in val2 of a diff dict. def _get_val2_dict_from_diff_dict(diff_dict): ''' Returns a dictionaries with the values stored in val2 of a diff dict. ''' ret_dict = {} for p in diff_dict.keys(): if not isinstance(diff_dict[p], dict): raise...
Returns a list of string message of the differences in a diff dict. Each inner message is tabulated one tab deeper def _get_changes_from_diff_dict(diff_dict): ''' Returns a list of string message of the differences in a diff dict. Each inner message is tabulated one tab deeper ''' changes_str...
Configures portgroups on a DVS. Creates/updates/removes portgroups in a provided DVS dvs Name of the DVS portgroups Portgroup dict representations (see module sysdocs) def portgroups_configured(name, dvs, portgroups): ''' Configures portgroups on a DVS. Creates/updates/remov...
Configures the uplink portgroup on a DVS. The state assumes there is only one uplink portgroup. dvs Name of the DVS upling_portgroup Uplink portgroup dict representations (see module sysdocs) def uplink_portgroup_configured(name, dvs, uplink_portgroup): ''' Configures the uplink p...
Ensure that the named user is present with the specified privileges Please note that the user/group notion in postgresql is just abstract, we have roles, where users can be seens as roles with the LOGIN privilege and groups the others. name The name of the system user to manage. createdb ...
Ensure property has a certain value name : string name of the zone property : string name of property value : string value of property def property_present(name, property, value): ''' Ensure property has a certain value name : string name of the zone proper...
Ensure property is absent name : string name of the zone property : string name of property .. note:: This does a zoneacfg clear call. So the property may be reset to a default value! Does has the side effect of always having to be called. def property_absent(name, propert...
Ensure resource exists with provided properties name : string name of the zone resource_type : string type of resource resource_selector_property : string unique resource identifier resource_selector_value : string value for resource selection kwargs : string|int|......
Ensure resource is absent name : string name of the zone resource_type : string type of resource resource_selector_property : string unique resource identifier resource_selector_value : string value for resource selection .. warning:: Both resource_selector_...
Ensure zone is booted name : string name of the zone single : boolean boot in single usermode def booted(name, single=False): ''' Ensure zone is booted name : string name of the zone single : boolean boot in single usermode ''' ret = {'name': name, ...
Ensure zone is halted name : string name of the zone graceful : boolean use shutdown instead of halt if true def halted(name, graceful=True): ''' Ensure zone is halted name : string name of the zone graceful : boolean use shutdown instead of halt if true '...
Export a zones configuration name : string name of the zone path : string path of file to export too. replace : boolean replace the file if it exists def export(name, path, replace=False): ''' Export a zones configuration name : string name of the zone path...
Import a zones configuration name : string name of the zone path : string path of the configuration file to import mode : string either import, install, or attach nodataset : boolean do not create a ZFS file system brand_opts : boolean brand specific options ...
Ensure a zone with certain properties and resources name : string name of the zone brand : string brand of the zone zonepath : string path of the zone properties : list of key-value pairs dict of properties resources : list of key-value pairs dict of resource...
Ensure a zone is absent name : string name of the zone uninstall : boolean when true, uninstall instead of detaching the zone first. def absent(name, uninstall=False): ''' Ensure a zone is absent name : string name of the zone uninstall : boolean when true, uni...
Ensure zone is attached name : string name of the zone force : boolean force attach the zone def attached(name, force=False): ''' Ensure zone is attached name : string name of the zone force : boolean force attach the zone ''' ret = {'name': name, ...
Ensure zone is detached name : string name of the zone def detached(name): ''' Ensure zone is detached name : string name of the zone ''' ret = {'name': name, 'changes': {}, 'result': None, 'comment': ''} zones = __salt__['zoneadm.list'](...
Ensure zone is installed name : string name of the zone nodataset : boolean do not create a ZFS file system brand_opts : boolean brand specific options to pass def installed(name, nodataset=False, brand_opts=None): ''' Ensure zone is installed name : string nam...
Ensure zone is uninstalled name : string name of the zone def uninstalled(name): ''' Ensure zone is uninstalled name : string name of the zone ''' ret = {'name': name, 'changes': {}, 'result': None, 'comment': ''} zones = __salt__['zonead...
Validate the beacon configuration def validate(config): ''' Validate the beacon configuration ''' _config = {} list(map(_config.update, config)) if not isinstance(config, list): return False, ('Configuration for avahi_announce ' 'beacon must be a list.') eli...
Broadcast values via zeroconf If the announced values are static, it is advised to set run_once: True (do not poll) on the beacon configuration. The following are required configuration settings: - ``servicetype`` - The service type to announce - ``port`` - The port of the service to announce ...
Enforce that the WAR will be deployed and started in the context path, while making use of WAR versions in the filename. .. note:: For more info about Tomcats file paths and context naming, please see http://tomcat.apache.org/tomcat-7.0-doc/config/context.html#Naming name The cont...
Wait for the Tomcat Manager to load. Notice that if tomcat is not running we won't wait for it start and the state will fail. This state can be required in the tomcat.war_deployed state to make sure tomcat is running and that the manager is running as well and ready for deployment. url : http://lo...
The tomcat watcher, called to invoke the watch command. When called, it will reload the webapp in question .. note:: This state exists to support special handling of the ``watch`` :ref:`requisite <requisites>`. It should not be called directly. Parameters for this function should be se...
Enforce that the WAR will be undeployed from the server name The context path to undeploy. url : http://localhost:8080/manager The URL of the server with the Tomcat Manager webapp. timeout : 180 Timeout for HTTP request to the Tomcat Manager. Example: .. code-block:: yaml ...
Send a message to an XMPP recipient. Designed for use in states. CLI Examples: .. code-block:: bash xmpp.send_msg 'admins@xmpp.example.com' 'This is a salt module test' \ profile='my-xmpp-account' xmpp.send_msg 'admins@xmpp.example.com' 'This is a salt module test' \ j...
Send a message to an XMPP recipient, support send message to multiple recipients or chat room. CLI Examples: .. code-block:: bash xmpp.send_msg recipients=['admins@xmpp.example.com'] \ rooms=['secret@conference.xmpp.example.com'] \ 'This is a salt module test' \ ...
Alternate constructor that accept multiple recipients and rooms def create_multi(cls, jid, password, msg, recipients=None, rooms=None, nick="SaltStack Bot"): ''' Alternate constructor that accept multiple recipients and rooms ''' obj = SendMsgBot(jid, password, None...
Emit a dict name "texts" whose value is a list of texts. .. code-block:: yaml beacons: twilio_txt_msg: - account_sid: "<account sid>" - auth_token: "<auth token>" - twilio_number: "+15555555555" - interval: 10 def beacon(config): ''' E...
Given a rule name, check to see if the given rule exists. Returns True if the given rule exists and returns False if the given rule does not exist. CLI example:: salt myminion boto_cloudwatch_event.exists myevent region=us-east-1 def exists(Name, region=None, key=None, keyid=None, profile=None):...
Given a valid config, create an event rule. Returns {created: true} if the rule was created and returns {created: False} if the rule was not created. CLI Example: .. code-block:: bash salt myminion boto_cloudwatch_event.create_or_update my_rule def create_or_update(Name, Schedule...
Given a rule name describe its properties. Returns a dictionary of interesting properties. CLI Example: .. code-block:: bash salt myminion boto_cloudwatch_event.describe myrule def describe(Name, region=None, key=None, keyid=None, profile=None): ''' Given a rule name descri...
List, with details, all Cloudwatch Event rules visible in the current scope. CLI example:: salt myminion boto_cloudwatch_event.list_rules region=us-east-1 def list_rules(region=None, key=None, keyid=None, profile=None): ''' List, with details, all Cloudwatch Event rules visible in the current sco...
Given a rule name list the targets of that rule. Returns a dictionary of interesting properties. CLI Example: .. code-block:: bash salt myminion boto_cloudwatch_event.list_targets myrule def list_targets(Rule, region=None, key=None, keyid=None, profile=None): ''' Given a ru...
Add the given targets to the given rule Returns a dictionary describing any failures. CLI Example: .. code-block:: bash salt myminion boto_cloudwatch_event.put_targets myrule [{'Id': 'target1', 'Arn': 'arn:***'}] def put_targets(Rule, Targets, region=None, key=None, keyid=None, pro...
DRY: Get all service FMRIs and their enabled property def _get_enabled_disabled(enabled_prop="true"): ''' DRY: Get all service FMRIs and their enabled property ''' ret = set() cmd = '/usr/bin/svcprop -c -p general/enabled "*"' lines = __salt__['cmd.run_stdout'](cmd, python_shell=False).splitlin...
Returns ``True`` if the specified service is available, otherwise returns ``False``. We look up the name with the svcs command to get back the FMRI This allows users to use simpler service names CLI Example: .. code-block:: bash salt '*' service.available net-snmp def available(name): ...
The inverse of service.available. Returns ``True`` if the specified service is not available, otherwise returns ``False``. CLI Example: .. code-block:: bash salt '*' service.missing net-snmp def missing(name): ''' The inverse of service.available. Returns ``True`` if the specifie...
Return all installed services CLI Example: .. code-block:: bash salt '*' service.get_all def get_all(): ''' Return all installed services CLI Example: .. code-block:: bash salt '*' service.get_all ''' ret = set() cmd = '/usr/bin/svcs -aH -o FMRI,STATE -s FMRI' ...
Start the specified service CLI Example: .. code-block:: bash salt '*' service.start <service name> def start(name): ''' Start the specified service CLI Example: .. code-block:: bash salt '*' service.start <service name> ''' cmd = '/usr/sbin/svcadm enable -s -t {0}...
Restart the named service CLI Example: .. code-block:: bash salt '*' service.restart <service name> def restart(name): ''' Restart the named service CLI Example: .. code-block:: bash salt '*' service.restart <service name> ''' cmd = '/usr/sbin/svcadm restart {0}'.f...
Reload the named service CLI Example: .. code-block:: bash salt '*' service.reload <service name> def reload_(name): ''' Reload the named service CLI Example: .. code-block:: bash salt '*' service.reload <service name> ''' cmd = '/usr/sbin/svcadm refresh {0}'.forma...
Return the status for a service. If the name contains globbing, a dict mapping service name to True/False values is returned. .. versionchanged:: 2018.3.0 The service name can now be a glob (e.g. ``salt*``) Args: name (str): The name of the service to check sig (str): Not imple...
Enable the named service to start at boot CLI Example: .. code-block:: bash salt '*' service.enable <service name> def enable(name, **kwargs): ''' Enable the named service to start at boot CLI Example: .. code-block:: bash salt '*' service.enable <service name> ''' ...
Disable the named service to start at boot CLI Example: .. code-block:: bash salt '*' service.disable <service name> def disable(name, **kwargs): ''' Disable the named service to start at boot CLI Example: .. code-block:: bash salt '*' service.disable <service name> ''...
Check to see if the named service is enabled to start on boot CLI Example: .. code-block:: bash salt '*' service.enabled <service name> def enabled(name, **kwargs): ''' Check to see if the named service is enabled to start on boot CLI Example: .. code-block:: bash salt '*'...
Check whether or not an upgrade is available for a given package Args: name (str): The name of a single package Kwargs: refresh (bool): Refresh package metadata. Default ``True`` saltenv (str): The salt environment. Default ``base`` Returns: bool: True if new version avail...
List all available package upgrades on this system Args: refresh (bool): Refresh package metadata. Default ``True`` Kwargs: saltenv (str): Salt environment. Default ``base`` Returns: dict: A dictionary of packages with available upgrades CLI Example: .. code-block:: bash...
Return a list of available versions of the specified package. Args: names (str): One or more package names Kwargs: saltenv (str): The salt environment to use. Default ``base``. refresh (bool): Refresh package metadata. Default ``False``. return_dict_always (bool): ...
Returns a string representing the package version or an empty string if not installed. If more than one package name is specified, a dict of name/version pairs is returned. Args: name (str): One or more package names Kwargs: saltenv (str): The salt environment to use. Default ``base``....
List the packages currently installed. .. note:: To view installed software as displayed in the Add/Remove Programs, set ``include_components`` and ``include_updates`` to False. Args: versions_as_list (bool): Returns the versions as a list include_components (bool...
This searches the uninstall keys in the registry to find a match in the sub keys, it will return a dict with the display name as the key and the version as the value Args: include_components (bool): Include sub components of installed software. Default is ``True`` include_upda...
Internal use only in this module, has a different set of defaults and returns True or False. And supports checking the age of the existing generated metadata db, as well as ensure metadata db exists to begin with Args: saltenv (str): Salt environment Kwargs: force (bool): ...
r''' Generates the local software metadata database (`winrepo.p`) on the minion. The database is stored in a serialized format located by default at the following location: ``C:\salt\var\cache\salt\minion\files\base\win\repo-ng\winrepo.p`` This module performs the following steps to generate the s...
Return repo details for the specified saltenv as a namedtuple def _get_repo_details(saltenv): ''' Return repo details for the specified saltenv as a namedtuple ''' contextkey = 'winrepo._get_repo_details.{0}'.format(saltenv) if contextkey in __context__: (winrepo_source_dir, local_dest, wi...
Generate package metadata db based on files within the winrepo_source_dir Kwargs: saltenv (str): Salt environment. Default: ``base`` verbose (bool): Return verbose data structure which includes 'success_list', a list of all sls files and the package names contained within....
Extract the hash sum, whether it is in a remote hash file, or just a string. def _get_source_sum(source_hash, file_path, saltenv): ''' Extract the hash sum, whether it is in a remote hash file, or just a string. ''' ret = dict() schemes = ('salt', 'http', 'https', 'ftp', 'swift', 's3', 'file') ...
Return if msiexec.exe will be used and the command to invoke it. def _get_msiexec(use_msiexec): ''' Return if msiexec.exe will be used and the command to invoke it. ''' if use_msiexec is False: return False, '' if isinstance(use_msiexec, six.string_types): if os.path.isfile(use_msie...
r''' Install the passed package(s) on the system using winrepo Args: name (str): The name of a single package, or a comma-separated list of packages to install. (no spaces after the commas) refresh (bool): Boolean value representing whether or not to refres...
Upgrade all software. Currently not implemented Kwargs: saltenv (str): The salt environment to use. Default ``base``. refresh (bool): Refresh package metadata. Default ``True``. .. note:: This feature is not yet implemented for Windows. Returns: dict: Empty dict, until imp...
Remove the passed package(s) from the system using winrepo .. versionadded:: 0.16.0 Args: name (str): The name(s) of the package(s) to be uninstalled. Can be a single package or a comma delimited list of packages, no spaces. pkgs (list): A list of packages ...