fix10
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
# Tải artifact từ Nexus
|
||||
# Tải artifact từ Nexus Repository
|
||||
- name: Download artifact from Nexus
|
||||
win_get_url:
|
||||
url: "{{ nexus_url }}/{{ artifact_name }}"
|
||||
@@ -18,9 +18,11 @@
|
||||
debug:
|
||||
var: download_status
|
||||
|
||||
- name: Check if the download was successful
|
||||
debug:
|
||||
msg: "Download successful: {{ download_status.msg }}"
|
||||
# Lỗi khi tải artifact từ nexus thất bại
|
||||
- name: Fail if download artifact from Nexus Repository fail
|
||||
fail:
|
||||
msg: "Download artifact from nexus fail"
|
||||
when: download_status.status_code != 200
|
||||
|
||||
# Kiểm tra ở trên server đã tồn tại file vùa tải xuống không
|
||||
- name: Check if the artifact file exists
|
||||
@@ -35,7 +37,6 @@
|
||||
debug:
|
||||
var: file_status
|
||||
|
||||
|
||||
# Giải nén artifact vào thư mục target
|
||||
- name: Deploy to target environment
|
||||
win_unzip:
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
debug:
|
||||
var: artifact_name
|
||||
|
||||
# Validate các biến var truyền vào
|
||||
- name: Validate required variables
|
||||
assert:
|
||||
that:
|
||||
@@ -30,32 +31,26 @@
|
||||
- artifact_name is defined and artifact_name | length > 0
|
||||
fail_msg: "One or more required variables are missing or empty!"
|
||||
|
||||
- name: Check if IIS site exists
|
||||
win_shell: |
|
||||
Import-Module WebAdministration
|
||||
if (Get-Website -Name "{{ iis_site_name }}") { "exists" } else { "not exists" }
|
||||
register: site_check
|
||||
failed_when: "'not exists' in site_check.stdout"
|
||||
|
||||
- name: Debug site existence
|
||||
debug:
|
||||
msg: "IIS site {{ iis_site_name }} exists!"
|
||||
|
||||
#Lấy đường dẫn vật lý của iis site
|
||||
#Lấy đường dẫn vật lý của iis site/kiểm tra sự tồn tại của site
|
||||
- name: Get the physical path of the current IIS site
|
||||
win_shell: |
|
||||
Import-Module WebAdministration
|
||||
$site = Get-Website -Name "{{ iis_site_name}}"
|
||||
$site.PhysicalPath
|
||||
if ($site) {
|
||||
Write-Output $site.PhysicalPath
|
||||
} else {
|
||||
Write-Output "NOT_FOUND"
|
||||
}
|
||||
register: active_path
|
||||
- debug:
|
||||
var: active_path
|
||||
|
||||
- name: Handle error if active_path is null
|
||||
- name: Debug output
|
||||
debug:
|
||||
msg: "Site path: {{ active_path.stdout }}"
|
||||
|
||||
- name: Fail if site does not exist
|
||||
fail:
|
||||
msg: "The IIS site active path could not be determined."
|
||||
when: active_path.stdout is not defined or active_path.stdout == ''
|
||||
|
||||
msg: "IIS site {{ iis_site_name }} not found!"
|
||||
when: active_path.stdout == "NOT_FOUND"
|
||||
|
||||
# Chuẩn hóa giá trị của active_path
|
||||
- name: Normalize active_path
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
# Cập nhật PhysicalPath mới cho site IIS (green/blue)
|
||||
- name: Update site IIS web application
|
||||
win_iis_website:
|
||||
name: "{{ iis_site_name }}"
|
||||
physical_path: "{{ target_path }}"
|
||||
|
||||
# Set ASPNETCORE_ENVIRONMENT cho site IIS
|
||||
- name: Set ASPNETCORE_ENVIRONMENT for IIS site
|
||||
win_shell: |
|
||||
Import-Module WebAdministration
|
||||
|
||||
Reference in New Issue
Block a user