-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add nodejs and npm to path via alternatives modules.
- Loading branch information
Showing
3 changed files
with
21 additions
and
15 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
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 |
---|---|---|
|
@@ -34,3 +34,4 @@ | |
force: yes | ||
|
||
- include: update_path.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 |
---|---|---|
@@ -1,20 +1,25 @@ | ||
# file: nodejs/tasks/update_path.yml | ||
|
||
- name: node.js | update_path | Add the node.js binary to the system path | ||
lineinfile: "dest={{item.dest}} regexp={{item.regexp}} line={{item.line}} state={{item.state}}" | ||
with_items: | ||
- { dest: "/etc/profile", regexp: "^NODE_HOME=/usr/local/nodejs/default", line: "NODE_HOME=/usr/local/nodejs/default", state: "present" } | ||
- { dest: "/etc/profile", regexp: "^PATH=.*NODE_HOME.*", line: "PATH=$PATH:$NODE_HOME/bin", state: "present" } | ||
- name: node.js | Add the node installation path to the system path | ||
lineinfile: | ||
dest: /etc/profile | ||
regexp: '^NODE_HOME={{ nodejs_directory }}/default' | ||
line: 'NODE_HOME={{ nodejs_directory }}/default' | ||
state: present | ||
|
||
- name: node.js | update_path | Inform the system where node is located and set this one as the default | ||
shell: "{{item}}" | ||
with_items: | ||
- 'update-alternatives --install "/usr/bin/node" "node" "/usr/local/nodejs/default/bin/node" 1' | ||
- 'update-alternatives --set node /usr/local/nodejs/default/bin/node' | ||
- 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 | ||
|
||
- name: node.js | update_path | Inform the system where npm is located and set this one as the default | ||
shell: "{{item}}" | ||
- name: node.js | Inform the system where the binaries are located and set as the default | ||
alternatives: | ||
name: "{{ item }}" | ||
path: "{{ nodejs_directory }}/default/bin/{{ item }}" | ||
link: "/usr/bin/{{ item }}" | ||
with_items: | ||
- 'update-alternatives --install "/usr/bin/npm" "npm" "/usr/local/nodejs/default/bin/npm" 1' | ||
- 'update-alternatives --set npm /usr/local/nodejs/default/bin/npm' | ||
- node | ||
- npm | ||
|