Ansible Unarchive Module Task failed

Hi @Inderpreet @rahul456,

The validation said the extracted file is incorrect or incomplete!!. How is that? the task asked to unarchive a file /usr/src/data/nautilus.zip on jump host to /opt/data/ directory on all application servers. The extracted data is one directory called unarchive and with in it contains a file called web.txt

Playbook run

Extracted file in /opt/data on stapp01

Extracted file in /opt/data on stapp02

Extracted file in /opt/data on stapp03

Playbook


Cheers,
Salim

Can someone please respond @Inderpreet @rahul456. Thanks.

@Salim, in your original answer you have used /tmp location instead of /opt for app1 and seems like you have updated the same after clicking on finish button so those changes are not considered.

Screenshot 2020-11-02 at 10.39.19 AM

Hi @rahul456 I have used /tmp to copy the zip file to the remote applications servers and extracted to /opt/data/ directory. The playbook is clearly showing that!..how is that wrong?

And I have not up updated anything after clicking the finish button, I have not done anything manually, all configs were run from the playbook. You can check the video of me doing this task, it is recorded right?

And why the validation says extracted data was incomplete?which data was expected?

@Salim, Since you used handlers, so when you tested it coped the file to the destination and extracted the same. But validation first cleans the archive from the location mentioned in the question and then runs your playbook. As you used a custom location i.e /tmp to keep the archive which was not actually mentioned in the question so validation didn’t clean the archive from that location hence when your playbook was re-ran the handlers were not triggered because handlers only triggers if task status is changed. So eventually the archive was not extracted to the destination location as needed.

Hi Please check to recurse option in the file, does all requirements met in the question ( manually go and check) ?

I did like this and it worked.

============================

  • hosts: all
    become: yes
    tasks:
    • name: unzip data
      unarchive:
      src: /usr/src/itadmin/nautilus.zip
      dest: /opt/itadmin/
    • name: change folder owner and perm
      file:
      path: /opt/itadmin/unarchive
      owner: “{{ item }}”
      group: “{{ item }}”
      recurse: yes
      mode: 0777
      with_items:
      • “{{ ansible_user }}”
        ======================================

Thanks
GauravK

Hello, @gaurav
Yeah, you can check manually but make sure you don’t create objects manually because after submitting the task validation script will rerun your playbook and validate the task.
You can manually check created items like this:

ssh tony@stapp01 "ls -l /opt/itadmin/"