- 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