Debian Codegraph @

ansible_collections/lowlydba/sqlserver/plugins/modules/install_script.py

raw
1 #!/usr/bin/python
2 # -*- coding: utf-8 -*-
3
4 # (c) 2022, John McCall (@lowlydba)
5 # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
6
7 DOCUMENTATION = r'''
8 ---
9 module: install_script
10 short_description: Runs migration scripts against a database
11 description:
12 - Uses the module C(DBOps) to run C(Dbo-InstallScript) against a target SQL Server database.
13 version_added: 0.11.0
14 options:
15 database:
16 description:
17 - Name of the target database.
18 required: true
19 type: str
20 path:
21 description:
22 - Directory where targeted sql scripts are stored.
23 type: str
24 required: true
25 schema_version_table:
26 description:
27 - A table that will hold the history of script execution. This table is used to choose what scripts are going to be
28 run during the deployment, preventing the scripts from being execured twice.
29 type: str
30 required: false
31 deployment_method:
32 description:
33 - C(SingleTransaction) - wrap all the deployment scripts into a single transaction and rollback whole deployment on error.
34 - C(TransactionPerScript) - wrap each script into a separate transaction; rollback single script deployment in case of error.
35 - C(NoTransaction) - deploy as is.
36 - C(AlwaysRollback) - roll back the transaction.
37 type: str
38 required: false
39 default: 'NoTransaction'
40 choices: ['NoTransaction', 'SingleTransaction', 'TransactionPerScript', 'AlwaysRollback']
41 no_log_version:
42 description:
43 - If set, the deployment will not be tracked in the database. That will also mean that all the scripts
44 and all the builds from the package are going to be deployed regardless of any previous deployment history.
45 type: bool
46 default: false
47 required: false
48 connection_timeout:
49 description:
50 - Database server connection timeout in seconds. Only affects connection attempts. Does not affect execution timeout.
51 type: int
52 default: 30
53 required: false
54 execution_timeout:
55 description:
56 - Script execution timeout. The script will be aborted if the execution takes more than specified number of seconds.
57 type: int
58 default: 0
59 required: false
60 output_file:
61 description:
62 - Log output into specified file.
63 type: str
64 required: false
65 create_database:
66 description:
67 - Will create an empty database if missing.
68 type: bool
69 default: false
70 required: false
71 no_recurse:
72 description:
73 - Only process the first level of the target path.
74 type: bool
75 required: false
76 default: false
77 match:
78 description:
79 - Runs a regex verification against provided file names using the provided string.
80 type: str
81 required: false
82 author: "John McCall (@lowlydba)"
83 requirements:
84 - L(dbatools,https://www.powershellgallery.com/packages/dbatools/) PowerShell module
85 - L(dbops,https://github.com/dataplat/dbops) PowerShell module
86 extends_documentation_fragment:
87 - lowlydba.sqlserver.sql_credentials
88 - lowlydba.sqlserver.attributes.check_mode
89 - lowlydba.sqlserver.attributes.platform_all
90 '''
91
92 EXAMPLES = r'''
93 - name: Migrate a database
94 lowlydba.sqlserver.install_script:
95 sql_instance: test-server.my.company.com
96 database: AdventureWorks
97 path: migrations
98 '''
99
100 RETURN = r'''
101 data:
102 description: Modified output from the C(Install-DboScript) function.
103 returned: success, but not in check_mode.
104 type: dict
105 '''