mirror of
https://bitbucket.org/atlassian/dc-deployments-automation.git
synced 2025-12-14 00:43:06 -06:00
DCD-224: Refactor downloads to be more explicit about the version cache file.
This commit is contained in:
@@ -9,3 +9,4 @@ rules:
|
||||
level: error
|
||||
line-length: disable
|
||||
truthy: disable
|
||||
trailing-spaces: false
|
||||
|
||||
@@ -5,6 +5,6 @@ atl_product_version_cache: "{{ atl_product_home_shared }}/{{ atl_product_edition
|
||||
|
||||
atl_release_base_url: "https://product-downloads.atlassian.com/software"
|
||||
atl_product_base_url: "{{ atl_release_base_url }}/{{ atl_product_family }}/downloads"
|
||||
atl_product_download_url: "{{ atl_product_base_url }}/atlassian-{{ atl_product_edition }}-{{ atl_product_version_file.stdout }}.tar.gz"
|
||||
atl_product_download_filename: "{{ atl_product_edition }}.{{ atl_product_version_file.stdout }}.tar.gz"
|
||||
atl_product_download_url: "{{ atl_product_base_url }}/atlassian-{{ atl_product_edition }}-{{ atl_product_version }}.tar.gz"
|
||||
atl_product_download_filename: "{{ atl_product_edition }}.{{ atl_product_version }}.tar.gz"
|
||||
atl_product_download: "{{ atl_installer_temp }}/{{ atl_product_download_filename }}"
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
atl_product_family: "jira"
|
||||
atl_product_edition: "jira-core"
|
||||
atl_product_user: "jira"
|
||||
# NOTE: This should be ignored because the version file exists.
|
||||
atl_product_version: "latest"
|
||||
|
||||
pre_tasks:
|
||||
- name: Create cache dir
|
||||
|
||||
@@ -1,25 +1,52 @@
|
||||
---
|
||||
|
||||
- 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 fetched version
|
||||
|
||||
- name: Set the local var to retrieved version
|
||||
set_fact:
|
||||
atl_product_version: "{{ atl_product_version_json.version }}"
|
||||
when: atl_product_version is undefined or atl_product_version == "latest"
|
||||
|
||||
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
|
||||
|
||||
- name: Use version for product version
|
||||
command: "cat {{ atl_product_version_cache }}"
|
||||
register: atl_product_version_file
|
||||
changed_when: false
|
||||
|
||||
# Note: We don't cache this in the shared drive to the complexity
|
||||
# around download race-conditions if multiple nodes are starting at
|
||||
@@ -34,7 +61,7 @@
|
||||
|
||||
- name: Create target version directory
|
||||
file:
|
||||
path: "{{ atl_product_installation_base }}/{{ atl_product_version_file.stdout }}"
|
||||
path: "{{ atl_product_installation_base }}/{{ atl_product_version }}"
|
||||
state: directory
|
||||
owner: "{{ atl_product_user }}"
|
||||
|
||||
@@ -42,8 +69,8 @@
|
||||
unarchive:
|
||||
remote_src: true
|
||||
src: "{{ atl_product_download }}"
|
||||
dest: "{{ atl_product_installation_base }}/{{ atl_product_version_file.stdout }}"
|
||||
creates: "{{ atl_product_installation_base }}/{{ atl_product_version_file.stdout }}/bin/catalina.sh"
|
||||
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
|
||||
@@ -53,7 +80,7 @@
|
||||
|
||||
- name: Symlink the installed version to current
|
||||
file:
|
||||
src: "{{ atl_product_installation_base }}/{{ atl_product_version_file.stdout }}"
|
||||
src: "{{ atl_product_installation_base }}/{{ atl_product_version }}"
|
||||
dest: "{{ atl_product_installation_target }}"
|
||||
state: link
|
||||
force: true
|
||||
|
||||
Reference in New Issue
Block a user