1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
|
#!/usr/bin/python
# -*- coding: utf-8 -*-
# (c) 2022, John McCall (@lowlydba)
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
DOCUMENTATION = r'''
---
module: availability_group
short_description: Configures availability group(s)
description:
- Configures SQL Server Availability Group(s) with up to one replica.
version_added: 0.4.0
options:
sql_instance_secondary:
description:
- The secondary SQL Server instance for the new Availability Group.
type: str
required: false
sql_username_secondary:
description:
- Username for SQL Authentication for the secondary replica.
type: str
required: false
sql_password_secondary:
description:
- Password for SQL Authentication for the secondary replica.
type: str
required: false
database:
description:
- Name of the database to create the Availability Group for.
type: str
required: false
aliases:
- database_name
ag_name:
description:
- Name of the Availability Group.
type: str
required: true
all_ags:
description:
- Apply changes to all availability groups on the instance. Only used for configuring existing availability groups.
type: bool
required: false
shared_path:
description:
- The network share where the backups will be backed up and restored from.
type: str
required: false
dtc_support_enabled:
description:
- Enables Dtc support.
type: bool
required: false
basic_availability_group:
description:
- Indicates whether the availability group is Basic Availability Group.
type: bool
required: false
database_health_trigger:
description:
- Indicates whether the availability group triggers the database health.
type: bool
required: false
is_distributed_ag:
description:
- Indicates whether the availability group is distributed.
type: bool
required: false
healthcheck_timeout:
description:
- This setting used to specify the length of time, in milliseconds,
that the SQL Server resource DLL should wait for information returned by the C(sp_server_diagnostics)
stored procedure before reporting the Always On Failover Cluster Instance (FCI) as unresponsive.
- Changes that are made to the timeout settings are effective immediately and do not require a restart of the SQL Server resource.
type: int
required: false
failure_condition_level:
description:
- Specifies the different conditions that can trigger an automatic failover in Availability Group.
type: str
required: false
choices: ['OnAnyQualifiedFailureCondition', 'OnCriticalServerErrors', 'OnModerateServerErrors', 'OnServerDown', 'OnServerUnresponsive']
cluster_type:
description:
- Cluster type of the Availability Group. Only supported in SQL Server 2017 and above.
type: str
required: false
default: 'Wsfc'
choices: ['Wsfc', 'External', 'None']
failover_mode:
description:
- Whether the replica have Automatic or Manual failover.
type: str
required: false
default: 'Automatic'
choices: ['Automatic', 'Manual']
availability_mode:
description:
- Whether the replica should be Asynchronous or Synchronous.
- Only used in creating a new availability group.
type: str
required: false
default: 'SynchronousCommit'
choices: ['AsynchronousCommit', 'SynchronousCommit']
seeding_mode:
description:
- Default seeding mode for the replica. Should remain as the default otherwise manual setup may be required.
type: str
required: false
default: 'Manual'
choices: ['Automatic', 'Manual']
automated_backup_preference:
description:
- How to handle backup requests by default.
type: str
required: false
default: 'Secondary'
choices: ['None', 'Primary', 'Secondary', 'SecondaryOnly']
allow_null_backup:
description:
- Allow taking a full backup to C(NULL) if one does not exist and I(seeding_mode=Automatic).
type: bool
required: false
force:
description:
- Drop and recreate the database on remote servers using fresh backup.
type: bool
use_last_backup:
description:
- Use the last full and log backup of database. A log backup must be the last backup.
type: bool
author: "John McCall (@lowlydba)"
requirements:
- L(dbatools,https://www.powershellgallery.com/packages/dbatools/) PowerShell module
extends_documentation_fragment:
- lowlydba.sqlserver.sql_credentials
- lowlydba.sqlserver.attributes.check_mode
- lowlydba.sqlserver.attributes.platform_all
- lowlydba.sqlserver.state
'''
EXAMPLES = r'''
- name: Create Availability Group
lowlydba.sqlserver.availability_group:
sql_instance: sql-01.myco.io
ag_name: AG_MyDatabase
'''
RETURN = r'''
data:
description: Output from the C(New-DbaAvailabilityGroup) or C(Set-DbaAvailabilityGroup) function.
returned: success, but not in check_mode.
type: dict
'''
|