Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 5 additions & 9 deletions Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,9 @@ Vagrant.configure(2) do |config|
# Enable provisioning with a shell script. Additional provisioners such as
# Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the
# documentation for more information about their specific syntax and use.
config.vm.provision "shell", inline: <<-SHELL
sudo apt-get update
# Needed installations
sudo apt-get install -y git
sudo apt-get install -y nodejs
sudo apt-get install -y npm
# Needed npm global modules
sudo npm install -g node-inspector forever
SHELL

config.vm.provision "ansible" do |ansible|
ansible.playbook = "provisioning/playbook.yml"
end

end
9 changes: 9 additions & 0 deletions provisioning/playbook.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

---

- name: apply common configuration to all nodes
hosts: all

roles:
- common
- nodejs
Empty file.
10 changes: 10 additions & 0 deletions provisioning/roles/common/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
# This playbook contains common plays that will be run on all nodes.

- name: Update repositories
apt: update_cache=yes
sudo: yes

- name: Git
apt: name=git state=installed
sudo: yes
Empty file.
Empty file.
41 changes: 41 additions & 0 deletions provisioning/roles/nodejs/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
---
# This playbook install and update nodejs

- name: Nodejs + npm + curl
apt: name={{item}} state=installed
with_items:
- nodejs
- npm
- curl
sudo: yes

- name: Checking installed version of node.js ({{ node.version }})
shell: /usr/bin/test `node -v` = v{{ node.version }} && echo True
register: nodeversion
ignore_errors: yes

- name: npm install -g n
npm: name=n global=yes registry=http://registry.npmjs.org/
sudo: yes
when: nodeversion|failed

- name: Install last nodejs version ({{ node.version }})
shell: n {{ node.version }}
sudo: yes
when: nodeversion|failed

- name: Create symlinks
file: src=/usr/local/n/versions/node/{{ node.version }}/bin/{{ item.src }} dest=/usr/bin/{{ item.dest }} state=link force=yes
with_items:
- { src: 'npm', dest: 'npm' }
- { src: 'node', dest: 'node' }
- { src: 'node', dest: 'nodejs' }
sudo: yes
when: nodeversion|failed

- name: NPM packages
npm: name={{ item }} global=yes
with_items:
- node-inspector
- forever
sudo: yes
Empty file.
2 changes: 2 additions & 0 deletions provisioning/roles/nodejs/vars/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node:
version: 0.12.7