From 77c19daefae49d8aa10a4a7dbfba6e8f22fe22b8 Mon Sep 17 00:00:00 2001 From: Mario Lenz Date: Tue, 11 Feb 2020 18:58:36 +0100 Subject: [PATCH] Fix creating IP specific firewall rules with Python 2 --- ...all_manager-fix_ip_specific_firewall_rules_for_python2.yml | 2 ++ .../modules/cloud/vmware/vmware_host_firewall_manager.py | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) create mode 100644 changelogs/fragments/67303-vmware_host_firewall_manager-fix_ip_specific_firewall_rules_for_python2.yml diff --git a/changelogs/fragments/67303-vmware_host_firewall_manager-fix_ip_specific_firewall_rules_for_python2.yml b/changelogs/fragments/67303-vmware_host_firewall_manager-fix_ip_specific_firewall_rules_for_python2.yml new file mode 100644 index 00000000000..7e69b87ba78 --- /dev/null +++ b/changelogs/fragments/67303-vmware_host_firewall_manager-fix_ip_specific_firewall_rules_for_python2.yml @@ -0,0 +1,2 @@ +bugfixes: +- vmware_host_firewall_manager - Fixed creating IP specific firewall rules with Python 2 (https://github.com/ansible/ansible/issues/67303) diff --git a/lib/ansible/modules/cloud/vmware/vmware_host_firewall_manager.py b/lib/ansible/modules/cloud/vmware/vmware_host_firewall_manager.py index e73fb709c5c..90182a9468a 100644 --- a/lib/ansible/modules/cloud/vmware/vmware_host_firewall_manager.py +++ b/lib/ansible/modules/cloud/vmware/vmware_host_firewall_manager.py @@ -173,7 +173,7 @@ except ImportError: from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.vmware import vmware_argument_spec, PyVmomi -from ansible.module_utils._text import to_native +from ansible.module_utils._text import to_native, to_text from ansible.module_utils.compat import ipaddress @@ -229,7 +229,7 @@ class VmwareFirewallManager(PyVmomi): ip_networks = allowed_hosts.get('ip_network', []) for ip_address in ip_addresses: try: - ipaddress.ip_address(ip_address) + ipaddress.ip_address(to_text(ip_address)) except ValueError: self.module.fail_json(msg="The provided IP address %s is not a valid IP" " for the rule %s" % (ip_address, rule_name))