cookbook 'vagrant-node-simple', '= 0.1.1'
vagrant-node-simple (9) Versions 0.1.1 Follow2
A simple cookbook to deploy your NodeJS app on Vagrant Ubuntu
cookbook 'vagrant-node-simple', '= 0.1.1', :supermarket
knife supermarket install vagrant-node-simple
knife supermarket download vagrant-node-simple
Simple Chef Cookbook for NodeJS on Ubuntu 14.04 for Vagrant [complementary to OpsWorks NodeJS cookbook]
This recipe enables to deploy of a NodeJS app in your Vagrant box. It is complementary to Opsworks NodeJS cookebook for Opsworks deployment :
recipes vagrant-node-simple::deploy
,vagrant-node-simple::install
,vagrant-node-simple:start
are equivalent to opsworks_nodejs:default
, deploy:nodejs
, and parametrization of an Opsworks app is the same as the parametrization of the environment's JSON.
Usage :
Create your Chef repository with a Berksfile
, a Vagrantfile
and environments
and roles
directories :
- In the Berksfile
cookbook 'ark'
cookbook 'git'
cookbook 'apt', git: 'git://github.com/opscode-cookbooks/apt.git'
cookbook 'vagrant-node-simple', git: 'git://github.com/christopher5106/vagrant-node-simple.git'
- In environments/development.rb :
{ "name": "development", "description": "The master development branch", "cookbook_versions": {}, "json_class": "Chef::Environment", "chef_type": "environment", "default_attributes": {}, "override_attributes": { "environment":"development", "nodejs":{ "name":"YOUR_APP_NAME", "repo":"git@bitbucket.org:YOUR_ORG/YOUR_NODE_APP_REPO.git", "revision":"HEAD" } } }
- In roles/nodejs_role.rb :
name "my node app" description "The base role" run_list "recipe[git]","recipe[apt]","recipe[ark]","recipe[vagrant-node-simple::deploy]","recipe[vagrant-node-simple::install]","recipe[vagrant-node-simple:start]"
- In the Vagrantfile
VAGRANTFILE_API_VERSION = "2" Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| config.vm.box = "ubuntu/trusty64" config.vm.network "forwarded_port", guest: 3000, host: 3000 config.berkshelf.enabled = true; config.vm.provision :chef_solo do |chef| chef.cookbooks_path = "./" chef.roles_path = "roles" chef.environments_path = "environments" chef.environment = "development" chef.add_role("nodejs_role") end end
Add your node app repository deploy key
deploy.pem
to your repository and give it the right permissions (chmod 600 ./deploy.pem
).Commit your Chef repository.
You can Launch your instance with vagrant up
command.
In Opsworks,
create a stack with your Chef repository, Chef and Berkshelf enabled (no need for a custom JSON, everything will be in the app settings.)
create a NodeJS layer (you can also create a custom layer and add the recipe "opsworks_nodejs" to the setup step, the recipe "opsworks_nodejs::configure" to the configure step, and the recipe to "deploy::nodejs" to the deploy step).
create an app with the link to your YOUR_NODE_APP_REPO.
Launch your instance in Opsworks. Opsworks will deploy the code corresponding to the Branch/Revision specified in the app configuration, to the HEAD if not specified.
You can configure a hook in Github so that committed code will be automatically deployed in Opsworks.
Note : for your NodeJS app to work with Opsworks cookbook, you need a server.js file at the root of your YOUR_NODE_APP_REPO. Link
Dependent cookbooks
apt >= 0.0.0 |
git >= 0.0.0 |
Contingent cookbooks
There are no cookbooks that are contingent upon this one.
Foodcritic Metric
0.1.1 failed this metric
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/94d99087198717e82d3d57ab/vagrant-node-simple/attributes/default.rb:1
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/94d99087198717e82d3d57ab/vagrant-node-simple/attributes/default.rb:2
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/94d99087198717e82d3d57ab/vagrant-node-simple/attributes/default.rb:3
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/94d99087198717e82d3d57ab/vagrant-node-simple/recipes/deploy.rb:19
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/94d99087198717e82d3d57ab/vagrant-node-simple/recipes/deploy.rb:24
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/94d99087198717e82d3d57ab/vagrant-node-simple/recipes/deploy.rb:25
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/94d99087198717e82d3d57ab/vagrant-node-simple/recipes/deploy.rb:26
FC019: Access node attributes in a consistent manner: /tmp/cook/94d99087198717e82d3d57ab/vagrant-node-simple/attributes/default.rb:1
FC019: Access node attributes in a consistent manner: /tmp/cook/94d99087198717e82d3d57ab/vagrant-node-simple/attributes/default.rb:2
FC019: Access node attributes in a consistent manner: /tmp/cook/94d99087198717e82d3d57ab/vagrant-node-simple/attributes/default.rb:3
0.1.1 failed this metric
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/94d99087198717e82d3d57ab/vagrant-node-simple/attributes/default.rb:2
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/94d99087198717e82d3d57ab/vagrant-node-simple/attributes/default.rb:3
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/94d99087198717e82d3d57ab/vagrant-node-simple/recipes/deploy.rb:19
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/94d99087198717e82d3d57ab/vagrant-node-simple/recipes/deploy.rb:24
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/94d99087198717e82d3d57ab/vagrant-node-simple/recipes/deploy.rb:25
FC001: Use strings in preference to symbols to access node attributes: /tmp/cook/94d99087198717e82d3d57ab/vagrant-node-simple/recipes/deploy.rb:26
FC019: Access node attributes in a consistent manner: /tmp/cook/94d99087198717e82d3d57ab/vagrant-node-simple/attributes/default.rb:1
FC019: Access node attributes in a consistent manner: /tmp/cook/94d99087198717e82d3d57ab/vagrant-node-simple/attributes/default.rb:2
FC019: Access node attributes in a consistent manner: /tmp/cook/94d99087198717e82d3d57ab/vagrant-node-simple/attributes/default.rb:3