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

RSS

nginx_conf (8) Versions 2.0.0

Installs/Configures nginx_conf

Berkshelf/Librarian
Policyfile
Knife
cookbook 'nginx_conf', '~> 2.0.0'
cookbook 'nginx_conf', '~> 2.0.0', :supermarket
knife cookbook site install nginx_conf
knife cookbook site download nginx_conf
README
Dependencies
Changelog
Quality

Circle CI

Description

Manage nginx server configuration files.

Requirements

  • Chef >= 11.0
  • Nginx cookbook - As of version 2.0.0, we no longer require the nginx cookbook explicitly. You can use whatever means to install nginx. The only requirement is a Chef service resource called nginx be made available to this cookbook.

Attributes

See a list of all attributes.

Usage

Add the nginx_conf recipe to your runlist.

confs

Rather then accessing the LWRP directly, add a site hash to the confs attribute list.

node['nginx_conf']['confs'] = [{
  'test1.mywebsite.com' => {
    'socket' => "/var/www/myapp/shared/tmp/sockets/unicorn.socket"
  },
  'test2.mywebsite.com' => {
    'root' => "/var/www/myapp",
    'site_type' => :static
  },
  'test3.mywebsite.com' => {
    'action' => :disable
  },
  'test4.mywebsite.com' => {
    'action' => :delete
  },
}]

Create

Creates a nginx configuration in the sites-available directory, tests it, symlinks to sites-enabled, and restarts nginx. See a list of all LWRP attributes.

nginx_conf_file "mywebsite.com" do
  socket "/var/www/myapp/shared/tmp/sockets/unicorn.socket"
end

Outputs to sites-available/mywebsite.com:

server {
  listen 80;

  server_name mywebsite.com;

  location / {
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Host $http_host;
    proxy_redirect off;
    proxy_pass http://unix:/var/www/myapp/shared/tmp/sockets/unicorn.socket;
  }
}

Creating a static conf is even easier.

nginx_conf_file "mywebsite.com" do
  root "/var/www/myapp"
  site_type :static
end

Outputs to sites-available/mywebsite.com:

server {
  listen 80;

  server_name mywebsite.com;

  root "/var/www/myapp";
}

SSL

To configure ssl:

nginx_conf_file "mywebsite.com" do
  ssl({'public' => 'public_key', 'private' => 'private_key', 'name' => 'mywebsite'})
end

NOTE The name attribute is optional. It defaults to the resource conf_name or resource name. It is only necessary, if you want to define the public and private key file name. EXE Using the value above, the file names would be mywebsite.public.crt & mywebsite.private.key respectively.

Disable

Removes the symlink between sites-enabled and sites-available for the named configuration.

nginx_conf_file "mywebsite.com" do
  action :disable
end

Delete

Removes the symlink and deletes the configuration:

nginx_conf_file "mywebsite.com" do
  action :delete
end

SSL Delete

Deleting SSL certs is managed by the delete resource, but there are some situations where you want to manage the deletion yourself. To do this, set the [:nginx_conf][:defaults][:delete][:ssl] to false or add :delete false to the nginx_conf_file ssl attribute hash.

nginx_conf_file "mywebsite.com" do
  action :delete
  ssl({'delete' => false})
end

Testing

We use foodcritic and chefspec to check basic functionality. To run tests:

bundle install
berks install
strainer test

Change Log

2.0.0 (2016-09-23)

Full Changelog

Implemented enhancements:

Fixed bugs:

  • template change should notify nginx restart #8
  • the new library has issues with strings #7

Closed issues:

  • More complexe exemple #15

v1.0.1 (2015-10-14)

Full Changelog

Closed issues:

  • cookbook is failing rubocop #22
  • Update supermarket version #19
  • update ssl cert #16

Merged pull requests:

v1.0.0 (2015-06-23)

Implemented enhancements:

  • Add basic chefspec tests #9

Closed issues:

  • using upstream attributes/lwrp #12
  • [BUG] ImmutableAttributeModification error #5
  • add https specific parameters #4
  • nginx_conf doesn't trigger nginx restart #1

Merged pull requests:

* This Change Log was automatically generated by github_changelog_generator

Collaborator Number Metric
            

2.0.0 failed this metric

Failure: Cookbook has 0 collaborators. A cookbook must have at least 2 collaborators to pass this metric.

Contributing File Metric
            

2.0.0 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 http://github.com/user/repo, and your repo must contain a CONTRIBUTING.md file

Foodcritic Metric
            

2.0.0 failed this metric

FC059: LWRP provider does not declare use_inline_resources: nginx_conf/providers/file.rb:1
FC074: LWRP should use DSL to define resource's default action: nginx_conf/resources/file.rb:1
Run with Foodcritic Version 10.3.1 with tags metadata,correctness ~FC031 ~FC045 and failure tags any

License Metric
            

2.0.0 passed this metric

No Binaries Metric
            

2.0.0 passed this metric

Publish Metric
            

2.0.0 passed this metric

Supported Platforms Metric
            

2.0.0 passed this metric

Testing File Metric
            

2.0.0 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 http://github.com/user/repo, and your repo must contain a TESTING.md file

Version Tag Metric
            

2.0.0 passed this metric