Files
nsg_ansible/roles/deploy/tasks/setup.yml
T

49 lines
1.2 KiB
YAML
Raw Normal View History

2024-12-23 01:09:53 +07:00
#Debug
2024-12-12 11:53:34 +07:00
- name: Debug iis_site_name
debug:
var: iis_site_name
2024-12-23 01:09:53 +07:00
- 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
2024-12-12 11:53:34 +07:00
#Lấy đường dẫn vật lý của iis site
- name: Get the physical path of the current IIS site
2024-12-23 01:12:01 +07:00
win_shell: |
2024-12-12 11:53:34 +07:00
Import-Module WebAdministration
$site = Get-Website -Name "{{ iis_site_name }}"
2024-12-23 01:12:01 +07:00
$site.PhysicalPath
2024-12-12 11:53:34 +07:00
register: active_path
2024-12-23 01:09:53 +07:00
- debug:
2024-12-23 00:12:58 +07:00
var: active_path
2024-12-23 00:48:32 +07:00
2024-12-23 01:19:02 +07:00
- 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 == ''
2024-12-23 00:12:58 +07:00
2024-12-12 11:53:34 +07:00
# Chuẩn hóa giá trị của active_path
- name: Normalize active_path
set_fact:
2024-12-23 01:09:53 +07:00
active_path: "{{ active_path.stdout | trim }}"
- debug:
var: active_path
2024-12-12 11:53:34 +07:00
# 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
2024-12-23 01:09:53 +07:00
- debug:
var: target_path