From 3518f6c96c9024e0be82c5dba099a10ca198993a Mon Sep 17 00:00:00 2001 From: Brian Lee Date: Mon, 11 Nov 2024 12:00:21 -0800 Subject: [PATCH] Add variable for deno version. --- defaults/main.yml | 1 + tasks/deno.yml | 27 ++++++++++++++++----------- tasks/main.yml | 1 + 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/defaults/main.yml b/defaults/main.yml index d321bec..585d639 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -1,4 +1,5 @@ --- +deno_version: latest strfry_version: beta strfry_binary_path: /usr/local/bin/strfry strfry_make_jobs: "{{ ansible_processor_cores }}" diff --git a/tasks/deno.yml b/tasks/deno.yml index abba79a..6bf3795 100644 --- a/tasks/deno.yml +++ b/tasks/deno.yml @@ -10,20 +10,25 @@ path: /etc/ansible/facts.d state: directory -- name: 'Detect the latest Deno version' +- name: Fetch latest Deno version if 'latest' is specified ansible.builtin.uri: url: https://api.github.com/repos/denoland/deno/releases/latest - register: deno_latest_release_tag + register: deno_latest_release + when: deno_version == 'latest' -- name: 'Determine whether or not the latest version of Deno is already installed' +- name: Set actual Deno version ansible.builtin.set_fact: - install_deno: "{{ (ansible_local.deno is not defined) or \ - ((ansible_local.deno is defined) and \ - (ansible_local['deno']['settings']['version'] != deno_latest_release_tag.json.tag_name | replace('v',''))) }}" + actual_deno_version: "{{ deno_latest_release.json.tag_name | replace('v','') if deno_version == 'latest' else deno_version }}" -- name: 'Ensure Deno is installed' +- name: Determine whether or not the specified version of Deno is already installed + ansible.builtin.set_fact: + install_deno: "{{ (ansible_local.deno is not defined) or + ((ansible_local.deno is defined) and + (ansible_local['deno']['settings']['version'] != actual_deno_version)) }}" + +- name: Ensure Deno is installed unarchive: - src: 'https://github.com/denoland/deno/releases/download/{{ deno_latest_release_tag.json.tag_name }}/deno-x86_64-unknown-linux-gnu.zip' + src: "https://github.com/denoland/deno/releases/download/v{{ actual_deno_version }}/deno-x86_64-unknown-linux-gnu.zip" dest: /usr/local/bin mode: 0755 remote_src: true @@ -31,13 +36,13 @@ - -j when: install_deno -- name: 'Save meta information about the version of Deno that was installed' +- name: Save meta information about the version of Deno that was installed community.general.ini_file: path: /etc/ansible/facts.d/deno.fact mode: 0644 section: settings option: version - value: "{{ deno_latest_release_tag.json.tag_name | replace('v','') }}" + value: "{{ actual_deno_version }}" backup: true no_extra_spaces: true - when: install_deno + when: install_deno \ No newline at end of file diff --git a/tasks/main.yml b/tasks/main.yml index 00ccee0..c342e9a 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -18,6 +18,7 @@ apply: become: true when: strfry_policies_enabled + tags: deno - name: Install build dependencies ansible.builtin.package: