From 26275894faea0f5432e96725f4e63bc7ff570e83 Mon Sep 17 00:00:00 2001 From: Brian Lee Date: Thu, 3 Aug 2023 08:49:38 -0700 Subject: [PATCH] Install Deno for strfry-policies. --- README.md | 5 +++++ tasks/build.yml | 9 ++++++--- tasks/deno.yml | 41 +++++++++++++++++++++++++++++++++++++++++ tasks/main.yml | 7 +++++++ 4 files changed, 59 insertions(+), 3 deletions(-) create mode 100644 tasks/deno.yml diff --git a/README.md b/README.md index 77b3576..8ef898a 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,11 @@ This Ansible Role builds and installs [strfry](https://github.com/hoytech/strfry). It is intended to be composed with a separate role to handle the web proxy configuration. +Tested on: +* Archlinux +* Debian 11 +* Ubuntu 22.04 + ## Requirements None. diff --git a/tasks/build.yml b/tasks/build.yml index f45945a..167858a 100644 --- a/tasks/build.yml +++ b/tasks/build.yml @@ -16,16 +16,19 @@ ansible.builtin.command: cmd: git submodule update --init chdir: "{{ ansible_env.HOME }}/src/strfry" - #when: git_repository.changed +# when: git_repository.changed + changed_when: git_repository.changed - name: Run make setup-golpe ansible.builtin.command: cmd: make setup-golpe chdir: "{{ ansible_env.HOME }}/src/strfry" - #when: git_repository.changed +# when: git_repository.changed + changed_when: git_repository.changed - name: Build strfry ansible.builtin.command: cmd: "make -j{{ strfry_make_jobs|default(1) }}" chdir: "{{ ansible_env.HOME }}/src/strfry" - #when: git_repository.changed \ No newline at end of file +# when: git_repository.changed + changed_when: git_repository.changed \ No newline at end of file diff --git a/tasks/deno.yml b/tasks/deno.yml new file mode 100644 index 0000000..5e2fced --- /dev/null +++ b/tasks/deno.yml @@ -0,0 +1,41 @@ +--- +- name: Ensure unzip is installed + ansible.builtin.package: + name: unzip + state: present + +- name: Ensure custom facts directory exists + ansible.builtin.file: + mode: 0755 + path: /etc/ansible/facts.d + state: directory + +- name: 'Detect the latest {{ app_name }} version' + ansible.builtin.uri: + url: https://api.github.com/repos/denoland/deno/releases/latest + register: deno_latest_release_tag + +- name: 'Determine whether or not the latest version of {{ app_name }} 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'] != deno_latest_release_tag.json.tag_name | replace('v',''))) }}" + +- name: 'Ensure {{ app_name }} 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' + dest: /usr/local/bin + mode: 0755 + remote_src: true + extra_opts: + - -j + +- name: 'Save meta information about the version of {{ app_name }} 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','') }}" + backup: true + no_extra_spaces: true diff --git a/tasks/main.yml b/tasks/main.yml index c28b3d2..4cf1191 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -6,6 +6,13 @@ - "{{ ansible_distribution }}.yml" - "{{ ansible_os_family }}.yml" +- name: Install Deno + ansible.builtin.include_tasks: + file: deno.yml + apply: + tags: deno + become: true + - name: Install build dependencies ansible.builtin.package: name: "{{ strfry_build_dependencies }}"