mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
* compare source address prefix * remove useless quote
This commit is contained in:
parent
1cc7f9f2ea
commit
b6c401ccc8
2 changed files with 21 additions and 13 deletions
|
@ -426,6 +426,9 @@ def compare_rules(r, rule):
|
||||||
if rule['direction'] != r['direction']:
|
if rule['direction'] != r['direction']:
|
||||||
changed = True
|
changed = True
|
||||||
r['direction'] = rule['direction']
|
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
|
return matched, changed
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -14,9 +14,9 @@
|
||||||
access: Deny
|
access: Deny
|
||||||
priority: 100
|
priority: 100
|
||||||
direction: Inbound
|
direction: Inbound
|
||||||
- name: 'AllowSSH'
|
- name: AllowSSH
|
||||||
protocol: Tcp
|
protocol: Tcp
|
||||||
source_address_prefix: '174.109.158.0/24'
|
source_address_prefix: 174.109.158.0/24
|
||||||
destination_port_range: 22
|
destination_port_range: 22
|
||||||
access: Allow
|
access: Allow
|
||||||
priority: 101
|
priority: 101
|
||||||
|
@ -41,33 +41,38 @@
|
||||||
resource_group: "{{ resource_group }}"
|
resource_group: "{{ resource_group }}"
|
||||||
name: mysecgroup
|
name: mysecgroup
|
||||||
rules:
|
rules:
|
||||||
- name: DenySSH
|
- name: AllowSSH
|
||||||
protocol: Tcp
|
protocol: Tcp
|
||||||
destination_port_range: 22-23
|
source_address_prefix: 174.108.158.0/24
|
||||||
access: Deny
|
destination_port_range: 22
|
||||||
priority: 100
|
access: Allow
|
||||||
|
priority: 101
|
||||||
- name: AllowSSHFromHome
|
- name: AllowSSHFromHome
|
||||||
protocol: Tcp
|
protocol: Tcp
|
||||||
source_address_prefix: '174.109.158.0/24'
|
source_address_prefix: 174.109.158.0/24
|
||||||
destination_port_range: 22-23
|
destination_port_range: 22-23
|
||||||
priority: 102
|
priority: 102
|
||||||
register: output
|
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
|
- name: Test idempotence
|
||||||
azure_rm_securitygroup:
|
azure_rm_securitygroup:
|
||||||
resource_group: "{{ resource_group }}"
|
resource_group: "{{ resource_group }}"
|
||||||
name: mysecgroup
|
name: mysecgroup
|
||||||
rules:
|
rules:
|
||||||
- name: DenySSH
|
- name: AllowSSH
|
||||||
protocol: Tcp
|
protocol: Tcp
|
||||||
destination_port_range: 22-23
|
source_address_prefix: 174.108.158.0/24
|
||||||
access: Deny
|
destination_port_range: 22
|
||||||
priority: 100
|
access: Allow
|
||||||
|
priority: 101
|
||||||
- name: AllowSSHFromHome
|
- name: AllowSSHFromHome
|
||||||
protocol: Tcp
|
protocol: Tcp
|
||||||
source_address_prefix: '174.109.158.0/24'
|
source_address_prefix: 174.109.158.0/24
|
||||||
destination_port_range: 22-23
|
destination_port_range: 22-23
|
||||||
priority: 102
|
priority: 102
|
||||||
register: output
|
register: output
|
||||||
|
|
Loading…
Add table
Reference in a new issue