# unarchive a file is failing

**URL:** <https://forum.ansible.com/t/unarchive-a-file-is-failing/29010>\
**Category:** Ansible Project\
**Created:** [November 12, 2018, 5:39pm UTC](https://forum.ansible.com/t/unarchive-a-file-is-failing/29010 "2018-11-12T17:39:08Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![anushakeshipeddy4](https://avatars.discourse-cdn.com/v4/letter/a/b782af/32.png) [@anushakeshipeddy4](https://forum.ansible.com/u/anushakeshipeddy4)\
**Post date:** [November 12, 2018, 5:39pm UTC](https://forum.ansible.com/t/unarchive-a-file-is-failing/29010/1 "2018-11-12T17:39:08Z")

</div>

Hi Team,

I am trying to unarchive a file is failing with below errors. Could someone please look into it.

**Playbook:**

---

<div class="post-metadata">

**Author:** ![Foss\_Geek](https://avatars.discourse-cdn.com/v4/letter/f/df705f/32.png) [@Foss\_Geek](https://forum.ansible.com/u/Foss_Geek)\
**Post date:** [November 13, 2018, 6:26am UTC](https://forum.ansible.com/t/unarchive-a-file-is-failing/29010/2 "2018-11-13T06:26:19Z")

</div>

You have to quote the dictionary key as well.

FROM

- { src\_tar: ‘/home/virtual/xx/sample.tar.gz’, dest\_tar: ‘/tmp/sss/’ }

TO

- { ‘src\_tar’: ‘/home/virtual/xx/sample.tar.gz’, ‘dest\_tar’: ‘/tmp/sss/’ }

Here is the working example. If you write a role and call that role from playbook then you no need to use var\_files section. vars/main.yml is one of the default ansible search path.

See how my tasks/main.yml :

# cat roles/xyz/tasks/main.yml

---

<div class="post-metadata">

**Author:** ![anushakeshipeddy4](https://avatars.discourse-cdn.com/v4/letter/a/b782af/32.png) [@anushakeshipeddy4](https://forum.ansible.com/u/anushakeshipeddy4)\
**Post date:** [November 13, 2018, 7:16am UTC](https://forum.ansible.com/t/unarchive-a-file-is-failing/29010/3 "2018-11-13T07:16:40Z")

</div>

Thank you Mohan that worked for me, but may I know why we need to place them in double quotes??

---

<div class="post-metadata">

**Author:** ![anushakeshipeddy4](https://avatars.discourse-cdn.com/v4/letter/a/b782af/32.png) [@anushakeshipeddy4](https://forum.ansible.com/u/anushakeshipeddy4)\
**Post date:** [November 13, 2018, 7:23am UTC](https://forum.ansible.com/t/unarchive-a-file-is-failing/29010/4 "2018-11-13T07:23:39Z")

</div>

It is unpacking a tar file successfully but at the same time I am getting below error. Could you please help.

{“msg”: “The task includes an option with an undefined variable. The error was: ‘dict object’ has no attribute ‘dest\_tar’\n\nThe error appears to have been in ‘/etc/ansible/xxx/xy/tasks/main.yml’: line 26, column 5, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n - name: test\n ^ here\n”}

---

<div class="post-metadata">

**Author:** ![Foss\_Geek](https://avatars.discourse-cdn.com/v4/letter/f/df705f/32.png) [@Foss\_Geek](https://forum.ansible.com/u/Foss_Geek)\
**Post date:** [November 13, 2018, 8:34am UTC](https://forum.ansible.com/t/unarchive-a-file-is-failing/29010/5 "2018-11-13T08:34:44Z")

</div>

Ansible think src\_tar as variable If you don’t place quotes so through error saying undefined variable.

---

<div class="post-metadata">

**Author:** ![Foss\_Geek](https://avatars.discourse-cdn.com/v4/letter/f/df705f/32.png) [@Foss\_Geek](https://forum.ansible.com/u/Foss_Geek)\
**Post date:** [November 13, 2018, 8:36am UTC](https://forum.ansible.com/t/unarchive-a-file-is-failing/29010/6 "2018-11-13T08:36:40Z")

</div>

It looks like again you are not placing quotes around dictionary key. Can you please show your code which through this error?

---

<div class="post-metadata">

**Author:** ![anushakeshipeddy4](https://avatars.discourse-cdn.com/v4/letter/a/b782af/32.png) [@anushakeshipeddy4](https://forum.ansible.com/u/anushakeshipeddy4)\
**Post date:** [November 13, 2018, 8:44am UTC](https://forum.ansible.com/t/unarchive-a-file-is-failing/29010/7 "2018-11-13T08:44:24Z")

</div>

Please find the files below.

**vars/main.yml**

XYZ:

- { src: ‘/tmp/abc/ab.warr’, dest: ‘/tmp/abc/’ }

TAR:

- { “src\_tar”: “/tmp/xx/sample.tar.gz”, “dest\_tar”: “/tmp/sss/” }

**tasks/main.yml**

---

<div class="post-metadata">

**Author:** ![Foss\_Geek](https://avatars.discourse-cdn.com/v4/letter/f/df705f/32.png) [@Foss\_Geek](https://forum.ansible.com/u/Foss_Geek)\
**Post date:** [November 13, 2018, 8:58am UTC](https://forum.ansible.com/t/unarchive-a-file-is-failing/29010/8 "2018-11-13T08:58:54Z")

</div>

I am not clear about what you are trying to achieve here. are you using XYZ in with\_items? Please note you have to quote src and dest in XYZ other Ansible will src/dest are variables.

---

<div class="post-metadata">

**Author:** ![Foss\_Geek](https://avatars.discourse-cdn.com/v4/letter/f/df705f/32.png) [@Foss\_Geek](https://forum.ansible.com/u/Foss_Geek)\
**Post date:** [November 13, 2018, 9:00am UTC](https://forum.ansible.com/t/unarchive-a-file-is-failing/29010/9 "2018-11-13T09:00:39Z")

</div>

I am not clear about what you are trying to achieve here. are you using XYZ in with\_items? Please note you have to quote src and dest in XYZ otherwise Ansible will treat src/dest are variables.
