From e7dd93c5c196001bb8f5e5b8e2387911b158cb5e Mon Sep 17 00:00:00 2001 From: David Shrewsbury Date: Thu, 18 Jun 2015 19:22:56 -0400 Subject: [PATCH] Compare ports as strings Ports as returned from shade are ints. They are strings as they come in to the module. --- .../cloud/openstack/os_security_group_rule.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/ansible/modules/cloud/openstack/os_security_group_rule.py b/lib/ansible/modules/cloud/openstack/os_security_group_rule.py index d96a9394450..ecee67332f5 100644 --- a/lib/ansible/modules/cloud/openstack/os_security_group_rule.py +++ b/lib/ansible/modules/cloud/openstack/os_security_group_rule.py @@ -105,8 +105,16 @@ def _find_matching_rule(module, secgroup): for rule in secgroup['security_group_rules']: # No port, or -1, will be returned from shade as None - rule_port_range_min = rule['port_range_min'] or -1 - rule_port_range_max = rule['port_range_max'] or -1 + if rule['port_range_min'] is None: + rule_port_range_min = "-1" + else: + rule_port_range_min = str(rule['port_range_min']) + + if rule['port_range_max'] is None: + rule_port_range_max = "-1" + else: + rule_port_range_max = str(rule['port_range_max']) + if (protocol == rule['protocol'] and port_range_min == rule_port_range_min