Skip to content
This repository has been archived by the owner on Oct 30, 2018. It is now read-only.

get_url fails on rhel5 hosts using ansible 2.0.2.0 #3608

Closed
MichaelBaydoun opened this issue May 6, 2016 · 5 comments · Fixed by ansible/ansible#15851
Closed

get_url fails on rhel5 hosts using ansible 2.0.2.0 #3608

MichaelBaydoun opened this issue May 6, 2016 · 5 comments · Fixed by ansible/ansible#15851
Assignees
Milestone

Comments

@MichaelBaydoun
Copy link
Contributor

MichaelBaydoun commented May 6, 2016

ISSUE TYPE
  • Bug Report
COMPONENT NAME

get_url

ANSIBLE VERSION
ansible 2.0.2.0
  config file = /home/icansible/.ansible.cfg
  configured module search path = Default w/o overrides
CONFIGURATION

[defaults]
callback_whitelist = profile_tasks,timer
forks = 50
host_key_checking = false
inventory = ~/ansible/hosts-dev
pattern = NONE
retry_files_enabled = false
transport = ssh

OS / ENVIRONMENT

control host rhel6
target hosts rhel5

SUMMARY

get_url fails with error on rhel5 targets when using 2.0.2.0, but works on rhel6 targets.
revert back to 2.0.1.0 and the get_url module works on both rhel5 and rhel6 targets

STEPS TO REPRODUCE

---
- hosts: someRhel5Server:someRhel6Server
  tasks:

    - name: demo the error
      get_url:
        url: "https://github.com/ansible/ansible/blob/devel/README.md"
        dest: /tmp/
        validate_certs: no
EXPECTED RESULTS

expected file to be downloaded to both target hosts

ACTUAL RESULTS

on the rhel5 target

fatal: [rhel5server]: FAILED! => {"changed": false, "dest": "/tmp/", "failed": true, "gid": 0, "group": "root", "mode": "01777", "msg": "Request failed", "owner": "root", "response": "An unknown error occurred: addinfourl instance has no attribute 'getcode'", "secontext": "system_u:object_r:tmp_t:s0", "size": 69632, "state": "directory", "status_code": -1, "uid": 0, "url": "https://github.com/ansible/ansible/blob/devel/README.md"}

on the rhel6 target

changed: [rhel6server]

Note: -vvvv and ANSIBLE_DEBUG=y produced no additional useful information

@MichaelBaydoun
Copy link
Contributor Author

MichaelBaydoun commented May 6, 2016

bisect on the main repository says this is the first bad commit.

7158eb489f1817adc01177f9d6d67417883e080b is the first bad commit
commit 7158eb489f1817adc01177f9d6d67417883e080b
Author: Matt Martz <matt@sivel.net>
Date:   Fri Feb 19 12:59:58 2016 -0600

    Add python info to facts

:040000 040000 16828d2099affa1b8afe79eda1667270e754dacf 8369b7e9a1ea0354c0fb890bf4d7edec93b5697c M    lib

tagging @sivel

@MichaelBaydoun
Copy link
Contributor Author

Going back one more commit in the main repo and the problem is not present. The subrepo reference for both the breaking and working commit is the same

➜  ansible-project git:(7766a9a) git ls-tree devel:lib/ansible/modules          
100644 blob ae8ccff5952585ebf8134e2f7d09dbfb63772976    __init__.py
160000 commit 9be870bb2a5f277ac7ba68e87243b74dcc0ab1ac  core
160000 commit 2e09202aae9e8f7934e4b05a8305f7c1352a61e6  extras

@MichaelBaydoun
Copy link
Contributor Author

I don't understand how changing facts could introduce this error ... but it appears to have done just that

➜  ansible-project git:(7158eb4) git diff HEAD^ HEAD
diff --git a/lib/ansible/module_utils/facts.py b/lib/ansible/module_utils/facts.py
index fd5729c..53c4133 100644
--- a/lib/ansible/module_utils/facts.py
+++ b/lib/ansible/module_utils/facts.py
@@ -166,6 +166,7 @@ class Facts(object):
             self.get_local_facts()
             self.get_env_facts()
             self.get_dns_facts()
+            self.get_python_facts()

     def populate(self):
         return self.facts
@@ -782,6 +783,21 @@ class Facts(object):
             pass
         return size_total, size_available

+    def get_python_facts(self):
+        self.facts['python'] = {
+            'version': {
+                'major': sys.version_info[0],
+                'minor': sys.version_info[1],
+                'micro': sys.version_info[2],
+                'releaselevel': sys.version_info[3],
+                'serial': sys.version_info[4]
+            },
+            'version_info': list(sys.version_info),
+            'executable': sys.executable,
+            'type': sys.subversion[0]
+        }
+
+
 class Hardware(Facts):
     """
     This is a generic Hardware subclass of Facts.  This should be further

@MichaelBaydoun MichaelBaydoun changed the title git_url fails on rhel5 hosts using ansible 2.0.2.0 get_url fails on rhel5 hosts using ansible 2.0.2.0 May 6, 2016
@alikins alikins added this to the stable-2.0 milestone May 9, 2016
@alikins alikins added the P2 label May 9, 2016
@alikins
Copy link
Contributor

alikins commented May 9, 2016

I suspect it's ed35e8b that causes it

commit ed35e8bce21180529e72f5bbe1d853b67ddac870
Author: James Cammarata <jimi@sngx.net>
Date:   Mon Apr 18 13:02:57 2016 -0400

    Don't override the http status code when successful in urls.py

diff --git lib/ansible/module_utils/urls.py lib/ansible/module_utils/urls.py
index 5526921..0c00fe8 100644
--- lib/ansible/module_utils/urls.py
+++ lib/ansible/module_utils/urls.py
@@ -887,8 +887,7 @@ def fetch_url
                      url_password=password, http_agent=http_agent, force_basic_auth=force_basic_auth,
                      follow_redirects=follow_redirects)
         info.update(r.info())
-        info['url'] = r.geturl()  # The URL goes in too, because of redirects.
-        info.update(dict(msg="OK (%s bytes)" % r.headers.get('Content-Length', 'unknown'), status=200))
+        info.update(dict(msg="OK (%s bytes)" % r.headers.get('Content-Length', 'unknown'), url=r.geturl(), status=r.getcode()))
     except NoSSLError, e:
         distribution = get_distribution()
         if distribution is not None and distribution.lower() == 'redhat':

The docs at https://docs.python.org/2/library/urllib.html#urllib.urlopen

Changed in version 2.6: Added getcode() to returned object and support for the no_proxy environment variable.

RHEL5 is python2.4, so it does not have getcode().

paging @jimi-c, @sivel

@sivel
Copy link
Member

sivel commented May 9, 2016

@alikins it looks like we may have access to r.code back as far as 2.4.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants