Add check for string type dport

the dport option could be a port number using a string instead of a array or int.
This change ensures our loop is able to properly handle dport options written as
list, string, or int.

Change-Id: I13dbdb2043ad216d1c89801c974508dd9b958cdc
Signed-off-by: Kevin Carter <kevin@cloudnull.com>
This commit is contained in:
Kevin Carter 2019-08-23 14:49:23 -05:00
parent 8ca1ca46a9
commit 2e7ec8ad2b
3 changed files with 6 additions and 6 deletions

View File

@ -22,11 +22,11 @@
tripleo_firewall_rules:
'003 accept ftp from all':
proto: 'tcp'
dport: 21
dport: "21"
'003 accept custom from all':
proto: 'udp'
dport:
- 2121
- "2121"
- 2122
- 2123
- 2200-2210

View File

@ -22,13 +22,13 @@
tripleo_firewall_rules:
'003 accept ftp from all':
proto: 'tcp'
dport: 21
dport: "21"
extras:
ensure: 'absent'
'003 accept custom from all':
proto: 'udp'
dport:
- 2121
- "2121"
- 2122
- 2123
- 2200-2210

View File

@ -60,7 +60,7 @@
when:
- (item['rule']['proto'] | default('tcp')) != 'ipv6'
- item['rule']['source'] | default('127.0.0.1') | ipv4
loop: "{{ (item['rule']['dport'] is iterable) | ternary(item['rule']['dport'], [item['rule']['dport']]) }}"
loop: "{{ ((item['rule']['dport'] is iterable) and (item['rule']['dport'] is not string)) | ternary(item['rule']['dport'], [item['rule']['dport']]) }}"
loop_control:
loop_var: port
notify:
@ -83,7 +83,7 @@
when:
- (item['rule']['proto'] | default('tcp')) != 'ipv4'
- item['rule']['source'] | default('::') | ipv6
loop: "{{ (item['rule']['dport'] is iterable) | ternary(item['rule']['dport'], [item['rule']['dport']]) }}"
loop: "{{ ((item['rule']['dport'] is iterable) and (item['rule']['dport'] is not string)) | ternary(item['rule']['dport'], [item['rule']['dport']]) }}"
loop_control:
loop_var: port
notify: