Code development platform for open source projects from the European Union institutions

Skip to content
Snippets Groups Projects
Commit ba02e583 authored by Jean-François HOVINNE's avatar Jean-François HOVINNE
Browse files

feat: Add option to install from an archive (fixes #19)

parent 40947e32
No related branches found
No related tags found
1 merge request!19feat: Add option to install from an archive (fixes #19)
......@@ -11,10 +11,17 @@ Requirements
Role Variables
--------------
- `nodejs_version`: Sets the Node.js version to install ("18.x", "20.x", etc).
- `nodejs_version`: Sets the Node.js version to install ("18.x", "20.x", etc),
using the distribution package manager.
The default version is 20.x.
Optionally, in order to install a specific version from a downloadable archive, set the below variables:
- `nodejs_download_url`: The Node.js archive to download (see https://nodejs.org/dist/)
- `nodejs_checksum`: The archive checksum
- `nodejs_install_path`: The path where Node.js will be installed
About Node.js 18.x and 20.x on Amazon Linux 2
---------------------------------------------
......
# Releases
## 2.3.x
- Option to install a specific version from an archive added.
## 2.2.x
- Node.js 16.x support removed.
......
---
# Set the version of Node.js to install ("12.x", "13.x", "14.x", "15.x", etc.).
# Version numbers from Nodesource: https://github.com/nodesource/distributions
nodejs_version: "20.x"
# Instead of using the distribution package manager, download a specific
# Node.js archive and install it globally.
# Archive Download URL, checksum and installation path values are mandatory in this case.
nodejs_download_url: ""
nodejs_checksum: ""
nodejs_install_path: ""
---
- name: Converge
hosts: all
become: true
tasks:
- name: Include nodejs role
ansible.builtin.include_role:
name: nodejs
vars:
nodejs_download_url: "https://nodejs.org/dist/v20.11.0/node-v20.11.0-linux-x64.tar.xz"
nodejs_checksum: "sha256:822780369d0ea309e7d218e41debbd1a03f8cdf354ebf8a4420e89f39cc2e612"
nodejs_install_path: "/opt/nodejs/20.11.0"
environment:
http_proxy: "{{ lookup('env', 'http_proxy') }}"
https_proxy: "{{ lookup('env', 'https_proxy') }}"
no_proxy: "{{ lookup('env', 'no_proxy') }}"
---
dependency:
name: galaxy
driver:
name: docker
platforms:
- name: rockylinux8-${CI_JOB_ID:-0}
image: code.europa.eu:4567/ecgalaxy/rockylinux8-ansible:latest
pre_build_image: true
environment:
http_proxy: "${http_proxy}"
https_proxy: "${https_proxy}"
no_proxy: "${no_proxy}"
- name: ubuntu2004-${CI_JOB_ID:-0}
image: code.europa.eu:4567/ecgalaxy/ubuntu2004-ansible:latest
pre_build_image: true
environment:
http_proxy: "${http_proxy}"
https_proxy: "${https_proxy}"
no_proxy: "${no_proxy}"
- name: ubuntu2204-${CI_JOB_ID:-0}
image: code.europa.eu:4567/ecgalaxy/ubuntu2204-ansible:latest
pre_build_image: true
environment:
http_proxy: "${http_proxy}"
https_proxy: "${https_proxy}"
no_proxy: "${no_proxy}"
provisioner:
name: ansible
inventory:
group_vars:
all:
ansible_user: ansible
scenario:
test_sequence:
- dependency
- cleanup
- destroy
- create
- prepare
- converge
- cleanup
- destroy
verifier:
name: ansible
lint: |
set -e
yamllint .
ansible-lint .
---
- name: Prepare
hosts: all
roles:
- role: ecgalaxy.bootstrap
- role: ecgalaxy.common_packages
environment:
http_proxy: "{{ lookup('env', 'http_proxy') }}"
https_proxy: "{{ lookup('env', 'https_proxy') }}"
no_proxy: "{{ lookup('env', 'no_proxy') }}"
become: true
---
- ecgalaxy.bootstrap
- ecgalaxy.common_packages
......@@ -3,14 +3,18 @@
ansible.builtin.set_fact:
nodejs_version_major: "{{ nodejs_version | regex_replace('.x', '') }}"
- name: Setup
- name: Setup (RedHat)
ansible.builtin.include_tasks: setup-RedHat.yml
when: ansible_os_family == 'RedHat' and ansible_distribution != 'Amazon' and nodejs_version_major | int > 16
when: nodejs_download_url == '' and ansible_os_family == 'RedHat' and ansible_distribution != 'Amazon' and nodejs_version_major | int > 16
- name: Setup
- name: Setup (Amazon Linux 2)
ansible.builtin.include_tasks: setup-Amazon.yml
when: ansible_distribution == 'Amazon' and nodejs_version_major | int > 16
when: nodejs_download_url == '' and ansible_distribution == 'Amazon' and nodejs_version_major | int > 16
- name: Setup
- name: Setup (Debian)
ansible.builtin.include_tasks: setup-Debian.yml
when: ansible_os_family == 'Debian'
when: nodejs_download_url == '' and ansible_os_family == 'Debian'
- name: Setup (Generic Linux x64)
ansible.builtin.include_tasks: setup-generic.yml
when: nodejs_download_url | length > 0 and nodejs_checksum | length > 0 and nodejs_install_path | length > 0
---
- name: Install prerequisites
ansible.builtin.package:
name: xz
state: present
become: true
when: ansible_os_family == 'RedHat'
- name: Create directory
ansible.builtin.file:
state: directory
owner: root
group: root
mode: 'u=rwx,go=rx'
path: "{{ nodejs_install_path }}"
become: true
- name: Download Node.js artifact
ansible.builtin.get_url:
url: "{{ nodejs_download_url }}"
checksum: "{{ nodejs_checksum }}"
mode: 'u=rwx,go=rx'
dest: /tmp
register: downloaded_file
- name: Extract artifact
ansible.builtin.unarchive:
src: "{{ downloaded_file.dest }}"
dest: "{{ nodejs_install_path }}"
owner: "root"
group: "root"
mode: "u=rwx,go=rx"
remote_src: yes
extra_opts: ["--strip-components=1", "-J"]
become: true
- name: Create node symlink
ansible.builtin.file:
src: "{{ nodejs_install_path }}/bin/node"
dest: /usr/local/bin/node
owner: "root"
group: "root"
mode: 'u=rwx,go=rx'
state: link
become: true
- name: Create npm symlink
ansible.builtin.file:
src: "{{ nodejs_install_path }}/bin/npm"
dest: /usr/local/bin/npm
owner: "root"
group: "root"
mode: 'u=rwx,go=rx'
state: link
become: true
- name: Create npx symlink
ansible.builtin.file:
src: "{{ nodejs_install_path }}/bin/npx"
dest: /usr/local/bin/npx
owner: "root"
group: "root"
mode: 'u=rwx,go=rx'
state: link
become: true
- name: Create corepack symlink
ansible.builtin.file:
src: "{{ nodejs_install_path }}/bin/corepack"
dest: /usr/local/bin/corepack
owner: "root"
group: "root"
mode: 'u=rwx,go=rx'
state: link
become: true
- name: Clean up temporary files
ansible.builtin.file:
path: "{{ downloaded_file.dest }}"
state: absent
- name: Install yarn
community.general.npm:
name: yarn
global: true
executable: /usr/local/bin/npm
environment:
PATH: /usr/local/bin:{{ ansible_env.PATH }}
become: true
- name: Create yarn symlink
ansible.builtin.file:
src: "{{ nodejs_install_path }}/bin/yarn"
dest: /usr/local/bin/yarn
owner: "root"
group: "root"
mode: 'u=rwx,go=rx'
state: link
become: true
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment