playbooks/roles/vhosts/acp_server_opencode/tasks/config.yml

88 lines
2.3 KiB
YAML

---
- name: Ensure local OpenCode ACP build directory exists
ansible.builtin.file:
path: "{{ acp_opencode_bridge_local_build_dir }}"
state: directory
mode: "0755"
delegate_to: localhost
become: false
- name: Build XWorkmate Go ACP server locally for OpenCode
ansible.builtin.command:
cmd: go build -o "{{ acp_opencode_bridge_local_binary_path }}" .
chdir: "{{ acp_opencode_bridge_local_source_dir }}"
environment:
GOOS: "{{ acp_opencode_bridge_build_goos }}"
GOARCH: "{{ acp_opencode_bridge_build_goarch }}"
CGO_ENABLED: "0"
delegate_to: localhost
become: false
check_mode: false
- name: Upload XWorkmate Go ACP server binary for OpenCode
ansible.builtin.copy:
src: "{{ acp_opencode_bridge_local_binary_path }}"
dest: "{{ acp_opencode_bridge_binary_path }}"
owner: root
group: root
mode: "0755"
- name: Ensure OpenCode runtime directories exist
ansible.builtin.file:
path: "{{ item }}"
state: directory
owner: "{{ acp_opencode_service_user }}"
group: "{{ acp_opencode_service_group }}"
mode: "0755"
loop:
- "{{ acp_opencode_home }}"
- "{{ acp_opencode_home }}/.local"
- "{{ acp_opencode_workdir }}"
- name: Deploy Caddy main file
ansible.builtin.template:
src: Caddyfile.j2
dest: "{{ acp_opencode_caddyfile_path }}"
owner: root
group: root
mode: "0644"
notify: Reload caddy
when:
- acp_opencode_manage_caddy | bool
- name: Remove deprecated standalone OpenCode Caddy fragments
ansible.builtin.file:
path: "{{ item }}"
state: absent
loop: "{{ acp_opencode_obsolete_caddy_fragment_paths }}"
notify: Reload caddy
- name: Deploy OpenCode ACP systemd service
ansible.builtin.template:
src: opencode-acp.service.j2
dest: "/etc/systemd/system/{{ acp_opencode_service_name }}.service"
owner: root
group: root
mode: "0644"
notify: Restart acp opencode
- name: Reload systemd manager configuration
ansible.builtin.systemd:
daemon_reload: true
- name: Ensure Caddy is enabled and running
ansible.builtin.systemd:
name: caddy
enabled: true
state: started
when:
- acp_opencode_manage_caddy | bool
- name: Ensure OpenCode ACP service is enabled and running
ansible.builtin.systemd:
name: "{{ acp_opencode_service_name }}"
enabled: true
state: started
when:
- not ansible_check_mode