|
|
@ -0,0 +1,25 @@ |
|
|
|
--- |
|
|
|
|
|
|
|
- name: Download file if necessary |
|
|
|
when: source | regex_search('^https?://') |
|
|
|
get_url: "url={{source}} dest={{localdir}}/{{source | basename | regex_replace('\\?.*$','')}}" |
|
|
|
register: downloaded |
|
|
|
connection: local |
|
|
|
run_once: yes |
|
|
|
|
|
|
|
- name: Figure out file source |
|
|
|
set_fact: |
|
|
|
compiledsource: "{{ (downloaded.skipped is defined) | ternary(source, downloaded.dest) }}" |
|
|
|
connection: local |
|
|
|
|
|
|
|
- name: Extract file to destination |
|
|
|
when: compiledsource | regex_search('\\.(zip|tar|tar\\.gz|tgz|tb2|tbz|tbz2|tar\\.bz2|txz|tar\\.xz)$') |
|
|
|
register: extractcopy |
|
|
|
unarchive: |
|
|
|
src: "{{compiledsource}}" |
|
|
|
dest: "{{destination}}" |
|
|
|
|
|
|
|
- name: Copy non-zipped file to destination |
|
|
|
when: extractcopy.skipped is defined |
|
|
|
copy: "src='{{compiledsource}}' dest='{{destination}}'" |
|
|
|
|