fix3
This commit is contained in:
@@ -1,6 +0,0 @@
|
|||||||
temp_dir: "C:\\deploy\\vpress\\temp"
|
|
||||||
iis_site_name: "api-portal-2025"
|
|
||||||
blue_path: "C:\\deploy\\vpress\\portal\\be\\blue"
|
|
||||||
green_path: "C:\\deploy\\vpress\\portal\\be\\green"
|
|
||||||
|
|
||||||
aspnetcore_environtment: "Uat"
|
|
||||||
@@ -31,23 +31,47 @@
|
|||||||
fail_msg: "One or more required variables are missing or empty!"
|
fail_msg: "One or more required variables are missing or empty!"
|
||||||
|
|
||||||
- name: Check if IIS site exists
|
- name: Check if IIS site exists
|
||||||
win_iis_website:
|
|
||||||
name: "{{ iis_site_name }}"
|
|
||||||
register: site_check
|
|
||||||
ignore_errors: yes
|
|
||||||
|
|
||||||
- name: Debug site check
|
|
||||||
debug:
|
|
||||||
msg: "IIS Site {{ iis_site_name }} does not exist!"
|
|
||||||
when: site_check.failed
|
|
||||||
|
|
||||||
- name: Set ASPNETCORE_ENVIRONMENT for site
|
|
||||||
win_shell: |
|
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!"
|
||||||
|
|
||||||
|
- name: Get current ASPNETCORE_ENVIRONMENT
|
||||||
|
ansible.windows.win_shell: |
|
||||||
|
Import-Module WebAdministration
|
||||||
|
$envVars = Get-WebConfigurationProperty -pspath "MACHINE/WEBROOT/APPHOST/{{ iis_site_name }}" `
|
||||||
|
-filter "system.webServer/aspNetCore/environmentVariables" `
|
||||||
|
-name "."
|
||||||
|
$envVar = $envVars | Where-Object { $_.name -eq "ASPNETCORE_ENVIRONMENT" }
|
||||||
|
if ($envVar) { $envVar.value } else { "NOT_SET" }
|
||||||
|
register: current_env
|
||||||
|
changed_when: false # Tránh bị đánh dấu là "changed" nếu chỉ đọc dữ liệu
|
||||||
|
|
||||||
|
- name: Debug current environment
|
||||||
|
debug:
|
||||||
|
var: current_env.stdout
|
||||||
|
|
||||||
|
- name: Set ASPNETCORE_ENVIRONMENT for IIS site if different
|
||||||
|
ansible.windows.win_shell: |
|
||||||
Import-Module WebAdministration
|
Import-Module WebAdministration
|
||||||
Add-WebConfigurationProperty -pspath "MACHINE/WEBROOT/APPHOST/{{ iis_site_name }}" `
|
Add-WebConfigurationProperty -pspath "MACHINE/WEBROOT/APPHOST/{{ iis_site_name }}" `
|
||||||
-filter "system.webServer/aspNetCore/environmentVariables" `
|
-filter "system.webServer/aspNetCore/environmentVariables" `
|
||||||
-name "." `
|
-name "." `
|
||||||
-value @{name="ASPNETCORE_ENVIRONMENT"; value="{{ aspnetcore_environtment }}"}
|
-value @{name='ASPNETCORE_ENVIRONMENT'; value='{{ aspnetcore_environment }}'}
|
||||||
|
when: current_env.stdout != aspnetcore_environment
|
||||||
|
|
||||||
|
# - name: Set ASPNETCORE_ENVIRONMENT for site
|
||||||
|
# win_shell: |
|
||||||
|
# Import-Module WebAdministration
|
||||||
|
# Add-WebConfigurationProperty -pspath "MACHINE/WEBROOT/APPHOST/{{ iis_site_name }}" `
|
||||||
|
# -filter "system.webServer/aspNetCore/environmentVariables" `
|
||||||
|
# -name "." `
|
||||||
|
# -value @{name="ASPNETCORE_ENVIRONMENT"; value="{{ aspnetcore_environtment }}"}
|
||||||
|
|
||||||
|
|
||||||
#Lấy đường dẫn vật lý của iis site
|
#Lấy đường dẫn vật lý của iis site
|
||||||
|
|||||||
Reference in New Issue
Block a user