# unarchive, zip and idempotence

**URL:** <https://forum.ansible.com/t/unarchive-zip-and-idempotence/30440>\
**Category:** Ansible Project\
**Created:** [May 28, 2019, 4:00pm UTC](https://forum.ansible.com/t/unarchive-zip-and-idempotence/30440 "2019-05-28T16:00:42Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Wawrzek\_Niewodniczan](https://avatars.discourse-cdn.com/v4/letter/w/bbe5ce/32.png) [@Wawrzek\_Niewodniczan](https://forum.ansible.com/u/Wawrzek_Niewodniczan)\
**Post date:** [May 28, 2019, 4:00pm UTC](https://forum.ansible.com/t/unarchive-zip-and-idempotence/30440/1 "2019-05-28T16:00:42Z")

</div>

Hi,  
I have a zip files with 3 jars inside (no directory). When I use  
unarchive it always finds diff, even if files already exist.  
With simple diff i see:

.f....o..?? bcpkix-jdk15on-1.60.jar  
.f....o..?? bcprov-jdk15on-1.60.jar  
.f....o..?? doorman.jar

Is that known problem? If not I'll try to prepare a test case for bug report.

Wawrzek

---

<div class="post-metadata">

**Author:** ![Dick\_Visser](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@Dick\_Visser](https://forum.ansible.com/u/Dick_Visser)\
**Post date:** [May 28, 2019, 7:29pm UTC](https://forum.ansible.com/t/unarchive-zip-and-idempotence/30440/2 "2019-05-28T19:29:01Z")

</div>

What does your task:playbook exactly look like?

---

<div class="post-metadata">

**Author:** ![Wawrzek\_Niewodniczan](https://avatars.discourse-cdn.com/v4/letter/w/bbe5ce/32.png) [@Wawrzek\_Niewodniczan](https://forum.ansible.com/u/Wawrzek_Niewodniczan)\
**Post date:** [May 31, 2019, 11:04pm UTC](https://forum.ansible.com/t/unarchive-zip-and-idempotence/30440/3 "2019-05-31T23:04:35Z")

</div>

I've played around and the problem is with setting files ownerships. I  
created simple example (see below) and attached test.zip example. If  
we remove 2 last lines task will be idempotence.

Wawrzek

> **(attachments)**
>
> [test.zip](https://forum.ansible.com/uploads/short-url/g9bsLxNgvDpvtCXmN25vHuAQPRK.zip) (451 Bytes)

---

<div class="post-metadata">

**Author:** ![Kai\_Stian\_Olstad](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@Kai\_Stian\_Olstad](https://forum.ansible.com/u/Kai_Stian_Olstad)\
**Post date:** [June 1, 2019, 1:03pm UTC](https://forum.ansible.com/t/unarchive-zip-and-idempotence/30440/4 "2019-06-01T13:03:53Z")

</div>

I can confirm this behavior, but it's only the owner that causing problems.

So it's a bug in unarchive when using become and the owner parameter is different from root in Ansible 2.8.0 that I tested on.

---

<div class="post-metadata">

**Author:** ![Wawrzek\_Niewodniczan](https://avatars.discourse-cdn.com/v4/letter/w/bbe5ce/32.png) [@Wawrzek\_Niewodniczan](https://forum.ansible.com/u/Wawrzek_Niewodniczan)\
**Post date:** [June 1, 2019, 4:51pm UTC](https://forum.ansible.com/t/unarchive-zip-and-idempotence/30440/5 "2019-06-01T16:51:48Z")

</div>

> \>\>  
> \>\> What does your task:playbook exactly look like?  
> \>  
> \> I've played around and the problem is with setting files ownerships.

[...]

> I can confirm this behavior, but it's only the owner that causing problems.
> 
> So it's a bug in unarchive when using become and the owner parameter is different from root in Ansible 2.8.0 that I tested on.

Thanks Kai,

I'm going to raise a ticket on Github.

Wawrzek

---

<div class="post-metadata">

**Author:** ![Wawrzek\_Niewodniczan](https://avatars.discourse-cdn.com/v4/letter/w/bbe5ce/32.png) [@Wawrzek\_Niewodniczan](https://forum.ansible.com/u/Wawrzek_Niewodniczan)\
**Post date:** [June 4, 2019, 7:07am UTC](https://forum.ansible.com/t/unarchive-zip-and-idempotence/30440/6 "2019-06-04T07:07:17Z")

</div>

[...]

> \> I can confirm this behavior, but it's only the owner that causing problems.  
> \>  
> \> So it's a bug in unarchive when using become and the owner parameter is different from root in Ansible 2.8.0 that I tested on.  
> I'm going to raise a ticket on Github.

FYI the ticket is [https://github.com/ansible/ansible/issues/57303](https://github.com/ansible/ansible/issues/57303)

Wawrzek

---

<div class="post-metadata">

**Author:** ![Wawrzek\_Niewodniczan](https://avatars.discourse-cdn.com/v4/letter/w/bbe5ce/32.png) [@Wawrzek\_Niewodniczan](https://forum.ansible.com/u/Wawrzek_Niewodniczan)\
**Post date:** [June 4, 2019, 11:08am UTC](https://forum.ansible.com/t/unarchive-zip-and-idempotence/30440/7 "2019-06-04T11:08:04Z")

</div>

Thanks to Kai findings (shared in another thread) I can confirm that  
following change to Ansible 2.7.2 fixes the problem:

--- unarchive.py.bak 2019-06-04 11:41:24.000000000 +0100  
+++ unarchive.py 2019-06-04 11:46:27.000000000 +0100  
@@ -316,7 +316,7 @@  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;fut\_owner = fut\_uid = None  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if self.file\_args['owner']:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;try:  
- tpw = pwd.getpwname(self.file\_args['owner'])  
+ tpw = pwd.getpwnam(self.file\_args['owner'])  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;except:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;try:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;tpw = pwd.getpwuid(self.file\_args['owner'])

I'm going to updated the ticket.

Wawrzek

---

<div class="post-metadata">

**Author:** ![Wawrzek\_Niewodniczan](https://avatars.discourse-cdn.com/v4/letter/w/bbe5ce/32.png) [@Wawrzek\_Niewodniczan](https://forum.ansible.com/u/Wawrzek_Niewodniczan)\
**Post date:** [June 4, 2019, 11:09am UTC](https://forum.ansible.com/t/unarchive-zip-and-idempotence/30440/8 "2019-06-04T11:09:58Z")

</div>

Clarification - it's ansible 2.7.10

Wawrzek
