Compare commits
27 Commits
main
..
94386913d3
| Author | SHA1 | Date | |
|---|---|---|---|
| 94386913d3 | |||
| 13bd8782bc | |||
| 318578a0d0 | |||
| 27eb7651c9 | |||
| 83c973eecc | |||
| 00cb30ee81 | |||
| 5dc1d2bfcd | |||
| 6451f8467c | |||
| b53189c5e5 | |||
| bd41a70979 | |||
| d3eb6b9351 | |||
| 88a3e6bf5b | |||
| e28200ad70 | |||
| 6531a9baa3 | |||
| 89a9cc4500 | |||
| 37af3c17eb | |||
| 01c6239bfe | |||
| d6788d42f8 | |||
| d789cc9843 | |||
| df12bcec3e | |||
| f71122991f | |||
| 46b517894e | |||
| 63f40a088e | |||
| 7664002bea | |||
| 267a77cc08 | |||
| fbefb3750d | |||
| 52dc8e68e6 |
@@ -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
|
||||
@@ -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,10 @@
|
||||
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"
|
||||
@@ -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"
|
||||
@@ -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"
|
||||
@@ -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"
|
||||
@@ -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,5 @@
|
||||
temp_dir: "C:\\deploy\\vpress\\temp"
|
||||
iis_site_name: "uat_be_acp_TEST"
|
||||
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"
|
||||
@@ -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"
|
||||
@@ -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
@@ -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,5 +1,5 @@
|
||||
- name: Deploy Backend for Project Acp, Portal
|
||||
hosts: "{{ target_host }}"
|
||||
hosts: "{{ deploy_env }}-{{project_name}}-backend"
|
||||
roles:
|
||||
- deploy
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
- name: Deploy Frontend for Project Acp, Portal
|
||||
hosts: "{{ target_host }}"
|
||||
hosts: "{{ deploy_env }}-{{project_name}}-frontend"
|
||||
roles:
|
||||
- deploy
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
- name: Deploy Frontend for Project Portal
|
||||
hosts: "{{ deploy_env }}-{{project_name}}-frontend"
|
||||
roles:
|
||||
- deploy-fe-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,51 @@
|
||||
#Debug
|
||||
- name: Debug iis_site_name_1
|
||||
debug:
|
||||
var: iis_site_name_1
|
||||
|
||||
- name: Debug iis_site_name_2
|
||||
debug:
|
||||
var: iis_site_name_2
|
||||
|
||||
- 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_1 }}"
|
||||
$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,15 @@
|
||||
- name: Update site 1 IIS web application
|
||||
win_iis_website:
|
||||
name: "{{ iis_site_name_1 }}"
|
||||
physical_path: "{{ target_path }}"
|
||||
|
||||
- name: Update site 2 IIS web application
|
||||
win_iis_website:
|
||||
name: "{{ iis_site_name_2 }}"
|
||||
physical_path: "{{ target_path }}"
|
||||
|
||||
# - name: Restart IIS site to apply changes
|
||||
# win_iis_website:
|
||||
# name: "{{ iis_site_name }}"
|
||||
# state: restarted
|
||||
|
||||
@@ -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 }}"
|
||||
|
||||
@@ -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:
|
||||
@@ -41,3 +15,35 @@
|
||||
- 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
|
||||
Reference in New Issue
Block a user