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

Select Status

RSS

nginx_resources (17) Versions 0.5.2

Cookbook to install nginx with resources

Policyfile
Berkshelf
Knife
cookbook 'nginx_resources', '= 0.5.2', :supermarket
cookbook 'nginx_resources', '= 0.5.2'
knife supermarket install nginx_resources
knife supermarket download nginx_resources
README
Dependencies
Changelog
Quality 0%

nginx_resources cookbook

Installs nginx and dependant modules from source in a modular fashion.

Requirements

Chef

This cookbook requires Chef 12.7 and above.

Platforms

At present, only Ubuntu < 16.04 is supported, however adding support for other distributions should be a simple matter.

Recipes

The recipes are designed to create a default nginx installation called default and will utilize the resources listed below.

Calling the standard nginx_resources::default recipe will cause the following events to occur:
- recipes/install_user is called
- The www-data user account is optionally created
- recipes/install_common is called
- The nginx_resources_instance[default] resource is created
- A few core and override configuration files are created
- The default site is created and optionally enabled
- The service files are created, but not the actual service due to timing
- recipes/install_modules is called
- We iterate through node['nginx_resources']['source']['include_recipes']
and include recipes listed to install dependencies.
- recipes/install_source is called
- Package dependencies are installed
- The nginx_resources_build[default] resources is created
- recipes/install_service is called
- The service is created and optionally started

Usage

  1. Within your cookbook, define an optional attribute file to customize the nginx_resources attributes to your liking. Each and every configuration parameter used by this cookbook is attribute driven.
  2. Include the nginx_resources::default recipe in your run_list.
  3. Customize the nginx_resources_site[default] resource.

Example

r = resources('nginx_resources_site[default]')
r.root '/var/www/backofficev2/current/public'
r.listen [80, '443 ssl']
r.locations [
{ 'uri' => '/',
'try_files' => '$uri @proxy'
},
{ 'uri' => '/admin/',
'configs' => {
'rewrite' => '^/admin/assets(/?.*)$ /assets$1 last'
},
'try_files' => '$uri @proxy'
},
{ 'uri' => '~\.php',
'configs' => {
'proxy_send_timeout' => 600,
'proxy_read_timeout' => 600
},
'fastcgi_pass' => '127.0.0.1:9000'
},
{ 'uri' => '@proxy',
'configs' => {
'proxy_send_timeout' => 600,
'proxy_read_timeout' => 600
},
'fastcgi_pass' => '127.0.0.1:9000'
}
]
r.includes << 'include.d/fastcgi.conf'
r.includes << 'include.d/stub_status.conf'
r.includes << 'include.d/health.conf'
r.enabled true

Custom Resources

A deployment of nginx is comprised of a number of different resources. First, an nginx_resources_instance is created to define the basic folder structure. Then, any number of nginx_resources_module and nginx_resources_config are created to further customize the deployment. Lastly, a nginx_resources_build resource is created to compile and install nginx.

nginx_resources_instance

This resource builds out the folder structure for a specific deployment of nginx and it's dependant configuration files as well as creates the main configuration file.

Most of the properties have default values which lazilly load node attributes and should not generally need to be modified. Should you need modify them, however, refer to the [source](resources/instance.rb) for more information.

With the default settings, the following structure will be created:

./var
./var/1.10.1
./var/1.10.1/logs
./var/1.10.1/logs/error.log
./var/1.10.1/html
./var/1.10.1/html/50x.html
./var/1.10.1/html/index.html
./var/1.10.1/modules
./var/1.10.1/modules/ndk_http_module.so
./etc
./etc/include.d
./etc/include.d/stub_status.conf
./etc/include.d/fastcgi.conf
./etc/include.d/health.conf
./etc/site.d
./etc/site.d/20-default
./etc/uwsgi_params
./etc/koi-utf
./etc/conf.d
./etc/conf.d/50-ssl_map.conf
./etc/conf.d/50-ssl.conf
./etc/conf.d/50-realip.conf
./etc/conf.d/50-gzip.conf
./etc/conf.d/20-mime_types.conf
./etc/conf.d/90-custom.conf
./etc/conf.d/20-core.conf
./etc/scgi_params
./etc/fastcgi.conf
./etc/nginx.conf
./etc/module.d
./etc/module.d/20-module_ndk.conf
./etc/fastcgi_params
./etc/mime.types
./etc/koi-win
./etc/win-utf
./sbin
./sbin/nginx

nginx_resources_module

This resource downloads an external dependency (ex.: the [lua module](recipes/module_lua.rb)), unpacks it, creates a configuration file for it, and adds the module to the node attributes for the next compile phase. It does so by wrapping nginx_resources_source and nginx_resources_config.

The following properties are required and have no defaults:
- instance: the nginx_resources_instance name this module belongs to
- version: the version of this module
- checksum: the checksum of the tarball to download
- source: the url where the tarball is downloaded from

Once downloaded, the resource will inject the module in the global module configure argument attributes found in node['nginx_resources']['source']['external_modules'].

Further properties, with defaults, may be modified and are referenced in the [source](resources/module.rb) file.

nginx_resources_source

This resource downloads an external dependency (ex.: the [lua module](recipes/module_lua.rb)) and unpacks it.

The following properties are required and have no defaults:
- version: the version of this module
- checksum: the checksum of the tarball to download
- source: the url where the tarball is downloaded from

Further properties, with defaults, may be modified and are referenced in the [source](resources/source.rb) file.

nginx_resources_config

This resource creates a configuration file for use with nginx. Examples of this in practice may be found [here](recipes/install_common.rb).

The following properties are required and have no defaults:
- instance: the nginx_resources_instance name this module belongs to
- category: the namespace both for source and destination files

Further properties, with defaults, may be modified and are referenced in the [source](resources/config.rb) file.

nginx_resources_build

This resource builds the nginx source code for a specific nginx_resources_instance and should be smart enough not to recompile needlessly on each chef run.

The following properties are required and have no defaults:
- root_dir: The root directory containing nginx builds
- sbin_path: The --sbin-path or path to the nginx binary
- conf_path: The --conf-path or path to the main nginx configuration file
- prefix: The --prefix or directory into which to install
- service: The service resource name to notify

Further properties, with defaults, may be modified and are referenced in the [source](resources/build.rb) file.

nginx_resources_maintenance

This resource is designed to create-or-remove a file which the health check looks for when determining if it should return a 503 for maintenance mode.

The following properties are all optional:
- path: The location of the maintenance file, defaults to: node['nginx_resources']['health']['config']['maintenance_override']
- compile_time: Boolean which determins whether to run the action of manage at compile time.
- enable_only_if: A block which must return true/false determining whether maintenance mode should activated.
- disable_only_if: A block which must return true/false determining whether the maintenance mode should be activated.

Further properties, with defaults, may be modified and are referenced in the [source](resources/maintenance.rb) file.

Dependent cookbooks

build-essential ~> 6.0.0
apt >= 0.0.0

Contingent cookbooks

There are no cookbooks that are contingent upon this one.

nginx_resources cookbook changelog

v0.5.2

  • Resolve typo in healthcheck template

v0.5.1

  • Resolve maintenance mode deletion bug

v0.5.0

  • Add maintenance mode resource

v0.4.2

  • Allow to change the FASTCGI document_root variable

v0.4.1

  • Resolve issue with friendly syslog log format

v0.4.0

  • Update proxy_fastcgi template syntax

v0.3.1

  • Add fastcgi_pass to locations handling

v0.3.0

  • Update installation recipes to split the download and build phases
  • Add ngx lua ssl patch

v0.2.6

  • Resolve issue with lua.so loading
  • Install ngx resty_core which no longer seems to be automatic

v0.2.5

  • Resolve logging syntax issue

v0.2.4

  • Bugfix rubocop errors

v0.2.3

  • Ensure glib module installs the zlib dependencies
  • Ensure health module logs to access log by default
  • Ensure error log logs to main config dir

v0.2.2

  • Update dependencies for build-essential 6

v0.2.1

  • Rubocop you HAVE FAILED ME! Bugfixes

v0.2.0

  • Bugfixes
  • Rubocop style changes
  • BREAKING CHANGE: node['nginx_resources']['source']['include_recipes'] is now a Hash of bools rather than an Array in order to better support attribute precedence mergin.

v0.1.4

  • Fix copy-paste type in user creation recipe
  • Streamline service definition

v0.1.2

  • Resolve timing issue with service templates
  • Resolve bug service notification issue due to bug in chef where it errors out if a nested resource is passed a notify resource by string rather than object

v0.1.1

  • Remove apt version pin to prevent conflict with newrelic

v0.1.0

  • Initial release

Collaborator Number Metric
            

0.5.2 failed this metric

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

Foodcritic Metric
            

0.5.2 failed this metric

FC009: Resource attribute not recognised: /tmp/6cd7a1b6c838381abf6ea47e/nginx_resources/recipes/install_common.rb:47
FC009: Resource attribute not recognised: /tmp/6cd7a1b6c838381abf6ea47e/nginx_resources/recipes/install_service.rb:5
FC016: LWRP does not declare a default action: /tmp/6cd7a1b6c838381abf6ea47e/nginx_resources/resources/build.rb:1
FC016: LWRP does not declare a default action: /tmp/6cd7a1b6c838381abf6ea47e/nginx_resources/resources/config.rb:1
FC016: LWRP does not declare a default action: /tmp/6cd7a1b6c838381abf6ea47e/nginx_resources/resources/instance.rb:1
FC016: LWRP does not declare a default action: /tmp/6cd7a1b6c838381abf6ea47e/nginx_resources/resources/maintenance.rb:1
FC016: LWRP does not declare a default action: /tmp/6cd7a1b6c838381abf6ea47e/nginx_resources/resources/module.rb:1
FC016: LWRP does not declare a default action: /tmp/6cd7a1b6c838381abf6ea47e/nginx_resources/resources/site.rb:1
FC016: LWRP does not declare a default action: /tmp/6cd7a1b6c838381abf6ea47e/nginx_resources/resources/source.rb:1