Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

azure_rm_securitygroup: allow string priority #23343

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 10 additions & 3 deletions lib/ansible/modules/cloud/azure/azure_rm_securitygroup.py
Expand Up @@ -336,6 +336,7 @@
}
''' # NOQA

from ansible.module_utils.six import string_types
from ansible.module_utils.basic import *
from ansible.module_utils.azure_rm_common import *

Expand Down Expand Up @@ -366,7 +367,13 @@ def validate_rule(rule, rule_type=None):
priority = rule.get('priority', None)
if not priority:
raise Exception("Rule priority is required.")
if not isinstance(priority, (int, long)):
if isinstance(priority, string_types):
try:
priority = int(priority)
rule['priority'] = priority
except ValueError:
raise Exception("Can't parse rule priority integer.")
elif not isinstance(priority, (int, long)):
raise Exception("Rule priority attribute must be an integer.")
if rule_type != 'default' and (priority < 100 or priority > 4096):
raise Exception("Rule priority must be between 100 and 4096")
Expand Down Expand Up @@ -416,10 +423,10 @@ def compare_rules(r, rule):
if rule['protocol'] != r['protocol']:
changed = True
r['protocol'] = rule['protocol']
if rule['source_port_range'] != r['source_port_range']:
if str(rule['source_port_range']) != r['source_port_range']:
changed = True
r['source_port_range'] = rule['source_port_range']
if rule['destination_port_range'] != r['destination_port_range']:
if str(rule['destination_port_range']) != r['destination_port_range']:
changed = True
r['destination_port_range'] = rule['destination_port_range']
if rule['access'] != r['access']:
Expand Down