Skip to content

Commit

Permalink
Merge pull request #24 from mtpereira/alternatives
Browse files Browse the repository at this point in the history
Alternatives
  • Loading branch information
otakup0pe committed Apr 30, 2016
2 parents c4586b4 + beeca72 commit 404d1a7
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 20 deletions.
4 changes: 3 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ before_install:
- sudo apt-get update -qq
- sudo apt-get install -qq python-apt python-pycurl
install:
- pip install ansible==1.5.0
- pip install ansible==1.8.4
script:
- echo localhost > inventory
- mkdir -p ~/roles/
- ansible-galaxy install -r requirements.yml
- ansible-playbook -i inventory -e nodejs_install_method=binary test.yml --syntax-check
- ansible-playbook -i inventory -e nodejs_install_method=binary test.yml --connection=local --sudo
- >
Expand Down
2 changes: 2 additions & 0 deletions ansible.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[defaults]
roles_path = ~/roles/
4 changes: 4 additions & 0 deletions requirements.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
- src: ANXS.build-essential
version: master

1 change: 1 addition & 0 deletions tasks/source.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,4 @@
force: yes

- include: update_path.yml

33 changes: 19 additions & 14 deletions tasks/update_path.yml
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

10 changes: 5 additions & 5 deletions test.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
- hosts: all
sudo: True
vars_files:
- 'defaults/main.yml'
tasks:
- include: 'tasks/main.yml'
sudo: yes

roles:
- .

0 comments on commit 404d1a7

Please sign in to comment.