text
stringlengths
81
112k
Unset quota on glusterfs volume name Name of the gluster volume path Folder path for restriction in volume CLI Example: .. code-block:: bash salt '*' glusterfs.unset_quota_volume <volume> <path> def unset_quota_volume(name, path): ''' Unset quota on glusterfs volume...
List quotas of glusterfs volume name Name of the gluster volume CLI Example: .. code-block:: bash salt '*' glusterfs.list_quota_volume <volume> def list_quota_volume(name): ''' List quotas of glusterfs volume name Name of the gluster volume CLI Example: .....
.. versionadded:: 2019.2.0 Returns the glusterfs volume op-version name Name of the glusterfs volume CLI Example: .. code-block:: bash salt '*' glusterfs.get_op_version <volume> def get_op_version(name): ''' .. versionadded:: 2019.2.0 Returns the glusterfs volume op-ve...
.. versionadded:: 2019.2.0 Returns the glusterfs volume's max op-version value Requires Glusterfs version > 3.9 CLI Example: .. code-block:: bash salt '*' glusterfs.get_max_op_version def get_max_op_version(): ''' .. versionadded:: 2019.2.0 Returns the glusterfs volume's max op-...
.. versionadded:: 2019.2.0 Set the glusterfs volume op-version version Version to set the glusterfs volume op-version CLI Example: .. code-block:: bash salt '*' glusterfs.set_op_version <volume> def set_op_version(version): ''' .. versionadded:: 2019.2.0 Set the gluste...
Check the version of Bower to ensure this module will work. Currently bower must be at least version 1.3. def _check_valid_version(): ''' Check the version of Bower to ensure this module will work. Currently bower must be at least version 1.3. ''' # pylint: disable=no-member bower_version =...
Create bower command line string def _construct_bower_command(bower_command): ''' Create bower command line string ''' if not bower_command: raise CommandExecutionError( 'bower_command, e.g. install, must be specified') cmd = ['bower'] + shlex.split(bower_command) cmd.exten...
Install a Bower package. If no package is specified, the dependencies (from bower.json) of the package in the given directory will be installed. pkg A package name in any format accepted by Bower, including a version identifier dir The target directory in which to install the ...
Linux hosts using systemd 207 or later ignore ``/etc/sysctl.conf`` and only load from ``/etc/sysctl.d/*.conf``. This function will do the proper checks and return a default config file which will be valid for the Minion. Hosts running systemd >= 207 will use ``/etc/sysctl.d/99-salt.conf``. CLI Example:...
Return a list of sysctl parameters for this minion config: Pull the data from the system configuration file instead of the live data. CLI Example: .. code-block:: bash salt '*' sysctl.show def show(config_file=False): ''' Return a list of sysctl parameters for this minion c...
Assign a single sysctl parameter for this minion CLI Example: .. code-block:: bash salt '*' sysctl.assign net.ipv4.ip_forward 1 def assign(name, value): ''' Assign a single sysctl parameter for this minion CLI Example: .. code-block:: bash salt '*' sysctl.assign net.ipv4.i...
Assign and persist a simple sysctl parameter for this minion. If ``config`` is not specified, a sensible default will be chosen using :mod:`sysctl.default_config <salt.modules.linux_sysctl.default_config>`. CLI Example: .. code-block:: bash salt '*' sysctl.persist net.ipv4.ip_forward 1 def p...
Connect to a mongo database and read per-node pillar information. Parameters: * `collection`: The mongodb collection to read data from. Defaults to ``'pillar'``. * `id_field`: The field in the collection that represents an individual minion id. Defaults to ``'_id'``. * `...
If this XML tree has an xmlns attribute, then etree will add it to the beginning of the tag, like: "{http://path}tag". def _conv_name(x): ''' If this XML tree has an xmlns attribute, then etree will add it to the beginning of the tag, like: "{http://path}tag". ''' if '}' in x: comps = x...
Converts an XML ElementTree to a dictionary that only contains items. This is the default behavior in version 2017.7. This will default to prevent unexpected parsing issues on modules dependant on this. def _to_dict(xmltree): ''' Converts an XML ElementTree to a dictionary that only contains items. ...
Returns the full XML dictionary including attributes. def _to_full_dict(xmltree): ''' Returns the full XML dictionary including attributes. ''' xmldict = {} for attrName, attrValue in xmltree.attrib.items(): xmldict[attrName] = attrValue if not xmltree.getchildren(): if not xm...
No-op state to support state config via the stateconf renderer. def _no_op(name, **kwargs): ''' No-op state to support state config via the stateconf renderer. ''' return dict(name=name, result=True, changes={}, comment='')
Helper for deriving the current state of the container from the inspect results. def _get_state(inspect_results): ''' Helper for deriving the current state of the container from the inspect results. ''' if inspect_results.get('State', {}).get('Paused', False): return 'paused' elif i...
Decorator to run a function that requires the use of a docker.Client() instance. def _docker_client(wrapped): ''' Decorator to run a function that requires the use of a docker.Client() instance. ''' @functools.wraps(wrapped) def wrapper(*args, **kwargs): ''' Ensure that the ...
Decorator to trigger a refresh of salt mine data. def _refresh_mine_cache(wrapped): ''' Decorator to trigger a refresh of salt mine data. ''' @functools.wraps(wrapped) def wrapper(*args, **kwargs): ''' refresh salt mine on exit. ''' returned = wrapped(*args, **__util...
Change the state of a container def _change_state(name, action, expected, *args, **kwargs): ''' Change the state of a container ''' pre = state(name) if action != 'restart' and pre == expected: return {'result': False, 'state': {'old': expected, 'new': expected}, ...
Get the MD5 checksum of a file from a container def _get_md5(name, path): ''' Get the MD5 checksum of a file from a container ''' output = run_stdout(name, 'md5sum {0}'.format(pipes.quote(path)), ignore_retcode=True) try: return output.split()...
Get the method to be used in shell commands def _get_exec_driver(): ''' Get the method to be used in shell commands ''' contextkey = 'docker.exec_driver' if contextkey not in __context__: from_config = __salt__['config.get'](contextkey, None) # This if block can be removed once we m...
Returns a list of the top-level images (those which are not parents). If ``subset`` (an iterable) is passed, the top-level images in the subset will be returned, otherwise all top-level images will be returned. def _get_top_level_images(imagedata, subset=None): ''' Returns a list of the top-level image...
Remove container name from HostConfig:Links values to enable comparing container configurations correctly. def _scrub_links(links, name): ''' Remove container name from HostConfig:Links values to enable comparing container configurations correctly. ''' if isinstance(links, list): ret = ...
Format bytes as human-readable file sizes def _size_fmt(num): ''' Format bytes as human-readable file sizes ''' try: num = int(num) if num < 1024: return '{0} bytes'.format(num) num /= 1024.0 for unit in ('KiB', 'MiB', 'GiB', 'TiB', 'PiB'): if num...
Common functionality for running low-level API calls def _client_wrapper(attr, *args, **kwargs): ''' Common functionality for running low-level API calls ''' catch_api_errors = kwargs.pop('catch_api_errors', True) func = getattr(__context__['docker.client'], attr, None) if func is None or not h...
Process a status update from a docker build, updating the data structure def _build_status(data, item): ''' Process a status update from a docker build, updating the data structure ''' stream = item['stream'] if 'Running in' in stream: data.setdefault('Intermediate_Containers', []).append( ...
Process a status update from docker import, updating the data structure def _import_status(data, item, repo_name, repo_tag): ''' Process a status update from docker import, updating the data structure ''' status = item['status'] try: if 'Downloading from' in status: return ...
Process a status update from a docker pull, updating the data structure. For containers created with older versions of Docker, there is no distinction in the status updates between layers that were already present (and thus not necessary to download), and those which were actually downloaded. Because o...
Process a status update from a docker push, updating the data structure def _push_status(data, item): ''' Process a status update from a docker push, updating the data structure ''' status = item['status'].lower() if 'id' in item: if 'already pushed' in status or 'already exists' in status:...
Process an API error, updating the data structure def _error_detail(data, item): ''' Process an API error, updating the data structure ''' err = item['errorDetail'] if 'code' in err: try: msg = ': '.join(( item['errorDetail']['code'], item['errorD...
Take input kwargs and return a kwargs dict to pass to docker-py's create_container() function. def _get_create_kwargs(skip_translate=None, ignore_collisions=False, validate_ip_addrs=True, client_args=None, **kwargs): ''...
.. versionadded:: 2017.7.0 .. versionchanged:: 2018.3.0 Renamed from ``docker.compare_container`` to ``docker.compare_containers`` (old function name remains as an alias) Compare two containers' Config and and HostConfig and return any differences between the two. first Name or...
.. versionadded:: 2018.3.0 Returns the differences between two containers' networks. When a network is only present one of the two containers, that network's diff will simply be represented with ``True`` for the side of the diff in which the network is present) and ``False`` for the side of the diff in...
.. versionadded:: 2018.3.0 Compare two networks and return any differences between the two first Name or ID of first container second Name or ID of second container ignore : Name,Id,Created,Containers A comma-separated list (or Python list) of keys to ignore when comp...
.. versionadded:: 2018.3.0 Return a list of running containers attached to the specified network name Network name verbose : False If ``True``, return extended info about each container (IP configuration, etc.) CLI Example: .. code-block:: bash salt myminion doc...
.. versionadded:: 2016.3.7,2016.11.4,2017.7.0 Performs a ``docker login`` to authenticate to one or more configured repositories. See the documentation at the top of this page to configure authentication credentials. Multiple registry URLs (matching those configured in Pillar) can be passed, and S...
Returns the containers and images, if any, which depend on the given image name Name or ID of image **RETURN DATA** A dictionary containing the following keys: - ``Containers`` - A list of containers which depend on the specified image - ``Images`` - A list of IDs of images which depend...
Get information on changes made to container's filesystem since it was created. Equivalent to running the ``docker diff`` Docker CLI command. name Container name or ID **RETURN DATA** A dictionary containing any of the following keys: - ``Added`` - A list of paths that were added. -...
Check if a given container exists name Container name or ID **RETURN DATA** A boolean (``True`` if the container exists, otherwise ``False``) CLI Example: .. code-block:: bash salt myminion docker.exists mycontainer def exists(name): ''' Check if a given container ex...
Return the history for an image. Equivalent to running the ``docker history`` Docker CLI command. name Container name or ID quiet : False If ``True``, the return data will simply be a list of the commands run to build the container. .. code-block:: bash $ salt...
Returns information about the Docker images on the Minion. Equivalent to running the ``docker images`` Docker CLI command. all : False If ``True``, untagged images will also be returned verbose : False If ``True``, a ``docker inspect`` will be run on each image returned. **RETURN DAT...
.. versionchanged:: 2017.7.0 Volumes and networks are now checked, in addition to containers and images. This is a generic container/image/volume/network inspecton function. It will run the following functions in order: - :py:func:`docker.inspect_container <salt.modules.dockermod.ins...
Retrieves image information. Equivalent to running the ``docker inspect`` Docker CLI command, but will only look for image information. .. note:: To inspect an image, it must have been pulled from a registry or built locally. Images on a Docker registry which have not been pulled cannot ...
Returns a list of containers by name. This is different from :py:func:`docker.ps <salt.modules.dockermod.ps_>` in that :py:func:`docker.ps <salt.modules.dockermod.ps_>` returns its results organized by container ID. all : False If ``True``, stopped containers will be included in return data ...
Returns a list of tagged images CLI Example: .. code-block:: bash salt myminion docker.list_tags def list_tags(): ''' Returns a list of tagged images CLI Example: .. code-block:: bash salt myminion docker.list_tags ''' ret = set() for item in six.itervalues(ima...
.. versionadded:: 2018.3.0 Given an image name (or partial image ID), return the full image ID. If no match is found among the locally-pulled images, then ``False`` will be returned. CLI Examples: .. code-block:: bash salt myminion docker.resolve_image_id foo salt myminion docker...
.. versionadded:: 2017.7.2 .. versionchanged:: 2018.3.0 Instead of matching against pulled tags using :py:func:`docker.list_tags <salt.modules.dockermod.list_tags>`, this function now simply inspects the passed image name using :py:func:`docker.inspect_image <salt.modules.dockermod.i...
.. versionchanged:: 2018.3.0 Support for all of docker-py's `logs()`_ function's arguments, with the exception of ``stream``. Returns the logs for the container. An interface to docker-py's `logs()`_ function. name Container name or ID stdout : True Return stdout lines...
Returns port mapping information for a given container. Equivalent to running the ``docker port`` Docker CLI command. name Container name or ID .. versionchanged:: 2019.2.0 This value can now be a pattern expression (using the pattern-matching characters defined in fnma...
Returns information about the Docker containers on the Minion. Equivalent to running the ``docker ps`` Docker CLI command. all : False If ``True``, stopped containers will also be returned host: False If ``True``, local host's network topology will be included verbose : False ...
Returns the state of the container name Container name or ID **RETURN DATA** A string representing the current state of the container (either ``running``, ``paused``, or ``stopped``) CLI Example: .. code-block:: bash salt myminion docker.state mycontainer def state(name)...
Searches the registry for an image name Search keyword official : False Limit results to official builds trusted : False Limit results to `trusted builds`_ **RETURN DATA** A dictionary with each key being the name of an image, and the following information for each i...
Runs the `docker top` command on a specific container name Container name or ID CLI Example: **RETURN DATA** A list of dictionaries containing information about each process .. code-block:: bash salt myminion docker.top mycontainer salt myminion docker.top 0123456789a...
Returns a dictionary of Docker version information. Equivalent to running the ``docker version`` Docker CLI command. CLI Example: .. code-block:: bash salt myminion docker.version def version(): ''' Returns a dictionary of Docker version information. Equivalent to running the ``docke...
Create a new container image Image from which to create the container name Name for the new container. If not provided, Docker will randomly generate one for you (it will be included in the return data). start : False If ``True``, start container after creating it ...
.. versionadded:: 2018.3.0 Equivalent to ``docker run`` on the Docker CLI. Runs the container, waits for it to exit, and returns the container's logs when complete. .. note:: Not to be confused with :py:func:`docker.run <salt.modules.dockermod.run>`, which provides a :py:func:`cmd.run ...
Copy a file from inside a container to the Minion name Container name source Path of the file on the container's filesystem dest Destination on the Minion. Must be an absolute path. If the destination is a directory, the file will be copied into that directory. overwr...
Copy a file from the host into a container name Container name source File to be copied to the container. Can be a local path on the Minion or a remote file from the Salt fileserver. dest Destination on the container. Must be an absolute path. If the destination is...
Exports a container to a tar archive. It can also optionally compress that tar archive, and push it up to the Master. name Container name or ID path Absolute path on the Minion where the container will be exported overwrite : False Unless this option is set to ``True``, then i...
Removes a container name Container name or ID force : False If ``True``, the container will be killed first before removal, as the Docker API will not permit a running container to be removed. This option is set to ``False`` by default to prevent accidental removal of a...
.. versionadded:: 2017.7.0 Renames a container. Returns ``True`` if successful, and raises an error if the API returns one. If unsuccessful and the API returns no error (should not happen), then ``False`` will be returned. name Name or ID of existing container new_name New name to...
.. versionchanged:: 2018.3.0 If the built image should be tagged, then the repository and tag must now be passed separately using the ``repository`` and ``tag`` arguments, rather than together in the (now deprecated) ``image`` argument. Builds a docker image from a Dockerfile or a U...
.. versionchanged:: 2018.3.0 The repository and tag must now be passed separately using the ``repository`` and ``tag`` arguments, rather than together in the (now deprecated) ``image`` argument. Commits a container, thereby promoting it to an image. Equivalent to running the ``docker co...
Return top-level images (those on which no other images depend) which do not have a tag assigned to them. These include: - Images which were once tagged but were later untagged, such as those which were superseded by committing a new copy of an existing tagged image. - Images which were loaded ...
.. versionchanged:: 2018.3.0 The repository and tag must now be passed separately using the ``repository`` and ``tag`` arguments, rather than together in the (now deprecated) ``image`` argument. Imports content from a local tarball or a URL as a new docker image source Content ...
.. versionchanged:: 2018.3.0 If the loaded image should be tagged, then the repository and tag must now be passed separately using the ``repository`` and ``tag`` arguments, rather than together in the (now deprecated) ``image`` argument. Load a tar archive that was created using :py...
Returns a list of the IDs of layers belonging to the specified image, with the top-most layer (the one correspnding to the passed name) appearing last. name Image name or ID CLI Example: .. code-block:: bash salt myminion docker.layers centos:7 def layers(name): ''' Retu...
.. versionchanged:: 2018.3.0 If no tag is specified in the ``image`` argument, all tags for the image will be pulled. For this reason is it recommended to pass ``image`` using the ``repo:tag`` notation. Pulls an image from a Docker registry image Image to be pulled insecur...
.. versionchanged:: 2015.8.4 The ``Id`` and ``Image`` keys are no longer present in the return data. This is due to changes in the Docker Remote API. Pushes an image to a Docker registry. See the documentation at top of this page to configure authentication credentials. image Image...
Removes an image name Name (in ``repo:tag`` notation) or ID of image. force : False If ``True``, the image will be removed even if the Minion has containers created from that image prune : True If ``True``, untagged parent image layers will be removed as well, set ...
.. versionchanged:: 2018.3.0 The repository and tag must now be passed separately using the ``repository`` and ``tag`` arguments, rather than together in the (now deprecated) ``image`` argument. Tag an image into a repository and return ``True``. If the tag was unsuccessful, an error wi...
.. versionchanged:: 2017.7.0 The ``names`` and ``ids`` can be passed as a comma-separated list now, as well as a Python list. .. versionchanged:: 2018.3.0 The ``Containers`` key for each network is no longer always empty. List existing networks names Filter by name ids...
.. versionchanged:: 2018.3.0 Support added for network configuration options other than ``driver`` and ``driver_opts``, as well as IPAM configuration. Create a new network .. note:: This function supports all arguments for network and IPAM pool configuration which are available...
.. versionadded:: 2015.8.3 .. versionchanged:: 2017.7.0 Support for ``ipv4_address`` argument added .. versionchanged:: 2018.3.0 All arguments are now passed through to `connect_container_to_network()`_, allowing for any new arguments added to this function to be supported automa...
.. versionadded:: 2015.8.3 Disconnect container from network container Container name or ID network_id Network name or ID CLI Examples: .. code-block:: bash salt myminion docker.disconnect_container_from_network web-1 mynet salt myminion docker.disconnect_contai...
.. versionadded:: 2018.3.0 Runs :py:func:`docker.disconnect_container_from_network <salt.modules.dockermod.disconnect_container_from_network>` on all containers connected to the specified network, and returns the names of all containers that were disconnected. network_id Network name or ID...
Create a new volume .. versionadded:: 2015.8.4 name name of volume driver Driver of the volume driver_opts Options for the driver volume CLI Example: .. code-block:: bash salt myminion docker.create_volume my_volume driver=local def create_volume(name, dri...
Pauses a container name Container name or ID **RETURN DATA** A dictionary will be returned, containing the following keys: - ``status`` - A dictionary showing the prior state of the container as well as the new state - ``result`` - A boolean noting whether or not the action was su...
Restarts a container name Container name or ID timeout : 10 Timeout in seconds after which the container will be killed (if it has not yet gracefully shut down) **RETURN DATA** A dictionary will be returned, containing the following keys: - ``status`` - A dictionary sho...
Start a container name Container name or ID **RETURN DATA** A dictionary will be returned, containing the following keys: - ``status`` - A dictionary showing the prior state of the container as well as the new state - ``result`` - A boolean noting whether or not the action was succ...
Stops a running container name Container name or ID unpause : False If ``True`` and the container is paused, it will be unpaused before attempting to stop the container. timeout Timeout in seconds after which the container will be killed (if it has not yet graceful...
Unpauses a container name Container name or ID **RETURN DATA** A dictionary will be returned, containing the following keys: - ``status`` - A dictionary showing the prior state of the container as well as the new state - ``result`` - A boolean noting whether or not the action was ...
Wait for the container to exit gracefully, and return its exit code .. note:: This function will block until the container is stopped. name Container name or ID ignore_already_stopped Boolean flag that prevents execution to fail, if a container is already stopped. fa...
.. versionadded:: 2019.2.0 Prune Docker's various subsystems .. note:: This requires docker-py version 2.1.0 or later. containers : False If ``True``, prunes stopped containers (documentation__) .. __: https://docs.docker.com/engine/reference/commandline/container_prune/#filterin...
Common logic for docker.run functions def _run(name, cmd, exec_driver=None, output=None, stdin=None, python_shell=True, output_loglevel='debug', ignore_retcode=False, use_vt=False, keep_env=None): ''' Common logic for docker.run f...
Common logic to run a script on a container def _script(name, source, saltenv='base', args=None, template=None, exec_driver=None, stdin=None, python_shell=True, output_loglevel='debug', ignore_retcode=False, ...
Run :py:func:`cmd.script <salt.modules.cmdmod.script>` within a container .. note:: While the command is run within the container, it is initiated from the host. Therefore, the PID in the return dict is from the host, not from the container. name Container name or ID sour...
Prepares a self contained tarball that has the state to be applied in the container def _prepare_trans_tar(name, sls_opts, mods=None, pillar=None, extra_filerefs=''): ''' Prepares a self contained tarball that has the state to be applied in the container ''' chunks = _com...
Generates the chunks of lowdata from the list of modules def _compile_state(sls_opts, mods=None): ''' Generates the chunks of lowdata from the list of modules ''' st_ = HighState(sls_opts) if not mods: return st_.compile_low_chunks() high_data, errors = st_.render_highstate({sls_opts[...
Executes a Salt function inside a running container .. versionadded:: 2016.11.0 The container does not need to have Salt installed, but Python is required. name Container name or ID function Salt execution module function CLI Example: .. code-block:: bash salt mymi...
.. versionadded:: 2019.2.0 Apply states! This function will call highstate or state.sls based on the arguments passed in, ``apply`` is intended to be the main gateway for all state executions. CLI Example: .. code-block:: bash salt 'docker' docker.apply web01 salt 'docker' docker...
Apply the states defined by the specified SLS modules to the running container .. versionadded:: 2016.11.0 The container does not need to have Salt installed, but Python is required. name Container name or ID mods : None A string containing comma-separated list of SLS with define...
.. versionchanged:: 2018.3.0 The repository and tag must now be passed separately using the ``repository`` and ``tag`` arguments, rather than together in the (now deprecated) ``image`` argument. Build a Docker image using the specified SLS modules on top of base image .. versionadded::...
Checks whether the input is a valid list of peers and transforms domain names into IP Addresses def _check(peers): '''Checks whether the input is a valid list of peers and transforms domain names into IP Addresses''' if not isinstance(peers, list): return False for peer in peers: if not ...
Manages the configuration of NTP peers and servers on the device, as specified in the state SLS file. NTP entities not specified in these lists will be removed whilst entities not configured on the device will be set. SLS Example: .. code-block:: yaml netntp_example: netntp.managed: ...
Add a virtual service. protocol The service protocol(only support tcp, udp and fwmark service). service_address The LVS service address. scheduler Algorithm for allocating TCP connections and UDP datagrams to real servers. CLI Example: .. code-block:: bash salt...
Ensure the kinesis stream is properly configured and scaled. name (string) Stream name retention_hours (int) Retain data for this many hours. AWS allows minimum 24 hours, maximum 168 hours. enhanced_monitoring (list of string) Turn on enhanced monitoring for the specified ...
Return information for the specified user CLI Example: .. code-block:: bash salt '*' shadow.info someuser def info(name): ''' Return information for the specified user CLI Example: .. code-block:: bash salt '*' shadow.info someuser ''' try: data = pwd.getpw...