neulab/tldr huggingface dataset:
sdb modules ┌───────────┬─────────────────────────────┐ │cache      │ cache Module                │ ├───────────┼─────────────────────────────┤ │confidant  │ An SDB module for getting   │ │           │ credentials from confidant. │ ├───────────┼─────────────────────────────┤ │consul     │ Consul sdb Module           │ ├───────────┼─────────────────────────────┤ │couchdb    │ CouchDB sdb Module          │ ├───────────┼─────────────────────────────┤ │env        │ Environment sdb Module      │ ├───────────┼─────────────────────────────┤ │etcd_db    │ etcd Database Module        │ ├───────────┼─────────────────────────────┤ │keyring_db │ Keyring Database Module     │ ├───────────┼─────────────────────────────┤ │memcached  │ Memcached sdb Module        │ ├───────────┼─────────────────────────────┤ │redis_sdb  │ Redis SDB module            │ ├───────────┼─────────────────────────────┤ │rest       │ Generic REST API SDB Module │ ├───────────┼─────────────────────────────┤ │sqlite3    │ SQLite sdb Module           │ └───────────┴─────────────────────────────┘
│tism       │ tISM - the Immutable        │ │           │ Secrets Manager SDB Module  │ ├───────────┼─────────────────────────────┤ │vault      │ Vault SDB Module            │ ├───────────┼─────────────────────────────┤ │yaml       │ Pull sdb values from a YAML │ │           │ file                        │ └───────────┴─────────────────────────────┘
salt.sdb.cache cache Module
This module provides access to Salt's cache subsystem.
Like all sdb modules, the cache module requires a configuration profile to be configured in either the minion or master configuration file. This profile requires very little. In the example:
mastercloudcache: driver: cache bank: cloud/active/ec2/my-ec2-conf/saltmaster cachedir: /var/cache/salt
The driver refers to the cache module, bank refers to the cache bank that contains the data and cachedir (optional), if used, points to an alternate directory for cache data storage.
master_ip: sdb://mastercloudcache/public_ips
It is also possible to override both the bank and cachedir options inside the SDB URI:
master_ip: sdb://mastercloudcache/public_ips?cachedir=/var/cache/salt
For this reason, both the bank and the cachedir options can be omitted from the SDB profile. However, if the bank option is omitted, it must be specified in the URI:
master_ip: sdb://mastercloudcache/public_ips?bank=cloud/active/ec2/my-ec2-conf/saltmaster
salt.sdb.cache.delete(key, service=None, profile=None) Get a value from the cache service
salt.sdb.cache.get(key, service=None, profile=None) Get a value from the cache service
salt.sdb.cache.set_(key, value, service=None, profile=None) Set a key/value pair in the cache service
salt.sdb.confidant An SDB module for getting credentials from confidant.
Configuring the Confidant module The module can be configured via sdb in the minion config:
confidant: driver: confidant # The URL of the confidant web service url: 'https://confidant-production.example.com' # The context to use for KMS authentication auth_context: from: example-production-iad to: confidant-production-iad user_type: service # The KMS master key to use for authentication auth_key: "alias/authnz" # Cache file for KMS auth token token_cache_file: /run/confidant/confidant_token # The duration of the validity of a token, in minutes token_duration: 60 # key, keyid and region can be defined in the profile, but it's generally # best to use IAM roles or environment variables for AWS auth. keyid: 98nh9h9h908h09kjjk key: jhf908gyeghehe0he0g8h9u0j0n0n09hj09h0 region: us-east-1
Module Documentation salt.sdb.confidant.get(key, profile=None) Read pillar data from Confidant via its API.
salt myminion sdb.get 'sdb://confidant/credentials'
Valid keys are: credentials, credentials_metadata, result. credentials returns a dict of joined credential_pairs, credentials_metadata returns a dict of metadata relevant to the credentials mapped to the confidant service, and result returns a bool that can be used to determine if the sdb call succeeded or failed to fetch credentials from confidant (or from local cache). If result is false, the data in credentials or credentials_metadata can't be trusted.
salt.sdb.consul Consul sdb Module
This module allows access to Consul using an sdb:// URI
Like all sdb modules, the Consul module requires a configuration profile to be configured in either the minion or master configuration file. This profile requires very little. For example:
myconsul: driver: consul host: 127.0.0.1 port: 8500 token: b6376760-a8bb-edd5-fcda-33bc13bfc556 scheme: http consistency: default dc: dev verify: True
The driver refers to the Consul module, all other options are optional. For option details see: https://python-consul.readthedocs.io/en/latest/#consul
salt.sdb.consul.get(key, profile=None)
salt.sdb.consul.get_conn(profile) Return a client object for accessing consul
salt.sdb.consul.set_(key, value, profile=None)
salt.sdb.couchdb CouchDB sdb Module
depends python2-couchdb
This allow interaction between Salt and a CouchDB [couchdb.apache.org] database. It uses salt's sdb system to allow for inserts and retrevals using the sdb:// prefix in salt configuration files.
To use the couchbase sdb module, it must first be configured in the salt master or minion config. The following arguments are required:
couchdb_sdb: driver: couchdb host: localhost port: 5984 database: salt_sdb
One could then query the CouchDB instance via an sdb:// URI such as the following:
password: sdb://couchdb_sdb/mykey
To use this interface, you must track IDs on your own or have another source to do the map-reduce logic necessary to calculate the ID you wish to fetch.
Additional contributions to build true map-reduce functionality into this module would be welcome.
salt.sdb.couchdb.get(key, profile=None) Get a value from couchdb by id
salt.sdb.couchdb.set_(key, value, profile=None) Set a key/value pair in couchdb
salt.sdb.env Environment sdb Module
This module allows access to environment variables using an sdb:// URI.
Example configuration for this module:
osenv: driver: env
WARNING: OS environment variables will be available to read via SDB.  Please make sure you don't have any sensitive data in your environment variables!!
Example usage of sdb env module:
set some env var: cmd.run: - name: echo {{ salt['sdb.set']('sdb://osenv/foo', 'bar') }} - order: 1
{% if salt['sdb.get']('sdb://osenv/foo') == 'bar' %} always-changes-and-succeeds: test.succeed_with_changes: - name: foo {% else %} always-changes-and-fails: test.fail_with_changes: - name: foo {% endif  %}
The above example will return success.
The env sdb module can also be used with salt cloud.  Assuming you have exported the environment variable named compute (and have osenv defined). The example below will look for the salt cloud config key compute_name in the environment:
my-openstack-config: compute_name: sdb://osenv/compute ..snip
salt.sdb.env.get(key, profile=None) Get a value
salt.sdb.env.set_(key, value, profile=None) Set a key/value pair
salt.sdb.etcd_db etcd Database Module
depends python-etcd
This module allows access to the etcd database using an sdb:// URI. This package is located at https://pypi.python.org/pypi/python-etcd.
Like all sdb modules, the etcd module requires a configuration profile to be configured in either the minion or master configuration file. This profile requires very little. In the example:
myetcd: driver: etcd etcd.host: 127.0.0.1 etcd.port: 2379
The driver refers to the etcd module, etcd.host refers to the host that is hosting the etcd database and etcd.port refers to the port on that host.
password: sdb://myetcd/mypassword
salt.sdb.etcd_db.delete(key, service=None, profile=None) Get a value from the etcd service
salt.sdb.etcd_db.get(key, service=None, profile=None) Get a value from the etcd service
salt.sdb.etcd_db.set_(key, value, service=None, profile=None) Set a key/value pair in the etcd service
salt.sdb.keyring_db Keyring Database Module
depends keyring
This module allows access to the keyring package using an sdb:// URI. This package is located at https://pypi.python.org/pypi/keyring.
Care must be taken when using keyring. Not all keyend backends are supported on all operating systems. Also, many backends require an agent to be running in order to work. For instance, the "Secret Service" backend requires a compatible agent such as gnome-keyring-daemon or kwallet to be running. The keyczar backend does not seem to enjoy the benefits of an agent, and so using it will require either that the password is typed in manually (which is unreasonable for the salt-minion and salt-master daemons, especially in production) or an agent is written for it.
Like all sdb modules, the keyring module requires a configuration profile to be configured in either the minion or master configuration file. This profile requires very little. In the example:
The driver refers to the keyring module, service refers to the service that will be used inside of keyring (which may be likened unto a database table) and mykeyring refers to the name that will appear in the URI:
password: sdb://mykeyring/mypassword
The underlying backend configuration must be configured via keyring itself. For examples and documentation, see keyring:
https://pypi.python.org/pypi/keyring
salt.sdb.keyring_db.get(key, service=None, profile=None) Get a value from a keyring service
salt.sdb.keyring_db.set_(key, value, service=None, profile=None) Set a key/value pair in a keyring service
salt.sdb.memcached Memcached sdb Module
depends python-memcached
This module allows access to memcached using an sdb:// URI. This package is located at https://pypi.python.org/pypi/python-memcached.
Like all sdb modules, the memcached module requires a configuration profile to be configured in either the minion or master configuration file. This profile requires very little. In the example:
mymemcache: driver: memcached memcached.host: localhost memcached.port: 11211
The driver refers to the memcached module, host and port the memcached server to connect to (defaults to localhost and 11211, and mymemcached refers to the name that will appear in the URI:
password: sdb://mymemcached/mykey
salt.sdb.memcached.get(key, profile=None) Get a value from memcached
salt.sdb.memcached.set_(key, value, profile=None) Set a key/value pair in memcached
salt.sdb.redis_sdb Redis SDB module New in version 2019.2.0.
This module allows access to Redis  using an sdb:// URI.
Like all SDB modules, the Redis module requires a configuration profile to be configured in either the minion or master configuration file. This profile requires very little. For example:
sdb_redis: driver: redis host: 127.0.0.1 port: 6379 password: pass db: 1
The driver refers to the Redis module, all other options are optional. For option details see: https://redis-py.readthedocs.io/en/latest/.
salt.sdb.redis_sdb.delete(key, profile=None) Delete a key from the Redis SDB.
salt.sdb.redis_sdb.get(key, profile=None) Get a value from the Redis SDB.
salt.sdb.redis_sdb.set_(key, value, profile=None) Set a value into the Redis SDB.
salt.sdb.rest Generic REST API SDB Module
This module allows access to a REST interface using an sdb:// URI.
Like all REST modules, the REST module requires a configuration profile to be configured in either the minion or master configuration file. This profile requires very little. In the example:
my-rest-api: driver: rest urls: url: https://api.github.com/ keys: url: https://api.github.com/users/{{user}}/keys backend: requests
The driver refers to the REST module, and must be set to rest in order to use this driver. Each of the other items inside this block refers to a separate set of HTTP items, including a URL and any options associated with it.  The options used here should match the options available in salt.utils.http.query().
In order to call the urls item in the example, the following reference can be made inside a configuration file:
github_urls: sdb://my-rest-api/urls
Key/Value pairs may also be used with this driver, and merged into the URL using the configured renderer (jinja, by default). For instance, in order to use the keys item in the example, the following reference can be made:
github_urls: sdb://my-rest-api/keys?user=myuser
This will cause the following URL to actually be called:
https://api.github.com/users/myuser/keys
Key/Value pairs will NOT be passed through as GET data. If GET data needs to be sent to the URL, then it should be configured in the SDB configuration block.  For instance:
another-rest-api: driver: rest user_data: url: https://api.example.com/users/ params: user: myuser
salt.sdb.rest.get(key, service=None, profile=None) Get a value from the REST interface
salt.sdb.rest.query(key, value=None, service=None, profile=None) Get a value from the REST interface
salt.sdb.rest.set_(key, value, service=None, profile=None) Set a key/value pair in the REST interface
salt.sdb.sqlite3 SQLite sdb Module
This module allows access to sqlite3 using an sdb:// URI
Like all sdb modules, the sqlite3 module requires a configuration profile to be configured in either the minion or master configuration file. This profile requires very little. For example:
mysqlite: driver: sqlite3 database: /tmp/sdb.sqlite table: sdb create_table: True
The driver refers to the sqlite3 module, database refers to the sqlite3 database file. table is the table within the db that will hold keys and values (defaults to sdb). The database and table will be created if they do not exist.
Advanced Usage: Instead of a table name, it is possible to provide custom SQL statements to create the table(s) and get and set values.
myadvanced driver: sqlite3 database: /tmp/sdb-advanced.sqlite create_statements: - "CREATE TABLE advanced (a text, b text, c blob, d blob)" - "CREATE INDEX myidx ON advanced (a)" get_query: "SELECT d FROM advanced WHERE a=:key" set_query: "INSERT OR REPLACE INTO advanced (a, d) VALUES (:key, :value)"
salt.sdb.sqlite3.get(key, profile=None) Get a value from sqlite3
salt.sdb.sqlite3.set_(key, value, profile=None) Set a key/value pair in sqlite3
salt.sdb.tism tISM - the Immutable Secrets Manager SDB Module
maintainer tISM
This module will decrypt PGP encrypted secrets against a tISM server.
sdb://<profile>/<encrypted secret>
sdb://tism/hQEMAzJ+GfdAB3KqAQf9E3cyvrPEWR1sf1tMvH0nrJ0bZa9kDFLPxvtwAOqlRiNp0F7IpiiVRF+h+sW5Mb4ffB1TElMzQ+/G5ptd6CjmgBfBsuGeajWmvLEi4lC6/9v1rYGjjLeOCCcN4Dl5AHlxUUaSrxB8akTDvSAnPvGhtRTZqDlltl5UEHsyYXM8RaeCrBw5Or1yvC9Ctx2saVp3xmALQvyhzkUv5pTb1mH0I9Z7E0ian07ZUOD+pVacDAf1oQcPpqkeNVTQQ15EP0fDuvnW+a0vxeLhkbFLfnwqhqEsvFxVFLHVLcs2ffE5cceeOMtVo7DS9fCtkdZr5hR7a+86n4hdKfwDMFXiBwSIPMkmY980N/H30L/r50+CBkuI/u4M2pXDcMYsvvt4ajCbJn91qaQ7BDI=
A profile must be setup in the minion configuration or pillar. If you want to use sdb in a runner or pillar you must also place a profile in the master configuration.
tism: driver: tism url: https://my.tismd:8080/decrypt token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhZG1pbiI6MSwiZXhwIjoxNTg1MTExNDYwLCJqdGkiOiI3NnA5cWNiMWdtdmw4Iiwia2V5cyI6WyJBTEwiXX0.RtAhG6Uorf5xnSf4Ya_GwJnoHkCsql4r1_hiOeDSLzo
salt.sdb.tism.get(key, service=None, profile=None) Get a decrypted secret from the tISMd API
salt.sdb.vault Vault SDB Module
This module allows access to Hashicorp Vault using an sdb:// URI.
Base configuration instructions are documented in the execution module docs.  Below are noted extra configuration required for the sdb module, but the base configuration must also be completed.
Like all sdb modules, the vault module requires a configuration profile to be configured in either the minion configuration file or a pillar. This profile requires only setting the driver parameter to vault:
myvault: driver: vault
Once configured you can access data using a URL such as:
password: sdb://myvault/secret/passwords/mypassword
In this URL, myvault refers to the configuration profile, secret/passwords is the path where the data resides, and mypassword is the key of the data to return.
The above URI is analogous to running the following vault command:
$ vault read -field=mypassword secret/passwords
salt.sdb.vault.get(key, profile=None) Get a value from the vault service
salt.sdb.vault.set_(key, value, profile=None) Set a key/value pair in the vault service
salt.sdb.yaml Pull sdb values from a YAML file
Configuration:
my-yaml-file: driver: yaml files: - /path/to/foo.yaml - /path/to/bar.yaml
The files are merged together and the result is searched using the same mechanism Salt uses for searching Grains and Pillar data structures.
Optional configuration:
my-yaml-file: driver: yaml files: - /path/to/foo.yaml - /path/to/bar.yaml merge: strategy: smart merge_list: false gpg: true
Setting the gpg option to true (default is false) will decrypt embedded GPG-encrypted data using the GPG renderer.
salt.sdb.yaml.get(key, profile=None) Get a value from the dictionary
salt.sdb.yaml.set_(*args, **kwargs) Setting a value is not supported; edit the YAML files directly
serializer modules ┌─────────────┬───────────────────────────────┐ │configparser │ salt.serializers.configparser │ ├─────────────┼───────────────────────────────┤ │json         │ salt.serializers.json         │ ├─────────────┼───────────────────────────────┤ │msgpack      │ salt.serializers.msgpack      │ ├─────────────┼───────────────────────────────┤ │plist        │ salt.serializers.plist        │ ├─────────────┼───────────────────────────────┤ │python       │ salt.serializers.python       │ ├─────────────┼───────────────────────────────┤ │toml         │ salt.serializers.toml         │ ├─────────────┼───────────────────────────────┤ │yaml         │ salt.serializers.yaml         │ ├─────────────┼───────────────────────────────┤ │yamlex       │ salt.serializers.yamlex       │ └─────────────┴───────────────────────────────┘
salt.serializers.configparser salt.serializers.configparser New in version 2016.3.0.
Implements a configparser serializer.
exception salt.serializers.configparser.DeserializationError(message, line_num=None, buf='', marker=' <======================', trace=None) Raised when stream of string failed to be deserialized
exception salt.serializers.configparser.SerializationError(message='') Raised when stream of string failed to be serialized
salt.serializers.configparser.deserialize(stream_or_string, **options) Deserialize any string or stream like object into a Python data structure.
• stream_or_string -- stream or string to deserialize.
• options -- options given to lower configparser module.
salt.serializers.configparser.serialize(obj, **options) Serialize Python data to a configparser formatted string or file.
• obj -- the data structure to serialize
salt.serializers.json salt.serializers.json Implements JSON serializer.
It's just a wrapper around json (or simplejson if available).
exception salt.serializers.json.DeserializationError(message, line_num=None, buf='', marker=' <======================', trace=None) Raised when stream of string failed to be deserialized
exception salt.serializers.json.SerializationError(message='') Raised when stream of string failed to be serialized
salt.serializers.json.deserialize(stream_or_string, **options) Deserialize any string or stream like object into a Python data structure.
• options -- options given to lower json/simplejson module.
salt.serializers.json.serialize(obj, **options) Serialize Python data to JSON.
salt.serializers.msgpack salt.serializers.msgpack Implements MsgPack serializer.
salt.serializers.msgpack.deserialize(stream_or_string, **options) Deserialize any string of stream like object into a Python data structure.
• options -- options given to lower msgpack module.
salt.serializers.msgpack.serialize(obj, **options) Serialize Python data to MsgPack.
salt.serializers.plist salt.serializers.plist New in version 3001.
Implements plist serializer.
Wrapper around plistlib.
exception salt.serializers.plist.DeserializationError(message, line_num=None, buf='', marker=' <======================', trace=None) Raised when stream of string failed to be deserialized
exception salt.serializers.plist.SerializationError(message='') Raised when stream of string failed to be serialized
salt.serializers.plist.deserialize(stream_or_string, **options) Deserialize any string or stream like object into a Python data structure.
• options -- options given to lower plist module.
Returns Deserialized data structure.
salt.serializers.plist.serialize(value, **options) Serialize Python data to plist. To create a binary plist pass fmt: FMT_BINARY as an option.
Returns bytes of serialized plist.
salt.serializers.python salt.serializers.python New in version 2016.3.0.
Implements a Python serializer (via pprint.format)
salt.serializers.python.serialize(obj, **options) Serialize Python data to a Python string representation (via pprint.format)
• options -- options given to pprint.format
salt.serializers.toml salt.serializers.toml Implements TOML serializer.
It's just a wrapper around the python toml module.
exception salt.serializers.toml.DeserializationError(message, line_num=None, buf='', marker=' <======================', trace=None) Raised when stream of string failed to be deserialized
exception salt.serializers.toml.SerializationError(message='') Raised when stream of string failed to be serialized
salt.serializers.toml.deserialize(stream_or_string, **options) Deserialize from TOML into Python data structure.
• stream_or_string -- toml stream or string to deserialize.
• options -- options given to the python toml module.
salt.serializers.toml.serialize(obj, **options) Serialize Python data to TOML.
• obj -- the data structure to serialize.
salt.serializers.yaml salt.serializers.yaml Implements YAML serializer.
Underneath, it is based on pyyaml and use the safe dumper and loader.  It also use C bindings if they are available.
salt.serializers.yaml.BaseDumper alias of yaml.cyaml.CSafeDumper
salt.serializers.yaml.BaseLoader alias of yaml.cyaml.CSafeLoader
exception salt.serializers.yaml.ConstructorError(context=None, context_mark=None, problem=None, problem_mark=None, note=None)
exception salt.serializers.yaml.DeserializationError(message, line_num=None, buf='', marker=' <======================', trace=None) Raised when stream of string failed to be deserialized
class salt.serializers.yaml.Dumper(stream, default_style=None, default_flow_style=False, canonical=None, indent=None, width=None, allow_unicode=None, line_break=None, encoding=None, explicit_start=None, explicit_end=None, version=None, tags=None, sort_keys=True) Overwrites Dumper as not for pollute legacy Dumper
yaml_multi_representers = {<class 'salt.serializers.yaml.EncryptedString'>: <function EncryptedString.yaml_dumper>, <class 'NoneType'>: <function SafeRepresenter.represent_none>, <class 'str'>: <function SafeRepresenter.represent_str>, <class 'bool'>: <function SafeRepresenter.represent_bool>, <class 'int'>: <function SafeRepresenter.represent_int>, <class 'float'>: <function SafeRepresenter.represent_float>, <class 'list'>: <function SafeRepresenter.represent_list>, <class 'tuple'>: <function SafeRepresenter.represent_list>, <class 'dict'>: <function SafeRepresenter.represent_dict>, <class 'set'>: <function SafeRepresenter.represent_set>, <class 'datetime.date'>: <function SafeRepresenter.represent_date>, <class 'datetime.datetime'>: <function SafeRepresenter.represent_datetime>, None: <function SafeRepresenter.represent_undefined>, <class 'salt.utils.odict.OrderedDict'>: <function SafeRepresenter.represent_dict>}
class salt.serializers.yaml.EncryptedString
static yaml_constructor(loader, tag, node)
static yaml_dumper(dumper, data)
yaml_tag = '!encrypted'
class salt.serializers.yaml.Loader(stream) Overwrites Loader as not for pollute legacy Loader
yaml_multi_constructors = {'!encrypted': <function EncryptedString.yaml_constructor>, 'tag:yaml.org,2002:binary': <function SafeConstructor.construct_yaml_binary>, 'tag:yaml.org,2002:bool': <function SafeConstructor.construct_yaml_bool>, 'tag:yaml.org,2002:float': <function SafeConstructor.construct_yaml_float>, 'tag:yaml.org,2002:int': <function SafeConstructor.construct_yaml_int>, 'tag:yaml.org,2002:map': <function SafeConstructor.construct_yaml_map>, 'tag:yaml.org,2002:null': <function SafeConstructor.construct_yaml_null>, 'tag:yaml.org,2002:omap': <function SafeConstructor.construct_yaml_omap>, 'tag:yaml.org,2002:pairs': <function SafeConstructor.construct_yaml_pairs>, 'tag:yaml.org,2002:seq': <function SafeConstructor.construct_yaml_seq>, 'tag:yaml.org,2002:set': <function SafeConstructor.construct_yaml_set>, 'tag:yaml.org,2002:str': <function SafeConstructor.construct_yaml_str>, 'tag:yaml.org,2002:timestamp': <function SafeConstructor.construct_yaml_timestamp>}
class salt.serializers.yaml.OrderedDict
exception salt.serializers.yaml.ScannerError(context=None, context_mark=None, problem=None, problem_mark=None, note=None)
exception salt.serializers.yaml.SerializationError(message='') Raised when stream of string failed to be serialized
salt.serializers.yaml.deserialize(stream_or_string, **options) Deserialize any string of stream like object into a Python data structure.
• options -- options given to lower yaml module.
salt.serializers.yaml.serialize(obj, **options) Serialize Python data to YAML.
salt.serializers.yamlex salt.serializers.yamlex YAMLEX is a format that allows for things like sls files to be more intuitive.
It's an extension of YAML that implements all the salt magic: - it implies omap for any dict like.  - it implies that string like data are str, not unicode - ...
For example, the file states.sls has this contents:
foo: bar: 42 baz: [1, 2, 3]
The file can be parsed into Python like this
from salt.serializers import yamlex
with open('state.sls', 'r') as stream: obj = yamlex.deserialize(stream)
Check that obj is an OrderedDict
from salt.utils.odict import OrderedDict
assert isinstance(obj, dict) assert isinstance(obj, OrderedDict)
yamlex __repr__ and __str__ objects' methods render YAML understandable string. It means that they are template friendly.
print '{0}'.format(obj)
returns:
{foo: {bar: 42, baz: [1, 2, 3]}}
and they are still valid YAML:
from salt.serializers import yaml yml_obj = yaml.deserialize(str(obj)) assert yml_obj == obj
yamlex implements also custom tags:
!aggregate this tag allows structures aggregation.
placeholder: !aggregate foo placeholder: !aggregate bar placeholder: !aggregate baz
is rendered as
placeholder: [foo, bar, baz]
!reset this tag flushes the computing value.
placeholder: {!aggregate foo: {foo: 42}} placeholder: {!aggregate foo: {bar: null}} !reset placeholder: {!aggregate foo: {baz: inga}}
placeholder: {!aggregate foo: {baz: inga}}
Document is defacto an aggregate mapping.
class salt.serializers.yamlex.AggregatedMap
class salt.serializers.yamlex.AggregatedSequence(iterable=(), /)
salt.serializers.yamlex.BaseDumper alias of yaml.dumper.SafeDumper
salt.serializers.yamlex.BaseLoader alias of yaml.cyaml.CSafeLoader
exception salt.serializers.yamlex.ConstructorError(context=None, context_mark=None, problem=None, problem_mark=None, note=None)
exception salt.serializers.yamlex.DeserializationError(message, line_num=None, buf='', marker=' <======================', trace=None) Raised when stream of string failed to be deserialized
class salt.serializers.yamlex.Dumper(stream, default_style=None, default_flow_style=False, canonical=None, indent=None, width=None, allow_unicode=None, line_break=None, encoding=None, explicit_start=None, explicit_end=None, version=None, tags=None, sort_keys=True) sls dumper.
represent_odict(data)
yaml_multi_representers = {<class 'NoneType'>: <function SafeRepresenter.represent_none>, <class 'bytes'>: <function SafeRepresenter.represent_binary>, <class 'str'>: <function SafeRepresenter.represent_str>, <class 'bool'>: <function SafeRepresenter.represent_bool>, <class 'int'>: <function SafeRepresenter.represent_int>, <class 'float'>: <function SafeRepresenter.represent_float>, <class 'list'>: <function SafeRepresenter.represent_list>, <class 'tuple'>: <function SafeRepresenter.represent_list>, <class 'dict'>: <function Dumper.represent_odict>, <class 'set'>: <function SafeRepresenter.represent_set>, <class 'datetime.date'>: <function SafeRepresenter.represent_date>, <class 'datetime.datetime'>: <function SafeRepresenter.represent_datetime>, None: <function SafeRepresenter.represent_undefined>}
class salt.serializers.yamlex.Loader(stream) Create a custom YAML loader that uses the custom constructor. This allows for the YAML loading defaults to be manipulated based on needs within salt to make things like sls file more intuitive.
DEFAULT_MAPPING_TAG = 'tag:yaml.org,2002:omap'
DEFAULT_SCALAR_TAG = 'tag:yaml.org,2002:str'
DEFAULT_SEQUENCE_TAG = 'tag:yaml.org,2002:seq'
compose_document()
construct_sls_aggregate(node)
construct_sls_int(node) Verify integers and pass them in correctly is they are declared as octal
construct_sls_reset(node)
construct_sls_str(node) Build the SLSString.
construct_yaml_omap(node) Build the SLSMap
resolve_sls_tag(node)
yaml_constructors = {'tag:yaml.org,2002:null': <function SafeConstructor.construct_yaml_null>, 'tag:yaml.org,2002:bool': <function SafeConstructor.construct_yaml_bool>, 'tag:yaml.org,2002:int': <function Loader.construct_sls_int>, 'tag:yaml.org,2002:float': <function SafeConstructor.construct_yaml_float>, 'tag:yaml.org,2002:binary': <function SafeConstructor.construct_yaml_binary>, 'tag:yaml.org,2002:timestamp': <function SafeConstructor.construct_yaml_timestamp>, 'tag:yaml.org,2002:omap': <function Loader.construct_yaml_omap>, 'tag:yaml.org,2002:pairs': <function SafeConstructor.construct_yaml_pairs>, 'tag:yaml.org,2002:set': <function SafeConstructor.construct_yaml_set>, 'tag:yaml.org,2002:str': <function Loader.construct_sls_str>, 'tag:yaml.org,2002:seq': <function SafeConstructor.construct_yaml_seq>, 'tag:yaml.org,2002:map': <function SafeConstructor.construct_yaml_map>, None: <function SafeConstructor.construct_undefined>, '!aggregate': <function Loader.construct_sls_aggregate>, '!reset': <function Loader.construct_sls_reset>}
yaml_multi_constructors = {'tag:yaml.org,2002:binary': <function SafeConstructor.construct_yaml_binary>, 'tag:yaml.org,2002:bool': <function SafeConstructor.construct_yaml_bool>, 'tag:yaml.org,2002:float': <function SafeConstructor.construct_yaml_float>, 'tag:yaml.org,2002:map': <function SafeConstructor.construct_yaml_map>, 'tag:yaml.org,2002:null': <function SafeConstructor.construct_yaml_null>, 'tag:yaml.org,2002:pairs': <function SafeConstructor.construct_yaml_pairs>, 'tag:yaml.org,2002:seq': <function SafeConstructor.construct_yaml_seq>, 'tag:yaml.org,2002:set': <function SafeConstructor.construct_yaml_set>, 'tag:yaml.org,2002:timestamp': <function SafeConstructor.construct_yaml_timestamp>}
class salt.serializers.yamlex.Map Map aggregation.
class salt.serializers.yamlex.MappingNode(tag, value, start_mark=None, end_mark=None, flow_style=None)
id = 'mapping'
class salt.serializers.yamlex.OrderedDict
class salt.serializers.yamlex.SLSMap Ensures that dict str() and repr() are YAML friendly.
>>> mapping = OrderedDict([('a', 'b'), ('c', None)]) >>> print mapping OrderedDict([('a', 'b'), ('c', None)])
>>> sls_map = SLSMap(mapping) >>> print sls_map.__str__() {a: b, c: null}
class salt.serializers.yamlex.SLSString Ensures that str str() and repr() are YAML friendly.
>>> scalar = str('foo') >>> print 'foo' foo
>>> sls_scalar = SLSString(scalar) >>> print sls_scalar "foo"
exception salt.serializers.yamlex.ScannerError(context=None, context_mark=None, problem=None, problem_mark=None, note=None)
class salt.serializers.yamlex.Sequence(iterable=(), /) Sequence aggregation.
exception salt.serializers.yamlex.SerializationError(message='') Raised when stream of string failed to be serialized
salt.serializers.yamlex.aggregate(obj_a, obj_b, level=False, map_class=<class 'salt.utils.aggregation.Map'>, sequence_class=<class 'salt.utils.aggregation.Sequence'>) Merge obj_b into obj_a.
>>> aggregate('first', 'second', True) == ['first', 'second'] True
salt.serializers.yamlex.deserialize(stream_or_string, **options) Deserialize any string of stream like object into a Python data structure.
salt.serializers.yamlex.merge_recursive(obj_a, obj_b, level=False) Merge obj_b into obj_a.
salt.serializers.yamlex.serialize(obj, **options) Serialize Python data to YAML.
state modules ┌─────────────────────────────┬─────────────────────────────────┐ │acme                         │ ACME / Let's Encrypt            │ │                             │ certificate management          │ │                             │ state                           │ ├─────────────────────────────┼─────────────────────────────────┤ │alias                        │ Configuration of email          │ │                             │ aliases                         │ ├─────────────────────────────┼─────────────────────────────────┤ │alternatives                 │ Configuration of the            │ │                             │ alternatives system             │ ├─────────────────────────────┼─────────────────────────────────┤ │ansiblegate                  │ Execution of Ansible            │ │                             │ modules from within states      │ ├─────────────────────────────┼─────────────────────────────────┤ │apache                       │ Apache state                    │ ├─────────────────────────────┼─────────────────────────────────┤ │apache_conf                  │ Manage Apache Confs             │ ├─────────────────────────────┼─────────────────────────────────┤ │apache_module                │ Manage Apache Modules           │ ├─────────────────────────────┼─────────────────────────────────┤ │apache_site                  │ Manage Apache Sites             │ ├─────────────────────────────┼─────────────────────────────────┤ │aptpkg                       │ Package management              │ │                             │ operations specific to APT-     │ │                             │ and DEB-based systems           │ ├─────────────────────────────┼─────────────────────────────────┤ │archive                      │ Extract an archive              │ ├─────────────────────────────┼─────────────────────────────────┤ │artifactory                  │ This state downloads            │ │                             │ artifacts from artifactory.     │ └─────────────────────────────┴─────────────────────────────────┘
salt.states.acme ACME / Let's Encrypt certificate management state New in version 2016.3.
See also the module documentation
reload-gitlab: cmd.run: - name: gitlab-ctl hup
dev.example.com: acme.cert: - aliases: - gitlab.example.com - email: acmemaster@example.com - webroot: /opt/gitlab/embedded/service/gitlab-rails/public - renew: 14 - fire_event: acme/dev.example.com - onchanges_in: - cmd: reload-gitlab
salt.states.acme.cert(name, aliases=None, email=None, webroot=None, test_cert=False, renew=None, keysize=None, server=None, owner='root', group='root', mode='0640', certname=None, preferred_challenges=None, tls_sni_01_port=None, tls_sni_01_address=None, http_01_port=None, http_01_address=None, dns_plugin=None, dns_plugin_credentials=None) Obtain/renew a certificate from an ACME CA, probably Let's Encrypt.
• webroot -- True or a full path to webroot. Otherwise use standalone mode
• dns_plugin -- Name of a DNS plugin to use (currently only 'cloudflare')
salt.states.alias Configuration of email aliases
The mail aliases file can be managed to contain definitions for specific email aliases:
username: alias.present: - target: user@example.com
thomas: alias.present: - target: thomas@example.com
The default alias file is set to /etc/aliases, as defined in Salt's config execution module. To change the alias file from the default location, set the following in your minion config:
aliases.file: /my/alias/file
salt.states.alias.absent(name) Ensure that the named alias is absent
name   The alias to remove
salt.states.alias.present(name, target) Ensures that the named alias is present with the given target or list of targets. If the alias exists but the target differs from the previous entry, the target(s) will be overwritten. If the alias does not exist, the alias will be created.
name   The local user/address to assign an alias to
target The forwarding address
salt.states.alternatives Configuration of the alternatives system
Control the alternatives system
{% set my_hadoop_conf = '/opt/hadoop/conf' %}
{{ my_hadoop_conf }}: file.directory
hadoop-0.20-conf: alternatives.install: - name: hadoop-0.20-conf - link: /etc/hadoop-0.20/conf - path: {{ my_hadoop_conf }} - priority: 30 - require: - file: {{ my_hadoop_conf }}
hadoop-0.20-conf: alternatives.remove: - name: hadoop-0.20-conf - path: {{ my_hadoop_conf }}
salt.states.alternatives.auto(name) New in version 0.17.0.
Instruct alternatives to use the highest priority path for <name>
name   is the master name for this link group (e.g. pager)
salt.states.alternatives.install(name, link, path, priority) Install new alternative for defined <name>
link   is the symlink pointing to /etc/alternatives/<name>.  (e.g. /usr/bin/pager)
path   is the location of the new alternative target.  NB: This file / directory must already exist.  (e.g. /usr/bin/less)
priority is an integer; options with higher numbers have higher priority in automatic mode.
salt.states.alternatives.remove(name, path) Removes installed alternative for defined <name> and <path> or fallback to default alternative, if some defined before.
path   is the location of one of the alternative target files. (e.g. /usr/bin/less)
salt.states.alternatives.set_(name, path) New in version 0.17.0.
Sets alternative for <name> to <path>, if <path> is defined as an alternative for <name>.
foo: alternatives.set: - path: /usr/bin/foo-2.0
salt.states.ansiblegate Execution of Ansible modules from within states With ansible.call these states allow individual Ansible module calls to be made via states. To call an Ansible module function use a module.run state:
some_set_of_tasks: ansible: - system.ping - packaging.os.zypper - name: emacs - state: installed
class salt.states.ansiblegate.AnsibleState Ansible state caller.
get_args(argset) Get args and kwargs from the argset.
Parameters argset --
salt.states.ansiblegate.playbooks(name, rundir=None, git_repo=None, git_kwargs=None, ansible_kwargs=None) Run Ansible Playbooks
• name -- path to playbook. This can be relative to rundir or the git repo
• rundir -- location to run ansible-playbook from.
• git_repo -- git repository to clone for ansible playbooks.  This is cloned using the git.latest state, and is cloned to the rundir if specified, otherwise it is clone to the cache_dir
• git_kwargs -- extra kwargs to pass to git.latest state module besides the name and target
• ansible_kwargs -- extra kwargs to pass to ansible.playbooks execution module besides the name and target
Returns Ansible playbook output.
run nginx install: ansible.playbooks: - name: install.yml - git_repo: git://github.com/gituser/playbook.git - git_kwargs: rev: master
salt.states.apache Apache state
Allows for inputting a yaml dictionary into a file for apache configuration files.
The variable this is special and signifies what should be included with the above word between angle brackets (<>).
/etc/httpd/conf.d/website.com.conf: apache.configfile: - config: - VirtualHost: this: '*:80' ServerName: - website.com ServerAlias: - www.website.com - dev.website.com ErrorLog: logs/website.com-error_log CustomLog: logs/website.com-access_log combined DocumentRoot: /var/www/vhosts/website.com Directory: this: /var/www/vhosts/website.com Order: Deny,Allow Deny from: all Allow from: - 127.0.0.1 - 192.168.100.0/24 Options: - Indexes - FollowSymlinks AllowOverride: All
Changed in version 2018.3.
Allows having the same section container multiple times (e.g. <Directory /path/to/dir>).
YAML structure stays the same only replace dictionary with a list.
When a section container does not have mandatory attribute, such as <Else>, it still needs keyword this with empty string (or " if nicer output is required - without space).
/etc/httpd/conf.d/website.com.conf: apache.configfile: - config: - VirtualHost: - this: '*:80' - ServerName: - website.com - DocumentRoot: /var/www/vhosts/website.com - Directory: this: /var/www/vhosts/website.com Order: Deny,Allow Deny from: all Allow from: - 127.0.0.1 - 192.168.100.0/24 Options: - Indexes - FollowSymlinks AllowOverride: All - Directory: - this: /var/www/vhosts/website.com/private - Order: Deny,Allow - Deny from: all - Allow from: - 127.0.0.1 - 192.168.100.0/24 - If: this: some condition do: something - Else: this: do: something else - Else: this: " do: another thing
salt.states.apache.configfile(name, config)
salt.states.apache_conf Manage Apache Confs
Enable and disable apache confs.
Enable security conf: apache_conf.enabled: - name: security
Disable security conf: apache_conf.disabled: - name: security
salt.states.apache_conf.disabled(name) Ensure an Apache conf is disabled.
name   Name of the Apache conf
salt.states.apache_conf.enabled(name) Ensure an Apache conf is enabled.
salt.states.apache_module Manage Apache Modules
Enable and disable apache modules.
Enable cgi module: apache_module.enabled: - name: cgi
Disable cgi module: apache_module.disabled: - name: cgi
salt.states.apache_module.disabled(name) Ensure an Apache module is disabled.
name   Name of the Apache module
salt.states.apache_module.enabled(name) Ensure an Apache module is enabled.
salt.states.apache_site Manage Apache Sites
Enable and disable apache sites.
Enable default site: apache_site.enabled: - name: default
Disable default site: apache_site.disabled: - name: default
salt.states.apache_site.disabled(name) Ensure an Apache site is disabled.
name   Name of the Apache site
salt.states.apache_site.enabled(name) Ensure an Apache site is enabled.
salt.states.aptpkg Package management operations specific to APT- and DEB-based systems salt.states.aptpkg.held(name) Set package in 'hold' state, meaning it will not be upgraded.
salt.states.archive Extract an archive
salt.states.archive.extracted(name, source, source_hash=None, source_hash_name=None, source_hash_update=False, skip_files_list_verify=False, skip_verify=False, password=None, options=None, list_options=None, force=False, overwrite=False, clean=False, clean_parent=False, user=None, group=None, if_missing=None, trim_output=False, use_cmd_unzip=None, extract_perms=True, enforce_toplevel=True, enforce_ownership_on=None, archive_format=None, **kwargs) New in version 2014.1.0.
Changed in version 2016.11.0: This state has been rewritten. Some arguments are new to this release and will not be available in the 2016.3 release cycle (and earlier).  Additionally, the ZIP Archive Handling section below applies specifically to the 2016.11.0 release (and newer).
Ensure that an archive is extracted to a specific directory.
IMPORTANT: Changes for 2016.11.0
In earlier releases, this state would rely on the if_missing argument to determine whether or not the archive needed to be extracted. When this argument was not passed, then the state would just assume if_missing is the same as the name argument (i.e. the parent directory into which the archive would be extracted).
This caused a number of annoyances. One such annoyance was the need to know beforehand a path that would result from the extraction of the archive, and setting if_missing to that directory, like so:
extract_myapp: archive.extracted: - name: /var/www - source: salt://apps/src/myapp-16.2.4.tar.gz - user: www - group: www - if_missing: /var/www/myapp-16.2.4
If /var/www already existed, this would effectively make if_missing a required argument, just to get Salt to extract the archive.
Some users worked around this by adding the top-level directory of the archive to the end of the name argument, and then used --strip or --strip-components to remove that top-level dir when extracting:
extract_myapp: archive.extracted: - name: /var/www/myapp-16.2.4 - source: salt://apps/src/myapp-16.2.4.tar.gz - user: www - group: www
With the rewrite for 2016.11.0, these workarounds are no longer necessary. if_missing is still a supported argument, but it is no longer required. The equivalent SLS in 2016.11.0 would be:
extract_myapp: archive.extracted: - name: /var/www - source: salt://apps/src/myapp-16.2.4.tar.gz - user: www - group: www
Salt now uses a function called archive.list to get a list of files/directories in the archive. Using this information, the state can now check the minion to see if any paths are missing, and know whether or not the archive needs to be extracted. This makes the if_missing argument unnecessary in most use cases.
IMPORTANT: ZIP Archive Handling
Note: this information applies to 2016.11.0 and later.
Salt has two different functions for extracting ZIP archives:
1. archive.unzip, which uses Python's zipfile module to extract ZIP files.
2. archive.cmd_unzip, which uses the unzip CLI command to extract ZIP files.
Salt will prefer the use of archive.cmd_unzip when CLI options are specified (via the options argument), and will otherwise prefer the archive.unzip function. Use of archive.cmd_unzip can be forced however by setting the use_cmd_unzip argument to True.  By contrast, setting this argument to False will force usage of archive.unzip. For example:
/var/www: archive.extracted: - source: salt://foo/bar/myapp.zip - use_cmd_unzip: True
When use_cmd_unzip is omitted, Salt will choose which extraction function to use based on the source archive and the arguments passed to the state. When in doubt, simply do not set this argument; it is provided as a means of overriding the logic Salt uses to decide which function to use.
There are differences in the features available in both extraction functions. These are detailed below.
• Command-line options (only supported by archive.cmd_unzip) - When the options argument is used, archive.cmd_unzip is the only function that can be used to extract the archive. Therefore, if use_cmd_unzip is specified and set to False, and options is also set, the state will not proceed.
• Permissions - Due to an upstream bug in Python, permissions are not preserved when the zipfile module is used to extract an archive.  As of the 2016.11.0 release, archive.unzip (as well as this state) has an extract_perms argument which, when set to True (the default), will attempt to match the permissions of the extracted files/directories to those defined within the archive. To disable this functionality and have the state not attempt to preserve the permissions from the ZIP archive, set extract_perms to False:
/var/www: archive.extracted: - source: salt://foo/bar/myapp.zip - extract_perms: False
name   Directory into which the archive should be extracted
source Archive to be extracted
NOTE: This argument uses the same syntax as its counterpart in the file.managed state.
source_hash Hash of source file, or file with list of hash-to-file mappings
Changed in version 2016.11.0: If this argument specifies the hash itself, instead of a URI to a file containing hashes, the hash type can now be omitted and Salt will determine the hash type based on the length of the hash. For example, both of the below states are now valid, while before only the second one would be:
foo_app: archive.extracted: - name: /var/www - source: https://mydomain.tld/foo.tar.gz - source_hash: 3360db35e682f1c5f9c58aa307de16d41361618c
bar_app: archive.extracted: - name: /var/www - source: https://mydomain.tld/bar.tar.gz - source_hash: sha1=5edb7d584b82ddcbf76e311601f5d4442974aaa5
source_hash_name When source_hash refers to a hash file, Salt will try to find the correct hash by matching the filename part of the source URI. When managing a file with a source of salt://files/foo.tar.gz, then the following line in a hash file would match:
acbd18db4cc2f85cedef654fccc4a4d8    foo.tar.gz
This line would also match:
acbd18db4cc2f85cedef654fccc4a4d8    ./dir1/foo.tar.gz
However, sometimes a hash file will include multiple similar paths:
37b51d194a7513e45b56f6524f2d51f2    ./dir1/foo.txt acbd18db4cc2f85cedef654fccc4a4d8    ./dir2/foo.txt 73feffa4b7f6bb68e44cf984c85f6e88    ./dir3/foo.txt
In cases like this, Salt may match the incorrect hash. This argument can be used to tell Salt which filename to match, to ensure that the correct hash is identified. For example:
/var/www: archive.extracted: - source: https://mydomain.tld/dir2/foo.tar.gz - source_hash: https://mydomain.tld/hashes - source_hash_name: ./dir2/foo.tar.gz
NOTE: This argument must contain the full filename entry from the checksum file, as this argument is meant to disambiguate matches for multiple files that have the same basename. So, in the example above, simply using foo.txt would not match.
source_hash_update False Set this to True if archive should be extracted if source_hash has changed and there is a difference between the archive and the local files.  This would extract regardless of the if_missing parameter.