Skip to content

Ansible: unpack a file on the remote host

Trying to unpack a file on the remote host using Ansible might end in an error message:

fatal: [192.168.0.188]: FAILED! => {"failed": true, "msg": "ERROR! file or module does not exist: /tmp/test.zip"}

I'm using Ansible 2.0.0.2 here, and have previously copied "test.zip" to the host (yes, I know, the unarchive module can do the copy as well). Now I'm trying to unpack it:

- name: unzip test.zip archive
  unarchive: src=/tmp/test.zip dest=/tmp/test-tmp-install remote_src=yes

This fails, even though I specify "remote_src" and tell Ansible that the file is already on the remote host.

 

The solution is easy, and braindead: there is another unarchive parameter named "copy". The default setting is "yes".

The documentation says that it is deprecated, and mutually exclusive to "remote_src". But still, not setting "copy=no" will result in Ansible looking for the file on your Ansible host, and failing miserable if it's not there. However, if the file is available on your Ansible host (think roles and the files directories), it will happily copy the file, and therefore overwrite your destination file with whatever is found on your Ansible host.

The correct Playbook statement is:

- name: unzip test archive
  unarchive: src=/tmp/test.zip dest=/tmp/test-tmp-install remote_src=yes copy=no

 

Update: see the updated posting for Ansible >= 2.2

  • Twitter
  • Bookmark Ansible: unpack a file on the remote host at del.icio.us
  • Facebook
  • Google Bookmarks
  • FriendFeed
  • Digg Ansible: unpack a file on the remote host
  • Bloglines Ansible: unpack a file on the remote host
  • Technorati Ansible: unpack a file on the remote host
  • Fark this: Ansible: unpack a file on the remote host
  • Bookmark Ansible: unpack a file on the remote host at YahooMyWeb
  • Bookmark Ansible: unpack a file on the remote host at Furl.net
  • Bookmark Ansible: unpack a file on the remote host at reddit.com
  • Bookmark Ansible: unpack a file on the remote host at blinklist.com
  • Bookmark Ansible: unpack a file on the remote host at Spurl.net
  • Bookmark Ansible: unpack a file on the remote host at Simpy.com
  • Bookmark Ansible: unpack a file on the remote host at blogmarks
  • Bookmark Ansible: unpack a file on the remote host with wists
  • wong it!
  • Bookmark using any bookmark manager!
  • Stumble It!
  • Identi.ca

Trackbacks

ads' corner on : Ansible: unpack a file on the remote host - Ansible version 2.2

Show preview
A while ago I posted about a nasty problem in the Ansible "unarchive" module: in version 2.0.x, if you do not specify "copy=no", Ansible will happily copy the file again from the Ansible host. Turns out, that problem was fixed in version 2.2, but now t Comments ()

Comments

Display comments as Linear | Threaded

No comments

Add Comment

Enclosing asterisks marks text as bold (*word*), underscore are made via _word_.
E-Mail addresses will not be displayed and will only be used for E-Mail notifications.
To leave a comment you must approve it via e-mail, which will be sent to your address after submission.
Form options