diff --git a/roles/vhosts/deploy_acp_vhosts/defaults/main.yml b/roles/vhosts/deploy_acp_vhosts/defaults/main.yml index f2f3dd1..0ab3fe9 100644 --- a/roles/vhosts/deploy_acp_vhosts/defaults/main.yml +++ b/roles/vhosts/deploy_acp_vhosts/defaults/main.yml @@ -13,6 +13,7 @@ xworkmate_bridge_listen_port: 8787 xworkmate_bridge_binary_path: /usr/local/bin/xworkmate-bridge xworkmate_bridge_local_source_dir: "{{ playbook_dir }}/../xworkmate-bridge" xworkmate_bridge_local_build_dir: "{{ playbook_dir }}/.artifacts/xworkmate_bridge" +xworkmate_bridge_artifact_path: "{{ lookup('ansible.builtin.env', 'XWORKMATE_BRIDGE_ARTIFACT_PATH') | default('', true) }}" xworkmate_bridge_local_binary_path: "{{ xworkmate_bridge_local_build_dir }}/xworkmate-bridge" xworkmate_bridge_build_goos: linux xworkmate_bridge_build_goarch: amd64 diff --git a/roles/vhosts/deploy_acp_vhosts/tasks/main.yml b/roles/vhosts/deploy_acp_vhosts/tasks/main.yml index 51b38e0..954cb5e 100644 --- a/roles/vhosts/deploy_acp_vhosts/tasks/main.yml +++ b/roles/vhosts/deploy_acp_vhosts/tasks/main.yml @@ -12,6 +12,26 @@ delegate_to: localhost become: false +- name: Check whether prebuilt xworkmate-bridge artifact exists + ansible.builtin.stat: + path: "{{ xworkmate_bridge_artifact_path }}" + register: xworkmate_bridge_artifact_stat + delegate_to: localhost + become: false + when: + - xworkmate_bridge_artifact_path | trim | length > 0 + +- name: Prefer downloaded xworkmate-bridge artifact + ansible.builtin.copy: + src: "{{ xworkmate_bridge_artifact_path }}" + dest: "{{ xworkmate_bridge_local_binary_path }}" + mode: "0755" + delegate_to: localhost + become: false + when: + - xworkmate_bridge_artifact_path | trim | length > 0 + - xworkmate_bridge_artifact_stat.stat.exists | default(false) + - name: Build xworkmate-bridge locally ansible.builtin.command: cmd: go build -o "{{ xworkmate_bridge_local_binary_path }}" . @@ -24,6 +44,11 @@ delegate_to: localhost become: false check_mode: false + when: + - not ( + xworkmate_bridge_artifact_path | trim | length > 0 and + xworkmate_bridge_artifact_stat.stat.exists | default(false) + ) - name: Upload xworkmate-bridge binary ansible.builtin.copy: