neulab/tldr huggingface dataset:
salt.modules.mysql.db_check(name, table=None, **connection_args) Repairs the full database or just a given table
salt '*' mysql.db_check dbname salt '*' mysql.db_check dbname dbtable
salt.modules.mysql.db_create(name, character_set=None, collate=None, **connection_args) Adds a databases to the MySQL server.
name   The name of the database to manage
character_set The character set, if left empty the MySQL default will be used
collate The collation, if left empty the MySQL default will be used
salt '*' mysql.db_create 'dbname' salt '*' mysql.db_create 'dbname' 'utf8' 'utf8_general_ci'
salt.modules.mysql.db_exists(name, **connection_args) Checks if a database exists on the MySQL server.
salt '*' mysql.db_exists 'dbname'
salt.modules.mysql.db_get(name, **connection_args) Return a list of databases of a MySQL server using the output from the SELECT DEFAULT_CHARACTER_SET_NAME, DEFAULT_COLLATION_NAME FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME='dbname'; query.
salt '*' mysql.db_get test
salt.modules.mysql.db_list(**connection_args) Return a list of databases of a MySQL server using the output from the SHOW DATABASES query.
salt '*' mysql.db_list
salt.modules.mysql.db_optimize(name, table=None, **connection_args) Optimizes the full database or just a given table
salt '*' mysql.db_optimize dbname
salt.modules.mysql.db_remove(name, **connection_args) Removes a databases from the MySQL server.
salt '*' mysql.db_remove 'dbname'
salt.modules.mysql.db_repair(name, table=None, **connection_args) Repairs the full database or just a given table
salt '*' mysql.db_repair dbname
salt.modules.mysql.db_tables(name, **connection_args) Shows the tables in the given MySQL database (if exists)
salt '*' mysql.db_tables 'database'
salt.modules.mysql.file_query(database, file_name, **connection_args) Run an arbitrary SQL query from the specified file and return the the number of affected rows.
database database to run script inside
file_name File name of the script.  This can be on the minion, or a file that is reachable by the fileserver
salt '*' mysql.file_query mydb file_name=/tmp/sqlfile.sql salt '*' mysql.file_query mydb file_name=salt://sqlfile.sql
{'query time': {'human': '39.0ms', 'raw': '0.03899'}, 'rows affected': 1L}
salt.modules.mysql.free_slave(**connection_args) Frees a slave from its master.  This is a WIP, do not use.
salt '*' mysql.free_slave
salt.modules.mysql.get_master_status(**connection_args) Retrieves the master status from the minion.
{'host.domain.com': {'Binlog_Do_DB': '', 'Binlog_Ignore_DB': '', 'File': 'mysql-bin.000021', 'Position': 107}}
salt '*' mysql.get_master_status
salt.modules.mysql.get_slave_status(**connection_args) Retrieves the slave status from the minion.
{'host.domain.com': {'Connect_Retry': 60, 'Exec_Master_Log_Pos': 107, 'Last_Errno': 0, 'Last_Error': '', 'Last_IO_Errno': 0, 'Last_IO_Error': '', 'Last_SQL_Errno': 0, 'Last_SQL_Error': '', 'Master_Host': 'comet.scion-eng.com', 'Master_Log_File': 'mysql-bin.000021', 'Master_Port': 3306, 'Master_SSL_Allowed': 'No', 'Master_SSL_CA_File': '', 'Master_SSL_CA_Path': '', 'Master_SSL_Cert': '', 'Master_SSL_Cipher': '', 'Master_SSL_Key': '', 'Master_SSL_Verify_Server_Cert': 'No', 'Master_Server_Id': 1, 'Master_User': 'replu', 'Read_Master_Log_Pos': 107, 'Relay_Log_File': 'klo-relay-bin.000071', 'Relay_Log_Pos': 253, 'Relay_Log_Space': 553, 'Relay_Master_Log_File': 'mysql-bin.000021', 'Replicate_Do_DB': '', 'Replicate_Do_Table': '', 'Replicate_Ignore_DB': '', 'Replicate_Ignore_Server_Ids': '', 'Replicate_Ignore_Table': '', 'Replicate_Wild_Do_Table': '', 'Replicate_Wild_Ignore_Table': '', 'Seconds_Behind_Master': 0, 'Skip_Counter': 0, 'Slave_IO_Running': 'Yes', 'Slave_IO_State': 'Waiting for master to send event', 'Slave_SQL_Running': 'Yes', 'Until_Condition': 'None', 'Until_Log_File': '', 'Until_Log_Pos': 0}}
salt '*' mysql.get_slave_status
salt.modules.mysql.grant_add(grant, database, user, host='localhost', grant_option=False, escape=True, ssl_option=False, **connection_args) Adds a grant to the MySQL server.
For database, make sure you specify database.table or database.*
salt '*' mysql.grant_add             'SELECT,INSERT,UPDATE,...' 'database.*' 'frank' 'localhost'
salt.modules.mysql.grant_exists(grant, database, user, host='localhost', grant_option=False, escape=True, **connection_args) Checks to see if a grant exists in the database
salt '*' mysql.grant_exists              'SELECT,INSERT,UPDATE,...' 'database.*' 'frank' 'localhost'
salt.modules.mysql.grant_revoke(grant, database, user, host='localhost', grant_option=False, escape=True, **connection_args) Removes a grant from the MySQL server.
salt '*' mysql.grant_revoke             'SELECT,INSERT,UPDATE' 'database.*' 'frank' 'localhost'
salt.modules.mysql.plugin_add(name, soname=None, **connection_args) Add a plugina.
salt '*' mysql.plugin_add auth_socket
salt.modules.mysql.plugin_remove(name, **connection_args) Remove a plugin.
salt '*' mysql.plugin_remove auth_socket
salt.modules.mysql.plugin_status(name, **connection_args) Return the status of a plugin.
salt '*' mysql.plugin_status auth_socket
salt.modules.mysql.plugins_list(**connection_args) Return a list of plugins and their status from the SHOW PLUGINS query.
salt '*' mysql.plugins_list
salt.modules.mysql.processlist(**connection_args) Retrieves the processlist from the MySQL server via "SHOW FULL PROCESSLIST".
Returns: a list of dicts, with each dict representing a process:
{'Command': 'Query', 'Host': 'localhost', 'Id': 39, 'Info': 'SHOW FULL PROCESSLIST', 'Rows_examined': 0, 'Rows_read': 1, 'Rows_sent': 0, 'State': None, 'Time': 0, 'User': 'root', 'db': 'mysql'}
salt '*' mysql.processlist
salt.modules.mysql.query(database, query, **connection_args) Run an arbitrary SQL query and return the results or the number of affected rows.
salt '*' mysql.query mydb "UPDATE mytable set myfield=1 limit 1"
salt '*' mysql.query mydb "SELECT id,name,cash from users limit 3"
{'columns': ('id', 'name', 'cash'), 'query time': {'human': '1.0ms', 'raw': '0.001'}, 'results': ((1L, 'User 1', Decimal('110.000000')), (2L, 'User 2', Decimal('215.636756')), (3L, 'User 3', Decimal('0.040000'))), 'rows returned': 3L}
salt '*' mysql.query mydb 'INSERT into users values (null,"user 4", 5)'
{'query time': {'human': '25.6ms', 'raw': '0.02563'}, 'rows affected': 1L}
salt '*' mysql.query mydb 'DELETE from users where id = 4 limit 1'
Jinja Example: Run a query on mydb and use row 0, column 0's data.
{{ salt['mysql.query']('mydb', 'SELECT info from mytable limit 1')['results'][0][0] }}
salt.modules.mysql.quote_identifier(identifier, for_grants=False) Return an identifier name (column, table, database, etc) escaped for MySQL
This means surrounded by "`" character and escaping this character inside.  It also means doubling the '%' character for MySQLdb internal usage.
• identifier -- the table, column or database identifier
• for_grants -- is False by default, when using database names on grant queries you should set it to True to also escape "_" and "%" characters as requested by MySQL. Note that theses characters should only be escaped when requesting grants on the database level (my_%db.*) but not for table level grants (my_%db.`foo`)
salt '*' mysql.quote_identifier 'foo`bar'
salt.modules.mysql.showglobal(**connection_args) Retrieves the show global variables from the minion.
Returns:: show global variables full dict
salt '*' mysql.showglobal
salt.modules.mysql.showvariables(**connection_args) Retrieves the show variables from the minion.
Returns:: show variables full dict
salt '*' mysql.showvariables
salt.modules.mysql.slave_lag(**connection_args) Return the number of seconds that a slave SQL server is lagging behind the master, if the host is not a slave it will return -1. If the server is configured to be a slave for replication but slave IO is not running then -2 will be returned. If there was an error connecting to the database or checking the slave status, -3 will be returned.
salt '*' mysql.slave_lag
salt.modules.mysql.status(**connection_args) Return the status of a MySQL server using the output from the SHOW STATUS query.
salt '*' mysql.status
salt.modules.mysql.tokenize_grant(grant) External wrapper function :param grant: :return: dict
salt '*' mysql.tokenize_grant             "GRANT SELECT, INSERT ON testdb.* TO 'testuser'@'localhost'"
salt.modules.mysql.user_chpass(user, host='localhost', password=None, password_hash=None, allow_passwordless=False, unix_socket=None, password_column=None, **connection_args) Change password for a MySQL user
host   Host for which this user/password combo applies
password The password to set for the new user. Will take precedence over the password_hash option if both are specified.
password_hash The password in hashed form. Be sure to quote the password because YAML doesn't like the *. A password hash can be obtained from the mysql command-line client like so:
mysql> SELECT PASSWORD('mypass'); +-------------------------------------------+ | PASSWORD('mypass')                        | +-------------------------------------------+ | *6C8989366EAF75BB670AD8EA7A7FC1176A95CEF4 | +-------------------------------------------+ 1 row in set (0.00 sec)
allow_passwordless If True, then password and password_hash can be omitted (or set to None) to permit a passwordless login.
New in version 0.16.2: The allow_passwordless option was added.
salt '*' mysql.user_chpass frank localhost newpassword salt '*' mysql.user_chpass frank localhost password_hash='hash' salt '*' mysql.user_chpass frank localhost allow_passwordless=True
salt.modules.mysql.user_create(user, host='localhost', password=None, password_hash=None, allow_passwordless=False, unix_socket=False, password_column=None, auth_plugin='mysql_native_password', **connection_args) Creates a MySQL user
password The password to use for the new user. Will take precedence over the password_hash option if both are specified.
unix_socket If True and allow_passwordless is True then will be used unix_socket auth plugin.
password_column The password column to use in the user table.
auth_plugin The authentication plugin to use, default is to use the mysql_native_password plugin.
salt '*' mysql.user_create 'username' 'hostname' 'password' salt '*' mysql.user_create 'username' 'hostname' password_hash='hash' salt '*' mysql.user_create 'username' 'hostname' allow_passwordless=True
salt.modules.mysql.user_exists(user, host='localhost', password=None, password_hash=None, passwordless=False, unix_socket=False, password_column=None, **connection_args) Checks if a user exists on the MySQL server. A login can be checked to see if passwordless login is permitted by omitting password and password_hash, and using passwordless=True.
New in version 0.16.2: The passwordless option was added.
salt '*' mysql.user_exists 'username' 'hostname' 'password' salt '*' mysql.user_exists 'username' 'hostname' password_hash='hash' salt '*' mysql.user_exists 'username' passwordless=True salt '*' mysql.user_exists 'username' password_column='authentication_string'
salt.modules.mysql.user_grants(user, host='localhost', **connection_args) Shows the grants for the given MySQL user (if it exists)
salt '*' mysql.user_grants 'frank' 'localhost'
salt.modules.mysql.user_info(user, host='localhost', **connection_args) Get full info on a MySQL user
salt '*' mysql.user_info root localhost
salt.modules.mysql.user_list(**connection_args) Return a list of users on a MySQL server
salt '*' mysql.user_list
salt.modules.mysql.user_remove(user, host='localhost', **connection_args) Delete MySQL user
salt '*' mysql.user_remove frank localhost
salt.modules.mysql.verify_login(user, password=None, **connection_args) Attempt to login using the provided credentials.  If successful, return true.  Otherwise, return False.
salt '*' mysql.verify_login root password
salt.modules.mysql.version(**connection_args) Return the version of a MySQL server using the output from the SELECT VERSION() query.
salt '*' mysql.version
salt.modules.nacl This module helps include encrypted passwords in pillars, grains and salt state files.
depends libnacl, https://github.com/saltstack/libnacl
This is often useful if you wish to store your pillars in source control or share your pillar data with others that you trust. I don't advise making your pillars public regardless if they are encrypted or not.
When generating keys and encrypting passwords use --local when using salt-call for extra security. Also consider using just the salt runner nacl when encrypting pillar passwords.
configuration The following configuration defaults can be define (pillar or config files) Avoid storing private keys in pillars! Ensure master does not have pillar_opts=True:
# cat /etc/salt/master.d/nacl.conf nacl.config: # NOTE: `key` and `key_file` have been renamed to `sk`, `sk_file` # also `box_type` default changed from secretbox to sealedbox. box_type: sealedbox                     (default) sk_file: /etc/salt/pki/master/nacl      (default) pk_file: /etc/salt/pki/master/nacl.pub  (default) sk: None pk: None
salt-call nacl.enc sk_file=/etc/salt/pki/master/nacl pk_file=/etc/salt/pki/master/nacl.pub
The nacl lib uses 32byte keys, these keys are base64 encoded to make your life more simple.  To generate your sk_file and pk_file use:
salt-call --local nacl.keygen sk_file=/etc/salt/pki/master/nacl # or if you want to work without files. salt-call --local nacl.keygen local: ---------- pk: /kfGX7PbWeu099702PBbKWLpG/9p06IQRswkdWHCDk0= sk: SVWut5SqNpuPeNzb1b9y6b2eXg2PLIog43GBzp48Sow=
Now with your keypair, you can encrypt data:
You have two option, sealedbox or secretbox.
SecretBox is data encrypted using private key pk. Sealedbox is encrypted using public key pk.
Recommend using Sealedbox because the one way encryption permits developers to encrypt data for source control but not decrypt.  Sealedbox only has one key that is for both encryption and decryption.
salt-call --local nacl.enc asecretpass pk=/kfGX7PbWeu099702PBbKWLpG/9p06IQRswkdWHCDk0= tqXzeIJnTAM9Xf0mdLcpEdklMbfBGPj2oTKmlgrm3S1DTVVHNnh9h8mU1GKllGq/+cYsk6m5WhGdk58=
To decrypt the data:
salt-call --local nacl.dec data='tqXzeIJnTAM9Xf0mdLcpEdklMbfBGPj2oTKmlgrm3S1DTVVHNnh9h8mU1GKllGq/+cYsk6m5WhGdk58='         sk='SVWut5SqNpuPeNzb1b9y6b2eXg2PLIog43GBzp48Sow='
When the keys are defined in the master config you can use them from the nacl runner without extra parameters:
# cat /etc/salt/master.d/nacl.conf nacl.config: sk_file: /etc/salt/pki/master/nacl pk: 'cTIqXwnUiD1ulg4kXsbeCE7/NoeKEzd4nLeYcCFpd9k='
salt-run nacl.enc 'asecretpass' salt-run nacl.dec data='tqXzeIJnTAM9Xf0mdLcpEdklMbfBGPj2oTKmlgrm3S1DTVVHNnh9h8mU1GKllGq/+cYsk6m5WhGdk58='
# a salt developers minion could have pillar data that includes a nacl public key nacl.config: pk: '/kfGX7PbWeu099702PBbKWLpG/9p06IQRswkdWHCDk0='
The developer can then use a less-secure system to encrypt data.
salt-call --local nacl.enc apassword
Pillar files can include protected data that the salt master decrypts:
pillarexample: user: root password1: {{salt.nacl.dec('DRB7Q6/X5gGSRCTpZyxS6hlbWj0llUA+uaVyvou3vJ4=')|json}} cert_key: {{salt.nacl.dec_file('/srv/salt/certs/example.com/key.nacl')|json}} cert_key2: {{salt.nacl.dec_file('salt:///certs/example.com/key.nacl')|json}}
Larger files like certificates can be encrypted with:
salt-call nacl.enc_file /tmp/cert.crt out=/tmp/cert.nacl # or more advanced cert=$(cat /tmp/cert.crt) salt-call --out=newline_values_only nacl.enc_pub data="$cert" > /tmp/cert.nacl
In pillars rended with jinja be sure to include |json so line breaks are encoded:
cert: "{{salt.nacl.dec('S2uogToXkgENz9...085KYt')|json}}"
In states rendered with jinja it is also good pratice to include |json:
{{sls}} private key: file.managed: - name: /etc/ssl/private/cert.key - mode: 700 - contents: "{{pillar['pillarexample']['cert_key']|json}}"
Optional small program to encrypt data without needing salt modules.
#!/bin/python3 import sys, base64, libnacl.sealed pk = base64.b64decode('YOURPUBKEY') b = libnacl.sealed.SealedBox(pk) data = sys.stdin.buffer.read() print(base64.b64encode(b.encrypt(data)).decode())
echo 'apassword' | nacl_enc.py
salt.modules.nacl.dec(data, **kwargs) Alias to {box_type}_decrypt
box_type: secretbox, sealedbox(default)
salt.modules.nacl.dec_file(name, out=None, **kwargs) This is a helper function to decrypt a file and return its contents.
You can provide an optional output file using out
name can be a local file or when not using salt-run can be a url like salt://, https:// etc.
salt-run nacl.dec_file name=/tmp/id_rsa.nacl salt-call nacl.dec_file name=salt://crt/mycert.nacl out=/tmp/id_rsa salt-run nacl.dec_file name=/tmp/id_rsa.nacl box_type=secretbox             sk_file=/etc/salt/pki/master/nacl.pub
salt.modules.nacl.enc(data, **kwargs) Alias to {box_type}_encrypt
salt.modules.nacl.enc_file(name, out=None, **kwargs) This is a helper function to encrypt a file and return its contents.
salt-run nacl.enc_file name=/tmp/id_rsa salt-call nacl.enc_file name=salt://crt/mycert out=/tmp/cert salt-run nacl.enc_file name=/tmp/id_rsa box_type=secretbox             sk_file=/etc/salt/pki/master/nacl.pub
salt.modules.nacl.keygen(sk_file=None, pk_file=None, **kwargs) Use libnacl to generate a keypair.
If no sk_file is defined return a keypair.
If only the sk_file is defined pk_file will use the same name with a postfix .pub.
When the sk_file is already existing, but pk_file is not. The pk_file will be generated using the sk_file.
salt-call nacl.keygen salt-call nacl.keygen sk_file=/etc/salt/pki/master/nacl salt-call nacl.keygen sk_file=/etc/salt/pki/master/nacl pk_file=/etc/salt/pki/master/nacl.pub salt-call --local nacl.keygen
salt.modules.nacl.sealedbox_decrypt(data, **kwargs) Decrypt data using a secret key that was encrypted using a public key with nacl.sealedbox_encrypt.
salt-call nacl.sealedbox_decrypt pEXHQM6cuaF7A= salt-call --local nacl.sealedbox_decrypt data='pEXHQM6cuaF7A=' sk_file=/etc/salt/pki/master/nacl salt-call --local nacl.sealedbox_decrypt data='pEXHQM6cuaF7A=' sk='YmFkcGFzcwo='
salt.modules.nacl.sealedbox_encrypt(data, **kwargs) Encrypt data using a public key generated from nacl.keygen.  The encryptd data can be decrypted using nacl.sealedbox_decrypt only with the secret key.
salt-run nacl.sealedbox_encrypt datatoenc salt-call --local nacl.sealedbox_encrypt datatoenc pk_file=/etc/salt/pki/master/nacl.pub salt-call --local nacl.sealedbox_encrypt datatoenc pk='vrwQF7cNiNAVQVAiS3bvcbJUnF0cN6fU9YTZD9mBfzQ='
salt.modules.nacl.secretbox_decrypt(data, **kwargs) Decrypt data that was encrypted using nacl.secretbox_encrypt using the secret key that was generated from nacl.keygen.
salt-call nacl.secretbox_decrypt pEXHQM6cuaF7A= salt-call --local nacl.secretbox_decrypt data='pEXHQM6cuaF7A=' sk_file=/etc/salt/pki/master/nacl salt-call --local nacl.secretbox_decrypt data='pEXHQM6cuaF7A=' sk='YmFkcGFzcwo='
salt.modules.nacl.secretbox_encrypt(data, **kwargs) Encrypt data using a secret key generated from nacl.keygen.  The same secret key can be used to decrypt the data using nacl.secretbox_decrypt.
salt-run nacl.secretbox_encrypt datatoenc salt-call --local nacl.secretbox_encrypt datatoenc sk_file=/etc/salt/pki/master/nacl salt-call --local nacl.secretbox_encrypt datatoenc sk='YmFkcGFzcwo='
salt.modules.nagios Run nagios plugins/checks from salt and get the return as data.
salt.modules.nagios.list_plugins() List all the nagios plugins
salt '*' nagios.list_plugins
salt.modules.nagios.retcode(plugin, args='', key_name=None) Run one nagios plugin and return retcode of the execution
salt.modules.nagios.retcode_pillar(pillar_name) Run one or more nagios plugins from pillar data and get the result of cmd.retcode The pillar have to be in this format:
------ webserver: Ping_google: - check_icmp: 8.8.8.8 - check_icmp: google.com Load: - check_load: -w 0.8 -c 1 APT: - check_apt -------
webserver is the role to check, the next keys are the group and the items the check with the arguments if needed
You must to group different checks(one o more) and always it will return the highest value of all the checks
salt '*' nagios.retcode webserver
salt.modules.nagios.run(plugin, args='') Run nagios plugin and return all the data execution with cmd.run
salt '*' nagios.run check_apt salt '*' nagios.run check_icmp '8.8.8.8'
salt.modules.nagios.run_all(plugin, args='') Run nagios plugin and return all the data execution with cmd.run_all
salt.modules.nagios.run_all_pillar(pillar_name) Run one or more nagios plugins from pillar data and get the result of cmd.run_all The pillar have to be in this format:
You have to group different checks in a group
salt '*' nagios.run webserver
salt.modules.nagios.run_pillar(pillar_name) Run one or more nagios plugins from pillar data and get the result of cmd.run The pillar have to be in this format:
salt.modules.nagios_rpc Check Host & Service status from Nagios via JSON RPC.
salt.modules.nagios_rpc.host_status(hostname=None, **kwargs) Check status of a particular host By default statuses are returned in a numeric format.
hostname The hostname to check the status of the service in Nagios.
numeric Turn to false in order to return status in text format ('OK' instead of 0, 'Warning' instead of 1 etc)
Returns status:     'OK', 'Warning', 'Critical' or 'Unknown'
salt '*' nagios_rpc.host_status hostname=webserver.domain.com salt '*' nagios_rpc.host_status hostname=webserver.domain.com numeric=False
salt.modules.nagios_rpc.service_status(hostname=None, service=None, **kwargs) Check status of a particular service on a host on it in Nagios. By default statuses are returned in a numeric format.
service The service to check the status of in Nagios.
salt '*' nagios_rpc.service_status hostname=webserver.domain.com service='HTTP' salt '*' nagios_rpc.service_status hostname=webserver.domain.com service='HTTP' numeric=False
salt.modules.namecheap_domains Namecheap Domain Management
Prerequisites This module uses the requests Python module to communicate to the namecheap API.
Configuration The Namecheap username, API key and URL should be set in the minion configuration file, or in the Pillar data.
namecheap.name: companyname namecheap.key: a1b2c3d4e5f67a8b9c0d1e2f3 namecheap.client_ip: 162.155.30.172 #Real url namecheap.url: https://api.namecheap.com/xml.response #Sandbox url #namecheap.url: https://api.sandbox.namecheap.xml.response
salt.modules.namecheap_domains.check(*domains_to_check) Checks the availability of domains
domains_to_check array of strings  List of domains to check
Returns a dictionary mapping the each domain name to a boolean denoting whether or not it is available.
salt 'my-minion' namecheap_domains.check domain-to-check
salt.modules.namecheap_domains.create(domain_name, years, **kwargs) Try to register the specified domain name
domain_name The domain name to be registered
years  Number of years to register
Returns the following information:
• Whether or not the domain was renewed successfully
• Whether or not WhoisGuard is enabled
• Whether or not registration is instant
• The amount charged for registration
• The domain ID
• The order ID
• The transaction ID
salt 'my-minion' namecheap_domains.create my-domain-name 2
salt.modules.namecheap_domains.get_info(domain_name) Returns information about the requested domain
returns a dictionary of information about the domain_name
domain_name string  Domain name to get information about
salt 'my-minion' namecheap_domains.get_info my-domain-name
salt.modules.namecheap_domains.get_list(list_type=None, search_term=None, page=None, page_size=None, sort_by=None) Returns a list of domains for the particular user as a list of objects offset by page length of page_size
list_type ALL One of ALL, EXPIRING, EXPIRED
search_term Keyword to look for on the domain list
page   1 Number of result page to return
page_size 20 Number of domains to be listed per page (minimum: 10, maximum: 100)
sort_by One of NAME, NAME_DESC, EXPIREDATE, EXPIREDATE_DESC, CREATEDATE, or CREATEDATE_DESC
salt 'my-minion' namecheap_domains.get_list
salt.modules.namecheap_domains.get_tld_list() Returns a list of TLDs as objects
salt 'my-minion' namecheap_domains.get_tld_list
salt.modules.namecheap_domains.reactivate(domain_name) Try to reactivate the expired domain name
• Whether or not the domain was reactivated successfully
• The amount charged for reactivation
salt 'my-minion' namecheap_domains.reactivate my-domain-name
salt.modules.namecheap_domains.renew(domain_name, years, promotion_code=None) Try to renew the specified expiring domain name for a specified number of years
domain_name The domain name to be renewed
years  Number of years to renew
• The amount charged for renewal
salt 'my-minion' namecheap_domains.renew my-domain-name 5
salt.modules.namecheap_domains_dns Namecheap DNS Management
salt.modules.namecheap_domains_dns.get_hosts(sld, tld) Retrieves DNS host record settings for the requested domain.
returns a dictionary of information about the requested domain
sld    SLD of the domain name
tld    TLD of the domain name
salt 'my-minion' namecheap_domains_dns.get_hosts sld tld
salt.modules.namecheap_domains_dns.get_list(sld, tld) Gets a list of DNS servers associated with the requested domain.
returns a dictionary of information about requested domain
salt 'my-minion' namecheap_domains_dns.get_list sld tld
salt.modules.namecheap_domains_dns.set_custom(sld, tld, nameservers) Sets domain to use custom DNS servers.
returns True if the custom nameservers were set successfully
nameservers array of strings  List of nameservers to be associated with this domain
salt 'my-minion' namecheap_domains_dns.set_custom sld tld nameserver
salt.modules.namecheap_domains_dns.set_default(sld, tld) Sets domain to use namecheap default DNS servers. Required for free services like Host record management, URL forwarding, email forwarding, dynamic DNS and other value added services.
Returns True if the domain was successfully pointed at the default DNS servers.
salt 'my-minion' namecheap_domains_dns.set_default sld tld
salt.modules.namecheap_domains_dns.set_hosts(sld, tld, hosts) Sets DNS host records settings for the requested domain.
returns True if the host records were set successfully
hosts  Must be passed as a list of Python dictionaries, with each dictionary containing the following keys:
• hostname
• recordtype - One of A, AAAA, CNAME, MX, MXE, TXT, URL, URL301, or FRAME
• address - URL or IP address
• ttl - An integer between 60 and 60000 (default: 1800)
Additionally, the mxpref key can be present, but must be accompanied by an emailtype key.
salt 'my-minion' namecheap_domains_dns.set_hosts sld tld hosts
salt.modules.namecheap_domains_ns Namecheap Nameserver Management
salt.modules.namecheap_domains_ns.create(sld, tld, nameserver, ip) Creates a new nameserver. Returns True if the nameserver was created successfully.
nameserver Nameserver to create
ip     Nameserver IP address
salt '*' namecheap_domains_ns.create sld tld nameserver ip
salt.modules.namecheap_domains_ns.delete(sld, tld, nameserver) Deletes a nameserver. Returns True if the nameserver was deleted successfully
nameserver Nameserver to delete
salt '*' namecheap_domains_ns.delete sld tld nameserver
salt.modules.namecheap_domains_ns.get_info(sld, tld, nameserver) Retrieves information about a registered nameserver. Returns the following information:
• IP Address set for the nameserver
• Domain name which was queried
• A list of nameservers and their statuses
nameserver Nameserver to retrieve
salt '*' namecheap_domains_ns.get_info sld tld nameserver
salt.modules.namecheap_domains_ns.update(sld, tld, nameserver, old_ip, new_ip) Deletes a nameserver. Returns True if the nameserver was updated successfully.
old_ip Current ip address
new_ip New ip address
salt '*' namecheap_domains_ns.update sld tld nameserver old_ip new_ip
salt.modules.namecheap_ssl Namecheap SSL Certificate Management
salt.modules.namecheap_ssl.activate(csr_file, certificate_id, web_server_type, approver_email=None, http_dc_validation=False, **kwargs) Activates a newly-purchased SSL certificate. Returns a dictionary of result values.
csr_file Path to Certificate Signing Request file
certificate_id Unique ID of the SSL certificate you wish to activate
web_server_type The type of certificate format to return. Possible values include:
• apache2
• apacheapachessl
• apacheopenssl
• apacheraven
• apachessl
• apachessleay
• c2net
• cobaltseries
• cpanel
• domino
• dominogo4625
• dominogo4626
• ensim
• hsphere
• ibmhttp
• iis
• iis4
• iis5
• iplanet
• ipswitch
• netscape
• other
• plesk
• tomcat
• weblogic
• website
• webstar
• zeusv3
approver_email The email ID which is on the approver email list.
NOTE: http_dc_validation must be set to False if this option is used.
http_dc_validation False Whether or not to activate using HTTP-based validation.
NOTE: For other parameters which may be required, see here.
salt 'my-minion' namecheap_ssl.activate my-csr-file my-cert-id apachessl
salt.modules.namecheap_ssl.create(years, certificate_type, promotion_code=None, sans_to_add=None) Creates a new SSL certificate. Returns the following information:
• Whether or not the SSL order was successful
• The certificate ID
• The amount charged for the order
• The date on which the certificate was created
• The date on which the certificate will expire
• The type of SSL certificate
• The number of years for which the certificate was purchased
• The current status of the SSL certificate
years  1 Number of years to register
certificate_type Type of SSL Certificate. Possible values include:
• EV Multi Domain SSL
• EV SSL
• EV SSL SGC
• EssentialSSL
• EssentialSSL Wildcard
• InstantSSL
• InstantSSL Pro
• Multi Domain SSL
• PositiveSSL
• PositiveSSL Multi Domain
• PositiveSSL Wildcard
• PremiumSSL
• PremiumSSL Wildcard
• QuickSSL Premium
• RapidSSL
• RapidSSL Wildcard
• SGC Supercert
• SSL Web Server
• SSL Webserver EV
• SSL123
• Secure Site
• Secure Site Pro
• Secure Site Pro with EV
• Secure Site with EV
• True BusinessID
• True BusinessID Multi Domain
• True BusinessID Wildcard
• True BusinessID with EV
• True BusinessID with EV Multi Domain
• Unified Communications
promotional_code An optional promo code to use when creating the certificate
sans_to_add 0 This parameter defines the number of add-on domains to be purchased in addition to the default number of domains included with a multi-domain certificate. Each certificate that supports SANs has the default number of domains included. You may check the default number of domains included and the maximum number of domains that can be added to it in the table below.
┌─────────┬────────────────┬───────────────┬───────────────┬───────────────┐ │Provider │ Product name   │ Default       │ Maximum       │ Maximum       │ │         │                │ number of     │ number of     │ number of     │ │         │                │ domains       │ total domains │ domains that  │ │         │                │ (domain from  │               │ can be passed │ │         │                │ CSR is        │               │ in            │ │         │                │ counted here) │               │ sans_to_add   │ │         │                │               │               │ parameter     │ ├─────────┼────────────────┼───────────────┼───────────────┼───────────────┤ │Comodo   │ PositiveSSL    │ 3             │ 100           │ 97            │ │         │ Multi-Domain   │               │               │               │ └─────────┴────────────────┴───────────────┴───────────────┴───────────────┘
│Comodo   │ Multi-Domain   │ 3             │ 100           │ 97            │ │         │ SSL            │               │               │               │ ├─────────┼────────────────┼───────────────┼───────────────┼───────────────┤ │Comodo   │ EV Multi-      │ 3             │ 100           │ 97            │ │         │ Domain SSL     │               │               │               │ ├─────────┼────────────────┼───────────────┼───────────────┼───────────────┤ │Comodo   │ Unified        │ 3             │ 100           │ 97            │ │         │ Communications │               │               │               │ ├─────────┼────────────────┼───────────────┼───────────────┼───────────────┤ │GeoTrust │ QuickSSL       │ 1             │ 1 domain + 4  │ The only      │ │         │ Premium        │               │ subdomains    │ supported     │ │         │                │               │               │ value is 4    │ ├─────────┼────────────────┼───────────────┼───────────────┼───────────────┤ │GeoTrust │ True           │ 5             │ 25            │ 20            │ │         │ BusinessID     │               │               │               │ │         │ with EV        │               │               │               │ │         │ Multi-Domain   │               │               │               │ ├─────────┼────────────────┼───────────────┼───────────────┼───────────────┤ │GeoTrust │ True Business  │ 5             │ 25            │ 20            │ │         │ ID Multi-      │               │               │               │ │         │ Domain         │               │               │               │ ├─────────┼────────────────┼───────────────┼───────────────┼───────────────┤ │Thawte   │ SSL Web Server │ 1             │ 25            │ 24            │ ├─────────┼────────────────┼───────────────┼───────────────┼───────────────┤ │Thawte   │ SSL Web Server │ 1             │ 25            │ 24            │ │         │ with EV        │               │               │               │ ├─────────┼────────────────┼───────────────┼───────────────┼───────────────┤ │Thawte   │ SGC Supercerts │ 1             │ 25            │ 24            │ ├─────────┼────────────────┼───────────────┼───────────────┼───────────────┤ │Symantec │ Secure Site    │ 1             │ 25            │ 24            │ │         │ Pro with EV    │               │               │               │ ├─────────┼────────────────┼───────────────┼───────────────┼───────────────┤ │Symantec │ Secure Site    │ 1             │ 25            │ 24            │ │         │ with EV        │               │               │               │ ├─────────┼────────────────┼───────────────┼───────────────┼───────────────┤ │Symantec │ Secure Site    │ 1             │ 25            │ 24            │ ├─────────┼────────────────┼───────────────┼───────────────┼───────────────┤ │Symantec │ Secure Site    │ 1             │ 25            │ 24            │ │         │ Pro            │               │               │               │ └─────────┴────────────────┴───────────────┴───────────────┴───────────────┘
salt 'my-minion' namecheap_ssl.create 2 RapidSSL
salt.modules.namecheap_ssl.get_info(certificate_id, returncertificate=False, returntype=None) Retrieves information about the requested SSL certificate. Returns a dictionary of information about the SSL certificate with two keys:
• ssl - Contains the metadata information
• certificate - Contains the details for the certificate such as the CSR, Approver, and certificate data
certificate_id Unique ID of the SSL certificate
returncertificate False Set to True to ask for the certificate in response
returntype Optional type for the returned certificate. Can be either "Individual" (for X.509 format) or "PKCS7"
NOTE: Required if returncertificate is True
salt 'my-minion' namecheap_ssl.get_info my-cert-id
salt.modules.namecheap_ssl.get_list(**kwargs) Returns a list of SSL certificates for a particular user
ListType All Possible values:
• All
• EmailSent
• TechnicalProblem
• InProgress
• Completed
• Deactivated
• Active
• Cancelled
• NewPurchase
• NewRenewal
SearchTerm Keyword to look for on the SSL list
Page   1 Page number to return
PageSize 20 Total number of SSL certificates to display per page (minimum: 10, maximum: 100)
SoryBy One of PURCHASEDATE, PURCHASEDATE_DESC, SSLTYPE, SSLTYPE_DESC, EXPIREDATETIME, EXPIREDATETIME_DESC, Host_Name, or Host_Name_DESC
salt 'my-minion' namecheap_ssl.get_list Processing
salt.modules.namecheap_ssl.parse_csr(csr_file, certificate_type, http_dc_validation=False) Parses the CSR. Returns a dictionary of result values.
http_dc_validation False Set to True if a Comodo certificate and validation should be done with files instead of emails and to return the info to do so
salt 'my-minion' namecheap_ssl.parse_csr my-csr-file PremiumSSL
salt.modules.namecheap_ssl.reissue(csr_file, certificate_id, web_server_type, approver_email=None, http_dc_validation=False, **kwargs) Reissues a purchased SSL certificate. Returns a dictionary of result values.
salt 'my-minion' namecheap_ssl.reissue my-csr-file my-cert-id apachessl
salt.modules.namecheap_ssl.renew(years, certificate_id, certificate_type, promotion_code=None) Renews an SSL certificate if it is ACTIVE and Expires <= 30 days. Returns the following information:
certificate_id Unique ID of the SSL certificate you wish to renew
promotional_code An optional promo code to use when renewing the certificate
salt 'my-minion' namecheap_ssl.renew 1 my-cert-id RapidSSL
salt.modules.namecheap_users Namecheap User Management
salt.modules.namecheap_users.check_balances(minimum=100) Checks if the provided minimum value is present in the user's account.
Returns a boolean. Returns False if the user's account balance is less than the provided minimum or True if greater than the minimum.
minimum 100 The value to check
salt 'my-minion' namecheap_users.check_balances salt 'my-minion' namecheap_users.check_balances minimum=150
salt.modules.namecheap_users.get_balances() Gets information about fund in the user's account. This method returns the following information: Available Balance, Account Balance, Earned Amount, Withdrawable Amount and Funds Required for AutoRenew.
NOTE: If a domain setup with automatic renewal is expiring within the next 90 days, the FundsRequiredForAutoRenew attribute shows the amount needed in your Namecheap account to complete auto renewal.
salt 'my-minion' namecheap_users.get_balances
salt.modules.napalm_bgp NAPALM BGP Manages BGP configuration on network devices and provides statistics.
codeauthor Mircea Ulinic <ping@mirceaulinic.net> & Jerome Fleury <‐ jf@cloudflare.com>
Dependencies • napalm proxy minion
salt.modules.napalm_bgp.config(group=None, neighbor=None, **kwargs) Provides the BGP configuration on the device.
• group -- Name of the group selected to display the configuration.
• neighbor -- IP Address of the neighbor to display the configuration.  If the group parameter is not specified, the neighbor setting will be ignored.
Returns A dictionary containing the BGP configuration from the network device. The keys of the main dictionary are the group names.
Each group has the following properties:
• type (string)
• description (string)
• apply_groups (string list)
• multihop_ttl (int)
• multipath (True/False)
• local_address (string)
• local_as (int)
• remote_as (int)
• import_policy (string)
• export_policy (string)
• remove_private_as (True/False)
• prefix_limit (dictionary)
• neighbors (dictionary)
Each neighbor in the dictionary of neighbors provides:
• authentication_key (string)
• route_reflector_client (True/False)
• nhs (True/False)
salt '*' bgp.config # entire BGP config salt '*' bgp.config PEERS-GROUP-NAME # provides detail only about BGP group PEERS-GROUP-NAME salt '*' bgp.config PEERS-GROUP-NAME 172.17.17.1 # provides details only about BGP neighbor 172.17.17.1, # configured in the group PEERS-GROUP-NAME
{ 'PEERS-GROUP-NAME':{ 'type'          : 'external', 'description'   : 'Here we should have a nice description', 'apply_groups'  : ['BGP-PREFIX-LIMIT'], 'import_policy' : 'PUBLIC-PEER-IN', 'export_policy' : 'PUBLIC-PEER-OUT', 'remove_private': True, 'multipath'     : True, 'multihop_ttl'  : 30, 'neighbors'     : { '192.168.0.1': { 'description'   : 'Facebook [CDN]', 'prefix_limit'  : { 'inet': { 'unicast': { 'limit': 100, 'teardown': { 'threshold' : 95, 'timeout'   : 5 } } } } 'peer-as'        : 32934, 'route_reflector': False, 'nhs'            : True }, '172.17.17.1': { 'description'   : 'Twitter [CDN]', 'prefix_limit'  : { 'inet': { 'unicast': { 'limit': 500, 'no-validate': 'IMPORT-FLOW-ROUTES' } } } 'peer_as'        : 13414 'route_reflector': False, 'nhs'            : False } } } }
salt.modules.napalm_bgp.neighbors(neighbor=None, **kwargs) Provides details regarding the BGP sessions configured on the network device.
Parameters neighbor -- IP Address of a specific neighbor.
Returns A dictionary with the statistics of the all/selected BGP neighbors. Outer dictionary keys represent the VRF name. Keys of inner dictionary represent the AS numbers, while the values are lists of dictionaries, having the following keys:
• up (True/False)
• routing_table (string)
• local_address_configured (True/False)
• local_port (int)
• remote_address (string)
• remote_port (int)
• multihop (True/False)
• input_messages (int)
• output_messages (int)
• input_updates (int)
• output_updates (int)
• messages_queued_out (int)
• connection_state (string)
• previous_connection_state (string)
• last_event (string)
• suppress_4byte_as (True/False)
• local_as_prepend (True/False)
• holdtime (int)
• configured_holdtime (int)
• keepalive (int)
• configured_keepalive (int)
• active_prefix_count (int)
• received_prefix_count (int)
• accepted_prefix_count (int)
• suppressed_prefix_count (int)
• advertised_prefix_count (int)
• flap_count (int)
salt '*' bgp.neighbors  # all neighbors salt '*' bgp.neighbors 172.17.17.1  # only session with BGP neighbor(s) 172.17.17.1
{ 'default': { 8121: [ { 'up'                        : True, 'local_as'                  : 13335, 'remote_as'                 : 8121, 'local_address'             : '172.101.76.1', 'local_address_configured'  : True, 'local_port'                : 179, 'remote_address'            : '192.247.78.0', 'router_id'                 : '192.168.0.1', 'remote_port'               : 58380, 'multihop'                  : False, 'import_policy'             : '4-NTT-TRANSIT-IN', 'export_policy'             : '4-NTT-TRANSIT-OUT', 'input_messages'            : 123, 'output_messages'           : 13, 'input_updates'             : 123, 'output_updates'            : 5, 'messages_queued_out'       : 23, 'connection_state'          : 'Established', 'previous_connection_state' : 'EstabSync', 'last_event'                : 'RecvKeepAlive', 'suppress_4byte_as'         : False, 'local_as_prepend'          : False, 'holdtime'                  : 90, 'configured_holdtime'       : 90, 'keepalive'                 : 30, 'configured_keepalive'      : 30, 'active_prefix_count'       : 132808, 'received_prefix_count'     : 566739, 'accepted_prefix_count'     : 566479, 'suppressed_prefix_count'   : 0, 'advertise_prefix_count'    : 0, 'flap_count'                : 27 } ] } }
salt.modules.napalm_formula NAPALM Formula helpers New in version 2019.2.0.
This is an Execution Module providing helpers for various NAPALM formulas, e.g., napalm-interfaces-formula, napalm-bgp-formula, napalm-ntp-formula etc., meant to provide various helper functions to make the templates more readable.
salt.modules.napalm_formula.container_path(model, key=None, container=None, delim=':') Return the list of all the possible paths in a container, down to the config container.  This function can be used to verify that the model is a Python object correctly structured and respecting the OpenConfig hierarchy.
model  The OpenConfig-structured object to inspect.
delim: : The key delimiter. In particular cases, it is indicated to use // as : might be already used in various cases, e.g., IPv6 addresses, interface name (e.g., Juniper QFX series), etc.
salt '*' napalm_formula.container_path "{'interfaces': {'interface': {'Ethernet1': {'config': {'name': 'Ethernet1'}}}}}"
The example above would return a list with the following element: interfaces:interface:Ethernet1:config which is the only possible path in that hierarchy.
Other output examples:
- interfaces:interface:Ethernet1:config - interfaces:interface:Ethernet1:subinterfaces:subinterface:0:config - interfaces:interface:Ethernet2:config
salt.modules.napalm_formula.defaults(model, defaults_, delim='//', flipped_merge=False) Apply the defaults to a Python dictionary having the structure as described in the OpenConfig standards.
model  The OpenConfig model to apply the defaults to.
defaults The dictionary of defaults. This argument must equally be structured with respect to the OpenConfig standards.
For ease of use, the keys of these support glob matching, therefore we don't have to provide the defaults for each entity but only for the entity type. See an example below.
delim: // The key delimiter to use. Generally, // should cover all the possible cases, and you don't need to override this value.
flipped_merge: False Whether should merge the model into the defaults, or the defaults into the model. Default: False (merge the model into the defaults, i.e., any defaults would be overridden by the values from the model).
salt '*' napalm_formula.defaults "{'interfaces': {'interface': {'Ethernet1': {'config': {'name': 'Ethernet1'}}}}}" "{'interfaces': {'interface': {'*': {'config': {'enabled': True}}}}}"
As one can notice in the example above, the * corresponds to the interface name, therefore, the defaults will be applied on all the interfaces.
salt.modules.napalm_formula.dictupdate(dest, upd, recursive_update=True, merge_lists=False) Recursive version of the default dict.update
Merges upd recursively into dest
If recursive_update=False, will use the classic dict.update, or fall back on a manual merge (helpful for non-dict types like FunctionWrapper).
If merge_lists=True, will aggregate list object types instead of replace.  The list in upd is added to the list in dest, so the resulting list is dest[key] + upd[key]. This behaviour is only activated when recursive_update=True. By default merge_lists=False.
salt.modules.napalm_formula.render_field(dictionary, field, prepend=None, append=None, quotes=False, **opts) Render a field found under the field level of the hierarchy in the dictionary object.  This is useful to render a field in a Jinja template without worrying that the hierarchy might not exist. For example if we do the following in Jinja: {{ interfaces.interface.Ethernet5.config.description }} for the following object: {'interfaces': {'interface': {'Ethernet1': {'config': {'enabled': True}}}}} it would error, as the Ethernet5 key does not exist.  With this helper, we can skip this and avoid existence checks. This must be however used with care.
dictionary The dictionary to traverse.
field  The key name or part to traverse in the dictionary.
prepend: None The text to prepend in front of the text. Usually, we need to have the name of the field too when generating the configuration.
append: None Text to append at the end.
quotes: False Whether should wrap the text around quotes.
salt '*' napalm_formula.render_field "{'enabled': True}" enabled # This would return the value of the ``enabled`` leaf key salt '*' napalm_formula.render_field "{'enabled': True}" description # This would not error
Jinja usage example:
{%- set config = {'enabled': True, 'description': 'Interface description'} %} {{ salt.napalm_formula.render_field(config, 'description', quotes=True) }}
The example above would be rendered on Arista / Cisco as:
description "Interface description"
While on Junos (the semicolon is important to be added, otherwise the configuration won't be accepted by Junos):
description "Interface description";
salt.modules.napalm_formula.render_fields(dictionary, *fields, **opts) This function works similarly to render_field but for a list of fields from the same dictionary, rendering, indenting and distributing them on separate lines.
fields A list of field names or paths in the dictionary.
indent: 0 The indentation to use, prepended to the rendered field.
separator: \n The separator to use between fields.
salt '*' napalm_formula.render_fields "{'mtu': 68, 'description': 'Interface description'}" mtu description
{%- set config={'mtu': 68, 'description': 'Interface description'} %} {{ salt.napalm_formula.render_fields(config, 'mtu', 'description', quotes=True) }}
The Jinja example above would generate the following configuration:
mtu "68" description "Interface description"
salt.modules.napalm_formula.setval(key, val, dict_=None, delim=':') Set a value under the dictionary hierarchy identified under the key. The target 'foo/bar/baz' returns the dictionary hierarchy {'foo': {'bar': {'baz': {}}}}.
NOTE: Currently this doesn't work with integers, i.e.  cannot build lists dynamically.
salt '*' formula.setval foo:baz:bar True