Each resource block MAY have an ensure
attribute. The possible values are
present
- If the resource doesn’t exist, create it. If it exists, alter it to match the resource block.absent
- If the resource exists, remove italter
- If the resource exists, alter it. If it doesn’t exist, do nothing.If no ensure
attribute is found, it defaults to present
sql_script
resource, the file is now specified in the script_file
field. script
is also supported but will be removed in a future release.sql_file
to sql_script
in 1.18 (12 April 2020)The following resource block types are supported
configuration
name
(string - optional starting in 1.18. If not provided, it defaults to the resource name) Any valid name from sys.configurations
where is_dynamic
= 1. Common value are:
backup compression default
clr enabled
cost threshold for parallelism
max degree of parallism
max server memory (MB)
max text repl size (B)
optimize for ad hoc workloads
xp_cmdshell
value
(int32 - required)present
is treated like alter
and absent
isn’t a valid value.login
name
(string - optional starting in 1.18. If not provided, it defaults to the resource name.)disabled
(true/false)sqldsc_credential
(string - required for SQL Server logins) - the local saved vault entry use to set the passworddefault_database
(string)policy_checked
(bool)expiration_checked
(bool)sid
- (string - only for SQL Server logins)server_permission
login
(string - required)permission
(string - required)server_role_member
login
(string - required)role
(string - required)agent_operator
name
(string - optional starting in 1.18. If not provided, it defaults to the resource name.)email
(string - required)database
name
(string - optional starting in 1.18. If not provided, it defaults to the resource name.)owner
(string)recovery_model
(string - full/simple/bulk_logged)rcsi
(true/false) read committed snapshot enabledsql_script
test_query
– SQL query that returns rows if the script has already run. If the query returns no rows, the SQL file specified in file
will be run.expected_rows
(int - optional) If provided, this is how many rows the test_query
is expected to return. If not provided, the script will only run if the test_query returns no rows.script_file
– file to look for in the scripts
directory. This file is run using sqlcmd.exe
. Prior to 1.17 this was named file_name
.ensure
– present
will run the file if no rows are returned by test_query
. All other values are an error.--push file.sql
’ parameter will always run a script if passed on the command line. This useful for situations where you want to update a common stored procedure across servers. Typically this is used to put something like sp_whoisactive on servers.database_user
database
(string - required)user
(string - required)default_schema
(string) - the default schema for this user. Prior to 1.18 this was named schema
.database_role_member
database
(string - required)role
(string - required)user
(string - required)database_permission
database
(string - required)user
(string - required)permission
(string - required)object_permission
sets a permission on a database object
database
(string - required)schema
(string - required)object
(string - required)user
(string - required)permission
(string - required)© 2020 ScaleOut Consulting, LLC