Cannot unzip the file located on remote centos machine using Ansible
Asked Answered
S

2

9
- name: Unzip the Elasticsearch file
  unarchive: src=/root/elasticsearch-1.4.0.tar.gz dest=/tmp/


TASK [Unzip the Elasticsearch file]     
*******************************************
fatal: [54.173.94.235]: FAILED! => {"failed": true, "msg": "ERROR! file or module does not exist: /root/elasticsearch-1.4.0.tar.gz"}

Is it consider the local file? ...I am running file on my local machine to unzip file on the remote machine. How can I solve this problem?

Sansone answered 30/12, 2015 at 20:43 Comment(2)
You would need to post related part of the playbook to get useful answer.Economically
@marbu: posted playbookSansone
S
30

By default, Ansible copies the file (src) from control machine to the remote machine and unarchives it. If you do not want Ansible to copy the file, set copy=no in your task.

The value of copy is yes by default, so Ansible will try to look for src file in the local machine if you do not set copy=no

unarchive: src=/root/elasticsearch-1.4.0.tar.gz dest=/tmp/ copy=no

Ansible - Unarchive

Copy

If true, the file is copied from local 'master' to the target machine, otherwise, the plugin will look for src archive at the target machine.

Stephaniestephannie answered 30/12, 2015 at 21:19 Comment(7)
I want to unzip the folder on the remote machine using ansible script. i am running my script on my local machine and apply those changes to the remote centos machine. Copy will not work in those case. What would be the alternative ?Sansone
Where is the archive file? on the local machine or on remote machine?Stephaniestephannie
It is on the remote machine and want to unzip it on the remote machine in a 'tmp' folderSansone
Then the archive file does not exist on the remote machine: ERROR! file or module does not exist: /root/elasticsearch-1.4.0.tar.gzStephaniestephannie
It is...It is already there on the remote machine. When I write 'src' it will look for the file on the local machine, that I don't wanna do. How can I let ansible know that file is already there and you just need to unzip it on the remote machine itself ?Sansone
set copy=no unarchive: src=/root/elasticsearch-1.4.0.tar.gz dest=/tmp/ copy=noStephaniestephannie
Note that as of right now the docs say that copy is deprecated and that you should use remote_src instead. This is a lie that's only true if you're running ansible from master. remote_src is not yet released, so if you're baffled why it's not working, it's because it doesn't exist yet.Burrussburry
S
0

add option "remote_src: yes" to unarchive module declaration

you can find it over here ""http://docs.ansible.com/ansible/latest/unarchive_module.html

Stocktonontees answered 19/12, 2017 at 8:3 Comment(1)
This is a better answer. copy has been deprecated.Larose

© 2022 - 2024 — McMap. All rights reserved.