Debian Codegraph @

ansible_collections/lowlydba/sqlserver/plugins/modules/ag_replica.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: ag_replica
10 short_description: Configures an availability group replica
11 description:
12 - Configures an availability group replica.
13 version_added: 0.5.0
14 options:
15 sql_instance_replica:
16 description:
17 - The SQL Server instance where of the replica to be configured.
18 type: str
19 required: true
20 sql_username_replica:
21 description:
22 - Username for SQL Authentication for the secondary replica.
23 type: str
24 required: false
25 sql_password_replica:
26 description:
27 - Password for SQL Authentication for the secondary replica.
28 type: str
29 required: false
30 ag_name:
31 description:
32 - Name of the Availability Group that will have the new replica joined to it.
33 type: str
34 required: true
35 endpoint:
36 description:
37 - By default, this command will attempt to find a DatabaseMirror endpoint. If one does not exist, it will create it.
38 type: str
39 required: false
40 default: 'hadr_endpoint'
41 endpoint_url:
42 description:
43 - By default, the property C(Fqdn) of C(Get-DbaEndpoint) is used as I(endpoint_url).
44 Use I(endpoint_url) if a different URL is required due to special network configurations.
45 type: str
46 required: false
47 backup_priority:
48 description:
49 - Sets the backup priority availability group replica.
50 type: int
51 default: 50
52 failover_mode:
53 description:
54 - Whether the replica have Automatic or Manual failover.
55 type: str
56 required: false
57 default: 'Manual'
58 choices: ['Automatic', 'Manual']
59 availability_mode:
60 description:
61 - Whether the replica should be Asynchronous or Synchronous.
62 type: str
63 required: false
64 default: 'AsynchronousCommit'
65 choices: ['AsynchronousCommit', 'SynchronousCommit']
66 seeding_mode:
67 description:
68 - Default seeding mode for the replica. Should remain as the default otherwise manual setup may be required.
69 type: str
70 required: false
71 default: 'Automatic'
72 choices: ['Automatic', 'Manual']
73 connection_mode_in_primary_role:
74 description:
75 - Which connections can be made to the database when it is in the primary role.
76 type: str
77 required: false
78 default: 'AllowAllConnections'
79 choices: ['AllowReadIntentConnectionsOnly','AllowAllConnections']
80 connection_mode_in_secondary_role:
81 description:
82 - Which connections can be made to the database when it is in the secondary role.
83 type: str
84 required: false
85 default: 'AllowNoConnections'
86 choices: ['AllowNoConnections','AllowReadIntentConnectionsOnly','AllowAllConnections']
87 read_only_routing_connection_url:
88 description:
89 - Sets the read only routing connection url for the availability replica.
90 type: str
91 required: false
92 read_only_routing_list:
93 description:
94 - Sets the read only routing ordered list of replica server names to use when redirecting read-only connections through this availability replica.
95 type: str
96 required: false
97 cluster_type:
98 description:
99 - Cluster type of the Availability Group. Only supported in SQL Server 2017 and above.
100 type: str
101 required: false
102 default: 'Wsfc'
103 choices: ['Wsfc', 'External', 'None']
104 configure_xe_session:
105 description:
106 - Configure the AlwaysOn_health extended events session to start automatically as the SSMS wizard would do.
107 type: bool
108 default: false
109 session_timeout:
110 description:
111 - How many seconds an availability replica waits for a ping response from a connected replica before considering the connection to have failed.
112 type: int
113 required: false
114 author: "John McCall (@lowlydba)"
115 requirements:
116 - L(dbatools,https://www.powershellgallery.com/packages/dbatools/) PowerShell module
117 extends_documentation_fragment:
118 - lowlydba.sqlserver.sql_credentials
119 - lowlydba.sqlserver.attributes.check_mode
120 - lowlydba.sqlserver.attributes.platform_all
121 - lowlydba.sqlserver.state
122 '''
123
124 EXAMPLES = r'''
125 - name: Create Availability Group
126 lowlydba.sqlserver.availability_group:
127 sql_instance: sql-01.myco.io
128 ag_name: AG_MyDatabase
129
130 - name: Add a DR replica
131 lowlydba.sqlserver.ag_replica:
132 ag_name: 'AG_MyDatabase'
133 sql_instance_primary: sql-01.myco.io
134 sql_instance_replica: sql-02.myco.io
135 failover_mode: 'Manual'
136 availability_mode: 'Asynchronous'
137 seeding_mode: 'Automatic'
138 connection_mode_in_primary_role: 'AllowAllConnections'
139 connection_mode_in_secondary_role: 'AllowNoConnections'
140 '''
141
142 RETURN = r'''
143 data:
144 description: Output from the C(Add-DbaAgReplica) or C(Set-DbaAgReplica) function.
145 returned: success, but not in check_mode.
146 type: dict
147 '''