neulab/tldr huggingface dataset:
salt.modules.deb_apache.check_site_enabled(site) Checks to see if the specific site symlink is in /etc/apache2/sites-enabled.
salt '*' apache.check_site_enabled example.com salt '*' apache.check_site_enabled example.com.conf
salt.modules.deb_postgres Module to provide Postgres compatibility to salt for debian family specific tools.
salt.modules.deb_postgres.cluster_create(version, name='main', port=None, locale=None, encoding=None, datadir=None, allow_group_access=None, data_checksums=None, wal_segsize=None) Adds a cluster to the Postgres server.
salt '*' postgres.cluster_create '9.3'
salt '*' postgres.cluster_create '9.3' 'main'
salt '*' postgres.cluster_create '9.3' locale='fr_FR'
salt '*' postgres.cluster_create '11' data_checksums=True wal_segsize='32'
salt.modules.deb_postgres.cluster_exists(version, name='main') Checks if a given version and name of a cluster exists.
salt '*' postgres.cluster_exists '9.3'
salt '*' postgres.cluster_exists '9.3' 'main'
salt.modules.deb_postgres.cluster_list(verbose=False) Return a list of cluster of Postgres server (tuples of version and name).
salt '*' postgres.cluster_list
salt '*' postgres.cluster_list verbose=True
salt.modules.deb_postgres.cluster_remove(version, name='main', stop=False) Remove a cluster on a Postgres server. By default it doesn't try to stop the cluster.
salt '*' postgres.cluster_remove '9.3'
salt '*' postgres.cluster_remove '9.3' 'main'
salt '*' postgres.cluster_remove '9.3' 'main' stop=True
salt.modules.debconfmod Support for Debconf
salt.modules.debconfmod.get_selections(fetchempty=True) Answers to debconf questions for all packages in the following format:
{'package': [['question', 'type', 'value'], ...]}
salt '*' debconf.get_selections
salt.modules.debconfmod.set_(package, question, type, value, *extra) Set answers to debconf questions for a package.
salt '*' debconf.set <package> <question> <type> <value> [<value> ...]
salt.modules.debconfmod.set_file(path, saltenv='base', **kwargs) Set answers to debconf questions from a file.
salt '*' debconf.set_file salt://pathto/pkg.selections
salt.modules.debconfmod.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
default default values for the template environment
salt '*' debconf.set_template salt://pathto/pkg.selections.jinja jinja None None
salt.modules.debconfmod.show(name) Answers to debconf questions for a package in the following format:
[['question', 'type', 'value'], ...]
If debconf doesn't know about a package, we return None.
salt '*' debconf.show <package name>
salt.modules.debian_ip The networking module for Debian-based distros
• http://www.debian.org/doc/manuals/debian-reference/ch05.en.html
salt.modules.debian_ip.apply_network_settings(**settings) Apply global network configuration.
salt '*' ip.apply_network_settings
salt.modules.debian_ip.build_bond(iface, **settings) Create a bond script in /etc/modprobe.d with the passed settings and load the bonding kernel module.
salt '*' ip.build_bond bond0 mode=balance-alb
salt.modules.debian_ip.build_interface(iface, iface_type, enabled, **settings) Build an interface script for a network interface.
salt '*' ip.build_interface eth0 eth <settings>
salt.modules.debian_ip.build_network_settings(**settings) Build the global network script.
salt '*' ip.build_network_settings <settings>
salt.modules.debian_ip.build_routes(iface, **settings) Add route scripts for a network interface using up commands.
salt '*' ip.build_routes eth0 <settings>
salt.modules.debian_ip.down(iface, iface_type) Shutdown a network interface
salt '*' ip.down eth0 eth
salt.modules.debian_ip.get_bond(iface) Return the content of a bond script
salt '*' ip.get_bond bond0
salt.modules.debian_ip.get_interface(iface) Return the contents of an interface script
salt '*' ip.get_interface eth0
salt.modules.debian_ip.get_network_settings() Return the contents of the global network script.
salt '*' ip.get_network_settings
salt.modules.debian_ip.get_routes(iface) Return the routes for the interface
salt '*' ip.get_routes eth0
salt.modules.debian_ip.up(iface, iface_type) Start up a network interface
salt '*' ip.up eth0 eth
salt.modules.debian_service Service support for Debian systems (uses update-rc.d and /sbin/service)
IMPORTANT: If you feel that Salt should be using this module to manage services on a minion, and it is using a different module (or gives an error similar to 'service.start' is not available), see here.
salt.modules.debian_service.available(name) Returns True if the specified service is available, otherwise returns False.
salt '*' service.available sshd
salt.modules.debian_service.disable(name, **kwargs) Disable the named service to start at boot
salt '*' service.disable <service name>
salt.modules.debian_service.disabled(name) Return True if the named service is disabled, false otherwise
salt '*' service.disabled <service name>
salt.modules.debian_service.enable(name, **kwargs) Enable the named service to start at boot
salt '*' service.enable <service name>
salt.modules.debian_service.enabled(name, **kwargs) Return True if the named service is enabled, false otherwise
salt '*' service.enabled <service name>
salt.modules.debian_service.force_reload(name) Force-reload the named service
salt '*' service.force_reload <service name>
salt.modules.debian_service.get_all() Return all available boot services
salt '*' service.get_all
salt.modules.debian_service.get_disabled() Return a set of services that are installed but disabled
salt '*' service.get_disabled
salt.modules.debian_service.get_enabled() Return a list of service that are enabled on boot
salt '*' service.get_enabled
salt.modules.debian_service.missing(name) The inverse of service.available.  Returns True if the specified service is not available, otherwise returns False.
salt '*' service.missing sshd
salt.modules.debian_service.reload_(name) Reload the named service
salt '*' service.reload <service name>
salt.modules.debian_service.restart(name) Restart the named service
salt '*' service.restart <service name>
salt.modules.debian_service.start(name) Start the specified service
salt '*' service.start <service name>
salt.modules.debian_service.status(name, sig=None) Return the status for a service.  If the name contains globbing, a dict mapping service name to True/False values is returned.
Changed in version 2018.3.0: The service name can now be a glob (e.g. salt*)
• name (str) -- The name of the service to check
• sig (str) -- Signature to use to find the service via ps
Returns True if running, False otherwise dict: Maps service name to True if running, False otherwise
salt '*' service.status <service name> [service signature]
salt.modules.debian_service.stop(name) Stop the specified service
salt '*' service.stop <service name>
salt.modules.debuild_pkgbuild Debian Package builder system
This system allows for all of the components to build debs safely in chrooted environments. This also provides a function to generate debian repositories
This module implements the pkgbuild interface
salt.modules.debuild_pkgbuild.build(runas, tgt, dest_dir, spec, sources, deps, env, template, saltenv='base', log_dir='/var/log/salt/pkgbuild') Given the package destination directory, the tarball containing debian files (e.g. control) and package sources, use pbuilder to safely build the platform package
salt '*' pkgbuild.make_src_pkg deb-8-x86_64 /var/www/html https://raw.githubusercontent.com/saltstack/libnacl/master/pkg/deb/python-libnacl.control https://pypi.python.org/packages/source/l/libnacl/libnacl-1.3.5.tar.gz
This example command should build the libnacl package for Debian using pbuilder and place it in /var/www/html/ on the minion
salt.modules.debuild_pkgbuild.make_repo(repodir, keyid=None, env=None, use_passphrase=False, gnupghome='/etc/salt/gpgkeys', runas='root', timeout=15.0) Make a package repository and optionally sign it and packages present
Given the repodir (directory to create repository in), create a Debian repository and optionally sign it and packages present. This state is best used with onchanges linked to your package building states.
repodir The directory to find packages that will be in the repository.
keyid  Changed in version 2016.3.0.
Optional Key ID to use in signing packages and repository. This consists of the last 8 hex digits of the GPG key ID.
Utilizes Public and Private keys associated with keyid which have been loaded into the minion's Pillar data. Leverages gpg-agent and gpg-preset-passphrase for caching keys, etc.  These pillar values are assumed to be filenames which are present in gnupghome. The pillar keys shown below have to match exactly.
For example, contents from a Pillar data file with named Public and Private keys as follows:
gpg_pkg_priv_keyname: gpg_pkg_key.pem gpg_pkg_pub_keyname: gpg_pkg_key.pub
env    Changed in version 2016.3.0.
A dictionary of environment variables to be utilized in creating the repository.
use_passphrase False New in version 2016.3.0.
Use a passphrase with the signing key presented in keyid. Passphrase is received from Pillar data which could be passed on the command line with pillar parameter. For example:
pillar='{ "gpg_passphrase" : "my_passphrase" }'
gnupghome /etc/salt/gpgkeys New in version 2016.3.0.
Location where GPG related files are stored, used with keyid.
runas  root New in version 2016.3.0.
User to create the repository as, and optionally sign packages.
NOTE: Ensure the user has correct permissions to any files and directories which are to be utilized.
timeout 15.0 New in version 2016.3.4.
Timeout in seconds to wait for the prompt for inputting the passphrase.
salt '*' pkgbuild.make_repo /var/www/html
salt.modules.debuild_pkgbuild.make_src_pkg(dest_dir, spec, sources, env=None, saltenv='base', runas='root') Create a platform specific source package from the given platform spec/control file and sources
salt '*' pkgbuild.make_src_pkg /var/www/html/ https://raw.githubusercontent.com/saltstack/libnacl/master/pkg/deb/python-libnacl.control.tar.xz https://pypi.python.org/packages/source/l/libnacl/libnacl-1.3.5.tar.gz
This example command should build the libnacl SOURCE package and place it in /var/www/html/ on the minion
dest_dir Absolute path for directory to write source package
spec   Absolute path to spec file or equivalent
sources Absolute path to source files to build source package from
env    None A list  or dictionary of environment variables to be set prior to execution.  Example:
- env: - DEB_BUILD_OPTIONS: 'nocheck'
WARNING: The above illustrates a common PyYAML pitfall, that yes, no, on, off, true, and false are all loaded as boolean True and False values, and must be enclosed in quotes to be used as strings. More info on this (and other) PyYAML idiosyncrasies can be found here.
saltenv: base Salt environment variables
runas  root New in version 2019.2.1.
User to create the files and directories
salt.modules.defaults Module to work with salt formula defaults files
salt.modules.defaults.deepcopy(source) Allows deep copy of objects in formulas. By default, Python does not copy objects, it creates bindings between a target and an object.
It is more typical to use this in a templating language in formulas, instead of directly on the command-line.
salt.modules.defaults.get(key, default='') defaults.get is used much like pillar.get except that it will read a default value for a pillar from defaults.json or defaults.yaml files that are stored in the root of a salt formula.
salt '*' defaults.get core:users:root
The defaults is computed from pillar key. The first entry is considered as the formula namespace.
For example, querying core:users:root will try to load salt://core/defaults.yaml and salt://core/defaults.json.
salt.modules.defaults.merge(dest, src, merge_lists=False, in_place=True) Allows deep merging of dicts in formulas.
merge_lists False If True, it will also merge lists instead of replace their items.
in_place True If True, it will merge into dest dict, if not it will make a new copy from that dict and return it.
salt '*' defaults.merge '{a: b}' '{d: e}'
salt.modules.defaults.update(dest, defaults, merge_lists=True, in_place=True) Allows setting defaults for group of data set e.g. group for nodes. This function is a combination of defaults.merge and defaults.deepcopy to avoid redundant in jinja.
group01: defaults: enabled: True extra: - test - stage nodes: host01: index: foo upstream: bar host02: index: foo2 upstream: bar2
{% do salt['defaults.update'](group01.nodes, group01.defaults) %}
Each node will look like the following:
host01: enabled: True index: foo upstream: bar extra: - test - stage
merge_lists True If True, it will also merge lists instead of replace their items.
in_place True If True, it will merge into dest dict.  if not it will make a new copy from that dict and return it.
salt.modules.devinfo maintainer Alberto Planas <aplanas@suse.com>
salt.modules.devinfo.filter_(udev_in=None, udev_ex=None) Returns a list of devices, filtered under udev keys.
udev_in A dictionary of key:values that are expected in the device udev information
udev_ex A dictionary of key:values that are not expected in the device udev information (excluded)
The key is a lower case string, joined by dots, that represent a path in the udev information dictionary. For example, 'e.id_bus' will represent the udev entry udev['E']['ID_BUS']
If the udev entry is a list, the algorithm will check that at least one item match one item of the value of the parameters.
Returns list of devices that match udev_in and do not match udev_ex.
salt '*' devinfo.filter udev_in='{"e.id_bus": "ata"}'
salt.modules.devinfo.hwinfo(items=None, short=True, listmd=False, devices=None) Probe for hardware
items  List of hardware items to inspect. Default ['bios', 'cpu', 'disk', 'memory', 'network', 'partition']
short  Show only a summary. Default True.
listmd Report RAID devices. Default False.
devices List of devices to show information from. Default None.
salt '*' devinfo.hwinfo salt '*' devinfo.hwinfo items='["disk"]' short=no salt '*' devinfo.hwinfo items='["disk"]' short=no devices='["/dev/sda"]' salt '*' devinfo.hwinfo devices=/dev/sda
salt.modules.devmap Device-Mapper module
salt.modules.devmap.multipath_flush(device) Device-Mapper Multipath flush
salt '*' devmap.multipath_flush mpath1
salt.modules.devmap.multipath_list() Device-Mapper Multipath list
salt '*' devmap.multipath_list
salt.modules.dig Compendium of generic DNS utilities.  The 'dig' command line tool must be installed in order to use this module.
salt.modules.dig.A(host, nameserver=None) Return the A record for host.
Always returns a list.
salt ns1 dig.A www.google.com
salt.modules.dig.AAAA(host, nameserver=None) Return the AAAA record for host.
salt ns1 dig.AAAA www.google.com
salt.modules.dig.MX(domain, resolve=False, nameserver=None) Return a list of lists for the MX of domain.
If the resolve argument is True, resolve IPs for the servers.
It's limited to one IP, because although in practice it's very rarely a round robin, it is an acceptable configuration and pulling just one IP lets the data be similar to the non-resolved version. If you think an MX has multiple IPs, don't use the resolver here, resolve them in a separate step.
salt ns1 dig.MX google.com
salt.modules.dig.NS(domain, resolve=True, nameserver=None) Return a list of IPs of the nameservers for domain
If resolve is False, don't resolve names.
salt ns1 dig.NS google.com
salt.modules.dig.SPF(domain, record='SPF', nameserver=None) Return the allowed IPv4 ranges in the SPF record for domain.
If record is SPF and the SPF record is empty, the TXT record will be searched automatically. If you know the domain uses TXT and not SPF, specifying that will save a lookup.
salt ns1 dig.SPF google.com
salt.modules.dig.TXT(host, nameserver=None) Return the TXT record for host.
salt ns1 dig.TXT google.com
salt.modules.dig.a(host, nameserver=None) Return the A record for host.
salt.modules.dig.aaaa(host, nameserver=None) Return the AAAA record for host.
salt.modules.dig.check_ip(addr) Check if address is a valid IP. returns True if valid, otherwise False.
salt ns1 dig.check_ip 127.0.0.1 salt ns1 dig.check_ip 1111:2222:3333:4444:5555:6666:7777:8888
salt.modules.dig.mx(domain, resolve=False, nameserver=None) Return a list of lists for the MX of domain.
salt.modules.dig.ns(domain, resolve=True, nameserver=None) Return a list of IPs of the nameservers for domain
salt.modules.dig.spf(domain, record='SPF', nameserver=None) Return the allowed IPv4 ranges in the SPF record for domain.
salt.modules.disk Module for managing disks and blockdevices
salt.modules.disk.blkid(device=None, token=None) Return block device attributes: UUID, LABEL, etc. This function only works on systems where blkid is available.
device Device name from the system
token  Any valid token used for the search
salt '*' disk.blkid salt '*' disk.blkid /dev/sda salt '*' disk.blkid token='UUID=6a38ee5-7235-44e7-8b22-816a403bad5d' salt '*' disk.blkid token='TYPE=ext4'
salt.modules.disk.dump(device, args=None) Return all contents of dumpe2fs for a specified device
salt '*' disk.dump /dev/sda1
salt.modules.disk.format_(device, fs_type='ext4', inode_size=None, lazy_itable_init=None, fat=None, force=False) Format a filesystem onto a device
device The device in which to create the new filesystem
fs_type The type of filesystem to create
inode_size Size of the inodes
This option is only enabled for ext and xfs filesystems
lazy_itable_init If enabled and the uninit_bg feature is enabled, the inode table will not be fully initialized by mke2fs.  This speeds up filesystem initialization noticeably, but it requires the kernel to finish initializing the filesystem  in  the background  when  the filesystem is first mounted.  If the option value is omitted, it defaults to 1 to enable lazy inode table zeroing.
This option is only enabled for ext filesystems
fat    FAT size option. Can be 12, 16 or 32, and can only be used on fat or vfat filesystems.
force  Force mke2fs to create a filesystem, even if the specified device is not a partition on a block special device. This option is only enabled for ext and xfs filesystems
This option is dangerous, use it with caution.
salt '*' disk.format /dev/sdX1
salt.modules.disk.fstype(device) Return the filesystem name of the specified device
device The name of the device
salt '*' disk.fstype /dev/sdX1
salt.modules.disk.hdparms(disks, args=None) Retrieve all info's for all disks parse 'em into a nice dict (which, considering hdparms output, is quite a hassle)
salt '*' disk.hdparms /dev/sda
salt.modules.disk.hpa(disks, size=None) Get/set Host Protected Area settings
T13 INCITS 346-2001 (1367D) defines the BEER (Boot Engineering Extension Record) and PARTIES (Protected Area Run Time Interface Extension Services), allowing for a Host Protected Area on a disk.
It's often used by OEMS to hide parts of a disk, and for overprovisioning SSD's
WARNING: Setting the HPA might clobber your data, be very careful with this on active disks!
salt '*' disk.hpa /dev/sda salt '*' disk.hpa /dev/sda 5% salt '*' disk.hpa /dev/sda 10543256
salt.modules.disk.inodeusage(args=None) Return inode usage information for volumes mounted on this minion
salt '*' disk.inodeusage
salt.modules.disk.iostat(interval=1, count=5, disks=None) Gather and return (averaged) IO stats.
Changed in version 2016.11.4: Added support for AIX
salt '*' disk.iostat 1 5 disks=sda
salt.modules.disk.percent(args=None) Return partition information for volumes mounted on this minion
salt '*' disk.percent /var
salt.modules.disk.resize2fs(device) Resizes the filesystem.
salt '*' disk.resize2fs /dev/sda1
salt.modules.disk.smart_attributes(dev, attributes=None, values=None) Fetch SMART attributes Providing attributes will deliver only requested attributes Providing values will deliver only requested values for attributes
Default is the Backblaze recommended set (‐ https://www.backblaze.com/blog/hard-drive-smart-stats/): (5,187,188,197,198)
salt '*' disk.smart_attributes /dev/sda salt '*' disk.smart_attributes /dev/sda attributes=(5,187,188,197,198)
salt.modules.disk.tune(device, **kwargs) Set attributes for the specified device
salt '*' disk.tune /dev/sda1 read-ahead=1024 read-write=True
Valid options are: read-ahead, filesystem-read-ahead, read-only, read-write.
See the blockdev(8) manpage for a more complete description of these options.
salt.modules.disk.usage(args=None) Return usage information for volumes mounted on this minion
Changed in version 2019.2.0: Default for SunOS changed to 1 kilobyte blocks
salt.modules.disk.wipe(device) Remove the filesystem information
salt '*' disk.wipe /dev/sda1
salt.modules.djangomod Manage Django sites
salt.modules.djangomod.collectstatic(settings_module, bin_env=None, no_post_process=False, ignore=None, dry_run=False, clear=False, link=False, no_default_ignore=False, pythonpath=None, env=None, runas=None) Collect static files from each of your applications into a single location that can easily be served in production.
salt '*' django.collectstatic <settings_module>
salt.modules.djangomod.command(settings_module, command, bin_env=None, pythonpath=None, env=None, runas=None, *args, **kwargs) Run arbitrary django management command
salt '*' django.command <settings_module> <command>
salt.modules.djangomod.createsuperuser(settings_module, username, email, bin_env=None, database=None, pythonpath=None, env=None, runas=None) Create a super user for the database.  This function defaults to use the --noinput flag which prevents the creation of a password for the superuser.
salt '*' django.createsuperuser <settings_module> user user@example.com
salt.modules.djangomod.loaddata(settings_module, fixtures, bin_env=None, database=None, pythonpath=None, env=None) Load fixture data
Fixtures: comma separated list of fixtures to load
salt '*' django.loaddata <settings_module> <comma delimited list of fixtures>
salt.modules.djangomod.migrate(settings_module, app_label=None, migration_name=None, bin_env=None, database=None, pythonpath=None, env=None, noinput=True, runas=None) Run migrate
Execute the Django-Admin migrate command (requires Django 1.7 or higher).
settings_module Specifies the settings module to use.  The settings module should be in Python package syntax, e.g. mysite.settings. If this isn’t provided, django-admin will use the DJANGO_SETTINGS_MODULE environment variable.
app_label Specific app to run migrations for, instead of all apps. This may involve running other apps’ migrations too, due to dependencies.
migration_name Named migration to be applied to a specific app.  Brings the database schema to a state where the named migration is applied, but no later migrations in the same app are applied. This may involve unapplying migrations if you have previously migrated past the named migration.  Use the name zero to unapply all migrations for an app.
bin_env Path to pip (or to a virtualenv). This can be used to specify the path to the pip to use when more than one Python release is installed (e.g.  /usr/bin/pip-2.7 or /usr/bin/pip-2.6. If a directory path is specified, it is assumed to be a virtualenv.
database Database to migrate. Defaults to 'default'.
pythonpath Adds the given filesystem path to the Python import search path.  If this isn’t provided, django-admin will use the PYTHONPATH environment variable.
module.run: - name: django.migrate - settings_module: my_django_app.settings - env: - DATABASE_USER: 'mydbuser'
noinput Suppresses all user prompts. Defaults to True.
runas  The user name to run the command as.
salt '*' django.migrate <settings_module> salt '*' django.migrate <settings_module> <app_label> salt '*' django.migrate <settings_module> <app_label> <migration_name>
salt.modules.djangomod.syncdb(settings_module, bin_env=None, migrate=False, database=None, pythonpath=None, env=None, noinput=True, runas=None) Run syncdb
Execute the Django-Admin syncdb command, if South is available on the minion the migrate option can be passed as True calling the migrations to run after the syncdb completes
NOTE: The syncdb command was deprecated in Django 1.7 and removed in Django 1.9.  For Django versions 1.9 or higher use the migrate command instead.
salt '*' django.syncdb <settings_module>
salt.modules.dnsmasq Module for managing dnsmasq
salt.modules.dnsmasq.fullversion() Shows installed version of dnsmasq and compile options.
salt '*' dnsmasq.fullversion
salt.modules.dnsmasq.get_config(config_file='/etc/dnsmasq.conf') Dumps all options from the config file.
config_file The location of the config file from which to obtain contents.  Defaults to /etc/dnsmasq.conf.
salt '*' dnsmasq.get_config salt '*' dnsmasq.get_config config_file=/etc/dnsmasq.conf
salt.modules.dnsmasq.set_config(config_file='/etc/dnsmasq.conf', follow=True, **kwargs) Sets a value or a set of values in the specified file. By default, if conf-dir is configured in this file, salt will attempt to set the option in any file inside the conf-dir where it has already been enabled. If it does not find it inside any files, it will append it to the main config file. Setting follow to False will turn off this behavior.
If a config option currently appears multiple times (such as dhcp-host, which is specified at least once per host), the new option will be added to the end of the main config file (and not to any includes). If you need an option added to a specific include file, specify it as the config_file.
• config_file (string) -- config file where settings should be updated / added.
• follow (bool) -- attempt to set the config option inside any file within the conf-dir where it has already been enabled.
• kwargs -- key value pairs that contain the configuration settings that you want set.
salt '*' dnsmasq.set_config domain=mydomain.com salt '*' dnsmasq.set_config follow=False domain=mydomain.com salt '*' dnsmasq.set_config config_file=/etc/dnsmasq.conf domain=mydomain.com
salt.modules.dnsmasq.version() Shows installed version of dnsmasq.
salt '*' dnsmasq.version
salt.modules.dnsutil Compendium of generic DNS utilities.
NOTE: Some functions in the dnsutil execution module depend on dig.
salt.modules.dnsutil.A(host, nameserver=None) Return the A record(s) for host.
salt ns1 dnsutil.A www.google.com
salt.modules.dnsutil.AAAA(host, nameserver=None) Return the AAAA record(s) for host.
New in version 2014.7.5.
salt ns1 dnsutil.AAAA www.google.com
salt.modules.dnsutil.MX(domain, resolve=False, nameserver=None) Return a list of lists for the MX of domain.
If the 'resolve' argument is True, resolve IPs for the servers.
salt ns1 dnsutil.MX google.com
salt.modules.dnsutil.NS(domain, resolve=True, nameserver=None) Return a list of IPs of the nameservers for domain
If 'resolve' is False, don't resolve names.
salt ns1 dnsutil.NS google.com
salt.modules.dnsutil.SPF(domain, record='SPF', nameserver=None) Return the allowed IPv4 ranges in the SPF record for domain.
salt ns1 dnsutil.SPF google.com
salt.modules.dnsutil.check_ip(ip_addr) Check that string ip_addr is a valid IP
salt ns1 dnsutil.check_ip 127.0.0.1
salt.modules.dnsutil.hosts_append(hostsfile='/etc/hosts', ip_addr=None, entries=None) Append a single line to the /etc/hosts file.
salt '*' dnsutil.hosts_append /etc/hosts 127.0.0.1 ad1.yuk.co,ad2.yuk.co
salt.modules.dnsutil.hosts_remove(hostsfile='/etc/hosts', entries=None) Remove a host from the /etc/hosts file. If doing so will leave a line containing only an IP address, then the line will be deleted. This function will leave comments and blank lines intact.
salt '*' dnsutil.hosts_remove /etc/hosts ad1.yuk.co salt '*' dnsutil.hosts_remove /etc/hosts ad2.yuk.co,ad1.yuk.co
salt.modules.dnsutil.parse_hosts(hostsfile='/etc/hosts', hosts=None) Parse /etc/hosts file.
salt '*' dnsutil.parse_hosts
salt.modules.dnsutil.parse_zone(zonefile=None, zone=None) Parses a zone file. Can be passed raw zone data on the API level.
salt ns1 dnsutil.parse_zone /var/lib/named/example.com.zone
salt.modules.dnsutil.serial(zone='', update=False) Return, store and update a dns serial for your zone files.
zone: a keyword for a specific zone
update: store an updated version of the serial in a grain
If update is False, the function will retrieve an existing serial or return the current date if no serial is stored. Nothing will be stored
If update is True, the function will set the serial to the current date if none exist or if the existing serial is for a previous date. If a serial for greater than the current date is already stored, the function will increment it.
This module stores the serial in a grain, you can explicitly set the stored value as a grain named dnsserial_<zone_name>.
salt ns1 dnsutil.serial example.com
salt.modules.dockercompose Module to import docker-compose via saltstack
maintainer Jean Praloran <jeanpralo@gmail.com>
depends docker-compose>=1.5
Introduction This module allows one to deal with docker-compose file in a directory.
This is  a first version only, the following commands are missing at the moment but will be built later on if the community is interested in this module:
• run
• logs
• scale
Installation Prerequisites This execution module requires at least version 1.4.0 of both docker-compose and Docker. docker-compose can easily be installed using pip.install:
salt myminion pip.install docker-compose>=1.5.0
How to use this module? In order to use the module if you have no docker-compose file on the server you can issue the command create, it takes two arguments the path where the docker-compose.yml will be stored and the content of this latter:
# salt-call -l debug dockercompose.create /tmp/toto ' database: image: mongo:3.0 command: mongod --smallfiles --quiet --logpath=/dev/null '
Then you can execute a list of method defined at the bottom with at least one argument (the path where the docker-compose.yml will be read) and an optional python list which corresponds to the services names:
# salt-call -l debug dockercompose.up /tmp/toto # salt-call -l debug dockercompose.restart /tmp/toto '[database]' # salt-call -l debug dockercompose.stop /tmp/toto # salt-call -l debug dockercompose.rm /tmp/toto
Docker-compose method supported • up
• restart
• start
• pause
• unpause
• kill
• rm
• ps
• pull
Functions •
docker-compose.yml management
• dockercompose.create
• dockercompose.get
• dockercompose.restart
• dockercompose.stop
• dockercompose.pause
• dockercompose.unpause
• dockercompose.start
• dockercompose.kill
• dockercompose.rm
• dockercompose.up
Manage containers image:
• dockercompose.pull
• dockercompose.build
Gather information about containers:
• dockercompose.ps
Manage service definitions:
• dockercompose.service_create
• dockercompose.service_upsert
• dockercompose.service_remove
• dockercompose.service_set_tag
Detailed Function Documentation salt.modules.dockercompose.build(path, service_names=None) Build image for containers in the docker-compose file, service_names is a python list, if omitted build images for all containers. Please note that at the moment the module does not allow you to upload your Dockerfile, nor any other file you could need with your docker-compose.yml, you will have to make sure the files you need are actually in the directory specified in the build keyword
path   Path where the docker-compose file is stored on the server
service_names If specified will pull only the image for the specified services
salt myminion dockercompose.build /path/where/docker-compose/stored salt myminion dockercompose.build /path/where/docker-compose/stored '[janus]'
salt.modules.dockercompose.create(path, docker_compose) Create and validate a docker-compose file into a directory
path   Path where the docker-compose file will be stored on the server
docker_compose docker_compose file
salt myminion dockercompose.create /path/where/docker-compose/stored content
salt.modules.dockercompose.get(path) Get the content of the docker-compose file into a directory
salt myminion dockercompose.get /path/where/docker-compose/stored
salt.modules.dockercompose.kill(path, service_names=None) Kill containers in the docker-compose file, service_names is a python list, if omitted kill all containers
service_names If specified will kill only the specified services
salt myminion dockercompose.kill /path/where/docker-compose/stored salt myminion dockercompose.kill /path/where/docker-compose/stored '[janus]'
salt.modules.dockercompose.pause(path, service_names=None) Pause running containers in the docker-compose file, service_names is a python list, if omitted pause all containers
service_names If specified will pause only the specified services
salt myminion dockercompose.pause /path/where/docker-compose/stored salt myminion dockercompose.pause /path/where/docker-compose/stored '[janus]'
salt.modules.dockercompose.ps(path) List all running containers and report some information about them
salt myminion dockercompose.ps /path/where/docker-compose/stored
salt.modules.dockercompose.pull(path, service_names=None) Pull image for containers in the docker-compose file, service_names is a python list, if omitted pull all images
salt myminion dockercompose.pull /path/where/docker-compose/stored salt myminion dockercompose.pull /path/where/docker-compose/stored '[janus]'
salt.modules.dockercompose.restart(path, service_names=None) Restart container(s) in the docker-compose file, service_names is a python list, if omitted restart all containers
service_names If specified will restart only the specified services
salt myminion dockercompose.restart /path/where/docker-compose/stored salt myminion dockercompose.restart /path/where/docker-compose/stored '[janus]'
salt.modules.dockercompose.rm(path, service_names=None) Remove stopped containers in the docker-compose file, service_names is a python list, if omitted remove all stopped containers
service_names If specified will remove only the specified stopped services
salt myminion dockercompose.rm /path/where/docker-compose/stored salt myminion dockercompose.rm /path/where/docker-compose/stored '[janus]'
salt.modules.dockercompose.service_create(path, service_name, definition) Create the definition of a docker-compose service This fails when the service already exists This does not pull or up the service This wil re-write your yaml file. Comments will be lost. Indentation is set to 2 spaces
service_name Name of the service to create
definition Service definition as yaml or json string
salt myminion dockercompose.service_create /path/where/docker-compose/stored service_name definition
salt.modules.dockercompose.service_remove(path, service_name) Remove the definition of a docker-compose service This does not rm the container This wil re-write your yaml file. Comments will be lost. Indentation is set to 2 spaces
service_name Name of the service to remove
salt myminion dockercompose.service_remove /path/where/docker-compose/stored service_name
salt.modules.dockercompose.service_set_tag(path, service_name, tag) Change the tag of a docker-compose service This does not pull or up the service This wil re-write your yaml file. Comments will be lost. Indentation is set to 2 spaces
tag    Name of the tag (often used as version) that the service image should have
salt myminion dockercompose.service_create /path/where/docker-compose/stored service_name tag
salt.modules.dockercompose.service_upsert(path, service_name, definition) Create or update the definition of a docker-compose service This does not pull or up the service This wil re-write your yaml file. Comments will be lost. Indentation is set to 2 spaces
salt myminion dockercompose.service_upsert /path/where/docker-compose/stored service_name definition
salt.modules.dockercompose.start(path, service_names=None) Start containers in the docker-compose file, service_names is a python list, if omitted start all containers
service_names If specified will start only the specified services
salt myminion dockercompose.start /path/where/docker-compose/stored salt myminion dockercompose.start /path/where/docker-compose/stored '[janus]'
salt.modules.dockercompose.stop(path, service_names=None) Stop running containers in the docker-compose file, service_names is a python list, if omitted stop all containers
service_names If specified will stop only the specified services
salt myminion dockercompose.stop /path/where/docker-compose/stored salt myminion dockercompose.stop  /path/where/docker-compose/stored '[janus]'
salt.modules.dockercompose.unpause(path, service_names=None) Un-Pause containers in the docker-compose file, service_names is a python list, if omitted unpause all containers
service_names If specified will un-pause only the specified services
salt.modules.dockercompose.up(path, service_names=None) Create and start containers defined in the docker-compose.yml file located in path, service_names is a python list, if omitted create and start all containers
service_names If specified will create and start only the specified services
salt myminion dockercompose.up /path/where/docker-compose/stored salt myminion dockercompose.up /path/where/docker-compose/stored '[janus]'
salt.modules.dockermod Management of Docker Containers
Changed in version 2017.7.0: This module has replaced the legacy docker execution module.
depends docker Python module
NOTE: Older releases of the Python bindings for Docker were called docker-py in PyPI. All releases of docker, and releases of docker-py >= 1.6.0 are supported. These python bindings can easily be installed using pip.install:
salt myminion pip.install docker
To upgrade from docker-py to docker, you must first uninstall docker-py, and then install docker:
salt myminion pip.uninstall docker-py salt myminion pip.install docker
Authentication If you have previously performed a docker login from the minion, then the credentials saved in ~/.docker/config.json will be used for any actions which require authentication. If not, then credentials can be configured in any of the following locations:
• Minion config file
• Grains
• Pillar data
• Master config file (requires pillar_opts to be set to True in Minion config file in order to work)
IMPORTANT: Versions prior to 3000 require that Docker credentials are configured in Pillar data. Be advised that Pillar data is still recommended though, because this keeps the configuration from being stored on the Minion.
Also, keep in mind that if one gets your ~/.docker/config.json, the password can be decoded from its contents.
The configuration schema is as follows:
docker-registries: <registry_url>: username: <username> password: <password>
docker-registries: hub: username: foo password: s3cr3t
NOTE: As of the 2016.3.7, 2016.11.4, and 2017.7.0 releases of Salt, credentials for the Docker Hub can be configured simply by specifying hub in place of the registry URL. In earlier releases, it is necessary to specify the actual registry URL for the Docker Hub (i.e. https://index.docker.io/v1/).
More than one registry can be configured. Salt will look for Docker credentials in the docker-registries Pillar key, as well as any key ending in -docker-registries. For example:
docker-registries: 'https://mydomain.tld/registry:5000': username: foo password: s3cr3t
foo-docker-registries: https://index.foo.io/v1/: username: foo password: s3cr3t
bar-docker-registries: https://index.bar.io/v1/: username: foo password: s3cr3t
To login to the configured registries, use the docker.login function. This only needs to be done once for a given registry, and it will store/update the credentials in ~/.docker/config.json.
NOTE: For Salt releases before 2016.3.7 and 2016.11.4, docker.login is not available. Instead, Salt will try to authenticate using each of your configured registries for each push/pull, behavior which is not correct and has been resolved in newer releases.
Configuration Options The following configuration options can be set to fine-tune how Salt uses Docker:
• docker.url: URL to the docker service (default: local socket).
• docker.version: API version to use (should not need to be set manually in the vast majority of cases)
• docker.exec_driver: Execution driver to use, one of nsenter, lxc-attach, or docker-exec. See the Executing Commands Within a Running Container section for more details on how this config parameter is used.
These configuration options are retrieved using config.get (click the link for further information).
Executing Commands Within a Running Container NOTE: With the release of Docker 1.13.1, the Execution Driver has been removed.  Starting in versions 2016.3.6, 2016.11.4, and 2017.7.0, Salt defaults to using docker exec to run commands in containers, however for older Salt releases it will be necessary to set the docker.exec_driver config option to either docker-exec or nsenter for Docker versions 1.13.1 and newer.
Multiple methods exist for executing commands within Docker containers:
• lxc-attach: Default for older versions of docker
• nsenter: Enters container namespace to run command
• docker-exec: Native support for executing commands in Docker containers (added in Docker 1.3)
Adding a configuration option (see config.get) called docker.exec_driver will tell Salt which execution driver to use:
docker.exec_driver: docker-exec
If this configuration option is not found, Salt will use the appropriate interface (either nsenter or lxc-attach) based on the Execution Driver value returned from docker info. docker-exec will not be used by default, as it is presently (as of version 1.6.2) only able to execute commands as the effective user of the container. Thus, if a USER directive was used to run as a non-privileged user, docker-exec would be unable to perform the action as root. Salt can still use docker-exec as an execution driver, but must be explicitly configured (as in the example above) to do so at this time.
If possible, try to manually specify the execution driver, as it will save Salt a little work.
This execution module provides functions that shadow those from the cmd module. They are as follows:
• docker.retcode
• docker.run
• docker.run_all
• docker.run_stderr
• docker.run_stdout
• docker.script
• docker.script_retcode
Detailed Function Documentation class salt.modules.dockermod.DockerJSONDecoder(*, object_hook=None, parse_float=None, parse_int=None, parse_constant=None, strict=True, object_pairs_hook=None)
decode(s, _w=None) Return the Python representation of s (a str instance containing a JSON document).
salt.modules.dockermod.apply_(name, mods=None, **kwargs) New in version 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.
salt 'docker' docker.apply web01 salt 'docker' docker.apply web01 test salt 'docker' docker.apply web01 test,pkgs
salt.modules.dockermod.build(path=None, repository=None, tag=None, cache=True, rm=True, api_response=False, fileobj=None, dockerfile=None, buildargs=None) Changed in version 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 URL
path   Path to directory on the Minion containing a Dockerfile
repository Optional repository name for the image being built
tag    latest Tag name for the image (required if repository is passed)
image  Deprecated since version 2018.3.0: Use both repository and tag instead
cache  True Set to False to force the build process not to use the Docker image cache, and pull all required intermediate image layers
rm     True Remove intermediate containers created during build
api_response False If True: an API_Response key will be present in the return data, containing the raw output from the Docker API.
fileobj Allows for a file-like object containing the contents of the Dockerfile to be passed in place of a file path argument. This argument should not be used from the CLI, only from other Salt code.
dockerfile Allows for an alternative Dockerfile to be specified. Path to alternative Dockefile is relative to the build path for the Docker container.
buildargs A dictionary of build arguments provided to the docker build process.
RETURN DATA
A dictionary containing one or more of the following keys:
• Id - ID of the newly-built image
• Time_Elapsed - Time in seconds taken to perform the build
• Intermediate_Containers - IDs of containers created during the course of the build process
(Only present if rm=False)
Images - A dictionary containing one or more of the following keys:
• Already_Pulled - Layers that that were already present on the Minion
• Pulled - Layers that that were pulled
(Only present if the image specified by the "repository" and "tag" arguments was not present on the Minion, or if cache=False)
• Status - A string containing a summary of the pull action (usually a message saying that an image was downloaded, or that it was up to date).
salt myminion docker.build /path/to/docker/build/dir salt myminion docker.build https://github.com/myuser/myrepo.git repository=myimage tag=latest salt myminion docker.build /path/to/docker/build/dir dockerfile=Dockefile.different repository=myimage tag=dev
salt.modules.dockermod.call(name, function, *args, **kwargs) Executes a Salt function inside a running container
The container does not need to have Salt installed, but Python is required.
name   Container name or ID
salt myminion docker.call test.ping salt myminion test.arg arg1 arg2 key1=val1 salt myminion dockerng.call compassionate_mirzakhani test.arg arg1 arg2 key1=val1
salt.modules.dockermod.commit(name, repository, tag='latest', message=None, author=None) Changed in version 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 commit Docker CLI command.
name   Container name or ID to commit
repository Repository name for the image being committed
tag    latest Tag name for the image
message Commit message (Optional)
author Author name (Optional)
A dictionary containing the following keys:
• Id - ID of the newly-created image
• Image - Name of the newly-created image
• Time_Elapsed - Time in seconds taken to perform the commit
salt myminion docker.commit mycontainer myuser/myimage mytag
salt.modules.dockermod.compare_container(first, second, ignore=None) This function is an alias of compare_containers. New in version 2017.7.0.
Changed in version 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 ID of first container
second Name or ID of second container
ignore A comma-separated list (or Python list) of keys to ignore when comparing. This is useful when comparing two otherwise identical containers which have different hostnames.
salt myminion docker.compare_containers foo bar salt myminion docker.compare_containers foo bar ignore=Hostname
salt.modules.dockermod.compare_container_networks(first, second) New in version 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 which the network is absent.
This function works by comparing the contents of both containers' Networks keys (under NetworkSettings) in the return data from docker.inspect_container. Because each network contains some items that either A) only set at runtime, B) naturally varying from container to container, or both, by default the following keys in each network are examined:
• Aliases
• Links
• IPAMConfig
The exception to this is if IPAMConfig is unset (i.e. null) in one container but not the other. This happens when no static IP configuration is set, and automatic IP configuration is in effect. So, in order to report on changes between automatic IP configuration in one container and static IP configuration in another container (as we need to do for the docker_container.running state), automatic IP configuration will also be checked in these cases.
This function uses the docker.compare_container_networks minion config option to determine which keys to examine. This provides flexibility in the event that features added in a future Docker release necessitate changes to how Salt compares networks. In these cases, rather than waiting for a new Salt release one can just set docker.compare_container_networks.