This will install the NGINX web server via package. It will install the current mainline version, currently 1.11
- ubuntu/xenial64
- ubuntu/trusty64
- centos/7
- centos/6
- debian/jessie64
- debian/wheezy64
- Chef '>= 12.5'
- TODO
node['nginx']['packages']
(hash) additional supporting packages to installnode['nginx']['modules']
(hash) paths to NGINX modules to load
The node['nginx']['blocks']
attribute allows for the inclusion of arbitrary
NGINX configuration files.
node['nginx']['block_dir']
(string) directory to create blocks, defaults to/etc/nginx/block.d/
node['nginx']['blocks']
(hash) configuration files to createnode['nginx']['blocks']['<BLOCK_NAME>']
(hash) block to create, filename matches<BLOCK_NAME>
node['nginx']['blocks']['<BLOCK_NAME>']['content']
(string or array) content of block, can be either single line (string), or multiple lines (array)
The following configuration will create a file /etc/nginx/block.d/en_rewrite
with the content rewrite ^/$ /en/ permanent;
. The vhost configuration shows the method of including this block.
nginx: {
blocks: {
en_rewrite: {
content: "rewrite ^/$ /en/ permanent;"
}
},
vhosts: {
'example.com' => {
server_name: 'example.com',
docroot: '/var/www/example.com/index',
includes: %w{
compression
},
blocks: %w{
en_rewrite
}
}
}
}
Here's an example nginx
role that will install Nginx.
name 'nginx'
description 'install nginx'
override_attributes(
'nginx' => {
...
}
)
run_list(
'recipe[cop_nginx::default]'
)
Testing is handled with ServerSpec, via Test Kitchen, which uses Vagrant to spin up VMs.
ServerSpec and Test Kitchen are bundled in the ChefDK package.
$ brew cask install chefdk
Get a listing of your instances with:
$ kitchen list
Run Chef on an instance, in this case default-ubuntu-1204, with:
$ kitchen converge default-ubuntu-1204
Destroy all instances with:
$ kitchen destroy
Run through and test all the instances in serial by running:
$ kitchen test
- The
Berksfile.lock
file has been purposely omitted, as we don't care about upstream dependencies.