ITOPSENG-164 Debug some changes to logic

This commit is contained in:
Glenn Stewart
2019-10-14 17:29:16 +11:00
parent fbb9316c26
commit 0a6501d781

View File

@@ -138,17 +138,11 @@
move_binary: false move_binary: false
atl_product_download: "{{ atl_product_temp_download }}" atl_product_download: "{{ atl_product_temp_download }}"
# Check for product installer in home_shared and lockdir to determine # Check for pre-downloaded binary on shared_home and completed lock dir.
# if it needs to be downloaded again. - name: Check for completed lock directory
- name: Check for moving lock directory
stat: stat:
path: "{{ atl_product_home_shared_moving_lock }}" path: "{{ atl_product_home_shared_completed_lock }}"
register: moving_lock register: completed_lock
- name: Check for downloaded lock directory
stat:
path: "{{ atl_product_home_shared_downloaded_lock }}"
register: downloaded_lock
- name: Check for product installer in home_shared - name: Check for product installer in home_shared
stat: stat:
@@ -162,9 +156,8 @@
atl_product_download: "{{ atl_product_home_shared_download }}" atl_product_download: "{{ atl_product_home_shared_download }}"
when: when:
- home_shared_download.stat.exists - home_shared_download.stat.exists
- downloaded_lock.stat.isdir is defined - completed_lock.stat.isdir is defined
- downloaded_lock.stat.isdir - completed_lock.stat.isdir
- ( moving_lock.stat.isdir is not defined or moving_lock.stat.isdir == False )
# If the binary was never installed, download it to temp location # If the binary was never installed, download it to temp location
- name: Installer not on home_shared. Fetch it. - name: Installer not on home_shared. Fetch it.
@@ -173,98 +166,121 @@
dest: "{{ atl_product_temp_download }}" dest: "{{ atl_product_temp_download }}"
mode: 0755 mode: 0755
force: false force: false
register: atl_product_downloaded register: atl_product_completed
when: download_binary when: download_binary
# If product installer was fetched to temp, install from there # If product installer was fetched
# If product installer was pre-downloaded on shared_home, install from there # Make the moving directory
# This is determined by {{ atl_product_download }} variable # - failure, continue and install from temp
- name: Unpack the downloaded application depending on format # - success, move binary and install from shared_home
include_tasks: "unpack_{{ atl_download_format }}.yml"
- name: Symlink the installed version to current - name: Create moving_lock.
file: file:
src: "{{ atl_product_installation_versioned }}" path: "{{ atl_product_home_shared_moving_lock }}"
dest: "{{ atl_product_installation_current }}" state: directory
state: link when: download_binary is succeeded
force: true register: moving_lock_created
# Temp product was downloaded and installed. - name: Debug Scenario A - lock created
# If the following conditions are true, move to home_shared debug: lock created
# 1. This node just downloaded binary. when: moving_lock_created is succeeded
# 2. Another node is not already moving into place.
# 3. The binary is downloaded and lockdir in place.
- name: "Check move product installer"
block:
- name: Check again for moving lock directory - name: Debug Scenario B - lock cannot created
stat: debug: lock not created
path: "{{ atl_product_home_shared_moving_lock }}" when: moving_lock_created is failed
register: moving_lock_2
# # If product installer was pre-downloaded on shared_home, install from there
# # This is determined by {{ atl_product_download }} variable
# - name: Unpack the downloaded application depending on format
# include_tasks: "unpack_{{ atl_download_format }}.yml"
# - name: Symlink the installed version to current
# file:
# src: "{{ atl_product_installation_versioned }}"
# dest: "{{ atl_product_installation_current }}"
# state: link
# force: true
# # Temp product was downloaded and installed.
# # If the following conditions are true, move to home_shared
# # 1. This node just downloaded binary.
# # 2. Another node is not already moving into place.
# # 3. The binary is downloaded and lockdir in place.
# - name: "Check move product installer"
# block:
# - name: Check again for moving lock directory
# stat:
# path: "{{ atl_product_home_shared_moving_lock }}"
# register: moving_lock_2
- name: Check again for downloaded lock directory # - name: Check again for completed lock directory
stat: # stat:
path: "{{ atl_product_home_shared_downloaded_lock }}" # path: "{{ atl_product_home_shared_completed_lock }}"
register: downloaded_lock_2 # register: completed_lock_2
- name: Check again for product installer in home_shared # - name: Check again for product installer in home_shared
stat: # stat:
path: "{{ atl_product_home_shared_download }}" # path: "{{ atl_product_home_shared_download }}"
register: home_shared_download_2 # register: home_shared_download_2
# If binary exists and lockdir exists use this binary instead # # If binary exists and lockdir exists use this binary instead
- name: Check lock directory and binary exists on shared_home # - name: Check lock directory and binary exists on shared_home
set_fact: # set_fact:
move_binary: true # move_binary: true
when: # when:
- ( home_shared_download.stat.exists == False or # - ( home_shared_download.stat.exists == False or
downloaded_lock.stat.isdir is not defined or downloaded_lock.stat.isdir == False ) # completed_lock.stat.isdir is not defined or completed_lock.stat.isdir == False )
- ( moving_lock.stat.isdir is not defined or moving_lock.stat.isdir == False ) # - ( moving_lock.stat.isdir is not defined or moving_lock.stat.isdir == False )
when: download_binary # when: download_binary
- name: "Move product installer if required" # - name: "Move product installer if required"
block: # block:
- name: Create moving_lock to ensure other nodes skip # - name: Create moving_lock to ensure other nodes skip
file: # file:
path: "{{ atl_product_home_shared_moving_lock }}" # path: "{{ atl_product_home_shared_moving_lock }}"
state: directory # state: directory
when: move_binary # when: move_binary
register: moving_lock_created # register: moving_lock_created
- name: Copy temp installer to home_shared # - name: Copy temp installer to home_shared
copy: # copy:
src: "{{ atl_product_temp_download }}" # src: "{{ atl_product_temp_download }}"
dest: "{{ atl_product_home_shared_download }}" # dest: "{{ atl_product_home_shared_download }}"
remote_src: true # remote_src: true
when: moving_lock_created is succeeded # when: moving_lock_created is succeeded
register: copied # register: copied
- name: Create downloaded_lock once product installer downloaded and copied # - name: Create completed_lock once product installer downloaded and copied
file: # file:
path: "{{ atl_product_home_shared_downloaded_lock }}" # path: "{{ atl_product_home_shared_completed_lock }}"
state: directory # state: directory
when: copied is succeeded # when: copied is succeeded
register: downloaded_lock_created # register: completed_lock_created
- name: Remove moving_lock to show that binary is completed # - name: Remove moving_lock to show that binary is completed
file: # file:
path: "{{ atl_product_home_shared_moving_lock }}" # path: "{{ atl_product_home_shared_moving_lock }}"
state: absent # state: absent
when: # when:
- downloaded_lock_created is succeeded # - completed_lock_created is succeeded
- copied is succeeded # - copied is succeeded
register: moving_lock_removed # register: moving_lock_removed
- name: Delete old temp installer # - name: Delete old temp installer
file: # file:
path: "{{ atl_product_temp_download }}" # path: "{{ atl_product_temp_download }}"
state: absent # state: absent
when: moving_lock_removed is succeeded # when: moving_lock_removed is succeeded
register: temp_deleted # register: temp_deleted
when: move_binary # when: move_binary