{"action":"created","issue":{"url":"https://api.github.com/repos/ansible/ansible-modules-core/issues/3560","repository_url":"https://api.github.com/repos/ansible/ansible-modules-core","labels_url":"https://api.github.com/repos/ansible/ansible-modules-core/issues/3560/labels{/name}","comments_url":"https://api.github.com/repos/ansible/ansible-modules-core/issues/3560/comments","events_url":"https://api.github.com/repos/ansible/ansible-modules-core/issues/3560/events","html_url":"https://github.com/ansible/ansible-modules-core/issues/3560","id":151393056,"number":3560,"title":"Failure to Handle ZipFile Issues with Older Versions of Python","user":{"login":"selble","id":13648768,"avatar_url":"https://avatars.githubusercontent.com/u/13648768?v=3","gravatar_id":"","url":"https://api.github.com/users/selble","html_url":"https://github.com/selble","followers_url":"https://api.github.com/users/selble/followers","following_url":"https://api.github.com/users/selble/following{/other_user}","gists_url":"https://api.github.com/users/selble/gists{/gist_id}","starred_url":"https://api.github.com/users/selble/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/selble/subscriptions","organizations_url":"https://api.github.com/users/selble/orgs","repos_url":"https://api.github.com/users/selble/repos","events_url":"https://api.github.com/users/selble/events{/privacy}","received_events_url":"https://api.github.com/users/selble/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/ansible/ansible-modules-core/labels/bug_report","name":"bug_report","color":"fbca04"}],"state":"open","locked":false,"assignee":{"login":"abadger","id":209242,"avatar_url":"https://avatars.githubusercontent.com/u/209242?v=3","gravatar_id":"","url":"https://api.github.com/users/abadger","html_url":"https://github.com/abadger","followers_url":"https://api.github.com/users/abadger/followers","following_url":"https://api.github.com/users/abadger/following{/other_user}","gists_url":"https://api.github.com/users/abadger/gists{/gist_id}","starred_url":"https://api.github.com/users/abadger/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/abadger/subscriptions","organizations_url":"https://api.github.com/users/abadger/orgs","repos_url":"https://api.github.com/users/abadger/repos","events_url":"https://api.github.com/users/abadger/events{/privacy}","received_events_url":"https://api.github.com/users/abadger/received_events","type":"User","site_admin":false},"milestone":null,"comments":2,"created_at":"2016-04-27T13:59:25Z","updated_at":"2016-04-29T03:50:50Z","closed_at":null,"body":"\r\n##### ISSUE TYPE\r\n - Bug Report\r\n\r\n##### COMPONENT NAME\r\nunarchive\r\n\r\n##### ANSIBLE VERSION\r\n```\r\nansible 2.0.1.0\r\n  config file = /opt/ansible/sysadmin/ansible.cfg\r\n  configured module search path = /usr/share/ansible/\r\n```\r\n\r\n##### CONFIGURATION\r\n\r\nNothing noteworthy.\r\n\r\n##### OS / ENVIRONMENT\r\n\r\nAnsible is running from a CentOS 7 machine\r\nAffected clients are running RHEL 5\r\n\r\n##### SUMMARY\r\nWe are building code on a RHEL 6 system, using a relatively contemporary version of zip and unzip utilities. After building, the resulting artifacts exists as a zip file which we use Ansible to deploy.\r\n\r\nWhen deploying to RHEL 5 systems, we first ran into an issue where the shipped version of unzip choked on the file. We built a RHEL 5 package for unzip 6.0 (taken from a RHEL 6 source RPM), and then ran into an issue where Python 2.4 (as shipped with RHEL 5) was also failing to validate the ZipFile, as when called from the files_in_archive function:\r\n\r\n```\r\n    def files_in_archive(self, force_refresh=False):\r\n        if self._files_in_archive and not force_refresh:\r\n            return self._files_in_archive\r\n\r\n        archive = ZipFile(self.src)\r\n        try:\r\n            self._files_in_archive = archive.namelist()\r\n        except:\r\n            raise UnarchiveError('Unable to list files in the archive')\r\n\r\n        return self._files_in_archive\r\n```\r\n\r\nThis causes our code deployment to fail.\r\n\r\n##### STEPS TO REPRODUCE\r\n\r\n1. Create a zip file on a host running a modern version of zip\r\n2. Use the unarchive module to deploy the file to an older system (that has a newer version of unzip).\r\n3. Wait for failure\r\n\r\n```\r\n  - name: Unpack app on host\r\n    unarchive: src={{ destinationDirectory }}/{{ project }}-{{ version }}.zip \r\n                 dest={{ destinationDirectory }}\r\n                 copy=no\r\n```\r\n\r\n##### EXPECTED RESULTS\r\nThe file explodes properly\r\n\r\n##### ACTUAL RESULTS\r\nThe explode fails\r\n\r\n```\r\nTASK [Unpack app on host] ******************************************************\r\nfatal: [nw-hweb-d10]: FAILED! => {\"changed\": false, \"failed\": true, \"module_stderr\": \"\", \"module_stdout\": \"Traceback (most recent call last):\\r\\n  File \\\"/apps/home/exampleuser/.ansible/tmp/ansible-tmp-1461759972.63-110735257718247/unarchive\\\", line 3108, in ?\\r\\n    main()\\r\\n  File \\\"/apps/home/exampleuser/.ansible/tmp/ansible-tmp-1461759972.63-110735257718247/unarchive\\\", line 336, in main\\r\\n    for filename in handler.files_in_archive:\\r\\n  File \\\"/apps/home/engadmin/.ansible/tmp/ansible-tmp-1461759972.63-110735257718247/unarchive\\\", line 120, in files_in_archive\\r\\n    archive = ZipFile(self.src)\\r\\n  File \\\"/usr/lib64/python2.4/zipfile.py\\\", line 210, in __init__\\r\\n    self._GetContents()\\r\\n  File \\\"/usr/lib64/python2.4/zipfile.py\\\", line 230, in _GetContents\\r\\n    self._RealGetContents()\\r\\n  File \\\"/usr/lib64/python2.4/zipfile.py\\\", line 262, in _RealGetContents\\r\\n    raise BadZipfile, \\\"Bad magic number for central directory\\\"\\r\\nzipfile.BadZipfile: Bad magic number for central directory\\r\\n\", \"msg\": \"MODULE FAILURE\", \"parsed\": false}\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/ansible/ansible-modules-core/issues/comments/215620416","html_url":"https://github.com/ansible/ansible-modules-core/issues/3560#issuecomment-215620416","issue_url":"https://api.github.com/repos/ansible/ansible-modules-core/issues/3560","id":215620416,"user":{"login":"abadger","id":209242,"avatar_url":"https://avatars.githubusercontent.com/u/209242?v=3","gravatar_id":"","url":"https://api.github.com/users/abadger","html_url":"https://github.com/abadger","followers_url":"https://api.github.com/users/abadger/followers","following_url":"https://api.github.com/users/abadger/following{/other_user}","gists_url":"https://api.github.com/users/abadger/gists{/gist_id}","starred_url":"https://api.github.com/users/abadger/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/abadger/subscriptions","organizations_url":"https://api.github.com/users/abadger/orgs","repos_url":"https://api.github.com/users/abadger/repos","events_url":"https://api.github.com/users/abadger/events{/privacy}","received_events_url":"https://api.github.com/users/abadger/received_events","type":"User","site_admin":false},"created_at":"2016-04-29T03:50:50Z","updated_at":"2016-04-29T03:50:50Z","body":"@selble I thought the tar.gz problem might be the same as https://github.com/ansible/ansible/issues/14283  Which I've been unable to reproduce.  I wasn't able to reproduce it using the tar.gz from there to a rhel5 box, though so I'm not sure if the tar.gz problem is the same or different.  If you can get me a tar.gz with maybe just that filename in it I could try and reproduce with yours.\r\n\r\nThe zip problem might be separate.. I'll try and reproduce that tomorrow."}}