-
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.
Added binary installation option to download pre-compiled code.
- Loading branch information
Showing
8 changed files
with
85 additions
and
34 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 |
---|---|---|
@@ -1,6 +1,15 @@ | ||
# file: nodejs/defaults/main.yml | ||
|
||
nodejs_install_method: "source" | ||
nodejs_version: "0.10.26" | ||
nodejs_url: "http://nodejs.org/dist/v{{nodejs_version}}/node-v{{nodejs_version}}.tar.gz" | ||
nodejs_prefix: "/usr/local/nodejs/node-v{{nodejs_version}}" | ||
#nodejs_install_method : "source" | ||
#nodejs_version : "0.10.26" | ||
|
||
nodejs_install_method : "binary" | ||
nodejs_version : "0.11.13" | ||
|
||
nodejs_directory : "/usr/local/nodejs" | ||
nodejs_source_url : "http://nodejs.org/dist/v{{nodejs_version}}/node-v{{nodejs_version}}.tar.gz" | ||
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 : "http://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')}}" |
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,26 @@ | ||
# file: nodejs/tasks/binary.yml | ||
|
||
- name: node.js | binary | Make sure that the directory to hold the node.js binaries exists | ||
file: | ||
path: "{{nodejs_binary_prefix}}" | ||
state: directory | ||
recurse: yes | ||
mode: 0755 | ||
|
||
- name: node.js | binary | Download the node.js binary for your distribution | ||
get_url: | ||
url: "{{nodejs_binary_url}}" | ||
dest: "/tmp/node-v{{nodejs_version}}.tar.gz" | ||
|
||
- name: node.js | binary | Unpack the node.js package | ||
unarchive: src="/tmp/node-v{{nodejs_version}}.tar.gz" dest="/usr/local/nodejs" copy=no | ||
|
||
- name: node.js | binary | Update the symbolic link to the node.js install | ||
file: | ||
path: "{{nodejs_directory}}/default" | ||
src: "{{nodejs_binary_prefix}}" | ||
state: link | ||
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
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,52 +1,36 @@ | ||
# file: nodejs/tasks/source.yml | ||
|
||
- name: node.js | Make sure that the directory to hold the node.js binaries exists | ||
- name: node.js | source | Make sure that the directory to hold the node.js binaries exists | ||
file: | ||
path: /usr/local/nodejs | ||
path: "{{nodejs_directory}}" | ||
state: directory | ||
recurse: yes | ||
mode: 0755 | ||
|
||
- name: node.js | Download the node.js source | ||
- name: node.js | source | Download the node.js source | ||
get_url: | ||
url: "{{nodejs_url}}" | ||
dest: "/tmp/node-v{{nodejs_version}}.tar.gz" | ||
|
||
- name: node.js | Unpack the node.js source | ||
- name: node.js | source | Unpack the node.js source | ||
shell: tar -xvzf /tmp/node-v{{nodejs_version}}.tar.gz chdir=/tmp creates=/tmp/node-v{{nodejs_version}} | ||
|
||
- name: node.js | Get the number of processors | ||
- name: node.js | source |Get the number of processors | ||
command: nproc | ||
register: cpu_count | ||
|
||
- name: node.js | Build node.js from source | ||
- name: node.js | source | Build node.js from source | ||
shell: > | ||
cd /tmp/node-v{{nodejs_version}} && | ||
./configure --prefix={{nodejs_prefix}} && | ||
./configure --prefix={{nodejs_source_prefix}} && | ||
make -j {{cpu_count.stdout}} && | ||
sudo make install | ||
- name: node.js | Update the symbolic link to the node.js install | ||
- name: node.js | source | Update the symbolic link to the node.js install | ||
file: | ||
path: /usr/local/nodejs/default | ||
src: "{{nodejs_prefix}}" | ||
path: "{{nodejs_directory}}/default" | ||
src: "{{nodejs_source_prefix}}" | ||
state: link | ||
force: yes | ||
|
||
- name: node.js | 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 | 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: node.js | Inform the system where npm is located and set this one as the default | ||
shell: "{{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' | ||
- 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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# 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 | 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: node.js | update_path | Inform the system where npm is located and set this one as the default | ||
shell: "{{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' | ||
|
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,4 +1,6 @@ | ||
--- | ||
- hosts: all | ||
sudo: True | ||
vars_files: | ||
- 'defaults/main.yml' | ||
tasks: | ||
|