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


pg (6) Versions 1.0.0

Installs/Configures PostgreSQL.

cookbook 'pg', '= 1.0.0'
cookbook 'pg', '= 1.0.0', :supermarket
knife cookbook site install pg
knife cookbook site download pg
Quality 100%

pg Cookbook

Build Status

Table of Contents

  1. Overview
  2. Requirements
  3. Attributes
  4. Usage
  5. Contributing
  6. License & Authors


This module manages the installation and configuration of NGINX.


Requires Chef 12.5 or later as this cookbook makes use of Custom Resources.



Key Type Description Default
['nginx_server']['manage_repo'] Boolean If the cookbook should manage the NGINX repo. true
['nginx_server']['repo'] String Which repo to install NGINX from. Only used when ['nginx_server']['manage_repo'] is true. Possible values are; epel, nginx-stable & nginx-mainline. nginx-stable
['nginx_server']['manage_confd'] Boolean Whether or not we should zap /etc/nginx/conf.d. true
['nginx_server']['error_log_level'] String warn
['nginx_server']['worker_connections'] Integer 1024
['nginx_server']['log_format'] String "\'$remote_addr - \$remote_user [\$time_local] \"\$request\" ' '\$status \$body_bytes_sent \"\$http_referer\" ' '\"\$http_user_agent\" \"\$http_x_forwarded_for\"'"
['nginx_server']['sendfile'] String on
['nginx_server']['tcp_nopush'] String off
['nginx_server']['keepalive_timeout'] Integer 65
['nginx_server']['gzip'] String off


You always need to include the main recipe:

include_recipe 'nginx_server::default'

This recipe:

  • Sets up the NGINX repo (stable repo by default).
  • Installs the nginx package.
  • Writes the main config to /etc/nginx/nginx.conf.
  • zaps any files in /etc/nginx/conf.d/ not managed by Chef.
  • Enables & starts the nginx service.


This resource defines a standard NGINX vhost.

Each nginx_server_vhost has the following attributes:

Attribute Type Description Default
name String or Symbol Resource name. N/A
listen Array An array of hashes that describes the NGINX listen statements for the vhost. N/A
server_name String or Array Server name(s) that the vhost should respond to. N/A
root String Web root of the vhost. /usr/share/nginx/html
index String Index file for the website. index.html
config Hash Additional config options to pass to the vhost. N/A

To setup a basic vhost for example:

nginx_server_vhost '' do
  server_name [
  root '/var/www/'
  action :create


The listen statement is an array of hashes that consists of:

  • ipaddress
  • port
  • options

All parts of each hash are options and have sane defaults:

  • ipaddress =
  • port = 80
  • options = N/A

For example to listen on the loopback address with SSL:

listen [
    'ipaddress': '',
    'port': 443,
    'options': 'ssl'

this produces a line like this:

listen ssl;

For more examples see the cookbook's integration test cookbook.


The config is a hash of additional config for the vhost not provided by the other properties.

This supports nested config such as location statements as well, for example:

config ({
    'error_page' => '404 /404.html',
    'location ~ \.php$' => {
      'try_files' => '$uri =404',
      'fastcgi_pass' => 'unix:/var/run/php5-fpm.sock',
      'fastcgi_index' => 'index.php',
      'fastcgi_param' => 'SCRIPT_FILENAME $document_root$fastcgi_script_name',
      'include' => 'fastcgi_params'

this is rendered as:

error_page 404 /404.html;
location ~ \.php$ {
  try_files $uri =404;
  fastcgi_pass unix:/var/run/php5-fpm.sock;
  fastcgi_index index.php;
  fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  include fastcgi_params;

For more examples see the cookbook's integration test cookbook.


The nginx_server_upstream defines an NGINX upstream to be used in tandem with a nginx_server_vhost that uses proxy_pass or similar to proxy connections to backend servers.

Each nginx_server_upstream has the following attributes:

Attribute Type Description Default
name String or Symbol Resource name. N/A
upstream_name String Name of the upstream. Defaults to name if not set. N/A
servers Array An Array of Arrays of backend servers that the upstream proxies to including associated options. N/A
ip_hash Boolean Whether or not to turn on the ip_hash functionality. false
keepalive Integer If set to an Integer turn on and set the keepalive functionality with the value supplied. N/A
least_conn Boolean Whether or not to turn on the least_conn functionality. false

To proxy through to a group of application servers for example:

nginx_server_upstream 'appservers' do
  ip_hash true
  least_conn true
  servers [
    ['', 'max_fails=3', 'fail_timeout=30s'],
    ['', 'max_fails=3', 'fail_timeout=30s'],
    ['', 'max_fails=3', 'fail_timeout=30s']
  action :create

will render as:

upstream appservers {

  server max_fails=3 fail_timeout=30s;
  server max_fails=3 fail_timeout=30s;
  server max_fails=3 fail_timeout=30s;


If you would like to contribute to this cookbook please follow these steps;

  1. Fork the repository on Github.
  2. Create a named feature branch (like add_component_x).
  3. Write your change.
  4. Write tests for your change (if applicable).
  5. Write documentation for your change (if applicable).
  6. Run the tests, ensuring they all pass.
  7. Submit a Pull Request using GitHub.

License and Authors

License: [BSD 2-clause](\(freebsd\)


Dependent cookbooks

yum >= 3.5.2

Contingent cookbooks

There are no cookbooks that are contingent upon this one.



Initial release.


  • Optionally manage repo to install NGINX from.
  • Install NGINX.
  • Manage main configuration.
  • Add vhost and upstream configuration via custom resources.
  • zap config files not managed by Chef.
  • Manage the NGINX service.

Foodcritic Metric

1.0.0 passed this metric