2017-10-19 16:17:11 +08:00
|
|
|
---
|
2017-10-25 18:45:54 +08:00
|
|
|
- name: file_download | Downloading...
|
|
|
|
debug:
|
|
|
|
msg:
|
|
|
|
- "URL: {{ download.url }}"
|
|
|
|
- "Dest: {{ download.dest }}"
|
|
|
|
|
2017-10-19 16:17:11 +08:00
|
|
|
- name: file_download | Create dest directory
|
|
|
|
file:
|
2019-05-03 05:24:21 +08:00
|
|
|
path: "{{ download.dest | dirname }}"
|
2017-10-19 16:17:11 +08:00
|
|
|
state: directory
|
|
|
|
recurse: yes
|
|
|
|
when:
|
|
|
|
- download.enabled
|
|
|
|
- download.file
|
2018-03-31 10:40:01 +08:00
|
|
|
- group_names | intersect(download.groups) | length
|
2017-10-19 16:17:11 +08:00
|
|
|
|
2019-05-01 16:10:56 +08:00
|
|
|
# As in 'download_container.yml':
|
|
|
|
# In Ansible 2.4 omitting download delegate is broken. Move back
|
|
|
|
# to one task in the future.
|
|
|
|
- name: file_download | Download item (delegate)
|
2017-10-19 16:17:11 +08:00
|
|
|
get_url:
|
2019-05-03 05:24:21 +08:00
|
|
|
url: "{{ download.url }}"
|
|
|
|
dest: "{{ download.dest }}"
|
|
|
|
sha256sum: "{{ download.sha256|default(omit) }}"
|
2017-10-19 16:17:11 +08:00
|
|
|
owner: "{{ download.owner|default(omit) }}"
|
|
|
|
mode: "{{ download.mode|default(omit) }}"
|
2018-09-21 17:51:17 +08:00
|
|
|
validate_certs: "{{ download_validate_certs }}"
|
2019-01-09 09:36:13 +08:00
|
|
|
url_username: "{{ download.username|default(omit) }}"
|
|
|
|
url_password: "{{ download.password|default(omit) }}"
|
|
|
|
force_basic_auth: "{{ download.force_basic_auth|default(omit) }}"
|
2017-10-19 16:17:11 +08:00
|
|
|
register: get_url_result
|
|
|
|
until: "'OK' in get_url_result.msg or 'file already exists' in get_url_result.msg"
|
|
|
|
retries: 4
|
2018-10-20 19:56:55 +08:00
|
|
|
delay: "{{ retry_stagger | default(5) }}"
|
2019-05-01 16:10:56 +08:00
|
|
|
delegate_to: "{{ download_delegate }}"
|
2017-10-19 16:17:11 +08:00
|
|
|
when:
|
2019-05-01 16:10:56 +08:00
|
|
|
- download_run_once
|
|
|
|
- download.enabled
|
|
|
|
- download.file
|
|
|
|
- group_names | intersect(download.groups) | length
|
|
|
|
run_once: yes
|
|
|
|
|
|
|
|
- name: file_download | Download item (all)
|
|
|
|
get_url:
|
2019-05-03 05:24:21 +08:00
|
|
|
url: "{{ download.url }}"
|
|
|
|
dest: "{{ download.dest }}"
|
|
|
|
sha256sum: "{{ download.sha256|default(omit) }}"
|
2019-05-01 16:10:56 +08:00
|
|
|
owner: "{{ download.owner|default(omit) }}"
|
|
|
|
mode: "{{ download.mode|default(omit) }}"
|
|
|
|
validate_certs: "{{ download_validate_certs }}"
|
|
|
|
url_username: "{{ download.username|default(omit) }}"
|
|
|
|
url_password: "{{ download.password|default(omit) }}"
|
|
|
|
force_basic_auth: "{{ download.force_basic_auth|default(omit) }}"
|
|
|
|
register: get_url_result
|
|
|
|
until: "'OK' in get_url_result.msg or 'file already exists' in get_url_result.msg"
|
|
|
|
retries: 4
|
|
|
|
delay: "{{ retry_stagger | default(5) }}"
|
|
|
|
when:
|
|
|
|
- not download_run_once
|
2017-10-19 16:17:11 +08:00
|
|
|
- download.enabled
|
|
|
|
- download.file
|
2018-03-31 10:40:01 +08:00
|
|
|
- group_names | intersect(download.groups) | length
|
2017-10-19 16:17:11 +08:00
|
|
|
|
|
|
|
- name: file_download | Extract archives
|
|
|
|
unarchive:
|
2019-05-03 05:24:21 +08:00
|
|
|
src: "{{ download.dest }}"
|
|
|
|
dest: "{{ download.dest |dirname }}"
|
2017-10-19 16:17:11 +08:00
|
|
|
owner: "{{ download.owner|default(omit) }}"
|
|
|
|
mode: "{{ download.mode|default(omit) }}"
|
|
|
|
copy: no
|
|
|
|
when:
|
|
|
|
- download.enabled
|
|
|
|
- download.file
|
|
|
|
- download.unarchive|default(False)
|
2018-03-31 10:40:01 +08:00
|
|
|
- group_names | intersect(download.groups) | length
|