Skip to content
Browse files

Merge branch 'nvm-config'

# Conflicts:
#	README.md
#	TODOLIST.md
#	Vagrantfile
#	provision/puppet/manifests/main.pp
#	provision/puppet/modules/nodejs/manifests/init.pp
  • Loading branch information...
2 parents 6c991d4 + 42ce3ca commit ec95cde9b6948b6e3ecbce2b30a07edacf74b713 @mikemimik mikemimik committed
Showing with 114 additions and 53 deletions.
  1. +4 −1 .gitignore
  2. +18 −26 README.md
  3. +13 −0 TODO.md
  4. +6 −6 Vagrantfile
  5. +27 −5 provision/puppet/manifests/main.pp
  6. +46 −15 provision/puppet/modules/nodejs/manifests/init.pp
View
5 .gitignore
@@ -31,4 +31,7 @@ freecodecamp
typings
# Vagrant directory
-.vagrant
+.vagrant
+
+# Working directory
+freecodecamp/
View
44 README.md
@@ -1,29 +1,21 @@
-# README
+#README
- This repo is currently incomplete (Updated: 2015-06-05)
+
+##Pre-req
+ - Install [Vagrant](https://www.vagrantup.com/downloads.html)
+ - Select the OS that you're working with
+ - Download and run the installer
+ - Install [hostmanager](https://github.com/smdahlen/vagrant-hostmanager) vagrant plugin
+ - Open a terminal window in which ever OS you're working in
+ - Enter the command `vagrant plugin install vagrant-hostmanager`
-## Pre-req
- - Vagrant installed
- - hostmanager vagrant plugin installed
-
-## Vagrant Flow
-- Vagrant will spin up Ubuntu 14.04 (trusty64)
-- Vagrant will create sync folder
- - Sync:: ./freecodecamp -> /home/vagrant/developer/freecodecamp
+##Repo Flow
- Vagrantfile for FreeCodeCamp
- - Puppet:: apt-get update
- - Puppet:: othertools
- - Puppet:: nodejs
- - Puppet:: mongodb
- - Puppet:: corefcc
- - Puppet:: git clone fcc
- - Puppet:: ownership node/npm
- - Puppet:: limit npm jobs
- - Puppet:: npm install -g babel@5.8.29
- - Puppet:: npm install --loglevel silent
- - Puppet:: npm install -g gulp
- - Puppet:: npm install -g bower
- - Puppet:: bower install
- - Puppet:: env-file -> developer/freecodecamp
- - Puppet:: run seeding
-
-npm config jobs
+ - Vagrant will spin up Ubuntu 14.04 (Trusty)
+ - Machine will be provisioned by puppet
+ - Puppet:: Node.js
+ - Puppet:: MongoDB
+ - Puppet:: Tools (Git, Vim, Curl, HTOP)
+ - Puppet:: Ruby, G++, Build-Essentials
+ - Vagrant will create sync folder
+ - Sync:: ./freecodecamp -> /home/fccuser/developer/freecodecamp
View
13 TODO.md
@@ -0,0 +1,13 @@
+#LIST OF THINGS
+
+###Short Term
+- update README.md
+ - update repo flow list
+ - create 'how to use' section
+
+###Mid Term
+
+###Long Term
+
+####NOTES
+- must have hostmanager vagrant plugin installed (add to readme)
View
12 Vagrantfile
@@ -4,12 +4,12 @@
Vagrant.configure(2) do |config|
config.vm.box = "ubuntu/trusty64"
config.vm.hostname = "dev-freecodecamp"
- config.vm.boot_timeout = 400
+ config.vm.boot_timeout = 900
# Disable automatic box update checking. If you disable this, then
# boxes will only be checked for updates when the user runs
# `vagrant box outdated`. This is not recommended.
- config.vm.box_check_update = true
+ config.vm.box_check_update = false
# Hostmanager plugin must be installed with vagrant
# for these commands to work. Check README.md for
@@ -36,7 +36,7 @@ Vagrant.configure(2) do |config|
# the path on the host to the actual folder. The second argument is
# the path on the guest to mount the folder. And the optional third
# argument is a set of non-required options.
- config.vm.synced_folder "./freecodecamp", "/home/vagrant/development/freecodecamp", create: true
+ config.vm.synced_folder "./freecodecamp", "/home/vagrant/freecodecamp", create: true
# Provider-specific configuration so you can fine-tune various
# backing providers for Vagrant. These expose provider-specific options.
@@ -46,8 +46,8 @@ Vagrant.configure(2) do |config|
vb.name = "fcc-box"
vb.gui = false
vb.cpus = 1
- vb.customize ["modifyvm", :id, "--cpuexecutioncap", "100"]
- vb.memory = "2048"
+ vb.customize ["modifyvm", :id, "--cpuexecutioncap", "75"]
+ vb.memory = "512"
end
config.vm.provision "puppet" do |puppet|
@@ -59,4 +59,4 @@ Vagrant.configure(2) do |config|
'--debug',
]
end
-end
+end
View
32 provision/puppet/manifests/main.pp
@@ -1,7 +1,7 @@
# class user_creation {
# $pass = "password"
# $salt = "somesalt"
-#
+
# user { "fccuser":
# name => 'fccuser', # redundant
# ensure => 'present',
@@ -19,8 +19,7 @@
class apt_update {
exec { "aptGetUpdate":
command => "sudo apt-get update",
- path => ["/bin", "/usr/bin"],
- timeout => 0
+ path => ["/bin", "/usr/bin"]
}
}
@@ -37,10 +36,33 @@
class {'::mongodb::client': }
}
+# List out provisioning stages
+stage { 'pre':
+ before => Stage['main']
+}
+stage { 'post': }
+Stage['main'] -> Stage['post']
+
+# List classes in stages
+class { 'apt_update':
+ stage => pre
+}
+class { 'othertools':
+ stage => pre
+}
+class { 'nodejs':
+ stage => main
+}
+class { 'mongodb':
+ stage => main
+}
+class { 'freecodecamp':
+ stage => post
+}
-#include user_creation
include apt_update
include othertools
include nodejs
include mongodb
-include corefcc
+include freecodecamp
+#include user_creation
View
61 provision/puppet/modules/nodejs/manifests/init.pp
@@ -1,21 +1,52 @@
class nodejs {
- exec { "git_clone_n":
- command => "git clone https://github.com/visionmedia/n.git /home/vagrant/n",
- path => ["/bin", "/usr/bin"],
- onlyif => ['test ! -d /home/vagrant/n'],
- require => [Exec["aptGetUpdate"], Package["git"], Package["curl"], Package["g++"]]
+ include stdlib
+
+ $bin = '/usr/local/bin:/usr/bin:/bin'
+ $user = 'vagrant'
+
+ # Get nvm and pipe to bash shell to run script
+ # INFO: Will install as root
+ # INFO: install dir is /.nvm
+ exec { 'nodejs::install_nvm':
+ user => $user,
+ command => 'curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.29.0/install.sh | NVM_DIR=/home/vagrant/.nvm bash',
+ path => $bin,
+ require => [Package['git'], Package['curl']]
+ }
+
+ # Use nvm to install node
+ exec { 'nodejs::nvm_install_node':
+ user => $user,
+ command => "bash -c 'source /home/vagrant/.nvm/nvm.sh ; nvm install 4.2.2'",
+ path => $bin,
+ # unless => "bash -c 'source /home/vagrant/.nvm/nvm.sh ; nvm list | grep node | grep v4.2.2'",
+ logoutput => on_failure,
+ require => [Exec['nodejs::install_nvm']]
}
- exec { "install_n":
- command => "make install",
- path => ["/bin", "/usr/bin"],
- cwd => "/home/vagrant/n",
- require => Exec["git_clone_n"]
+ # use nvm node version
+ exec { 'nodejs::nvm_use_node':
+ user => $user,
+ command => "bash -c 'source /home/vagrant/.nvm/nvm.sh ; nvm use v4.2.2'",
+ path => $bin,
+ # unless => "bash -c 'source /home/vagrant/.nvm/nvm.sh ; nvm list | grep node | grep v4.2.2'",
+ logoutput => on_failure,
+ require => [Exec['nodejs::nvm_install_node']]
}
- exec { "install_node":
- command => "n 4.2.1",
- path => ["/bin", "/usr/bin", "/usr/local/bin"],
- require => [Exec["git_clone_n"], Exec["install_n"]]
+ # Add nvm to .bashrc
+ file_line { 'nodejs::nvm_profile_config_env':
+ path => '/home/vagrant/.bashrc',
+ # line => 'export NVM_DIR="$NVM_DIR"',
+ line => 'export NVM_DIR="/home/vagrant/.nvm"',
+ require => [Exec['nodejs::nvm_install_node']]
+ }->
+ file_line { 'nodejs::nvm_profile_config_path':
+ path => '/home/vagrant/.bashrc',
+ line => '[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm'
+ }->
+ file_line { 'nodejs::nvm_profile_config_path_node':
+ path => '/home/vagrant/.bashrc',
+ line => 'export PATH=$PATH:/home/vagrant/.nvm/versions/node/v4.2.2/bin'
}
-}
+}

0 comments on commit ec95cde

Please sign in to comment.
Something went wrong with that request. Please try again.