hkonala
hkonala

Reputation: 359

unable to create a directory path using ansible unarchive module?

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

Upvotes: 22

Views: 34172

Answers (1)

tux
tux

Reputation: 1820

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

Upvotes: 27

Related Questions