44 Commits

Author SHA1 Message Date
thienqb123456 9d15ed743a fix11 2025-03-04 10:37:14 +07:00
thienqb123456 f94804e277 fix10 2025-03-04 10:06:53 +07:00
thienqb123456 c4d166d418 fix9 2025-03-04 09:47:28 +07:00
thienqb123456 bf9ea21b47 fix8 2025-03-04 09:44:41 +07:00
thienqb123456 147d55fc20 fix7 2025-03-04 09:12:21 +07:00
thienqb123456 843c43228e fix6 2025-03-03 18:40:02 +07:00
thienqb123456 317e7a0f65 fix5 2025-03-03 18:37:50 +07:00
thienqb123456 3232452543 fix4 2025-03-03 18:37:04 +07:00
thienqb123456 22d94c2530 fix3 2025-03-03 18:27:51 +07:00
thienqb123456 3d4e0b4791 fix2 2025-03-03 18:11:52 +07:00
thienqb123456 fc9cbbd564 fix 2025-03-03 18:08:45 +07:00
thienqb123456 ad216b4fef be-portal env 2025-03-03 16:23:31 +07:00
thienqb123456 965d8b431c đổi tên site iis nên phải sửa cho nó ăn theo 2025-03-03 14:05:33 +07:00
thienqb123456 b5c8404a6f ud 2025-02-28 18:12:05 +07:00
thienqb123456 2d6d20c912 update 2025-02-28 18:06:51 +07:00
thienqb123456 f9aa3baad3 x 2025-02-28 17:56:11 +07:00
thienqb123456 38d9908946 update 2025-02-28 17:24:14 +07:00
thienqb123456 94386913d3 xxx 2025-02-22 19:30:31 +07:00
thienqb123456 13bd8782bc x 2025-02-22 16:34:36 +07:00
thienqb123456 318578a0d0 Thienvv 2025-02-22 12:21:09 +07:00
thienqb123456 27eb7651c9 thienvv 2025-01-15 15:21:31 +07:00
thienqb123456 83c973eecc thiem host vao file ini 2025-01-15 15:02:52 +07:00
thienqb123456 00cb30ee81 portal beta 2025-01-15 14:58:12 +07:00
thienqb123456 5dc1d2bfcd Thienvv - host_vars cho cd mt beta 2025-01-15 14:57:03 +07:00
thienqb123456 6451f8467c beta env 2025-01-15 14:41:03 +07:00
thienqb123456 b53189c5e5 Thienvv - host prod resource 2025-01-13 10:19:35 +07:00
thienqb123456 bd41a70979 Thienvv - ansible , thêm host cho resource api 2025-01-11 19:50:57 +07:00
thienqb123456 d3eb6b9351 Thienvv - them playbook cho deploy_fe_portal, roles,... 2025-01-09 18:35:25 +07:00
thienqb123456 88a3e6bf5b Thienvv - 2025-01-09 16:50:25 +07:00
thienqb123456 e28200ad70 portal fe uat 2025-01-09 16:34:07 +07:00
thienqb123456 6531a9baa3 Thienvv - 2024-12-23 01:32:23 +07:00
thienqb123456 89a9cc4500 Thienvv - 2024-12-23 01:28:28 +07:00
thienqb123456 37af3c17eb t 2024-12-23 01:19:02 +07:00
thienqb123456 01c6239bfe Thienvv- 2024-12-23 01:12:01 +07:00
thienqb123456 d6788d42f8 Thienvv - 2024-12-23 01:09:53 +07:00
thienqb123456 d789cc9843 Thienvv 2024-12-23 01:02:43 +07:00
thienqb123456 df12bcec3e Thienvv 2024-12-23 00:55:04 +07:00
thienqb123456 f71122991f Thienvv - 2024-12-23 00:50:18 +07:00
thienqb123456 46b517894e Thienvv - 2024-12-23 00:48:32 +07:00
thienqb123456 63f40a088e Thienvv 2024-12-23 00:35:23 +07:00
thienqb123456 7664002bea Thienvv - 2024-12-23 00:27:39 +07:00
thienqb123456 267a77cc08 Thienvv - 2024-12-23 00:23:40 +07:00
thienqb123456 fbefb3750d Thienvv - 2024-12-23 00:12:58 +07:00
thienqb123456 52dc8e68e6 v2 ngay 19/12/24 2024-12-19 00:40:20 +07:00
38 changed files with 416 additions and 77 deletions
+11
View File
@@ -0,0 +1,11 @@
[beta-acp-backend-webservers]
beta-acp-backend ansible_host=123.30.238.12 ansible_user=jenkins_cicd_beta ansible_password=Thienthien123@ ansible_connection=winrm ansible_port=5985 ansible_winrm_transport=ntlm ansible_winrm_server_cert_validation=ignore
[beta-portal-backend-webservers]
beta-portal-backend ansible_host=123.30.238.12 ansible_user=jenkins_cicd_beta ansible_password=Thienthien123@ ansible_connection=winrm ansible_port=5985 ansible_winrm_transport=ntlm ansible_winrm_server_cert_validation=ignore
[beta-acp-frontend-webservers]
beta-acp-frontend ansible_host=123.30.238.12 ansible_user=jenkins_cicd_beta ansible_password=Thienthien123@ ansible_connection=winrm ansible_port=5985 ansible_winrm_transport=ntlm ansible_winrm_server_cert_validation=ignore
[beta-portal-frontend-webservers]
beta-portal-frontend ansible_host=123.30.238.12 ansible_user=jenkins_cicd_beta ansible_password=Thienthien123@ ansible_connection=winrm ansible_port=5985 ansible_winrm_transport=ntlm ansible_winrm_server_cert_validation=ignore
+4
View File
@@ -0,0 +1,4 @@
temp_dir: "C:\\deploy\\vpress\\temp"
iis_site_name: "acp-api.kinhtedothi.vn"
blue_path: "C:\\deploy\\acp\\be\\blue"
green_path: "C:\\deploy\\acp\\be\\green"
@@ -0,0 +1,4 @@
temp_dir: "C:\\deploy\\vpress\\temp"
iis_site_name: "tsht.kinhtedothi.vn"
blue_path: "C:\\deploy\\acp\\fe\\blue"
green_path: "C:\\deploy\\acp\\fe\\green"
@@ -0,0 +1,4 @@
temp_dir: "C:\\deploy\\vpress\\temp"
iis_site_name: "portal-api.kinhtedothi.vn"
blue_path: "C:\\deploy\\portal\\be\\blue"
green_path: "C:\\deploy\\portal\\be\\green"
@@ -0,0 +1,6 @@
temp_dir: "C:\\deploy\\vpress\\temp"
iis_site_name: "portal-api.hanoitimes.vn"
blue_path: "C:\\deploy\\portal\\be\\hnt\\blue"
green_path: "C:\\deploy\\portal\\be\\hnt\\green"
aspnetcore_environment: "Hnt_Beta"
@@ -0,0 +1,4 @@
temp_dir: "C:\\deploy\\vpress\\temp"
iis_site_name: "hanoitimes.vn"
blue_path: "C:\\deploy\\portal\\fe\\hnt\\blue"
green_path: "C:\\deploy\\portal\\fe\\hnt\\green"
@@ -0,0 +1,6 @@
temp_dir: "C:\\deploy\\vpress\\temp"
iis_site_name: "portal-api.kinhtedothi.vn"
blue_path: "C:\\deploy\\portal\\be\\ktdt\\blue"
green_path: "C:\\deploy\\portal\\be\\ktdt\\green"
aspnetcore_environment: "Ktdt_Beta"
@@ -0,0 +1,4 @@
temp_dir: "C:\\deploy\\vpress\\temp"
iis_site_name: "beta.kinhtedothi.vn"
blue_path: "C:\\deploy\\portal\\fe\\ktdt\\blue"
green_path: "C:\\deploy\\portal\\fe\\ktdt\\green"
-4
View File
@@ -1,4 +0,0 @@
temp_dir: "C:\\deploy\\vpress\\temp"
iis_site_name: "api-acp.kinhtedothi.vn"
blue_path: "C:\\deploy\\vpress\\acp\\be\\blue"
green_path: "C:\\deploy\\vpress\\acp\\be\\green"
-4
View File
@@ -1,4 +0,0 @@
temp_dir: "C:\\deploy\\vpress\\temp"
iis_site_name: "api-portal.kinhtedothi.vn"
blue_path: "C:\\deploy\\vpress\\portal\\be\\blue"
green_path: "C:\\deploy\\vpress\\portal\\be\\green"
-4
View File
@@ -1,4 +0,0 @@
temp_dir: "C:\\deploy\\vpress\\temp"
iis_site_name: "acp.kinhtedothi.vn"
blue_path: "C:\\deploy\\vpress\\acp\\fe\\blue"
green_path: "C:\\deploy\\vpress\\acp\\fe\\green"
-4
View File
@@ -1,4 +0,0 @@
temp_dir: "C:\\deploy\\vpress\\temp"
iis_site_name: "demo.kinhtedothi.vn"
blue_path: "C:\\deploy\\vpress\\portal\\fe\\blue"
green_path: "C:\\deploy\\vpress\\portal\\fe\\green"
@@ -1,4 +1,6 @@
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"
green_path: "C:\\deploy\\vpress\\portal\\be\\green"
aspnetcore_environment: "Uat"
@@ -0,0 +1,4 @@
temp_dir: "C:\\deploy\\vpress\\temp"
iis_site_name: "uat-portal2"
blue_path: "C:\\deploy\\vpress\\portal\\fe\\hnt\\blue"
green_path: "C:\\deploy\\vpress\\portal\\fe\\hnt\\green"
@@ -0,0 +1,6 @@
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_environment: "Uat"
@@ -0,0 +1,4 @@
temp_dir: "C:\\deploy\\vpress\\temp"
iis_site_name: "uat-portal.vpress.vn"
blue_path: "C:\\deploy\\vpress\\portal\\fe\\ktdt\\blue"
green_path: "C:\\deploy\\vpress\\portal\\fe\\ktdt\\green"
@@ -0,0 +1,4 @@
temp_dir: "C:\\deploy\\vpress\\temp"
iis_site_name: "resource.vpress.vn"
blue_path: "C:\\deploy\\vpress\\resource\\blue"
green_path: "C:\\deploy\\vpress\\resource\\green"
-4
View File
@@ -1,4 +0,0 @@
temp_dir: "C:\\deploy\\vpress\\temp"
iis_site_name: "uat_be_acp_TEST"
blue_path: "C:\\deploy\\vpress\\portal\\fe\\blue"
green_path: "C:\\deploy\\vpress\\portal\\fe\\green"
-11
View File
@@ -1,11 +0,0 @@
[prod_be_acp_webservers]
prod_be_acp ansible_host=123.30.186.68 ansible_user=jenkins_cicd_ktdt ansible_password=Thienthien123@ ansible_connection=winrm ansible_port=5985 ansible_winrm_transport=ntlm ansible_winrm_server_cert_validation=ignore
[prod_be_portal_webservers]
prod_be_portal ansible_host=123.30.186.68 ansible_user=jenkins_cicd_ktdt ansible_password=Thienthien123@ ansible_connection=winrm ansible_port=5985 ansible_winrm_transport=ntlm ansible_winrm_server_cert_validation=ignore
[prod_fe_acp_webservers]
prod_fe_acp ansible_host=123.30.186.68 ansible_user=jenkins_cicd_ktdt ansible_password=Thienthien123@ ansible_connection=winrm ansible_port=5985 ansible_winrm_transport=ntlm ansible_winrm_server_cert_validation=ignore
[prod_be_portal_webservers]
prod_fe_portal ansible_host=123.30.186.68 ansible_user=jenkins_cicd_ktdt ansible_password=Thienthien123@ ansible_connection=winrm ansible_port=5985 ansible_winrm_transport=ntlm ansible_winrm_server_cert_validation=ignore
+11 -8
View File
@@ -1,11 +1,14 @@
[uat_be_acp_webservers]
uat_be_acp ansible_host=123.30.172.34 ansible_user=jenkins_cicd ansible_password=Thienthien123@ ansible_connection=winrm ansible_port=5985 ansible_winrm_transport=ntlm ansible_winrm_server_cert_validation=ignore
[uat-acp-backend-webservers]
uat-acp-backend ansible_host=123.30.172.34 ansible_user=jenkins_cicd ansible_password=Thienthien123@ ansible_connection=winrm ansible_port=5985 ansible_winrm_transport=ntlm ansible_winrm_server_cert_validation=ignore
[uat_be_portal_webservers]
uat_be_portal ansible_host=123.30.172.34 ansible_user=jenkins_cicd ansible_password=Thienthien123@ ansible_connection=winrm ansible_port=5985 ansible_winrm_transport=ntlm ansible_winrm_server_cert_validation=ignore
[uat-portal-backend-webservers]
uat-portal-backend ansible_host=123.30.172.34 ansible_user=jenkins_cicd ansible_password=Thienthien123@ ansible_connection=winrm ansible_port=5985 ansible_winrm_transport=ntlm ansible_winrm_server_cert_validation=ignore
[uat_fe_acp_webservers]
uat_fe_acp ansible_host=123.30.172.34 ansible_user=jenkins_cicd ansible_password=Thienthien123@ ansible_connection=winrm ansible_port=5985 ansible_winrm_transport=ntlm ansible_winrm_server_cert_validation=ignore
[uat-resource-backend-webservers]
uat-resource-backend ansible_host=123.30.172.34 ansible_user=jenkins_cicd ansible_password=Thienthien123@ ansible_connection=winrm ansible_port=5985 ansible_winrm_transport=ntlm ansible_winrm_server_cert_validation=ignore
[uat_be_portal_webservers]
uat_fe_portal ansible_host=123.30.172.34 ansible_user=jenkins_cicd ansible_password=Thienthien123@ ansible_connection=winrm ansible_port=5985 ansible_winrm_transport=ntlm ansible_winrm_server_cert_validation=ignore
[uat-acp-frontend-webservers]
uat-acp-frontend ansible_host=123.30.172.34 ansible_user=jenkins_cicd ansible_password=Thienthien123@ ansible_connection=winrm ansible_port=5985 ansible_winrm_transport=ntlm ansible_winrm_server_cert_validation=ignore
[uat-portal-frontend-webservers]
uat-portal-frontend ansible_host=123.30.172.34 ansible_user=jenkins_cicd ansible_password=Thienthien123@ ansible_connection=winrm ansible_port=5985 ansible_winrm_transport=ntlm ansible_winrm_server_cert_validation=ignore
+1 -1
View File
@@ -1,5 +1,5 @@
- name: Deploy Backend for Project Acp, Portal
hosts: "{{ target_host }}"
hosts: "{{ deploy_env }}-{{project_name}}-backend"
roles:
- deploy
+10
View File
@@ -0,0 +1,10 @@
- name: Deploy Backend for Project Portal
hosts: "{{ deploy_env }}-{{project_name}}-backend"
vars:
portal_name: "{{ portal_name }}"
pre_tasks:
- name: Include portal-specific variables
include_vars: "../inventory/host_vars/{{ deploy_env }}-{{ project_name }}-{{ portal_name }}-backend.yml"
roles:
- deploy-be-portal
+1 -1
View File
@@ -1,4 +1,4 @@
- name: Deploy Frontend for Project Acp, Portal
hosts: "{{ target_host }}"
hosts: "{{ deploy_env }}-{{project_name}}-frontend"
roles:
- deploy
+9
View File
@@ -0,0 +1,9 @@
- name: Deploy Frontend for Project Portal
hosts: "{{ deploy_env }}-{{project_name}}-frontend"
vars:
portal_name: "{{ portal_name }}"
pre_tasks:
- name: Include portal-specific variables
include_vars: "../inventory/host_vars/{{ deploy_env }}-{{ project_name }}-{{ portal_name }}-frontend.yml"
roles:
- deploy-fe-portal
+5
View File
@@ -0,0 +1,5 @@
# Xóa file tạm
- name: Clean up temporary files
win_file:
path: "{{ temp_dir }}\\{{ artifact_name }}"
state: absent
+46
View File
@@ -0,0 +1,46 @@
# Tải artifact từ Nexus Repository
- name: Download artifact from Nexus
win_get_url:
url: "{{ nexus_url }}/{{ artifact_name }}"
dest: "{{ temp_dir }}\\{{ artifact_name }}"
validate_certs: no
url_username: "{{ nexus_username }}"
url_password: "{{ nexus_password }}"
register: download_status
vars:
nexus_url: "{{ nexus_url }}"
artifact_name: "{{ artifact_name }}"
nexus_username: "{{ nexus_username }}"
nexus_password: "{{ nexus_password }}"
# Debug download_status
- name: Debug download_status
debug:
var: download_status
# 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
stat:
path: "{{ temp_dir }}/{{ artifact_name }}"
register: file_status
changed_when: false
failed_when: false
# Debug file_status
- name: Debug file_status
debug:
var: file_status
# Giải nén artifact vào thư mục target
- name: Deploy to target environment
win_unzip:
src: "{{ temp_dir }}\\{{ artifact_name }}"
dest: "{{ target_path }}"
overwrite: yes
+13
View File
@@ -0,0 +1,13 @@
- name: Setup environment
import_tasks: setup.yml
- name: Deploy application
import_tasks: deploy.yml
- name: Clean up temporary files
import_tasks: cleanup.yml
- name: Switch
import_tasks: switch.yml
+60
View File
@@ -0,0 +1,60 @@
#Debug
- name: Debug iis_site_name
debug:
var: iis_site_name
- name: Debug aspnetcore_environment
debug:
var: aspnetcore_environment
- 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
# Validate các biến var truyền vào
- name: Validate required variables
assert:
that:
- iis_site_name is defined and iis_site_name | length > 0
- aspnetcore_environment is defined and aspnetcore_environment | length > 0
- blue_path is defined and blue_path | length > 0
- nexus_url is defined and nexus_url | length > 0
- artifact_name is defined and artifact_name | length > 0
fail_msg: "One or more required variables are missing or empty!"
#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}}"
if ($site) {
Write-Output $site.PhysicalPath
} else {
Write-Output "NOT_FOUND"
}
register: site_path
- name: Set fact for site path
set_fact:
active_path: "{{ site_path.stdout_lines[0] }}"
- name: Fail if site does not exist
fail:
msg: "IIS site {{ iis_site_name }} not found!"
when: active_path == "NOT_FOUND"
# 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
+20
View File
@@ -0,0 +1,20 @@
# 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
Add-WebConfigurationProperty -pspath "MACHINE/WEBROOT/APPHOST/{{ iis_site_name }}" `
-filter "system.webServer/aspNetCore/environmentVariables" `
-name "." `
-value @{name="ASPNETCORE_ENVIRONMENT"; value="{{ aspnetcore_environment }}"}
# - name: Restart IIS site to apply changes
# win_iis_website:
# name: "{{ iis_site_name }}"
# state: restarted
+5
View File
@@ -0,0 +1,5 @@
# Xóa file tạm
- name: Clean up temporary files
win_file:
path: "{{ temp_dir }}\\{{ artifact_name }}"
state: absent
+45
View File
@@ -0,0 +1,45 @@
# Tải artifact từ Nexus
- name: Download artifact from Nexus
win_get_url:
url: "{{ nexus_url }}/{{ artifact_name }}"
dest: "{{ temp_dir }}\\{{ artifact_name }}"
validate_certs: no
url_username: "{{ nexus_username }}"
url_password: "{{ nexus_password }}"
register: download_status
vars:
nexus_url: "{{ nexus_url }}"
artifact_name: "{{ artifact_name }}"
nexus_username: "{{ nexus_username }}"
nexus_password: "{{ nexus_password }}"
# Debug download_status
- name: Debug download_status
debug:
var: download_status
- name: Check if the download was successful
debug:
msg: "Download successful: {{ download_status.msg }}"
# 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
stat:
path: "{{ temp_dir }}/{{ artifact_name }}"
register: file_status
changed_when: false
failed_when: false
# Debug file_status
- name: Debug file_status
debug:
var: file_status
# Giải nén artifact vào thư mục target
- name: Deploy to target environment
win_unzip:
src: "{{ temp_dir }}\\{{ artifact_name }}"
dest: "{{ target_path }}"
overwrite: yes
+13
View File
@@ -0,0 +1,13 @@
- name: Setup environment
import_tasks: setup.yml
- name: Deploy application
import_tasks: deploy.yml
- name: Clean up temporary files
import_tasks: cleanup.yml
- name: Switch
import_tasks: switch.yml
+47
View File
@@ -0,0 +1,47 @@
#Debug
- name: Debug iis_site_name
debug:
var: iis_site_name
- 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
#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
+10
View File
@@ -0,0 +1,10 @@
- name: Update site IIS web application
win_iis_website:
name: "{{ iis_site_name }}"
physical_path: "{{ target_path }}"
# - name: Restart IIS site to apply changes
# win_iis_website:
# name: "{{ iis_site_name }}"
# state: restarted
+23 -6
View File
@@ -13,14 +13,31 @@
nexus_username: "{{ nexus_username }}"
nexus_password: "{{ nexus_password }}"
# Kiểm tra xem artifact đã được tải thành công chưa
- name: Verify artifact download
fail:
msg: "Failed to download artifact from Nexus."
when: download_status is failed
# Debug download_status
- name: Debug download_status
debug:
var: download_status
- name: Check if the download was successful
debug:
msg: "Download successful: {{ download_status.msg }}"
# 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
stat:
path: "{{ temp_dir }}/{{ artifact_name }}"
register: file_status
changed_when: false
failed_when: false
# Debug file_status
- name: Debug file_status
debug:
var: file_status
# Giải nén artifact vào thư mục target
- name: Deploy Backend to target environment
- name: Deploy to target environment
win_unzip:
src: "{{ temp_dir }}\\{{ artifact_name }}"
dest: "{{ target_path }}"
+33 -29
View File
@@ -1,38 +1,12 @@
#Debug
- name: Debug iis_site_name
debug:
var: iis_site_name
#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
# Chuẩn hóa giá trị của active_path
- name: Normalize active_path
set_fact:
active_path: "{{ active_path.stdout | trim }}"
# Debug các biến quan trọng
- name: Debug active_path
debug:
var: active_path
- name: Debug blue_path
debug:
var: blue_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
- name: Debug target_path
debug:
var: target_path
# Kiểm tra các thông số Nexus
- name: Debug Nexus URL
debug:
@@ -40,4 +14,34 @@
- name: Debug artifact name
debug:
var: artifact_name
var: artifact_name
#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