Skip to content

Commit

Permalink
Fixes ansible#30863: support update source_address_prefix in azure_rm…
Browse files Browse the repository at this point in the history
…_securitygroup (ansible#32614)

* compare source address prefix

* remove useless quote
  • Loading branch information
yuwzho authored and ansibot committed Nov 22, 2017
1 parent 1cc7f9f commit b6c401c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 13 deletions.
3 changes: 3 additions & 0 deletions lib/ansible/modules/cloud/azure/azure_rm_securitygroup.py
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,9 @@ def compare_rules(r, rule):
if rule['direction'] != r['direction']:
changed = True
r['direction'] = rule['direction']
if rule['source_address_prefix'] != str(r['source_address_prefix']):
changed = True
r['source_address_prefix'] = rule['source_address_prefix']
return matched, changed


Expand Down
31 changes: 18 additions & 13 deletions test/integration/targets/azure_rm_securitygroup/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
access: Deny
priority: 100
direction: Inbound
- name: 'AllowSSH'
- name: AllowSSH
protocol: Tcp
source_address_prefix: '174.109.158.0/24'
source_address_prefix: 174.109.158.0/24
destination_port_range: 22
access: Allow
priority: 101
Expand All @@ -41,33 +41,38 @@
resource_group: "{{ resource_group }}"
name: mysecgroup
rules:
- name: DenySSH
- name: AllowSSH
protocol: Tcp
destination_port_range: 22-23
access: Deny
priority: 100
source_address_prefix: 174.108.158.0/24
destination_port_range: 22
access: Allow
priority: 101
- name: AllowSSHFromHome
protocol: Tcp
source_address_prefix: '174.109.158.0/24'
source_address_prefix: 174.109.158.0/24
destination_port_range: 22-23
priority: 102
register: output

- assert: { that: "{{ output.state.rules | length }} == 3" }
- assert:
that:
- "{{ output.state.rules | length }} == 3"
- output.state.rules[1].source_address_prefix == '174.108.158.0/24'

- name: Test idempotence
azure_rm_securitygroup:
resource_group: "{{ resource_group }}"
name: mysecgroup
rules:
- name: DenySSH
- name: AllowSSH
protocol: Tcp
destination_port_range: 22-23
access: Deny
priority: 100
source_address_prefix: 174.108.158.0/24
destination_port_range: 22
access: Allow
priority: 101
- name: AllowSSHFromHome
protocol: Tcp
source_address_prefix: '174.109.158.0/24'
source_address_prefix: 174.109.158.0/24
destination_port_range: 22-23
priority: 102
register: output
Expand Down

0 comments on commit b6c401c

Please sign in to comment.