salt.modules.mssql

Module to provide MS SQL Server compatibility to salt.

depends:
  • FreeTDS
  • pymssql Python module
configuration:

In order to connect to MS SQL Server, certain configuration is required in minion configs/pillars on the relevant minions. Some sample pillars might look like:

mssql.server: 'localhost'
mssql.port:   1433
mssql.user:   'sysdba'
mssql.password:   'Some preferable complex password'
mssql.database: ''

The default for the port is '1433' and for the database is '' (empty string); in most cases they can be left at the default setting. Options that are directly passed into functions will overwrite options from configs or pillars.

salt.modules.mssql.db_exists(database_name, **kwargs)

Find if a specific database exists on the MS SQL server.

CLI Example:

salt minion mssql.db_exists database_name='DBNAME'
salt.modules.mssql.db_list(**kwargs)

Return the databse list created on a MS SQL server.

CLI Example:

salt minion mssql.db_list
salt.modules.mssql.db_remove(database_name, **kwargs)

Drops a specific database from the MS SQL server. It will not drop any of 'master', 'model', 'msdb' or 'tempdb'.

CLI Example:

salt minion mssql.db_remove database_name='DBNAME'
salt.modules.mssql.login_exists(login, **kwargs)

Find if a login exists in the MS SQL server.

CLI Example:

salt minion mssql.login_exists 'LOGIN'
salt.modules.mssql.role_create(role, owner=None, **kwargs)

Creates a new database role. If no owner is specified, the role will be owned by the user that executes CREATE ROLE, which is the user argument or mssql.user option.

CLI Example:

salt minion mssql.role_create role=product01 owner=sysdba
salt.modules.mssql.role_exists(role, **kwargs)

Checks if a role exists.

CLI Example:

salt minion mssql.role_exists db_owner
salt.modules.mssql.role_list(**kwargs)

Lists database roles.

CLI Example:

salt minion mssql.role_list
salt.modules.mssql.role_remove(role, **kwargs)

Remove a database role.

CLI Example:

salt minion mssql.role_create role=test_role01
salt.modules.mssql.tsql_query(query, **kwargs)

Run a SQL query and return query result as list of tuples, or a list of dictionaries if as_dict was passed, or an empty list if no data is available.

CLI Example:

salt minion mssql.tsql_query 'SELECT @@version as version' as_dict=True
salt.modules.mssql.user_create(username, new_login_password=None, **kwargs)

Creates a new user. If new_login_password is not specified, the user will be created without a login.

CLI Example:

salt minion mssql.user_create USERNAME database=DBNAME [new_login_password=PASSWORD]
salt.modules.mssql.user_exists(username, **kwargs)

Find if an user exists in a specific database on the MS SQL server.

Note:
database argument is mandatory

CLI Example:

salt minion mssql.user_exists 'USERNAME' [database='DBNAME']
salt.modules.mssql.user_list(**kwargs)

Get the user list for a specific database on the MS SQL server.

CLI Example:

salt minion mssql.user_list [database='DBNAME']
salt.modules.mssql.user_remove(username, **kwargs)

Removes an user.

CLI Example:

salt minion mssql.user_remove USERNAME database=DBNAME
salt.modules.mssql.version(**kwargs)

Return the version of a MS SQL server.

CLI Example:

salt minion mssql.version