Skip to content

Commit

Permalink
Merge pull request #8 from industrialresolution/master
Browse files Browse the repository at this point in the history
A few small updates from my experience on CentOS and Debian machines
  • Loading branch information
grzegorznowak authored Dec 15, 2022
2 parents e6b4428 + fedb49e commit 844e6a0
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 3 deletions.
1 change: 1 addition & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
nvm_install_script_version: "0.33.11"
nvm_user_name: "root"
nvm_dir: "/var/lib/nvm" # for global installation
nvm_link_global: "yes"
nvm_node_version: "8.11.3"
nvm_install_globally: [] # libraries to add globally
# nvm_dir: "~" # for user installation -> isn't working yet however
8 changes: 8 additions & 0 deletions tasks/_symlink.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,18 @@
file_type: any
register: find_result

- name: Remove original global packages before symlink
file:
path: "/usr/bin/{{ item.path | basename }}"
state: absent
loop: "{{ find_result.files }}"
when: nvm_link_global == "yes"

- name: Symlink global packages into PATH for specific environments (like cron's) to be able to access them.
file:
src: "{{ item.path }}"
dest: "/usr/bin/{{ item.path | basename }}"
state: link
mode: "u+rwx,g+rx,o+rx"
loop: "{{ find_result.files }}"
when: nvm_link_global == "yes"
20 changes: 17 additions & 3 deletions tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
---
- include: setup-Redhat.yml
- include_tasks: setup-Redhat.yml
when: ansible_os_family == "RedHat"

- include: setup-Debian.yml
- include_tasks: setup-Debian.yml
when: ansible_os_family == "Debian"

# make it so that anyone can use it!
- name: Create the target VNM dir
- name: Create the target NVM dir
file: path="{{ nvm_dir }}" state=directory owner="{{ nvm_user_name }}" mode="o+rwx"

# variablize the name of the installation script so it fire installation script properly when
Expand Down Expand Up @@ -40,13 +40,27 @@
[ -s \"$NVM_DIR/bash_completion\" ] && \. \"$NVM_DIR/bash_completion\""
when: ansible_os_family == "RedHat"

- name: Remove original node binary before symlink
file:
path: "/usr/bin/node"
state: absent
when: nvm_link_global == "yes"

- name: Make the node binary always discoverable by symlinking to a system bin PATH that cron sees by default too
file: src="{{ nvm_dir }}/versions/node/v{{ nvm_node_version }}/bin/node"
dest="/usr/bin/node" state=link mode="u+rwx,g+rx,o+rx"
when: nvm_link_global == "yes"

- name: Remove original npm binary before symlink
file:
path: "/usr/bin/npm"
state: absent
when: nvm_link_global == "yes"

- name: Make the npm binary always discoverable by symlinking to a system bin PATH that cron sees by default too
file: src="{{ nvm_dir }}/versions/node/v{{ nvm_node_version }}/bin/npm"
dest="/usr/bin/npm" state=link mode="u+rwx,g+rx,o+rx"
when: nvm_link_global == "yes"

### ---- Install version-agnostic and version-aware version of globals ---- ###
### TODO: DRY it some way smart
Expand Down

0 comments on commit 844e6a0

Please sign in to comment.