-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add fnm role and update linux runner path to look in .fnm (#391)
- Loading branch information
1 parent
36846a8
commit 96327eb
Showing
8 changed files
with
104 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
user: ubuntu | ||
group: ubuntu | ||
|
||
fnm_version: v1.37.2 | ||
|
||
# Optional, will skip installing any version if left empty | ||
fnm_install_node_version: "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
- name: Check if a file exists with a wildcard pattern | ||
stat: | ||
path: /home/ubuntu/.fnm/node-versions/v{{ fnm_install_node_version }}* | ||
register: fnm_version_check | ||
|
||
- ansible.builtin.debug: | ||
var: fnm_version_check | ||
|
||
- name: Install desired version of node | ||
become: yes | ||
become_user: "{{ user }}" | ||
ansible.builtin.command: fnm install {{ fnm_install_node_version }} --fnm-dir /home/{{ user }}/.fnm | ||
when: not fnm_version_check.stat.exists | ||
|
||
- name: Set default version of node | ||
become: yes | ||
become_user: "{{ user }}" | ||
ansible.builtin.command: fnm default {{ fnm_install_node_version }} --fnm-dir /home/{{ user }}/.fnm | ||
args: | ||
creates: /home/{{ user }}/.fnm/aliases/default/bin/node |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
--- | ||
- name: Load architecture specific vars | ||
ansible.builtin.include_vars: "{{ lookup('first_found', params) }}" | ||
vars: | ||
params: | ||
files: | ||
- '{{ansible_architecture}}.yml' | ||
paths: | ||
- 'vars' | ||
|
||
- name: Install Common Deps | ||
become: true | ||
ansible.builtin.apt: | ||
name: | ||
- xz-utils | ||
state: present | ||
update_cache: true | ||
cache_valid_time: 300 | ||
register: apt_action | ||
retries: 100 | ||
until: apt_action is success or ('Failed to lock apt for exclusive operation' not in apt_action.msg and '/var/lib/dpkg/lock' not in apt_action.msg) | ||
|
||
- name: Download the FNM release binary | ||
become: yes | ||
become_user: "{{ user }}" | ||
get_url: | ||
url: https://github.com/Schniz/fnm/releases/download/{{ fnm_version }}/fnm-{{ fnm_suffix }}.zip | ||
dest: "/home/{{ user }}/fnm-{{ fnm_version }}.zip" | ||
mode: 0644 | ||
|
||
- name: Unarchive FNM | ||
become: yes | ||
become_user: "{{ user }}" | ||
ansible.builtin.unarchive: | ||
src: "/home/{{ user }}/fnm-{{ fnm_version }}.zip" | ||
dest: "/usr/local/bin/" | ||
remote_src: yes | ||
creates: "/usr/local/bin/fnm" | ||
|
||
- name: Ensure FNM has the correct permissions | ||
become: yes | ||
ansible.builtin.file: | ||
path: "/usr/local/bin/fnm" | ||
state: file | ||
mode: '0755' | ||
|
||
- name: Ensure fnm is configured in the shell | ||
become: yes | ||
become_user: "{{ user }}" | ||
ansible.builtin.lineinfile: | ||
path: /home/ubuntu/.bashrc | ||
search_string: 'fnm env' | ||
line: 'eval "$(fnm env --fnm-dir /home/{{ user }}/.fnm)"' | ||
owner: ubuntu | ||
group: ubuntu | ||
mode: '0644' | ||
|
||
- name: Install node | ||
when: fnm_install_node_version != "" | ||
ansible.builtin.include_tasks: "install-node.yml" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
--- | ||
fnm_suffix: "arm64" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
--- | ||
fnm_suffix: "linux" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,3 +21,4 @@ runner_post_run_exclusions: | |
- .bash_logout | ||
- .bashrc | ||
- .profile | ||
- .fnm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/home/ubuntu/.fnm/aliases/default/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin |