Browse Source

Introduced setfile playbook

pull/1943/head
Greg Szabo 7 years ago
parent
commit
f9ae600a61
2 changed files with 34 additions and 0 deletions
  1. +25
    -0
      ansible/roles/setfile/tasks/main.yml
  2. +9
    -0
      ansible/setfile.yml

+ 25
- 0
ansible/roles/setfile/tasks/main.yml View File

@ -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}}'"

+ 9
- 0
ansible/setfile.yml View File

@ -0,0 +1,9 @@
---
#variable "source" is required
#variable "destination" is required
- hosts: "{{ lookup('env','TF_VAR_TESTNET_NAME') }}:tag_Environment_{{ lookup('env','TF_VAR_TESTNET_NAME') | regex_replace('-','_') }}"
roles:
- setfile

Loading…
Cancel
Save