Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

unable to create a directory path using ansible unarchive module?

Tags:

ansible

I am trying to download and extract a tar archive in the remote machine and remote destination must be created if not exists. BUT it is not happening.

ERROR: destination directory doesn't exist

MYCODE:

- unarchive:
    src: http://apache.mirrors.ionfish.org/tomcat/tomcat-8/v8.5.15/bin/apache-tomcat-8.5.15.tar.gz
    dest: /opt/tomcat/
    creates: yes
    remote_src: True 

NOTE: * running the play as root.

thanks in advance

like image 762
hkonala Avatar asked Jun 23 '17 10:06

hkonala


People also ask

What is unarchive module in Ansible?

The unarchive module unpacks an archive. It will not unpack a compressed file that does not contain an archive. By default, it will copy the source file from the local system to the target before unpacking. Set remote_src=yes to unpack an archive which already exists on the target.

Which module is used to extract a compressed file in Ansible?

win_unzip module – Unzips compressed files and archives on the Windows node — Ansible Documentation.


1 Answers

While using the unarchive module, the dest path should be a path to an existing directory, and creates should be a path to a file and not a boolean.

- name: ensure tomcat directory exists
  file:
    path: /opt/tomcat
    state: directory

- unarchive: 
    src: http://apache.mirrors.ionfish.org/tomcat/tomcat-8/v8.5.15/bin/apache-tomcat-8.5.15.tar.gz
    dest: /opt/tomcat/  # already existing path
    creates: /opt/tomcat/config  # some path to make sure that the archive has already been unpacked
    remote_src: yes
like image 181
tux Avatar answered Sep 29 '22 01:09

tux