blob: a43ec20959a9e06604bbd57535ac3c5751c6867b [file] [log] [blame]
# Copyright (c) 2023 VEXXHOST, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
- name: Starting download of file
ansible.builtin.debug:
msg: "{{ download_artifact_url }}"
- name: Ensure the work directory exists on the target host
ansible.builtin.file:
path: "{{ download_artifact_work_directory }}"
state: directory
mode: "0755"
- name: Create destination directory on node
ansible.builtin.file:
path: "{{ download_artifact_dest | dirname }}"
owner: "{{ download_artifact_owner | default(omit) }}"
mode: "0755"
state: directory
recurse: true
- name: Download item
ansible.builtin.get_url:
url: "{{ download_artifact_url }}"
dest: "{{ download_artifact_dest }}"
owner: "{{ download_artifact_owner | default(omit) }}"
mode: "{{ download_artifact_mode | default(omit) }}"
checksum: "{{ download_artifact_checksum | default(omit) }}"
validate_certs: "{{ download_artifact_validate_certs | default(omit) }}"
force_basic_auth: "{{ download_artifact_force_basic_auth | default(omit) }}"
url_username: "{{ download_artifact_url_username | default(omit) }}"
url_password: "{{ download_artifact_url_password | default(omit) }}"
register: _download_artifact_result
until: "'OK' in _download_artifact_result.msg or 'file already exists' in _download_artifact_result.msg"
retries: 4
# NOTE(fitbeard): This task will avoid logging it's parameters to not leak
# environment passwords in the log.
no_log: "{{ download_artifact_no_log | bool }}"
- name: Extract archive
when: download_artifact_unarchive
block:
- name: Ensure that 'tar' command is available
ansible.builtin.package:
name: tar
state: present
- name: Create new folder for unarchiving
ansible.builtin.file:
path: "{{ download_artifact_unarchive_dest }}"
state: directory
mode: "0755"
recurse: true
- name: Extract archive
ansible.builtin.unarchive:
src: "{{ download_artifact_dest }}"
dest: "{{ download_artifact_unarchive_dest }}"
owner: "{{ download_artifact_owner | default(omit) }}"
mode: "{{ download_artifact_mode | default(omit) }}"
remote_src: true
extra_opts: "{{ download_artifact_unarchive_extra_opts | default(omit) }}"