mirror of
https://bitbucket.org/atlassian/dc-deployments-automation.git
synced 2025-12-13 16:33:08 -06:00
Merge branch 'master' into feature/ITOPSENG-101-support-JiraProduct-All
This commit is contained in:
@@ -116,6 +116,7 @@
|
||||
- "{{ atl_product_home }}"
|
||||
- "{{ atl_product_installation_versioned }}"
|
||||
- "{{ atl_product_version_cache_dir }}"
|
||||
- "{{ atl_product_home_shared_download_dir }}"
|
||||
changed_when: false # For Molecule idempotence check
|
||||
|
||||
# At this point atl_product_version should be set, cache if necessary.
|
||||
@@ -125,18 +126,120 @@
|
||||
dest: "{{ atl_product_version_cache }}"
|
||||
force: true
|
||||
|
||||
# For the first run a temp binary should be downloaded but moved to
|
||||
# shared home to ensure all subsequent nodes have access
|
||||
# to the same specific version binary.
|
||||
# To prevent a race condition with multiple downloads at the same time
|
||||
# a directory is used as a lockfile (atomic operation) when moving binary.
|
||||
|
||||
# Note: We don't the cache binary 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: 0755
|
||||
force: false
|
||||
- name: Set assumptions to avoid race condition
|
||||
set_fact:
|
||||
download_binary: true
|
||||
move_binary: false
|
||||
atl_product_download: "{{ atl_product_temp_download }}"
|
||||
|
||||
# Check for pre-downloaded binary on shared_home and completed lock dir.
|
||||
- name: Check for completed lock directory
|
||||
stat:
|
||||
path: "{{ atl_product_home_shared_completed_lock }}"
|
||||
register: completed_lock
|
||||
|
||||
- name: Check for product installer in home_shared
|
||||
stat:
|
||||
path: "{{ atl_product_home_shared_download }}"
|
||||
register: home_shared_download
|
||||
|
||||
# If binary exists and lockdir exists use this binary instead
|
||||
- name: Check lock directory and binary exists on shared_home
|
||||
set_fact:
|
||||
download_binary: false
|
||||
atl_product_download: "{{ atl_product_home_shared_download }}"
|
||||
when:
|
||||
- home_shared_download.stat.exists
|
||||
- completed_lock.stat.isdir is defined
|
||||
- completed_lock.stat.isdir
|
||||
|
||||
# Fetch binary if required
|
||||
- name: download_binary is true so fetch and do all the things
|
||||
block:
|
||||
|
||||
# Fetch binary and copy to temp
|
||||
- name: Fetch binary
|
||||
get_url:
|
||||
url: "{{ atl_product_download_url }}"
|
||||
dest: "{{ atl_product_temp_download }}"
|
||||
mode: 0755
|
||||
force: false
|
||||
register: atl_product_completed
|
||||
|
||||
# If product installer was fetched make the lock directory
|
||||
- name: Create moving_lock.
|
||||
file:
|
||||
path: "{{ atl_product_home_shared_moving_lock }}"
|
||||
state: directory
|
||||
when:
|
||||
- atl_product_completed is succeeded
|
||||
register: moving_lock_created
|
||||
|
||||
# Directory lock was created by this run?
|
||||
# If so, then set a fact intending to move binary
|
||||
- name: Move binary Scenario - lock created by this run
|
||||
set_fact:
|
||||
move_binary: true
|
||||
when:
|
||||
- moving_lock_created is succeeded
|
||||
- moving_lock_created.changed
|
||||
# Otherwise directory lock was either already created or
|
||||
# could not be created. Fall back is to continue and install from temp
|
||||
|
||||
when: download_binary
|
||||
|
||||
# If the intention is to move binary to home_shared
|
||||
- name: Move product installer to home_shared
|
||||
block:
|
||||
|
||||
- name: Copy temp installer to home_shared
|
||||
copy:
|
||||
src: "{{ atl_product_temp_download }}"
|
||||
dest: "{{ atl_product_home_shared_download }}"
|
||||
remote_src: true
|
||||
when:
|
||||
- moving_lock_created is succeeded
|
||||
- moving_lock_created.changed
|
||||
register: copied
|
||||
|
||||
- name: Create completed_lock once product installer downloaded and copied
|
||||
file:
|
||||
path: "{{ atl_product_home_shared_completed_lock }}"
|
||||
state: directory
|
||||
when: copied is succeeded
|
||||
register: completed_lock_created
|
||||
|
||||
- name: Remove moving_lock to show that binary is completed
|
||||
file:
|
||||
path: "{{ atl_product_home_shared_moving_lock }}"
|
||||
state: absent
|
||||
when:
|
||||
- completed_lock_created is succeeded
|
||||
- copied is succeeded
|
||||
register: moving_lock_removed
|
||||
|
||||
- name: Delete old temp installer
|
||||
file:
|
||||
path: "{{ atl_product_temp_download }}"
|
||||
state: absent
|
||||
when: moving_lock_removed is succeeded
|
||||
register: temp_deleted
|
||||
|
||||
- name: Set install to home_shared location
|
||||
set_fact:
|
||||
atl_product_download: "{{ atl_product_home_shared_download }}"
|
||||
when: temp_deleted is succeeded
|
||||
|
||||
when: move_binary
|
||||
|
||||
# At this point the binary is in {{ atl_product_download }}
|
||||
# (which is either on home_shared or temp)
|
||||
- name: Unpack the downloaded application depending on format
|
||||
include_tasks: "unpack_{{ atl_download_format }}.yml"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user