mirror of
https://github.com/fscotto/infra.git
synced 2026-05-30 15:39:58 +00:00
Install OpenCode on Ubuntu workstation
This commit is contained in:
@@ -35,6 +35,83 @@
|
|||||||
loop_control:
|
loop_control:
|
||||||
label: "{{ item.dest }}"
|
label: "{{ item.dest }}"
|
||||||
|
|
||||||
|
- name: Set workstation external tool release metadata
|
||||||
|
tags: [packages]
|
||||||
|
ansible.builtin.set_fact:
|
||||||
|
workstation_tools_tmp_dir: /tmp/workstation-tools
|
||||||
|
opencode_asset_name: >-
|
||||||
|
{{
|
||||||
|
'opencode-linux-x64-baseline.tar.gz' if ansible_facts['architecture'] == 'x86_64'
|
||||||
|
else 'opencode-linux-arm64.tar.gz' if ansible_facts['architecture'] in ['aarch64', 'arm64']
|
||||||
|
else ''
|
||||||
|
}}
|
||||||
|
|
||||||
|
- name: Ensure architecture is supported for OpenCode binary
|
||||||
|
tags: [packages]
|
||||||
|
ansible.builtin.fail:
|
||||||
|
msg: "Unsupported architecture {{ ansible_facts['architecture'] }} for OpenCode release binary"
|
||||||
|
when: opencode_asset_name == ''
|
||||||
|
|
||||||
|
- name: Ensure temporary directory exists for workstation external tools
|
||||||
|
tags: [packages]
|
||||||
|
ansible.builtin.file:
|
||||||
|
path: "{{ workstation_tools_tmp_dir }}"
|
||||||
|
state: directory
|
||||||
|
mode: "0755"
|
||||||
|
|
||||||
|
- name: Fetch latest OpenCode release metadata
|
||||||
|
tags: [packages]
|
||||||
|
ansible.builtin.uri:
|
||||||
|
url: https://api.github.com/repos/anomalyco/opencode/releases/latest
|
||||||
|
headers:
|
||||||
|
Accept: application/vnd.github+json
|
||||||
|
return_content: true
|
||||||
|
register: opencode_latest_release
|
||||||
|
changed_when: false
|
||||||
|
|
||||||
|
- name: Set OpenCode release asset metadata
|
||||||
|
tags: [packages]
|
||||||
|
ansible.builtin.set_fact:
|
||||||
|
opencode_version: "{{ opencode_latest_release.json.tag_name }}"
|
||||||
|
opencode_asset: >-
|
||||||
|
{{
|
||||||
|
opencode_latest_release.json.assets
|
||||||
|
| selectattr('name', 'equalto', opencode_asset_name)
|
||||||
|
| first
|
||||||
|
| default({})
|
||||||
|
}}
|
||||||
|
|
||||||
|
- name: Ensure latest OpenCode asset metadata is available
|
||||||
|
tags: [packages]
|
||||||
|
ansible.builtin.fail:
|
||||||
|
msg: "Could not find OpenCode asset {{ opencode_asset_name }} in release {{ opencode_version }}"
|
||||||
|
when: opencode_asset == {}
|
||||||
|
|
||||||
|
- name: Download OpenCode release archive
|
||||||
|
tags: [packages]
|
||||||
|
ansible.builtin.get_url:
|
||||||
|
url: "{{ opencode_asset.browser_download_url }}"
|
||||||
|
dest: "{{ workstation_tools_tmp_dir }}/{{ opencode_asset.name }}"
|
||||||
|
checksum: "{{ opencode_asset.digest | default(omit) }}"
|
||||||
|
mode: "0644"
|
||||||
|
|
||||||
|
- name: Extract OpenCode release archive
|
||||||
|
tags: [packages]
|
||||||
|
ansible.builtin.unarchive:
|
||||||
|
src: "{{ workstation_tools_tmp_dir }}/{{ opencode_asset.name }}"
|
||||||
|
dest: "{{ workstation_tools_tmp_dir }}"
|
||||||
|
remote_src: true
|
||||||
|
|
||||||
|
- name: Install OpenCode binary
|
||||||
|
tags: [packages]
|
||||||
|
ansible.builtin.copy:
|
||||||
|
src: "{{ workstation_tools_tmp_dir }}/opencode"
|
||||||
|
dest: /usr/local/bin/opencode
|
||||||
|
remote_src: true
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: "0755"
|
||||||
|
|
||||||
- name: Ensure GNOME extension directories exist
|
- name: Ensure GNOME extension directories exist
|
||||||
tags: [packages, gnome]
|
tags: [packages, gnome]
|
||||||
ansible.builtin.file:
|
ansible.builtin.file:
|
||||||
|
|||||||
Reference in New Issue
Block a user