cookbook 'nginx_conf', '~> 2.0.0'
nginx_conf (8) Versions 2.0.0 Follow19
Installs/Configures nginx_conf
cookbook 'nginx_conf', '~> 2.0.0', :supermarket
knife supermarket install nginx_conf
knife supermarket download nginx_conf
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
Dependent cookbooks
This cookbook has no specified dependencies.
Contingent cookbooks
Change Log
2.0.0 (2016-09-23)
Implemented enhancements:
Fixed bugs:
Closed issues:
- More complexe exemple #15
v1.0.1 (2015-10-14)
Closed issues:
Merged pull requests:
- Add Stove gem #25 (phoolish)
- Switch to Circle CI #24 (phoolish)
- fixed spacing for rubocop style #23 (rgindes)
- when ssl certs are updated test and restart nginx #21 (phoolish)
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:
- add rubocop, update chefspec, and foodcritic. #20 (phoolish)
- Allow strings together with symbols #18 (realloc)
- Fixing CI #17 (facastagnini)
- Fixed the provider, when using template from another cookbook #13 (gustavovnicius)
- added support for limit_except #11 (namtzigla)
- try to fix resource names. #10 (mwhooker)
- Specify precedence for values we later modify #6 (jakedavis)
- Adding enable/autoenable functionnality and sites-available/enabled parameters for tuning #2 (dduportal)
* 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 https://github.com/user/repo, and your repo must contain a CONTRIBUTING.md file
Foodcritic Metric
2.0.0 failed this metric
FC074: LWRP should use DSL to define resource's default action: nginx_conf/resources/file.rb:1
FC085: Resource using new_resource.updated_by_last_action to converge resource: nginx_conf/providers/file.rb:99
FC085: Resource using new_resource.updated_by_last_action to converge resource: nginx_conf/providers/file.rb:134
FC085: Resource using new_resource.updated_by_last_action to converge resource: nginx_conf/providers/file.rb:151
FC085: Resource using new_resource.updated_by_last_action to converge resource: nginx_conf/providers/file.rb:163
Run with Foodcritic Version 16.3.0 with tags metadata,correctness ~FC031 ~FC045 and failure tags any
No Binaries 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 https://github.com/user/repo, and your repo must contain a TESTING.md file
Version Tag 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 https://github.com/user/repo, and your repo must include a tag that matches this cookbook version number
2.0.0 failed this 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 https://github.com/user/repo, and your repo must contain a CONTRIBUTING.md file
Foodcritic Metric
2.0.0 failed this metric
FC074: LWRP should use DSL to define resource's default action: nginx_conf/resources/file.rb:1
FC085: Resource using new_resource.updated_by_last_action to converge resource: nginx_conf/providers/file.rb:99
FC085: Resource using new_resource.updated_by_last_action to converge resource: nginx_conf/providers/file.rb:134
FC085: Resource using new_resource.updated_by_last_action to converge resource: nginx_conf/providers/file.rb:151
FC085: Resource using new_resource.updated_by_last_action to converge resource: nginx_conf/providers/file.rb:163
Run with Foodcritic Version 16.3.0 with tags metadata,correctness ~FC031 ~FC045 and failure tags any
No Binaries 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 https://github.com/user/repo, and your repo must contain a TESTING.md file
Version Tag 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 https://github.com/user/repo, and your repo must include a tag that matches this cookbook version number
2.0.0 failed this metric
FC085: Resource using new_resource.updated_by_last_action to converge resource: nginx_conf/providers/file.rb:99
FC085: Resource using new_resource.updated_by_last_action to converge resource: nginx_conf/providers/file.rb:134
FC085: Resource using new_resource.updated_by_last_action to converge resource: nginx_conf/providers/file.rb:151
FC085: Resource using new_resource.updated_by_last_action to converge resource: nginx_conf/providers/file.rb:163
Run with Foodcritic Version 16.3.0 with tags metadata,correctness ~FC031 ~FC045 and failure tags any
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 https://github.com/user/repo, and your repo must contain a TESTING.md file
Version Tag 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 https://github.com/user/repo, and your repo must include a tag that matches this cookbook version number
2.0.0 failed this 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 https://github.com/user/repo, and your repo must include a tag that matches this cookbook version number