Skip to content

Commit

Permalink
changing ip_address param to expect list (#246)
Browse files Browse the repository at this point in the history
* changing ip_address param to expect list

* 1) changing all list expecting params to be typed as list and including element type 2) updated fragment to be inclusive of all changes

* updating documented options to match

* spaces for pslint satisfaction

* updated tests file to use lists for list type parameters

* updated code examples to show passing in lists instead of single or comma separated strings

---------

Co-authored-by: John McCall <[email protected]>
  • Loading branch information
daarrn and lowlydba authored Jun 6, 2024
1 parent 01a1812 commit 8512031
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 14 deletions.
2 changes: 2 additions & 0 deletions changelogs/fragments/245-ag_listener-ip_address-fix.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bugfixes:
- fixed the expected type of the ip_address, subnet_ip, and subnet_mask parameters to be lists instead of strings (lowlydba.sqlserver.ag_listener)
6 changes: 3 additions & 3 deletions plugins/modules/ag_listener.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ $spec = @{
options = @{
ag_name = @{type = 'str'; required = $true }
listener_name = @{type = 'str'; required = $true }
ip_address = @{type = 'str'; required = $false }
subnet_ip = @{type = 'str'; required = $false }
subnet_mask = @{type = 'str'; required = $false; default = '255.255.255.0' }
ip_address = @{type = 'list'; elements = 'str'; required = $false }
subnet_ip = @{type = 'list'; elements = 'str'; required = $false }
subnet_mask = @{type = 'list'; elements = 'str'; required = $false; default = '255.255.255.0' }
port = @{type = 'int'; required = $false; default = 1433 }
dhcp = @{type = 'bool'; required = $false; default = $false }
state = @{type = "str"; required = $false; default = "present"; choices = @("present", "absent") }
Expand Down
19 changes: 13 additions & 6 deletions plugins/modules/ag_listener.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,20 @@
ip_address:
description:
- IP address(es) of the listener. Comma separated if multiple.
type: str
type: list
elements: str
required: false
subnet_ip:
description:
- Subnet IP address(es) of the listener. Comma separated if multiple.
type: str
type: list
elements: str
required: false
subnet_mask:
description:
- Sets the subnet IP mask(s) of the availability group listener. Comma separated if multiple.
type: str
type: list
elements: str
required: false
default: 255.255.255.0
port:
Expand Down Expand Up @@ -71,9 +74,13 @@
sql_instance_primary: sql-01.myco.io
ag_name: AG_MyDatabase
listener_name: aglMyDatabase
ip_address: 10.0.20.20,10.1.77.77
subnet_ip: 255.255.252.0
subnet_mask: 255.255.255.0
ip_address:
- 10.0.20.20
- 10.1.77.77
subnet_ip:
- 255.255.252.0
subnet_mask:
- 255.255.255.0
'''

RETURN = r'''
Expand Down
10 changes: 7 additions & 3 deletions plugins/modules/spn.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,13 @@
sql_instance_primary: sql-01.myco.io
ag_name: AG_MyDatabase
listener_name: aglMyDatabase
ip_address: 10.0.20.20,10.1.77.77
subnet_ip: 255.255.252.0
subnet_mask: 255.255.255.0
ip_address:
- 10.0.20.20
- 10.1.77.77
subnet_ip:
- 255.255.252.0
subnet_mask:
- 255.255.255.0
- name: Add SPN for new AG listener on port 1433
lowlydba.sqlserver.spn:
Expand Down
6 changes: 4 additions & 2 deletions tests/integration/targets/win_ag_listener/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@
ag_name: "{{ ag_name }}"
listener_name: "{{ listener_name }}"
port: "{{ port }}"
ip_address: "192.168.6.9"
subnet_mask: "255.255.255.0"
ip_address:
- "192.168.6.9"
subnet_mask:
- "255.255.255.0"
tags: ["ag_listener"]
block:
- name: Enable hadr
Expand Down

0 comments on commit 8512031

Please sign in to comment.