Skip to content

Commit

Permalink
only maybe handle system paths, allowing installation as non-root
Browse files Browse the repository at this point in the history
  • Loading branch information
otakup0pe committed Jan 17, 2018
1 parent af85389 commit 2da9c1f
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
2 changes: 2 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,5 @@ nodejs_source_prefix : "{{nodejs_directory}}/node-v{{nodejs_version}}"
# possible achitectures: darwin-x64, darwin-x86, linux-x64, linux-x86, sunos-x64, sunos-x86
nodejs_binary_url : "https://nodejs.org/dist/v{{nodejs_version}}/node-v{{nodejs_version}}-{{ansible_system | lower}}-x{{ansible_userspace_bits |replace('32', '86')}}.tar.gz"
nodejs_binary_prefix : "{{nodejs_directory}}/node-v{{nodejs_version}}-{{ansible_system | lower}}-x{{ansible_userspace_bits |replace('32', '86')}}"

nodejs_system_paths: true
4 changes: 2 additions & 2 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
when: nodejs_install_method == "package"

- name: node.js | Check if the node version is already installed
command: node --version
command: "{{nodejs_directory}}/node-v{{nodejs_version}}/bin/node --version"
ignore_errors: yes
register: node_version
changed_when: node_version.rc != 0 or node_version.stdout != "v{{ nodejs_version }}"
changed_when: node_version.rc != 0 or node_version.stdout.find(nodejs_version) < 0
when: nodejs_install_method == "source" or nodejs_install_method == "binary"

- include: source.yml
Expand Down
2 changes: 1 addition & 1 deletion tasks/source.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
cd /tmp/node-v{{nodejs_version}} &&
./configure --prefix={{nodejs_source_prefix}} &&
make -j {{cpu_count.stdout}} &&
sudo make install
make install
- name: node.js | source | Update the symbolic link to the node.js install
file:
Expand Down
4 changes: 3 additions & 1 deletion tasks/update_path.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@
regexp: '^NODE_HOME={{ nodejs_directory }}/default'
line: 'NODE_HOME={{ nodejs_directory }}/default'
state: present
when: nodejs_system_paths

- name: mode.js | Add the node binary path to the system path
lineinfile:
dest: /etc/profile
regexp: '^PATH=.*NODE_HOME.*'
line: 'PATH=$PATH:$NODE_HOME/bin'
state: present
when: nodejs_system_paths

- name: node.js | Inform the system where the binaries are located and set as the default
alternatives:
Expand All @@ -22,4 +24,4 @@
with_items:
- node
- npm

when: nodejs_system_paths

0 comments on commit 2da9c1f

Please sign in to comment.