Adoptable Cookbooks List

Looking for a cookbook to adopt? You can now see a list of cookbooks available for adoption!
List of Adoptable Cookbooks

Supermarket Belongs to the Community

Supermarket belongs to the community. While Chef has the responsibility to keep it running and be stewards of its functionality, what it does and how it works is driven by the community. The chef/supermarket repository will continue to be where development of the Supermarket application takes place. Come be part of shaping the direction of Supermarket by opening issues and pull requests or by joining us on the Chef Mailing List.

Select Badges

Select Supported Platforms


nodestack (6) Versions 2.4.1

Installs/Configures nodestack

cookbook 'nodestack', '~> 2.4.1'
cookbook 'nodestack', '~> 2.4.1', :supermarket
knife supermarket install nodestack
knife supermarket download nodestack
Quality 75%

nodestack Cookbook

This cookbook deploys a NodeJS applitcation stack.



  • apt
  • mysql
  • mysql-multi
  • database
  • chef-sugar
  • apt
  • mysql-multi
  • pg-multi
  • database
  • chef-sugar
  • elasticsearch
  • apache2, ~> 1.10
  • memcached
  • openssl
  • redisio
  • varnish
  • rackspace_gluster
  • platformstack
  • mongodb
  • build-essential
  • java
  • yum
  • git
  • nodejs
  • ssh_known_hosts
  • application
  • magic_shell
  • logrotate


Note: the 'my_nodejs_app' defines the name of the app, please change this to something more relevant to the customer.

node['nodestack']['apps']['my_nodejs_app']['app_dir'] path where the application will be deployed

node['nodestack']['apps']['my_nodejs_app']['git_repo'] Git repository where the code lives.

node['nodestack']['apps']['my_nodejs_app']['git_rev'] Code revision or branch that should be used ('origin/' should not be specified for remote branches.) Example: HEAD

node['nodestack']['apps']['my_nodejs_app']['git_repo_domain'] The domain name for the git repo. Example:

node['nodestack']['apps']['my_nodejs_app']['entry_point'] the .js file that will be ran as the server.

node['nodestack']['apps']['my_nodejs_app']['npm'] true/false - Wether we should run npm install during a deployment.

node['nodestack']['apps']['my_nodejs_app']['npm_options'] Array - NPM command line options to use for the application. '--production' should usually be included unless development is being done on the server.

node['nodestack']['apps']['my_nodejs_app']['config_file'] true/false - Wether the coobook will write a config.js from the following config hash.

node['nodestack']['apps']['my_nodejs_app']['env']= {} - This config hash contains environment variables that will be available to the application.

node['nodestack']['apps']['my_nodejs_app']['env']['PORT'] This is the only env attribute the cookbook expects to have by default, this is the port the app listens on.

node['nodestack']['apps']['my_nodejs_app']['monitoring']['body'] Text that will be matched from the GET request

node['nodestack']['apps']['my_nodejs_app']['deployment']['before_symlink'] Exposes the before_symlink attribute for the application resource. Set this to nil if you're not planning on using it.

node['nodestack']['apps']['my_nodejs_app']['deployment']['before_symlink_template'] Template file that will be dropped on the revision folder that will be ran by the before_symlink callback. Set this to nil if you're not planning on using it.

node['nodestack']['apps']['my_nodejs_app']['deployment']['template_options'] Hash of values that can be used in the before_symlink_template.

node['nodestack']['apps']['my_nodejs_app']['deployment']['strategy'] This is the strategy that will be used to run the Node.js application. Currently Nodestack only supports forever. Scroll further down to the deployment strategy section to read more about this.

node['nodestack']['apps']['my_nodejs_app']['open_files'] This sets the application user's file open limit (ulimit -n) - this is useful for upping the total number of concurrent websockets.

node['nodestack']['forever']['watch_ignore_patterns'] = ['*.log', '*.logs'] This is a list of patterns that will be ignored and not watched by forever-monitor. Forever-monitor watches the code directory (in the demo app /var/app/current) and will reload the application if it notices any changes in the files.

node['nodestack']['code_deployment'] This enables or disabled code deployment.

Deployment strategy

In the near future, nodestack may support more than one deployment strategy, for now it only supports forever.


With this deployment strategy, we use whatever init system is running on the OS to start/stop a service that starts a very simple Node.js app that starts forever-monitor.

This application will monitor and supervise the Node.js application the application being deployed. Forever-monitor will monitor any changes on the application files and reload itself if it finds any changes. It will also control the logging and the pids for the child process. There's also other options that can be implemented in the future, like the amount of child processes.

Code deployment is optional.

Nodestack can be deployed on a server without the deploying an application. Please note that the deployment strategy used will need to consider installing dependencies through NPM and starting/stopping the application. Some of these could be handled on a wrapper cookbook if so desired.

To make code deployment optional you need to set the following attribute node['nodestack']['code_deployment'] = false

Encrypted Data Bags

This cookbook uses encrypted databags to fill in the config.js file for the application. This config.js file is where you would usually include credentials for third party services, API keys, database passwords, etc. The data bag also stores the deployment private key. The top level key in the databag represents the environment.

Example of the contents of a databag:

  "id": "config",
  "staging": {
    "ssh_deployment_key": "-----BEGIN RSA PRIVATE KEY-----\Ia+q5KO/FfGc2pD2bt2Vh9Tjg==\n-----END RSA PRIVATE KEY-----",
    "config": {
      "mysql": {
        "password": "randompass"
      "mongo": {
        "host": "",
        "port": 27027

Attributes expected from an encrypted databag:

config = {} Configuration hash with all the information that the application needs

ssh_deployment_key ='' SSH private key for deployment.

It's important to name the databag with the app_name and then _databag


To deploy an app node these is how a nodejs_app role would look like: text $ knife role show nodejs_app chef_type: role default_attributes: description: env_run_lists: json_class: Chef::Role name: nodejs_app override_attributes: run_list: recipe[platformstack::default] recipe[rackops_rolebook::default] recipe[nodestack::application_nodejs]

To deploy a standalone db for an app node these is how a nodejs_mysql role would look like: text $ knife role show nodejs_mysql chef_type: role default_attributes: description: env_run_lists: json_class: Chef::Role name: nodejs_mysql override_attributes: run_list: recipe[platformstack::default] recipe[rackops_rolebook::default] recipe[nodestack::mysql_base]

To deploy a mongo node these is how a nodejs_mongo role would look like: text $ knife role show nodejs_mongo chef_type: role default_attributes: description: env_run_lists: json_class: Chef::Role name: nodejs_mongo override_attributes: run_list: recipe[platformstack::default] recipe[rackops_rolebook::default] recipe[nodestack::mongodb_standalone]

These are the minimum environment variables that would be needed: text $ knife environment show nodejs chef_type: environment cookbook_versions: default_attributes: description: json_class: Chef::Environment name: nodejs override_attributes: mysql: server_root_password: randompass mysql-multi: master: 10.x.x.x nodestack: app_name: beer_survey git_repo: platformstack: cloud_backup: enabled: false cloud_monitoring: enabled: false rackspace: cloud_credentials: api_key: xxx username: xxx

  • Building MySQL cluster for nodestack.

Ensure the following attributes are set within environment or wrapper cookbook.

['mysql']['server_repl_password'] = 'rootlogin'
['mysql']['server_repl_password'] = 'replicantlogin'
['mysql-multi']['master'] = ''
['mysql-multi']['slaves'] = ['']

MySQL Master node: text $ knife role show nodejs_mysql_master chef_type: role default_attributes: description: env_run_lists: json_class: Chef::Role name: nodejs_mysql_master override_attributes: run_list: recipe[platformstack::default] recipe[rackops_rolebook::default] recipe[nodestack::mysql_master]

MySQL Slave node: text $ knife role show nodejs_mysql_slave chef_type: role default_attributes: description: env_run_lists: json_class: Chef::Role name: nodejs_mysql_slave override_attributes: run_list: recipe[platformstack::default] recipe[rackops_rolebook::default] recipe[nodestack::mysql_slave]

  • Building a PostgreSQL cluster for nodestack.

Ensure the following attributes are set within environment or wrapper cookbook.

['postgresql']['version'] = '9.3'
['postgresql']['password'] = 'postgresdefault'
['pg-multi']['replication']['password'] = 'useagudpasswd'
['pg-multi']['master_ip'] = ''
['pg-multi']['slave_ip'] = ['']

Depending on OS one of the following two must be set:
['postgresql']['enable_pdgd_yum'] = true  (Redhat Family)
['postgresql']['enable_pdgd_apt'] = true  (Debian Family)

PostgreSQL Master node: text $ knife role show nodejs_postgresql_master chef_type: role default_attributes: description: env_run_lists: json_class: Chef::Role name: nodejs_postgresql_master override_attributes: run_list: recipe[platformstack::default] recipe[rackops_rolebook::default] recipe[nodestack::postgresql_master]

PostgreSQL Slave node: text $ knife role show nodejs_postgresql_slave chef_type: role default_attributes: description: env_run_lists: json_class: Chef::Role name: nodejs_postgresql_slave override_attributes: run_list: recipe[platformstack::default] recipe[rackops_rolebook::default] recipe[nodestack::postgresql_slave]

  • Adding an Nginx proxy in front of your Nodejs App.

See nodestack::demo.rb for an example of the attributes. Simply set the attributes similar to below, and then include nodestack::nginx

Here is a realistic scenario:

['nginx']['source']['modules'] = %w(
['nodestack']['nginx']['confd']['http_directives']['cookbook']     = 'nodestack'
['nodestack']['nginx']['confd']['http_directives']['template']     = "nginx/nodestack_http_directives.erb"
['nodestack']['nginx']['confd']['http_directives']['variables'] = {}

site = 'nodestack-demo'
port = '80'
['nodestack']['nginx']['sites']['80']['my_proxy_site']['cookbook']     = 'nodestack'
['nodestack']['nginx']['sites']['80']['my_proxy_site']['template']     = 'nginx/nodestack-demo.conf.erb'
['nodestack']['nginx']['sites']['80']['my_proxy_site']['variables'] = {
  server_name: '',
  server_aliases: [''],
  proxy_pass: ''

indlude 'nodestack::nginx'

PostgreSQL Master node:
$ knife role show nodejs_postgresql_master
chef_type:           role
json_class:          Chef::Role
name:                nodejs_postgresql_master

Cloud Monitoring

To enable monitoring you need to set node['platformstack']['cloud_monitoring']['enabled'] = true. This will setup the OS monitors like filesystem, CPU, memory, networking, etc.

To enable HTTP checks for a Node.js app deployed with Nodestack, set the node['nodestack']['cloud_monitoring']['remote_http']['disabled'] = false.

default['nodestack']['cloud_monitoring']['remote_http']['disabled'] Enable/disable remote HTTP monitoring. default['nodestack']['cloud_monitoring']['remote_http']['alarm'] Enable/disable alarm notifications. default['nodestack']['cloud_monitoring']['remote_http']['period'] Seconds value on how often the check will be performed. default['nodestack']['cloud_monitoring']['remote_http']['timeout'] Seconds value on the timeout before the check fails.

New Relic Monitoring

To configure New Relic, make sure the node['newrelic']['license'] attribute is set and include the platformstack cookbook in your run_list.

New Relic monitoring plugins can be configured by including the newrelic::meetme-plugin recipe in your run_list and setting the following attribute hash in an application cookbook:

node.override['newrelic']['meetme-plugin']['services'] = {
  "memcached": {
    "name": "localhost",
    "host":  "host",
    "port":  11211
  "elasticsearch": {
    "name": "clustername",
    "host": "localhost",
    "port": 9200

More examples can be found here and here.


logrotate is now enabled, by default, for customer app(forever.[log|out|err]) log files. The logrotate recipe iterates over every item(app_name) in the node['nodestack']['apps_to_deploy'] list and creates a configuration file. i.e /etc/logrotate.d/my_nodejs_app

NOTE: The logrotate recipe does not rotate custom log files, so make sure the customer's app uses STDOUT and STDERR.

Configuration examples can be found here and here


  • See the guide here

License and Authors

Copyright 2014, Rackspace, US Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
See the License for the specific language governing permissions and
limitations under the License.

nodestack CHANGELOG

This file is used to list changes made in each version of the nodestack cookbook.


  • Forever cookbook unpinned.
  • Removed old ELK attributes.
  • Added unless to nginx confd hash.
  • Fix Chefspec test for mysql_add_drive.
  • Removed all ocurrences of action parameters as strings.


  • @lmunro - Added nginx reverse proxy with tests. Fixed logstash log path.


  • Seandon Mooy - Added "cwd" option for forever-monitor to enter the applications actual directory


  • @marcoamorales - Disable setcap by default.
  • @marcoamorales - Support Chef 12


  • @marcoamorales - Unpinned apache2 cookbook
  • @marcoamorales - Specify Kiabana branch
  • @mattjbarlow - Make setcap optional via attribute


  • Marco Morales - Rewrote the init script for CentOS 6, which was causing problems when stopping/restarting an app. Issue 164


  • Seandon Mooy - Added "open_files" option per-app to allow setting the "ulimit -n" value per application.


  • Marco Morales - Removed recipe import from platformstack.


  • Marco Morales - Pin the version of forever, 0.12.0 was causing restarts in CentOS 6.5 to fail.


  • @martinb3 - Move away from logstash_commons, just set attributes in case elkstack is present.


  • Marco Morales - Adding template variables to be available for the before_symlink_template.


  • Marco Morales - Decoupled forever from application_nodejs recipe to make nodestack more modular and add more deployment strategies in the future. The attribute node['nodestack']['apps']['my_nodejs_app']['deployment']['strategy'] = 'forever' will need to be set when updating to 2.0.0.


  • Marco Morales - Removed npm-install-retry since it's no longer being used. Resource nodejs_npm is used now.


  • Marco Morales - Added attribute app_config['deployment']['before_symlink_template'] that should have a template name to be called by the the before_symlink callback.


  • Marco Morales - Moved the demo attributes to recipes/demo.rb default['nodestack']['apps_to_deploy'] is no longer needed. It will deploy all the apps in the apps hash.


  • Marco Morales - Exposes the before_symlink attribute from the application resource.


  • Martin Smith - Added ELK stack logging customization for node and forever logs, if ELK stack is available through platformstack.


  • Marco Morales - Code deployment is now optional


  • Jacob Dearing - Expose git_submodule attribute for application resource call.


  • Marco Morales - Removed platformstack from Berksfile and fixed the new serverspec syntax.


  • Sheppy Reno - Added basic Chefspec for application_nodejs.rb


  • Marco Morales - Allow options to be passed to apps via forevers 'options'


  • John Schwinghammer - Updated cloud_monitoring recipe name


  • Sheppy Reno - Make npm options an attribute


  • Sheppy Reno - Set NPM to only pull in production dependencies for the application.


  • Bob Garza - Added logrotate recipe and included in application_nodejs.rb. Configures logrotate, by default, for daily rotation of forever.(err|out|log)


  • Sheppy Reno - Cleanup application_nodejs.rb



  • Marco Morales - Added support for CentOS 7.


  • Bob Garza - Forever logs are now being appended instead of being overwritten.


  • Sheppy Reno - Check for attributes prior to setting iptables rules. - Corrected some Rubocop warnings


  • Sheppy Reno - Prettify the config.js JSON


  • Marco Morales - Added HTTP monitor check

Check the Markdown Syntax Guide for help with Markdown.

The Github Flavored Markdown page describes the differences between markdown on github and standard markdown.

Collaborator Number Metric

2.4.1 passed this metric

Contributing File Metric

2.4.1 passed this metric

Foodcritic Metric

2.4.1 failed this metric

FC009: Resource attribute not recognised: nodestack/recipes/_user.rb:29
Run with Foodcritic Version 16.3.0 with tags metadata,correctness ~FC031 ~FC045 and failure tags any

No Binaries Metric

2.4.1 passed this metric

Publish Metric

2.4.1 passed this metric

Supported Platforms Metric

2.4.1 passed this metric

Testing File Metric

2.4.1 failed this metric

Failure: To pass this metric, your cookbook metadata must include a source url, the source url must be in the form of, and your repo must contain a file

Version Tag Metric

2.4.1 passed this metric