Files
dc-deployments-automation/roles/product_download/tasks/main.yml

87 lines
2.6 KiB
YAML

---
- name: Check for existing version cache file
stat:
path: "{{ atl_product_version_cache }}"
register: cached
# Case: File exists, always use its value
- name: Use version for product version
block:
- name: Read cached version from file
command: "cat {{ atl_product_version_cache }}"
register: atl_product_version_file
changed_when: false
- name: Set the local var to cached version
set_fact:
atl_product_version: "{{ atl_product_version_file.stdout }}"
when: cached.stat.exists
# Case: File doesn't exist and no version has been set; find latest.
- name: Fetch and cache latest version when no override
block:
- name: Fetch the latest version from URL
set_fact:
atl_product_version_json: "{{ lookup('url', '{{ atl_product_latest_version_url }}') }}"
- name: Set the local var to retrieved version
set_fact:
atl_product_version: "{{ atl_product_version_json.version }}"
when:
not cached.stat.exists and
(atl_product_version is undefined or
not atl_product_version or
atl_product_version == "latest")
# At this point atl_product_version should be set, cache if necessary.
- name: Write override cached version when specified
template:
src: version.j2
dest: "{{ atl_product_version_cache }}"
force: false
# Note: We don't cache this in the shared drive to the complexity
# around download race-conditions if multiple nodes are starting at
# the same time. When downloading from product-downloads.atlassian.com
# (which is a CDN) takes seconds anyway.
- name: Fetch product installer
get_url:
url: "{{ atl_product_download_url }}"
dest: "{{ atl_product_download }}"
mode: 0644
force: false
- name: Create target version directory
file:
path: "{{ atl_product_installation_base }}/{{ atl_product_version }}"
state: directory
owner: "{{ atl_product_user }}"
- name: Unpack the product packages
unarchive:
remote_src: true
src: "{{ atl_product_download }}"
dest: "{{ atl_product_installation_base }}/{{ atl_product_version }}"
creates: "{{ atl_product_installation_base }}/{{ atl_product_version }}/bin/catalina.sh"
owner: "{{ atl_product_user }}"
group: "{{ atl_product_user }}"
mode: 0755
# Strip off the lead product/version specific directory to normaise naming
extra_opts:
- "--strip-components=1"
- name: Symlink the installed version to current
file:
src: "{{ atl_product_installation_base }}/{{ atl_product_version }}"
dest: "{{ atl_product_installation_target }}"
state: link
force: true