26 Commits

Author SHA1 Message Date
thienqb123456 da179bd1c3 quite-good 2025-03-04 18:17:07 +07:00
thienqb123456 87eef3e85b deploy-fe-portal new 2025-03-04 18:06:31 +07:00
thienqb123456 3c083c6dba fix 22 2025-03-04 17:33:51 +07:00
thienqb123456 26f8e27b5f fix 21 2025-03-04 17:31:13 +07:00
thienqb123456 26f303c862 fix 20 2025-03-04 17:21:15 +07:00
thienqb123456 a999f635ad new format ansible-playhook, role 2025-03-04 17:16:35 +07:00
thienqb123456 c7500c16ef tang --maxmemory cua portal 2025-03-04 17:13:09 +07:00
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
29 changed files with 299 additions and 35 deletions
@@ -1,9 +0,0 @@
temp_dir: "C:\\deploy\\vpress\\temp"
# iis_site_name_1: "beta.kinhtedothi.vn"
# iis_site_name_2: "beta.hanoitimes.vn"
# blue_path: "C:\\deploy\\portal\\fe\\blue"
# green_path: "C:\\deploy\\portal\\fe\\green"
iis_site_name_1: "kinhtedothi.vn"
iis_site_name_2: "hanoitimes.vn"
blue_path: "C:\\deploy\\portal\\fe2\\blue"
green_path: "C:\\deploy\\portal\\fe2\\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"
@@ -1,5 +0,0 @@
temp_dir: "C:\\deploy\\vpress\\temp"
iis_site_name_1: "uat-portal.vpress.vn"
iis_site_name_2: "uat-portal2"
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" temp_dir: "C:\\deploy\\vpress\\temp"
iis_site_name: "api-portal-2025" iis_site_name: "api-portal-2025"
blue_path: "C:\\deploy\\vpress\\portal\\be\\blue" 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"
@@ -1,4 +0,0 @@
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"
@@ -0,0 +1,6 @@
temp_dir: "C:\\deploy\\vpress\\temp"
iis_site_name: "resource.vpress.vn"
blue_path: "C:\\deploy\\vpress\\resource\\hnt\\blue"
green_path: "C:\\deploy\\vpress\\resource\\hnt\\green"
aspnetcore_environment: "Uat"
@@ -0,0 +1,6 @@
temp_dir: "C:\\deploy\\vpress\\temp"
iis_site_name: "resource.vpress.vn"
blue_path: "C:\\deploy\\vpress\\resource\\ktdt\\blue"
green_path: "C:\\deploy\\vpress\\resource\\ktdt\\green"
aspnetcore_environment: "Uat"
+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
+10
View File
@@ -0,0 +1,10 @@
- name: Deploy Backend for Project Resource
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-resource
+5
View File
@@ -1,4 +1,9 @@
- name: Deploy Frontend for Project Portal - name: Deploy Frontend for Project Portal
hosts: "{{ deploy_env }}-{{project_name}}-frontend" 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: roles:
- deploy-fe-portal - deploy-fe-portal
+32
View File
@@ -0,0 +1,32 @@
- name: get_site_current_active_path.yml
import_role:
name: iis_utils
tasks_from: get_site_current_active_path.yml
- name: set_target_path
import_role:
name: iis_utils
tasks_from: set_target_path.yml
- name: artifact_download
import_role:
name: iis_utils
tasks_from: artifact_download.yml
- name: artifact_deploy
import_role:
name: iis_utils
tasks_from: artifact_deploy.yml
- name: update_iis_physical_path
import_role:
name: iis_utils
tasks_from: update_iis_physical_path.yml
- name: set_site_aspnetcore_environment
import_role:
name: iis_utils
tasks_from: set_site_aspnetcore_environment.yml
+34
View File
@@ -0,0 +1,34 @@
- name: get_site_current_active_path.yml
import_role:
name: iis_utils
tasks_from: get_site_current_active_path.yml
- name: set_target_path
import_role:
name: iis_utils
tasks_from: set_target_path.yml
- name: artifact_download
import_role:
name: iis_utils
tasks_from: artifact_download.yml
- name: artifact_deploy
import_role:
name: iis_utils
tasks_from: artifact_deploy.yml
- name: update_iis_physical_path
import_role:
name: iis_utils
tasks_from: update_iis_physical_path.yml
- name: set_site_aspnetcore_environment
import_role:
name: iis_utils
tasks_from: set_site_aspnetcore_environment.yml
+3 -7
View File
@@ -1,11 +1,7 @@
#Debug #Debug
- name: Debug iis_site_name_1 - name: Debug iis_site_name
debug: debug:
var: iis_site_name_1 var: iis_site_name
- name: Debug iis_site_name_2
debug:
var: iis_site_name_2
- name: Debug blue_path - name: Debug blue_path
debug: debug:
@@ -24,7 +20,7 @@
- name: Get the physical path of the current IIS site - name: Get the physical path of the current IIS site
win_shell: | win_shell: |
Import-Module WebAdministration Import-Module WebAdministration
$site = Get-Website -Name "{{ iis_site_name_1 }}" $site = Get-Website -Name "{{ iis_site_name}}"
$site.PhysicalPath $site.PhysicalPath
register: active_path register: active_path
- debug: - debug:
+2 -7
View File
@@ -1,11 +1,6 @@
- name: Update site 1 IIS web application - name: Update site IIS web application
win_iis_website: win_iis_website:
name: "{{ iis_site_name_1 }}" name: "{{ iis_site_name }}"
physical_path: "{{ target_path }}"
- name: Update site 2 IIS web application
win_iis_website:
name: "{{ iis_site_name_2 }}"
physical_path: "{{ target_path }}" physical_path: "{{ target_path }}"
# - name: Restart IIS site to apply changes # - name: Restart IIS site to apply changes
-2
View File
@@ -16,8 +16,6 @@
debug: debug:
var: artifact_name var: artifact_name
#Lấy đường dẫn vật lý của iis site #Lấy đường dẫn vật lý của iis site
- name: Get the physical path of the current IIS site - name: Get the physical path of the current IIS site
win_shell: | win_shell: |
+14
View File
@@ -0,0 +1,14 @@
- name: Validate variables
assert:
that:
- artifact_name is defined and artifact_name | length > 0
- target_path is defined and target_path | length > 0
- temp_dir is defined and temp_dir | length > 0
fail_msg: "Thiếu hoặc rỗng biến cần thiết để deploy artifact!"
# 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
@@ -0,0 +1,48 @@
- name: Validate variables
assert:
that:
- nexus_url is defined and nexus_url | length > 0
- temp_dir is defined and temp_dir | length > 0
- artifact_name is defined and artifact_name | length > 0
- nexus_username is defined and nexus_username | length > 0
- nexus_password is defined and nexus_password | length > 0
fail_msg: "Thiếu hoặc rỗng biến cần thiết để download artifact!"
# 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
@@ -0,0 +1,12 @@
- name: Validate variables
assert:
that:
- temp_dir is defined and temp_dir | length > 0
- artifact_name is defined and artifact_name | length > 0
fail_msg: "Thiếu hoặc rỗng biến cần thiết để cleanup_temp_artifact!"
# Xóa file tạm
- name: Clean up temporary files
win_file:
path: "{{ temp_dir }}\\{{ artifact_name }}"
state: absent
@@ -0,0 +1,26 @@
- name: Validate variables
assert:
that:
- iis_site_name is defined and iis_site_name | length > 0
fail_msg: "Thiếu hoặc rỗng biến cần thiết để get_site_current_active_path!"
#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"
@@ -0,0 +1,11 @@
- name: Validate variables
assert:
that:
- iis_site_name is defined and iis_site_name | length > 0
fail_msg: "Thiếu hoặc rỗng biến cần thiết để restart_iis_site.yml!"
# Restart IIS site
- name: Restart IIS site
win_iis_website:
name: "{{ iis_site_name }}"
state: restarted
@@ -0,0 +1,15 @@
- name: Validate variables
assert:
that:
- iis_site_name is defined and iis_site_name | length > 0
- aspnetcore_environment is defined and aspnetcore_environment | length > 0
fail_msg: "Thiếu hoặc rỗng biến cần thiết để set_site_aspnetcore_environment!"
# 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 }}"}
+16
View File
@@ -0,0 +1,16 @@
- name: Validate variables
assert:
that:
- green_path is defined and green_path | length > 0
- blue_path is defined and blue_path | length > 0
- active_path is defined and active_path | length > 0
fail_msg: "Thiếu hoặc rỗng biến cần thiết để set_target_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
@@ -0,0 +1,12 @@
- name: Validate variables
assert:
that:
- iis_site_name is defined and iis_site_name | length > 0
- target_path is defined and target_path | length > 0
fail_msg: "Thiếu hoặc rỗng biến cần thiết để set_target_path!"
# 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 }}"