# ansible unarchive module idempotency

**URL:** <https://forum.ansible.com/t/ansible-unarchive-module-idempotency/34039>\
**Category:** Ansible Project\
**Created:** [October 15, 2020, 3:54pm UTC](https://forum.ansible.com/t/ansible-unarchive-module-idempotency/34039 "2020-10-15T15:54:14Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Michael3](https://avatars.discourse-cdn.com/v4/letter/m/ecccb3/32.png) [@Michael3](https://forum.ansible.com/u/Michael3)\
**Post date:** [October 15, 2020, 3:54pm UTC](https://forum.ansible.com/t/ansible-unarchive-module-idempotency/34039/1 "2020-10-15T15:54:14Z")

</div>

I have a Jenkins pipeline that automates an install using Ansible. One of the steps includes copying a tar file to the target host using the unarchive module. This step finishes with a ‘changed’ status if rerun and so isn’t idempotent as would be preferred. Is there a way to perform a check on the target and not redo this step? Any suggestions would be appreciated

code snippet:

- name: unarchive gg installer to target gg server  
unarchive:  
src: “{{ pkg\_src }}/{{ ogg\_installer }}”  
dest: “{{ ogg\_product\_dir }}”  
become: yes  
become\_method: sudo  
become\_user: ogg

Thanks.

---

<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:** [October 15, 2020, 4:25pm UTC](https://forum.ansible.com/t/ansible-unarchive-module-idempotency/34039/2 "2020-10-15T16:25:45Z")

</div>

The unarchive module is idempotent.  
So if your task reports as changed, then this means you are either  
unpacking a different archive each time, or your unpacked tree has  
changed somehow.

Try adding a stat task right before the unarchive task and watch the  
checksum to verify.

---

<div class="post-metadata">

**Author:** ![Michael3](https://avatars.discourse-cdn.com/v4/letter/m/ecccb3/32.png) [@Michael3](https://forum.ansible.com/u/Michael3)\
**Post date:** [October 15, 2020, 6:38pm UTC](https://forum.ansible.com/t/ansible-unarchive-module-idempotency/34039/3 "2020-10-15T18:38:08Z")

</div>

adding the option “exclude: target\_directory” appears to solve the issue. It recognizes the target already exists and doesn’t make any changes. Thanks for your input Dick
