đổi tên site iis nên phải sửa cho nó ăn theo
This commit is contained in:
@@ -0,0 +1,7 @@
|
|||||||
|
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_environtment: "Hnt_Beta"
|
||||||
|
iis_app_pool: "portal-api.hanoitimes.vn"
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
temp_dir: "C:\\deploy\\vpress\\temp"
|
temp_dir: "C:\\deploy\\vpress\\temp"
|
||||||
iis_site_name: "beta.hanoitimes.vn"
|
iis_site_name: "hanoitimes.vn"
|
||||||
blue_path: "C:\\deploy\\portal\\fe\\hnt\\blue"
|
blue_path: "C:\\deploy\\portal\\fe\\hnt\\blue"
|
||||||
green_path: "C:\\deploy\\portal\\fe\\hnt\\green"
|
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_environtment: "Ktdt_Beta"
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
- name: Deploy Backend for Project Acp, 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
|
||||||
|
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
# Xóa file tạm
|
||||||
|
- name: Clean up temporary files
|
||||||
|
win_file:
|
||||||
|
path: "{{ temp_dir }}\\{{ artifact_name }}"
|
||||||
|
state: absent
|
||||||
@@ -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
|
||||||
|
|
||||||
@@ -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
|
||||||
|
|
||||||
|
|
||||||
@@ -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
|
||||||
@@ -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
|
||||||
|
|
||||||
@@ -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: |
|
||||||
|
|||||||
Reference in New Issue
Block a user