-
Notifications
You must be signed in to change notification settings - Fork 82
Implement custom blocks to be inserted in nginx config. #142
Changes from all commits
fee6a17
d416d9c
4da8b69
05e6907
eadc686
be74db7
b0bfcfc
8834d59
e3831b4
a2f5d31
85ac32d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Style/LineLength: | ||
Description: 'Limit lines to 130 characters.' | ||
Max: 130 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Copyright (c) 2014 Firmhouse.com | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
name "backups" | ||
maintainer "Firmhouse" | ||
maintainer_email "[email protected]" | ||
license "Apache 2.0" | ||
license "MIT" | ||
description "Installs/Configures backups" | ||
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) | ||
version "0.1.0" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
name "packages" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Put one space between the method name and the first argument. |
||
maintainer "Michiel Sikkes" | ||
maintainer_email "[email protected]" | ||
license "Apache 2.0" | ||
license "MIT" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Put one space between the method name and the first argument. |
||
description "Installs/Configures packages" | ||
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) | ||
version "0.1.0" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,2 @@ | ||
# CHANGELOG for rails | ||
|
||
This file is used to list changes made in each version of rails. | ||
|
||
## 0.1.0: | ||
|
||
* Initial release of rails | ||
|
||
- - - | ||
Check the [Markdown Syntax Guide](http://daringfireball.net/projects/markdown/syntax) for help with Markdown. | ||
|
||
The [Github Flavored Markdown page](http://github.github.com/github-flavored-markdown/) describes the differences between markdown on github and standard markdown. | ||
See https://github.com/intercity/chef-repo/blob/master/CHANGELOG.md for full | ||
changelog |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
module Rails | ||
module Helpers | ||
## | ||
# Create a default set of custom config | ||
# Assure we always send certain hash keys to the template | ||
def nginx_custom_configuration(app_info) | ||
empty_conf = { | ||
"before" => "", | ||
"server_main" => "", | ||
"server_app" => "", | ||
"server_ssl" => "", | ||
"server_ssl_app" => "", | ||
"upstream" => "", | ||
"after" => "", | ||
} | ||
|
||
empty_conf.merge(app_info["nginx_custom"] || {}) | ||
end | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,12 @@ | ||
name "rails" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Put one space between the method name and the first argument. |
||
maintainer "Michiel Sikkes" | ||
maintainer_email "[email protected]" | ||
license "Apache 2.0" | ||
license "MIT" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Put one space between the method name and the first argument. |
||
description "Installs/Configures rails" | ||
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) | ||
version "0.1.0" | ||
depends "sudo", "> 1.2.0" | ||
depends "database" | ||
depends "nginx" | ||
depends "bluepill" | ||
depends "logrotate" | ||
depends "logrotate" |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,18 +4,23 @@ | |
# | ||
# Copyright 2012, Michiel Sikkes | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
# Permission is hereby granted, free of charge, to any person obtaining a copy | ||
# of this software and associated documentation files (the "Software"), to deal | ||
# in the Software without restriction, including without limitation the rights | ||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
# copies of the Software, and to permit persons to whom the Software is | ||
# furnished to do so, subject to the following conditions: | ||
|
||
# The above copyright notice and this permission notice shall be included in | ||
# all copies or substantial portions of the Software. | ||
|
||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
# THE SOFTWARE. | ||
|
||
include_recipe "sudo" | ||
include_recipe "nginx" | ||
|
@@ -26,6 +31,9 @@ | |
|
||
if node[:active_applications] | ||
|
||
# Include library helpers | ||
::Chef::Resource.send(:include, Rails::Helpers) | ||
|
||
node[:active_applications].each do |app, app_info| | ||
rails_env = app_info['rails_env'] || "production" | ||
deploy_user = app_info['deploy_user'] || "deploy" | ||
|
@@ -105,8 +113,13 @@ | |
|
||
template "/etc/nginx/sites-available/#{app}.conf" do | ||
source "app_nginx.conf.erb" | ||
variables :name => app, :domain_names => app_info['domain_names'], :enable_ssl => File.exists?("#{applications_root}/#{app}/shared/config/certificate.crt") | ||
notifies :reload, resources(:service => "nginx") | ||
variables( | ||
name: app, | ||
domain_names: app_info["domain_names"], | ||
redirect_domain_names: app_info["redirect_domain_names"], | ||
enable_ssl: File.exists?("#{applications_root}/#{app}/shared/config/certificate.crt"), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Line is too long. [94/80] There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixing this involves a lot more then just wrapping the line. Proper fix would be to either introduce some helper modules and call methods such as The next best thing, and more chef-ish, is to make these blocks into LWRPs. That allows for a lot of cleaning up. The next best thing is to extract all these into variables, but that really does not make the code more readable. Alll this is is a much larger, and different task than what I'm trying to achieve in this PR, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah that's fine. I think I'm going to ignore the Hound line length setting and set it to 150 or something like that. Also: agree with you on refactoring this into nice cheffy libraries and LWRPs. But let's first see what the best approach is right now. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Line is too long. [94/80] |
||
custom_configuration: nginx_custom_configuration(app_info)) | ||
notifies :reload, resources(service: "nginx") | ||
end | ||
|
||
template "#{applications_root}/#{app}/shared/config/unicorn.rb" do | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,18 +4,23 @@ | |
# | ||
# Copyright 2012, Michiel Sikkes | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
# Permission is hereby granted, free of charge, to any person obtaining a copy | ||
# of this software and associated documentation files (the "Software"), to deal | ||
# in the Software without restriction, including without limitation the rights | ||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
# copies of the Software, and to permit persons to whom the Software is | ||
# furnished to do so, subject to the following conditions: | ||
|
||
# The above copyright notice and this permission notice shall be included in | ||
# all copies or substantial portions of the Software. | ||
|
||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
# THE SOFTWARE. | ||
|
||
package "apt-transport-https" | ||
|
||
|
@@ -43,6 +48,9 @@ | |
|
||
if node[:active_applications] | ||
|
||
# Include library helpers | ||
::Chef::Resource.send(:include, Rails::Helpers) | ||
|
||
node[:active_applications].each do |app, app_info| | ||
rails_env = app_info['rails_env'] || "production" | ||
deploy_user = app_info['deploy_user'] || "deploy" | ||
|
@@ -121,7 +129,12 @@ | |
|
||
template "/etc/nginx/sites-available/#{app}.conf" do | ||
source "app_passenger_nginx.conf.erb" | ||
variables :name => app, :rails_env => rails_env, :domain_names => app_info['domain_names'], :enable_ssl => File.exists?("#{applications_root}/#{app}/shared/config/certificate.crt") | ||
variables( | ||
name: app, | ||
rails_env: rails_env, | ||
domain_names: app_info["domain_names"], | ||
enable_ssl: File.exists?("#{applications_root}/#{app}/shared/config/certificate.crt"), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Line is too long. [94/80] There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Line is too long. [94/80] |
||
custom_configuration: nginx_custom_configuration(app_info)) | ||
notifies :reload, resources(:service => "nginx") | ||
end | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Put one space between the method name and the first argument.