Errors/issues faced with get_url, unarchive module of ansible

Errors/issues faced with get_url, unarchive module of ansible

Last Updated on February 18, 2023 by cscontents


Ansible is a very powerful automation tool. It is written in Python language. It has plenty of modules which we can use to automate many task like software installation, configuration etc. You can go through below article for complete high level information about ansible.

Introduction to Ansible | High Level Understanding of Ansible

If you want to learn Ansible basics then please check out the below course from KodeKloud which offers one of the best learning material in DevOps world.

Link of Training Course: Ansible for absolute beginners

Note: The above links are affiliate links, if you enroll this course using the above link, then it would help us to get some monetary benefit from KodeKloud. It won’t cost you anything.

In this article we will share some issue/error which we faced while using Ansible for automation.

Error/Issue faced with get_url module of ansible and its solution

Using get_url module, it tries to download the file at first in /tmp directory. Here by default, it chooses the /tmp directory.

Error Message:

“msg”: “failed to create temporary content file: [Errno 28] No space left on device”

Ansible Version:

For ansible version 2.5 & greater this error is noticed.

For example, you mentioned a directory in the playbook where you have enough space to download the file, but it won’t download it if you don’t have enough space in /tmp directory (by default).

Let say, your file size is 4 GB, and you have 2 GB left in /tmp directory, in that case below ansible task will throw error.

- name: Download file
    url: download_url
    url_username: user
    url_password: password
    dest: /disk1/test-dir/


If we see the official documentation of Ansible, it is mentioned we need to mention another parameter which is tmp_dest if we want to change the default directory which is /tmp.

Link of documentation:

Below is one such example where we have used tmp_dest parameter to avoid the above issue.

- name: Download file
    url: download_url
    url_username: user
    url_password: password
    tmp_dest: /disk1/test-dir
    dest: /disk1/test-dir/

In the above task, we kept tmp_dest & dest same directory. You can mention any other directory where you have enough space.

Error/Issue faced with unarchive module of ansible and its solution

The issue we faced with unarchive module is below –

We had a 4 GB zip file, and we wanted to unzip it using unarchive module of Ansible, but it was not able to unzip it.

Error message:

Command \”/usr/bin/unzip\” could not handle archive


This issue might not be with Ansible, we tried to manually unzip it using unzip command, but it was throwing “zip bomb” error.

Finally, we were able to unzip it using the below command.

jar -xf

To use jar, we need to install Java on the target/remote machine where ansible will execute the task. If above command throws an error like “jar not found”, then you need to provide the full path of jar from JAVA_HOME/bin directory. Below is the command.

/opt/jdk- -xf

Where, JAVA_HOME=/opt/jdk-

Accordingly, we adopted it in Ansible. For this we used “shell” module of ansible. Below is the ansible task.

- name: unzip
    chdir: /disk1/test-dir
    cmd: /opt/jdk- -xf


Thank You


If you are interested in learning DevOps, please have a look at the below articles, which will help you greatly.