đổi tên site iis nên phải sửa cho nó ăn theo
This commit is contained in:
@@ -0,0 +1,69 @@
|
||||
#Debug
|
||||
- name: Debug iis_site_name
|
||||
debug:
|
||||
var: iis_site_name
|
||||
|
||||
- name: Debug iis_app_pool
|
||||
debug:
|
||||
var: iis_app_pool
|
||||
|
||||
- name: Debug aspnetcore_environtment
|
||||
debug:
|
||||
var: aspnetcore_environtment
|
||||
|
||||
- name: Debug blue_path
|
||||
debug:
|
||||
var: blue_path
|
||||
|
||||
# Kiểm tra các thông số Nexus
|
||||
- name: Debug Nexus URL
|
||||
debug:
|
||||
var: nexus_url
|
||||
|
||||
- name: Debug artifact name
|
||||
debug:
|
||||
var: artifact_name
|
||||
|
||||
- name: Set environment variable for IIS App Pool
|
||||
hosts: windows_servers
|
||||
tasks:
|
||||
- name: Thiết lập ASPNETCORE_ENVIRONMENT cho App Pool
|
||||
win_shell: |
|
||||
$appPoolName = "{{ iis_app_pool }}"
|
||||
$envVarName = "ASPNETCORE_ENVIRONMENT"
|
||||
$envVarValue = "{{ aspnetcore_environtment }}"
|
||||
$appPool = Get-Item "IIS:\AppPools\$appPoolName"
|
||||
$appPool.EnvironmentVariables[$envVarName] = $envVarValue
|
||||
$appPool | Set-Item
|
||||
args:
|
||||
executable: powershell.exe
|
||||
|
||||
#Lấy đường dẫn vật lý của iis 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
|
||||
register: active_path
|
||||
- debug:
|
||||
var: active_path
|
||||
|
||||
- name: Handle error if active_path is null
|
||||
fail:
|
||||
msg: "The IIS site active path could not be determined."
|
||||
when: active_path.stdout is not defined or active_path.stdout == ''
|
||||
|
||||
|
||||
# Chuẩn hóa giá trị của active_path
|
||||
- name: Normalize active_path
|
||||
set_fact:
|
||||
active_path: "{{ active_path.stdout | trim }}"
|
||||
- debug:
|
||||
var: active_path
|
||||
|
||||
# Chọn môi trường Blue hoặc Green để deploy
|
||||
- name: Set target deployment environment
|
||||
set_fact:
|
||||
target_path: "{{ green_path if active_path == blue_path else blue_path }}" #lấy ra đường dẫn thư mục cần deploy
|
||||
- debug:
|
||||
var: target_path
|
||||
Reference in New Issue
Block a user