Repository: openshift/openshift-ansible

Issue:
python3 error in repoquery.py
#### Description
When installing on Fedora 25 with ansible_python_interpreter=/usr/bin/python3, the openshift_version task fails:

TASK [openshift_version : Get available origin version] ***********************************************************************************************************************************************************
fatal: [127.0.0.1]: FAILED! => {"changed": false, "failed": true, "module_stderr": "Shared connection to 127.0.0.1 closed.\r\n", "module_stdout": "Traceback (most recent call last):\r\n  File \"/tmp/ansible_ppoomizr/ansible_module_repoquery.py\", line 635, in <module>\r\n    main()\r\n  File \"/tmp/ansible_ppoomizr/ansible_module_repoquery.py\", line 626, in main\r\n    rval = Repoquery.run_ansible(module.params, module.check_mode)\r\n  File \"/tmp/ansible_ppoomizr/ansible_module_repoquery.py\", line 586, in run_ansible\r\n    results = repoquery.repoquery()\r\n  File \"/tmp/ansible_ppoomizr/ansible_module_repoquery.py\", line 549, in repoquery\r\n    processed_versions = Repoquery.process_versions(rval['results'].strip())\r\n  File \"/tmp/ansible_ppoomizr/ansible_module_repoquery.py\", line 468, in process_versions\r\n    for version in query_output.split('\\n'):\r\nTypeError: a bytes-like object is required, not 'str'\r\n", "msg": "MODULE FAILURE", "rc": 0}

##### Version

```
$ ansible --version
gansible 2.3.0.0
  config file = /home/vagrant/openshift-ansible/ansible.cfg
  configured module search path = Default w/o overrides
  python version = 2.7.13 (default, Jan 12 2017, 17:59:37) [GCC 6.3.1 20161221 (Red Hat 6.3.1-1)]

$ git describe
openshift-ansible-3.6.67-1-43-gd1d60e2
```

##### Steps To Reproduce
1. ansible-playbook -v openshift-ansible/playbooks/byo/config.yml

##### Expected Results
The origin version check to succeed.


Discussion:

Resolving patch:
diff --git a/roles/lib_utils/library/repoquery.py b/roles/lib_utils/library/repoquery.py
--- a/roles/lib_utils/library/repoquery.py
+++ b/roles/lib_utils/library/repoquery.py
@@ -465,7 +465,7 @@ def process_versions(query_output):
 
         version_dict = defaultdict(dict)
 
-        for version in query_output.split('\n'):
+        for version in query_output.decode().split('\n'):
             pkg_info = version.split("|")
 
             pkg_version = {}
diff --git a/roles/lib_utils/src/class/repoquery.py b/roles/lib_utils/src/class/repoquery.py
--- a/roles/lib_utils/src/class/repoquery.py
+++ b/roles/lib_utils/src/class/repoquery.py
@@ -48,7 +48,7 @@ def process_versions(query_output):
 
         version_dict = defaultdict(dict)
 
-        for version in query_output.split('\n'):
+        for version in query_output.decode().split('\n'):
             pkg_info = version.split("|")
 
             pkg_version = {}


Test patch:
diff --git a/roles/lib_utils/src/test/unit/test_repoquery.py b/roles/lib_utils/src/test/unit/test_repoquery.py
--- a/roles/lib_utils/src/test/unit/test_repoquery.py
+++ b/roles/lib_utils/src/test/unit/test_repoquery.py
@@ -45,7 +45,7 @@ def test_querying_a_package(self, mock_cmd):
 
         # Return values of our mocked function call. These get returned once per call.
         mock_cmd.side_effect = [
-            (0, '4.2.46|21.el7_3|x86_64|rhel-7-server-rpms|4.2.46-21.el7_3', valid_stderr),  # first call to the mock
+            (0, b'4.2.46|21.el7_3|x86_64|rhel-7-server-rpms|4.2.46-21.el7_3', valid_stderr),  # first call to the mock
         ]
 
         # Act