Repository: ansible/ansible

Issue:
Archive is unable to create zip archives over 4GB
<!---
Verify first that your issue/request is not already reported on GitHub.
Also test if the latest release, and master branch are affected too.
-->

##### ISSUE TYPE
<!--- Pick one below and delete the rest: -->
 - Bug Report
 
##### COMPONENT NAME
<!--- Name of the module/plugin/task/feature -->
archive module

##### ANSIBLE VERSION
<!--- Paste verbatim output from “ansible --version” between quotes below -->
```
ansible 2.3.0.0
  config file = /home/user/projectpath/ansible.cfg
  configured module search path - Default w/o overrides
  python version - 2.7.5 (default, Oct 11 2015, 17:47:16) [GCC 4.8.3 20140911 (Red Hat 4.8.3-9)]

```

##### CONFIGURATION
<!---
Mention any settings you have changed/added/removed in ansible.cfg
(or using the ANSIBLE_* environment variables).
-->

##### OS / ENVIRONMENT
<!---
Mention the OS you are running Ansible from, and the OS you are
managing, or say “N/A” for anything that is not platform-specific.
-->
N/A

##### SUMMARY
<!--- Explain the problem briefly -->
When trying to create a zip archive with a files over 4GB in size the task fails stating
the following:

Filesize would require ZIP64 extensions

##### STEPS TO REPRODUCE
<!---
For bugs, show exactly how to reproduce the problem, using a minimal test-case.
For new features, show how the feature would be used.
-->
Create a file over 4GB

$ truncate 5GB test.file

<!--- Paste example playbooks or commands between quotes below -->
```yaml
- name: Archive test
  hosts: localhost

  tasks:
    - archive:
         path: test.file
         dest: test.file.zip
         format: zip
```

<!--- You can also paste gist.github.com links for larger files -->

##### EXPECTED RESULTS
<!--- What did you expect to happen when running the steps above? -->
A zip archive named test.file.zip is created containing the file test.file

##### ACTUAL RESULTS
<!--- What actually happened? If possible run with extra verbosity (-vvvv) -->

<!--- Paste verbatim command output between quotes below -->
```
fatal: [hostname]: Failed! => {"changed": false, "failed": true, "msg": "Error when writing zip at test.file.zip: Filesize would require ZIP64 extensions"}
```



Discussion:
cc @bendoh
[click here for bot help](https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md)
<!--- boilerplate: notify --->

Resolving patch:
diff --git a/lib/ansible/modules/files/archive.py b/lib/ansible/modules/files/archive.py
--- a/lib/ansible/modules/files/archive.py
+++ b/lib/ansible/modules/files/archive.py
@@ -246,7 +246,7 @@ def main():
                 try:
                     # Slightly more difficult (and less efficient!) compression using zipfile module
                     if format == 'zip':
-                        arcfile = zipfile.ZipFile(dest, 'w', zipfile.ZIP_DEFLATED)
+                        arcfile = zipfile.ZipFile(dest, 'w', zipfile.ZIP_DEFLATED, True)
 
                     # Easier compression using tarfile module
                     elif format == 'gz' or format == 'bz2':
@@ -358,7 +358,7 @@ def main():
 
                 try:
                     if format == 'zip':
-                        arcfile = zipfile.ZipFile(dest, 'w', zipfile.ZIP_DEFLATED)
+                        arcfile = zipfile.ZipFile(dest, 'w', zipfile.ZIP_DEFLATED, True)
                         arcfile.write(path, path[len(arcroot):])
                         arcfile.close()
                         state = 'archive' # because all zip files are archives


Test patch: