Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

adding episode 339

  • Loading branch information...
commit 16353c75be2d375d779c54bc7f3e14546b744f13 1 parent aedd3c8
@ryanb authored
Showing with 3,932 additions and 0 deletions.
  1. +35 −0 episode-339/README.md
  2. +22 −0 episode-339/chef/cookbooks/bluepill/CHANGELOG.md
  3. +29 −0 episode-339/chef/cookbooks/bluepill/CONTRIBUTING
  4. +201 −0 episode-339/chef/cookbooks/bluepill/LICENSE
  5. +80 −0 episode-339/chef/cookbooks/bluepill/README.md
  6. +34 −0 episode-339/chef/cookbooks/bluepill/attributes/default.rb
  7. +30 −0 episode-339/chef/cookbooks/bluepill/metadata.json
  8. +7 −0 episode-339/chef/cookbooks/bluepill/metadata.rb
  9. +109 −0 episode-339/chef/cookbooks/bluepill/providers/service.rb
  10. +33 −0 episode-339/chef/cookbooks/bluepill/recipes/default.rb
  11. +26 −0 episode-339/chef/cookbooks/bluepill/resources/service.rb
  12. +32 −0 episode-339/chef/cookbooks/bluepill/templates/centos/bluepill_init.erb
  13. +31 −0 episode-339/chef/cookbooks/bluepill/templates/freebsd/bluepill_init.erb
  14. +24 −0 episode-339/chef/cookbooks/build-essential/README.md
  15. +35 −0 episode-339/chef/cookbooks/build-essential/metadata.json
  16. +10 −0 episode-339/chef/cookbooks/build-essential/metadata.rb
  17. +45 −0 episode-339/chef/cookbooks/build-essential/recipes/default.rb
  18. +33 −0 episode-339/chef/cookbooks/main/recipes/default.rb
  19. +6 −0 episode-339/chef/cookbooks/main/templates/default/zshrc.erb
  20. +26 −0 episode-339/chef/cookbooks/nginx/CHANGELOG.md
  21. +29 −0 episode-339/chef/cookbooks/nginx/CONTRIBUTING
  22. +201 −0 episode-339/chef/cookbooks/nginx/LICENSE
  23. +195 −0 episode-339/chef/cookbooks/nginx/README.md
  24. +65 −0 episode-339/chef/cookbooks/nginx/attributes/default.rb
  25. +30 −0 episode-339/chef/cookbooks/nginx/attributes/geoip.rb
  26. +34 −0 episode-339/chef/cookbooks/nginx/attributes/source.rb
  27. +23 −0 episode-339/chef/cookbooks/nginx/attributes/upload_progress.rb
  28. +35 −0 episode-339/chef/cookbooks/nginx/definitions/nginx_site.rb
  29. +73 −0 episode-339/chef/cookbooks/nginx/files/default/mime.types
  30. +256 −0 episode-339/chef/cookbooks/nginx/metadata.json
  31. +91 −0 episode-339/chef/cookbooks/nginx/metadata.rb
  32. +41 −0 episode-339/chef/cookbooks/nginx/recipes/authorized_ips.rb
  33. +64 −0 episode-339/chef/cookbooks/nginx/recipes/default.rb
  34. +103 −0 episode-339/chef/cookbooks/nginx/recipes/http_geoip_module.rb
  35. +23 −0 episode-339/chef/cookbooks/nginx/recipes/http_gzip_static_module.rb
  36. +46 −0 episode-339/chef/cookbooks/nginx/recipes/http_realip_module.rb
  37. +23 −0 episode-339/chef/cookbooks/nginx/recipes/http_ssl_module.rb
  38. +36 −0 episode-339/chef/cookbooks/nginx/recipes/http_stub_status_module.rb
  39. +35 −0 episode-339/chef/cookbooks/nginx/recipes/ohai_plugin.rb
  40. +194 −0 episode-339/chef/cookbooks/nginx/recipes/source.rb
  41. +47 −0 episode-339/chef/cookbooks/nginx/recipes/upload_progress_module.rb
  42. +11 −0 episode-339/chef/cookbooks/nginx/templates/default/default-site.erb
  43. +6 −0 episode-339/chef/cookbooks/nginx/templates/default/modules/authorized_ip.erb
  44. +4 −0 episode-339/chef/cookbooks/nginx/templates/default/modules/http_geoip.conf.erb
  45. +4 −0 episode-339/chef/cookbooks/nginx/templates/default/modules/http_realip.conf.erb
  46. +14 −0 episode-339/chef/cookbooks/nginx/templates/default/modules/nginx_status.erb
  47. +42 −0 episode-339/chef/cookbooks/nginx/templates/default/nginx.conf.erb
  48. +92 −0 episode-339/chef/cookbooks/nginx/templates/default/nginx.init.erb
  49. +15 −0 episode-339/chef/cookbooks/nginx/templates/default/nginx.pill.erb
  50. +1 −0  episode-339/chef/cookbooks/nginx/templates/default/nginx.sysconfig.erb
  51. +29 −0 episode-339/chef/cookbooks/nginx/templates/default/nxdissite.erb
  52. +38 −0 episode-339/chef/cookbooks/nginx/templates/default/nxensite.erb
  53. +66 −0 episode-339/chef/cookbooks/nginx/templates/default/plugins/nginx.rb.erb
  54. +2 −0  episode-339/chef/cookbooks/nginx/templates/default/sv-nginx-log-run.erb
  55. +3 −0  episode-339/chef/cookbooks/nginx/templates/default/sv-nginx-run.erb
  56. +54 −0 episode-339/chef/cookbooks/ohai/README.md
  57. +21 −0 episode-339/chef/cookbooks/ohai/attributes/default.rb
  58. +1 −0  episode-339/chef/cookbooks/ohai/files/default/plugins/README
  59. +44 −0 episode-339/chef/cookbooks/ohai/metadata.json
  60. +15 −0 episode-339/chef/cookbooks/ohai/metadata.rb
  61. +43 −0 episode-339/chef/cookbooks/ohai/recipes/default.rb
  62. +3 −0  episode-339/chef/cookbooks/runit/CHANGELOG.md
  63. +29 −0 episode-339/chef/cookbooks/runit/CONTRIBUTING
  64. +201 −0 episode-339/chef/cookbooks/runit/LICENSE
  65. +226 −0 episode-339/chef/cookbooks/runit/README.md
  66. +31 −0 episode-339/chef/cookbooks/runit/attributes/default.rb
  67. +164 −0 episode-339/chef/cookbooks/runit/definitions/runit_service.rb
  68. +1 −0  episode-339/chef/cookbooks/runit/files/default/runit.seed
  69. 0  episode-339/chef/cookbooks/runit/files/default/runsvdir
  70. +6 −0 episode-339/chef/cookbooks/runit/files/ubuntu-6.10/runsvdir
  71. +7 −0 episode-339/chef/cookbooks/runit/files/ubuntu-7.04/runsvdir
  72. +7 −0 episode-339/chef/cookbooks/runit/files/ubuntu-7.10/runsvdir
  73. +7 −0 episode-339/chef/cookbooks/runit/files/ubuntu-8.04/runsvdir
  74. +102 −0 episode-339/chef/cookbooks/runit/metadata.json
  75. +37 −0 episode-339/chef/cookbooks/runit/metadata.rb
  76. +72 −0 episode-339/chef/cookbooks/runit/recipes/default.rb
  77. +32 −0 episode-339/chef/cookbooks/runit/templates/gentoo/runit-start.sh.erb
  78. +8 −0 episode-339/chef/node.json
  79. +2 −0  episode-339/chef/solo.rb
View
35 episode-339/README.md
@@ -0,0 +1,35 @@
+# RailsCasts Episode #339: Chef Solo Basics
+
+http://railscasts.com/episodes/339-chef-solo-basics
+
+Requires Ruby 1.9.2 or higher.
+
+### Commands used on local machine
+
+```
+ssh root@72.14.183.209
+scp -r root@72.14.183.209:/var/chef .
+mate chef
+rsync -r . root@72.14.183.209:/var/chef
+ssh root@72.14.183.209 "chef-solo -c /var/chef/solo.rb"
+brew install ssh-copy-id
+ssh-copy-id root@72.14.183.209
+openssl passwd -1 "theplaintextpassword"
+ssh deployer@72.14.183.209
+```
+
+### Commands used on server
+
+```
+curl -L https://gist.github.com/raw/2307959/ff2d251c9f4f149c5ca73c873ad8990711b3ca74/chef_solo_bootstrap.sh | bash
+ruby -v
+chef-solo -v
+mkdir /var/chef
+cd /var/chef
+mkdir -p cookbooks/main/recipes
+vim cookbooks/main/recipes/default.rb
+vim solo.rb
+chef-solo -c solo.rb
+vim node.json
+chef-solo -c solo.rb -j node.json
+```
View
22 episode-339/chef/cookbooks/bluepill/CHANGELOG.md
@@ -0,0 +1,22 @@
+## v1.0.4:
+
+* [COOK-1106] - fix chkconfig loader for CentOS 5
+* [COOK-1107] - use integer for GID instead of string
+
+## v1.0.2:
+
+* [COOK-1043] - Bluepill cookbook fails on OS X because it tries to
+ use root group
+
+## v1.0.0:
+
+* [COOK-943] - add init script for freebsd
+
+## v0.3.0:
+
+* [COOK-867] - enable bluepill service on RHEL family
+* [COOK-550] - add freebsd support
+
+## v0.2.2:
+
+* Fixes COOK-524, COOK-632
View
29 episode-339/chef/cookbooks/bluepill/CONTRIBUTING
@@ -0,0 +1,29 @@
+If you would like to contribute, please open a ticket in JIRA:
+
+* http://tickets.opscode.com
+
+Create the ticket in the COOK project and use the cookbook name as the
+component.
+
+For all code contributions, we ask that contributors sign a
+contributor license agreement (CLA). Instructions may be found here:
+
+* http://wiki.opscode.com/display/chef/How+to+Contribute
+
+When contributing changes to individual cookbooks, please do not
+modify the version number in the metadata.rb. Also please do not
+update the CHANGELOG.md for a new version. Not all changes to a
+cookbook may be merged and released in the same versions. Opscode will
+handle the version updates during the release process. You are welcome
+to correct typos or otherwise make updates to documentation in the
+README.
+
+If a contribution adds new platforms or platform versions, indicate
+such in the body of the commit message(s), and update the relevant
+COOK ticket. When writing commit messages, it is helpful for others if
+you indicate the COOK ticket. For example:
+
+ git commit -m '[COOK-1041] Updated pool resource to correctly delete.'
+
+In the ticket itself, it is also helpful if you include log output of
+a successful Chef run, but this is not absolutely required.
View
201 episode-339/chef/cookbooks/bluepill/LICENSE
@@ -0,0 +1,201 @@
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+END OF TERMS AND CONDITIONS
+
+APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+Copyright [yyyy] [name of copyright owner]
+
+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.
View
80 episode-339/chef/cookbooks/bluepill/README.md
@@ -0,0 +1,80 @@
+Description
+===========
+
+Installs bluepill RubyGem and configures it to manage services. Also includes a LWRP.
+
+Requirements
+============
+
+Bluepill is a pure Ruby service management tool/library, so this cookbook should work on any system. The attributes do set up paths based on FHS locations, see below.
+
+Attributes
+==========
+
+Default locations for bluepill are in "FHS compliant" locations.
+
+* `node["bluepill"]["bin"]` - Path to bluepill program, default is 'bluepill' in the RubyGems binary directory.
+* `node["bluepill"]["logfile"]` - Location of the bluepill log file, default "/var/log/bluepill.log".
+* `node["bluepill"]["conf_dir"]` - Location of service config files (pills), default "/etc/bluepill".
+* `node["bluepill"]["pid_dir"]` - Location of pidfiles, default "/var/run/bluepill"
+* `node["bluepill"]["state_dir"]` - Location of state directory, default "/var/lib/bluepill"
+* `node["bluepill"]["init_dir"]` - Location of init script directory, default selected by platform.
+
+Resources/Providers
+===================
+
+This cookbook contains an LWRP, `bluepill_service`. This can be used with the normal Chef service resource, by using the `provider` parameter, or by specifying the `bluepill_service` shortcut. These two resources are equivalent.
+
+ service "my_app" do
+ provider bluepill_service
+ action [:enable, :load, :start]
+ end
+
+ bluepill_service "my_app" do
+ action [:enable, :load, :start]
+ end
+
+The load action should probably always be specified, to ensure that if bluepill isn't running already it gets started. The
+
+The recipe using the service must contain a template resource for the pill and it must be named `my_app.pill.erb`, where `my_app` is the service name passed to the bluepill service resource.
+
+Usage
+=====
+
+Be sure to include the bluepill recipe in the run list to ensure that the gem and bluepill-related directories are created. This will also make the cookbook available on the system and other cookbooks won't need to explicitly depend on it in the metadata.
+
+If the default directory locations in the attributes/default.rb aren't what you want, change them by setting them either in the attributes file itself, or create attributes in a role applied to any systems that will use bluepill.
+
+Example pill template resource and .erb file:
+
+ template "/etc/bluepill/my_app" do
+ source "my_app.pill.erb"
+ end
+
+ Bluepill.application("my_app") do |app|
+ app.process("my_app") do |process|
+ process.pid_file = "/var/run/my_app.pid"
+ process.start_command = "/usr/bin/my_app"
+ end
+ end
+
+See bluepill's documentation for more information on creating pill templates.
+
+License and Author
+==================
+
+Author:: Joshua Timberman (<joshua@opscode.com>)
+
+Copyright 2010, Opscode, Inc.
+
+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.
View
34 episode-339/chef/cookbooks/bluepill/attributes/default.rb
@@ -0,0 +1,34 @@
+# Cookbook Name:: bluepill
+# Attributes:: default
+#
+# Copyright 2010, Opscode, Inc.
+#
+# 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.
+
+default["bluepill"]["bin"] = "#{languages[:ruby][:bin_dir]}/bluepill"
+default["bluepill"]["logfile"] = "/var/log/bluepill.log"
+default["bluepill"]["pid_dir"] = "/var/run/bluepill"
+default["bluepill"]["state_dir"] = "/var/lib/bluepill"
+default["bluepill"]["group"] = 0
+
+case platform
+when "arch"
+ default["bluepill"]["init_dir"] = "/etc/rc.d"
+ default["bluepill"]["conf_dir"] = "/etc/bluepill"
+when "freebsd"
+ default["bluepill"]["init_dir"] = "/usr/local/etc/rc.d"
+ default["bluepill"]["conf_dir"] = "/usr/local/etc/bluepill"
+else
+ default["bluepill"]["init_dir"] = "/etc/init.d"
+ default["bluepill"]["conf_dir"] = "/etc/bluepill"
+end
View
30 episode-339/chef/cookbooks/bluepill/metadata.json
@@ -0,0 +1,30 @@
+{
+ "name": "bluepill",
+ "description": "Installs bluepill gem and configures to manage services, includes bluepill_service LWRP",
+ "long_description": "Description\n===========\n\nInstalls bluepill RubyGem and configures it to manage services. Also includes a LWRP.\n\nRequirements\n============\n\nBluepill is a pure Ruby service management tool/library, so this cookbook should work on any system. The attributes do set up paths based on FHS locations, see below.\n\nAttributes\n==========\n\nDefault locations for bluepill are in \"FHS compliant\" locations.\n\n* `node[\"bluepill\"][\"bin\"]` - Path to bluepill program, default is 'bluepill' in the RubyGems binary directory.\n* `node[\"bluepill\"][\"logfile\"]` - Location of the bluepill log file, default \"/var/log/bluepill.log\".\n* `node[\"bluepill\"][\"conf_dir\"]` - Location of service config files (pills), default \"/etc/bluepill\".\n* `node[\"bluepill\"][\"pid_dir\"]` - Location of pidfiles, default \"/var/run/bluepill\"\n* `node[\"bluepill\"][\"state_dir\"]` - Location of state directory, default \"/var/lib/bluepill\"\n* `node[\"bluepill\"][\"init_dir\"]` - Location of init script directory, default selected by platform.\n\nResources/Providers\n===================\n\nThis cookbook contains an LWRP, `bluepill_service`. This can be used with the normal Chef service resource, by using the `provider` parameter, or by specifying the `bluepill_service` shortcut. These two resources are equivalent.\n\n service \"my_app\" do\n provider bluepill_service\n action [:enable, :load, :start]\n end\n\n bluepill_service \"my_app\" do\n action [:enable, :load, :start]\n end\n\nThe load action should probably always be specified, to ensure that if bluepill isn't running already it gets started. The\n\nThe recipe using the service must contain a template resource for the pill and it must be named `my_app.pill.erb`, where `my_app` is the service name passed to the bluepill service resource.\n\nUsage\n=====\n\nBe sure to include the bluepill recipe in the run list to ensure that the gem and bluepill-related directories are created. This will also make the cookbook available on the system and other cookbooks won't need to explicitly depend on it in the metadata.\n\nIf the default directory locations in the attributes/default.rb aren't what you want, change them by setting them either in the attributes file itself, or create attributes in a role applied to any systems that will use bluepill.\n\nExample pill template resource and .erb file:\n\n template \"/etc/bluepill/my_app\" do\n source \"my_app.pill.erb\"\n end\n\n Bluepill.application(\"my_app\") do |app|\n app.process(\"my_app\") do |process|\n process.pid_file = \"/var/run/my_app.pid\"\n process.start_command = \"/usr/bin/my_app\"\n end\n end\n\nSee bluepill's documentation for more information on creating pill templates.\n\nLicense and Author\n==================\n\nAuthor:: Joshua Timberman (<joshua@opscode.com>)\n\nCopyright 2010, Opscode, Inc.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n",
+ "maintainer": "Opscode, Inc.",
+ "maintainer_email": "cookbooks@opscode.com",
+ "license": "Apache 2.0",
+ "platforms": {
+ },
+ "dependencies": {
+ },
+ "recommendations": {
+ },
+ "suggestions": {
+ },
+ "conflicting": {
+ },
+ "providing": {
+ },
+ "replacing": {
+ },
+ "attributes": {
+ },
+ "groupings": {
+ },
+ "recipes": {
+ "bluepill::default": "Installs bluepill rubygem and set up management directories"
+ },
+ "version": "1.0.4"
+}
View
7 episode-339/chef/cookbooks/bluepill/metadata.rb
@@ -0,0 +1,7 @@
+maintainer "Opscode, Inc."
+maintainer_email "cookbooks@opscode.com"
+license "Apache 2.0"
+description "Installs bluepill gem and configures to manage services, includes bluepill_service LWRP"
+long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
+version "1.0.4"
+recipe "bluepill::default", "Installs bluepill rubygem and set up management directories"
View
109 episode-339/chef/cookbooks/bluepill/providers/service.rb
@@ -0,0 +1,109 @@
+#
+# Cookbook Name:: bluepill
+# Provider:: service
+#
+# Copyright 2010, Opscode, Inc.
+#
+# 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.
+#
+
+require 'chef/mixin/command'
+require 'chef/mixin/language'
+include Chef::Mixin::Command
+
+action :enable do
+ config_file = "#{node['bluepill']['conf_dir']}/#{new_resource.service_name}.pill"
+
+ unless @bp.enabled
+ link "#{node['bluepill']['init_dir']}/#{new_resource.service_name}" do
+ to node['bluepill']['bin']
+ only_if { ::File.exists?(config_file) }
+ end
+ end
+
+ case node['platform']
+ when "centos", "redhat", "freebsd"
+ template "#{node["bluepill"]["init_dir"]}/bluepill-#{new_resource.service_name}" do
+ source "bluepill_init.erb"
+ cookbook "bluepill"
+ owner "root"
+ group node["bluepill"]["group"]
+ mode "0755"
+ variables(
+ :service_name => "#{new_resource.service_name}",
+ :config_file => config_file
+ )
+ end
+
+ service "bluepill-#{new_resource.service_name}" do
+ action [ :enable ]
+ end
+ end
+end
+
+action :load do
+ unless @bp.running
+ execute "#{node['bluepill']['bin']} load #{node['bluepill']['conf_dir']}/#{new_resource.service_name}.pill"
+ end
+end
+
+action :start do
+ unless @bp.running
+ execute "#{node['bluepill']['bin']} #{new_resource.service_name} start"
+ end
+end
+
+action :disable do
+ if @bp.enabled
+ file "#{node['bluepill']['conf_dir']}/#{new_resource.service_name}.pill" do
+ action :delete
+ end
+ link "#{node['bluepill']['init_dir']}/#{new_resource.service_name}" do
+ action :delete
+ end
+ end
+end
+
+action :stop do
+ if @bp.running
+ execute "#{node['bluepill']['bin']} #{new_resource.service_name} stop"
+ end
+end
+
+action :restart do
+ if @bp.running
+ execute "#{node['bluepill']['bin']} #{new_resource.service_name} restart"
+ end
+end
+
+def load_current_resource
+ @bp = Chef::Resource::BluepillService.new(new_resource.name)
+ @bp.service_name(new_resource.service_name)
+
+ Chef::Log.debug("Checking status of service #{new_resource.service_name}")
+
+ begin
+ if run_command_with_systems_locale(:command => "#{node['bluepill']['bin']} #{new_resource.service_name} status") == 0
+ @bp.running(true)
+ end
+ rescue Chef::Exceptions::Exec
+ @bp.running(false)
+ nil
+ end
+
+ if ::File.exists?("#{node['bluepill']['conf_dir']}/#{new_resource.service_name}.pill") && ::File.symlink?("#{node['bluepill']['init_dir']}/#{new_resource.service_name}")
+ @bp.enabled(true)
+ else
+ @bp.enabled(false)
+ end
+end
View
33 episode-339/chef/cookbooks/bluepill/recipes/default.rb
@@ -0,0 +1,33 @@
+#
+# Cookbook Name:: bluepill
+# Recipe:: default
+#
+# Copyright 2010, Opscode, Inc.
+#
+# 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.
+#
+
+gem_package "i18n"
+gem_package "bluepill"
+
+[
+ node["bluepill"]["conf_dir"],
+ node["bluepill"]["pid_dir"],
+ node["bluepill"]["state_dir"]
+].each do |dir|
+ directory dir do
+ recursive true
+ owner "root"
+ group node["bluepill"]["group"]
+ end
+end
View
26 episode-339/chef/cookbooks/bluepill/resources/service.rb
@@ -0,0 +1,26 @@
+#
+# Cookbook Name:: bluepill
+# Resource:: service
+#
+# Copyright 2010, Opscode, Inc.
+#
+# 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.
+#
+
+actions :start, :stop, :enable, :disable, :load, :restart
+
+attribute :service_name, :name_attribute => true
+attribute :enabled, :default => false
+attribute :running, :default => false
+attribute :variables, :kind_of => Hash
+attribute :supports, :default => { :restart => true, :status => true }
View
32 episode-339/chef/cookbooks/bluepill/templates/centos/bluepill_init.erb
@@ -0,0 +1,32 @@
+#!/bin/sh
+#
+# Author: Jamie Winsor (<jamie@vialstudios.com>)
+#
+# chkconfig: 345 99 1
+# Description: Bluepill loader for <%= @service_name %>
+# Provides: <%= @service_name %>
+# Default-Start: 3 4 5
+# Default-Stop: 0 1 2 6
+
+BLUEPILL_BIN=<%= node['bluepill']['bin'] %>
+BLUEPILL_CONFIG=<%= @config_file %>
+SERVICE_NAME=<%= @service_name %>
+
+case "$1" in
+ start)
+ echo "Loading bluepill configuration for $SERVICE_NAME "
+ $BLUEPILL_BIN load $BLUEPILL_CONFIG
+ ;;
+ stop)
+ $BLUEPILL_BIN $SERVICE_NAME stop
+ $BLUEPILL_BIN $SERVICE_NAME quit
+ ;;
+ restart)
+ $0 stop
+ $0 start
+ ;;
+ *)
+ echo "Usage: $0 {start|stop|restart}"
+ exit 1
+ ;;
+esac
View
31 episode-339/chef/cookbooks/bluepill/templates/freebsd/bluepill_init.erb
@@ -0,0 +1,31 @@
+#!/bin/sh
+##
+# PROVIDE: named
+# REQUIRE: SERVERS cleanvar
+# KEYWORD: shutdown
+#
+
+. /etc/rc.subr
+
+name="<%= @service_name %>"
+rcvar=`set_rcvar`
+
+# Set some defaults
+<%= @service_name %>_enable=${<%= @service_name %>_enable:-"NO"}
+
+pidfile="/var/run/<%= @service_name %>.pid"
+command="/usr/local/bin/bluepill"
+
+start_precmd="${command} load <%= node['bluepill']['conf_dir'] %>/<%= @service_name %>.pill"
+start_cmd="${command} ${name} start"
+
+status_cmd="${command} ${name} status"
+
+stop_cmd="${command} ${name} stop"
+stop_postcmd="${command} ${name} quit"
+
+load_rc_config ${name}
+
+PATH="${PATH}:/usr/local/bin"
+
+run_rc_command "$1"
View
24 episode-339/chef/cookbooks/build-essential/README.md
@@ -0,0 +1,24 @@
+DESCRIPTION
+===========
+
+Installs packages required for compiling C software from source.
+
+LICENSE AND AUTHOR
+==================
+
+Author:: Joshua Timberman (<joshua@opscode.com>)
+Author:: Seth Chisamore (<schisamo@opscode.com>)
+
+Copyright 2009-2011, Opscode, Inc.
+
+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.
View
35 episode-339/chef/cookbooks/build-essential/metadata.json
@@ -0,0 +1,35 @@
+{
+ "name": "build-essential",
+ "description": "Installs C compiler / build tools",
+ "long_description": "",
+ "maintainer": "Opscode, Inc.",
+ "maintainer_email": "cookbooks@opscode.com",
+ "license": "Apache 2.0",
+ "platforms": {
+ "fedora": ">= 0.0.0",
+ "redhat": ">= 0.0.0",
+ "centos": ">= 0.0.0",
+ "ubuntu": ">= 0.0.0",
+ "debian": ">= 0.0.0"
+ },
+ "dependencies": {
+ },
+ "recommendations": {
+ },
+ "suggestions": {
+ },
+ "conflicting": {
+ },
+ "providing": {
+ },
+ "replacing": {
+ },
+ "attributes": {
+ },
+ "groupings": {
+ },
+ "recipes": {
+ "build-essential": "Installs C compiler and build tools on Linux"
+ },
+ "version": "1.0.0"
+}
View
10 episode-339/chef/cookbooks/build-essential/metadata.rb
@@ -0,0 +1,10 @@
+maintainer "Opscode, Inc."
+maintainer_email "cookbooks@opscode.com"
+license "Apache 2.0"
+description "Installs C compiler / build tools"
+version "1.0.0"
+recipe "build-essential", "Installs C compiler and build tools on Linux"
+
+%w{ fedora redhat centos ubuntu debian }.each do |os|
+ supports os
+end
View
45 episode-339/chef/cookbooks/build-essential/recipes/default.rb
@@ -0,0 +1,45 @@
+#
+# Cookbook Name:: build-essential
+# Recipe:: default
+#
+# Copyright 2008-2009, Opscode, Inc.
+#
+# 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.
+#
+
+case node['platform']
+when "ubuntu","debian"
+ %w{build-essential binutils-doc}.each do |pkg|
+ package pkg do
+ action :install
+ end
+ end
+when "centos","redhat","fedora"
+ %w{gcc gcc-c++ kernel-devel make}.each do |pkg|
+ package pkg do
+ action :install
+ end
+ end
+end
+
+package "autoconf" do
+ action :install
+end
+
+package "flex" do
+ action :install
+end
+
+package "bison" do
+ action :install
+end
View
33 episode-339/chef/cookbooks/main/recipes/default.rb
@@ -0,0 +1,33 @@
+package "git-core" # apt-get install git-core
+package "zsh"
+
+include_recipe "nginx::source"
+
+user node[:user][:name] do
+ password node[:user][:password]
+ gid "admin"
+ home "/home/#{node[:user][:name]}"
+ supports manage_home: true
+ shell "/bin/zsh"
+end
+
+template "/home/#{node[:user][:name]}/.zshrc" do
+ source "zshrc.erb"
+ owner node[:user][:name]
+end
+
+directory "/home/#{node[:user][:name]}/example" do
+ owner node[:user][:name]
+end
+
+file "/home/#{node[:user][:name]}/example/index.html" do
+ owner node[:user][:name]
+ content "<h1>Hello World</h1>"
+end
+
+file "#{node[:nginx][:dir]}/sites-available/example" do
+ content "server { root /home/#{node[:user][:name]}/example; }"
+end
+
+nginx_site "example"
+
View
6 episode-339/chef/cookbooks/main/templates/default/zshrc.erb
@@ -0,0 +1,6 @@
+export PS1='%m:%3~%# '
+export RAILS_ENV=production
+
+<% if node[:user][:ls_color] %>
+alias ls='ls --color=auto'
+<% end %>
View
26 episode-339/chef/cookbooks/nginx/CHANGELOG.md
@@ -0,0 +1,26 @@
+## v0.101.0:
+
+**Attribute Change**: `node['nginx']['url']` -> `node['nginx']['source']['url']`; see the README.md.
+
+* [COOK-1115] - daemonize when using init script
+* [COOK-477] - module compilation support in nginx::source
+
+## v0.100.4:
+
+* [COOK-1126] - source version bump to 1.0.14
+
+## v0.100.2:
+
+* [COOK-1053] - Add :url attribute to nginx cookbook
+
+## v0.100.0:
+
+* [COOK-818] - add "application/json" per RFC.
+* [COOK-870] - bluepill init style support
+* [COOK-957] - Compress application/javascript.
+* [COOK-981] - Add reload support to NGINX service
+
+## v0.99.2:
+
+* [COOK-809] - attribute to disable access logging
+* [COOK-772] - update nginx download source location
View
29 episode-339/chef/cookbooks/nginx/CONTRIBUTING
@@ -0,0 +1,29 @@
+If you would like to contribute, please open a ticket in JIRA:
+
+* http://tickets.opscode.com
+
+Create the ticket in the COOK project and use the cookbook name as the
+component.
+
+For all code contributions, we ask that contributors sign a
+contributor license agreement (CLA). Instructions may be found here:
+
+* http://wiki.opscode.com/display/chef/How+to+Contribute
+
+When contributing changes to individual cookbooks, please do not
+modify the version number in the metadata.rb. Also please do not
+update the CHANGELOG.md for a new version. Not all changes to a
+cookbook may be merged and released in the same versions. Opscode will
+handle the version updates during the release process. You are welcome
+to correct typos or otherwise make updates to documentation in the
+README.
+
+If a contribution adds new platforms or platform versions, indicate
+such in the body of the commit message(s), and update the relevant
+COOK ticket. When writing commit messages, it is helpful for others if
+you indicate the COOK ticket. For example:
+
+ git commit -m '[COOK-1041] Updated pool resource to correctly delete.'
+
+In the ticket itself, it is also helpful if you include log output of
+a successful Chef run, but this is not absolutely required.
View
201 episode-339/chef/cookbooks/nginx/LICENSE
@@ -0,0 +1,201 @@
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+END OF TERMS AND CONDITIONS
+
+APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+Copyright [yyyy] [name of copyright owner]
+
+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.
View
195 episode-339/chef/cookbooks/nginx/README.md
@@ -0,0 +1,195 @@
+Description
+===========
+
+Installs nginx from package OR source code and sets up configuration handling similar to Debian's Apache2 scripts.
+
+Requirements
+============
+
+Cookbooks
+---------
+
+* build-essential (for nginx::source)
+* runit (for nginx::source)
+* ohai (for nginx::ohai_plugin)
+
+Platform
+--------
+
+* Debian
+* Ubuntu
+
+The `nginx::source` may work anywhere "build-essential" is avaialble.
+
+**RHEL/CentOS** The `nginx::source` recipe should work on RHEL/CentOS with "init" as the init style attribute.
+
+Attributes
+==========
+
+Node attributes for this cookbook are logically separated into
+different files. Some attributes are set only via a specific recipe.
+
+## default.rb
+
+Generally used attributes. Some have platform specific values. See `attributes/default.rb`. "The Config" refers to "nginx.conf" the main config file.
+
+**v0.101.0 - Attribute Change**: `node['nginx']['url']` is now `node['nginx']['source']['url']` as the URL was only used when retrieving the source to build Nginx.
+
+* `node['nginx']['dir']` - Location for Nginx configuration.
+* `node['nginx']['log_dir']` - Location for Nginx logs.
+* `node['nginx']['user']` - User that Nginx will run as.
+* `node['nginx']['binary']` - Path to the Nginx binary.
+* `node['nginx']['init_style']` - How to run Nginx as a service when using `nginx::source`. Values can be "runit", "init" or "bluepill". When using runit or bluepill, those recipes will be included as well and are dependencies of this cookbook. Not used in the `nginx` recipe because the package manager's init script style for the platform is assumed.
+* `node['nginx']['pid']` - Location of the PID file.
+* `node['nginx']['keepalive']` - Whether to use `keepalive_timeout`, any value besides "on" will leave that option out of the config.
+* `node['nginx']['keepalive_timeout']` - used for config value of `keepalive_timeout`.
+* `node['nginx']['worker_processes']` - used for config value of `worker_processes`.
+* `node['nginx']['worker_connections']` - used for config value of `events { worker_connections }`
+* `node['nginx']['server_names_hash_bucket_size']` - used for config value of `server_names_hash_bucket_size`.
+* `node['nginx']['disable_access_log']` - set to true to disable the general access log, may be useful on high traffic sites.
+
+### Attributes for configuring the gzip module
+
+* `node['nginx']['gzip']` - Whether to use gzip, can be "on" or "off"
+* `node['nginx']['gzip_http_version']` - used for config value of `gzip_http_version`.
+* `node['nginx']['gzip_comp_level']` - used for config value of `gzip_comp_level`.
+* `node['nginx']['gzip_proxied']` - used for config value of `gzip_proxied`.
+* `node['nginx']['gzip_types']` - used for config value of `gzip_types` - must be an Array.
+
+### Attributes set in recipes
+
+*nginx::source*
+
+* `node['nginx']['daemon_disable']` - Whether the daemon should be disabled which can be true or false; disable the daemon (run in the foreground) when using a service supervisor such as runit or bluepill for "init_style". This is automatically set in the `nginx::source` recipe when the init style is not bluepill or runit.
+
+*nginx::authorized_ips*
+
+* `node['nginx']['remote_ip_var']` - The remote ip variable name to use.
+* `node['nginx']['authorized_ips']` - IPs authorized by the module
+
+*nginx::http_realip_module*
+
+From: http://wiki.nginx.org/HttpRealIpModule
+
+* `node['nginx']['realip']['header']` - Header to use for the RealIp Module; only accepts "X-Forwarded-For" or "X-Real-IP"
+* `node['nginx']['realip']['addresses']` - Addresses to use for the `http_realip` configuration.
+
+## source.rb
+
+These attributes are used in the `nginx::source` recipe. Some of them are dynamically modified during the run. See `attributes/source.rb` for default values.
+
+* `node['nginx']['source']['url']` - (versioned) URL for the Nginx source code. By default this will use the version specified as `node['nginx']['version'].
+* `node['nginx']['source']['prefix']` - (versioned) prefix for installing nginx from source
+* `node['nginx']['source']['conf_path']` - location of the main config file, in `node['nginx']['dir']` by default.
+* `node['nginx']['source']['modules']` - Array of modules that should be compiled into Nginx by including their recipes in `nginx::source`.
+* `node['nginx']['source']['default_configure_flags']` - The default flags passed to the configure script when building Nginx.
+* `node['nginx']['configure_flags']` - Preserved for compatibility and dynamically generated from the `node['nginx']['source']['default_configure_flags']` in the `nginx::source` recipe.
+
+## geoip.rb
+
+These attributes are used in the `nginx::http_geoip_module` recipe.
+
+* `node['nginx']['geoip']['path']` - Location where to install the geoip libraries.
+* `node['nginx']['geoip']['enable_city']` - Whether to enable City data
+* `node['nginx']['geoip']['country_dat_url']` - Country data tarball URL
+* `node['nginx']['geoip']['country_dat_checksum']` - Country data tarball checksum
+* `node['nginx']['geoip']['city_dat_url']` - City data tarball URL
+* `node['nginx']['geoip']['city_dat_checksum']` - City data tarball checksum
+* `node['nginx']['geoip']['lib_version']` - Version of the GeoIP library to install
+* `node['nginx']['geoip']['lib_url']` - (Versioned) Tarball URL of the GeoIP library
+* `node['nginx']['geoip']['lib_checksum']` - Checksum of the GeoIP library tarball
+
+## upload_progress.rb
+
+These attributes are used in the `nginx::upload_progress_module` recipe.
+
+* `node['nginx']['upload_progress]['url']` - URL for the tarball.
+* `node['nginx']['upload_progress']['checksum']` - Checksum of the tarball.
+
+Recipes
+=======
+
+This cookbook provides two main recipes for installing Nginx.
+
+* default.rb: *Use this recipe* if you have a native package for Nginx.
+* source.rb: *Use this recipe* if you do not have a native package for Nginx, or if you want to install a newer version than is available, or if you have custom module compilation needs.
+
+Several recipes are related to the `source` recipe specifically. See that recipe's section below for a description.
+
+## default.rb
+
+The default recipe will install Nginx as a native package for the system through the package manager and sets up the configuration according to the Debian site enable/disable style with `sites-enabled` using the `nxensite` and `nxdissite` scripts. The nginx service will be managed with the normal init scripts that are presumably included in the native package.
+
+Includes the `ohai_plugin` recipe so the plugin is available.
+
+## ohai_plugin.rb
+
+This recipe provides an Ohai plugin as a template. It is included by both the `default` and `source` recipes.
+
+## authorized_ips.rb
+
+Sets up configuration for the `authorized_ip` nginx module.
+
+## source.rb
+
+This recipe is responsible for building Nginx from source. It ensures that the required packages to build Nginx are installed (pcre, openssl, compile tools). The source will be downloaded from the `node['nginx']['source']['url']`. The `node['nginx']['user']` will be created as a system user. The appropriate configuration and log directories and config files will be created as well according to the attributes `node['nginx']['dir']` and 'node['nginx']['log_dir']`.
+
+The recipe attempts to detect whether additional modules should be added to the configure command through recipe inclusion (see below), and whether the version or configuration flags have changed and should trigger a recompile.
+
+The nginx service will be set up according to `node['nginx']['init_style']`. Available options are:
+
+* runit: uses runit cookbook and sets up `runit_service`.
+* bluepill: uses bluepill cookbook and sets up `bluepill_service`.
+* anything else (e.g., "init") will use the nginx init script template.
+
+**RHEL/CentOS** This recipe should work on RHEL/CentOS with "init" as the init style.
+
+The following recipes are used to build module support into Nginx:
+
+* `http_geoip_module.rb` - installs the GeoIP libraries and data files and enables the module for compilation.
+* `http_gzip_static_module.rb` - enables the module for compilation.
+* `http_realip_module.rb` - enables the module for compilation and creates the configuration.
+* `http_ssl_module.rb` - enables SSL for compilation.
+* `http_stub_status_module.rb` - provides `nginx_status` configuration and enables the module for compilation.
+* `upload_progress_module.rb` - builds the `upload_progress` module and enables it as a module when compiling nginx.
+
+Ohai Plugin
+===========
+
+The `ohai_plugin` recipe includes an Ohai plugin. It will be automatically installed and activated, providing the following attributes via ohai, no matter how nginx is installed (source or package):
+
+* `node['nginx']['version']` - version of nginx
+* `node['nginx']['configure_arguments']` - options passed to ./configure when nginx was built
+* `node['nginx']['prefix']` - installation prefix
+* `node['nginx']['conf_path']` - configuration file path
+
+In the source recipe, it is used to determine whether control attributes for building nginx have changed.
+
+Usage
+=====
+
+Include the recipe on your node or role that fits how you wish to install Nginx on your system per the recipes section above. Modify the attributes as required in your role to change how various configuration is applied per the attributes section above. In general, override attributes in the role should be used when changing attributes.
+
+There's some redundancy in that the config handling hasn't been separated from the installation method (yet), so use only one of the recipes, default or source.
+
+License and Author
+==================
+
+Author:: Joshua Timberman (<joshua@opscode.com>)
+Author:: Adam Jacob (<adam@opscode.com>)
+Author:: AJ Christensen (<aj@opscode.com>)
+Author:: Jamie Winsor (<jamie@vialstudios.com>)
+
+Copyright:: 2008-2012, Opscode, Inc
+
+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.
View
65 episode-339/chef/cookbooks/nginx/attributes/default.rb
@@ -0,0 +1,65 @@
+#
+# Cookbook Name:: nginx
+# Attributes:: default
+#
+# Author:: Adam Jacob (<adam@opscode.com>)
+# Author:: Joshua Timberman (<joshua@opscode.com>)
+#
+# Copyright 2009-2011, Opscode, Inc.
+#
+# 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.
+#
+
+default[:nginx][:version] = "1.0.14"
+
+case platform
+when "debian","ubuntu"
+ default[:nginx][:dir] = "/etc/nginx"
+ default[:nginx][:log_dir] = "/var/log/nginx"
+ default[:nginx][:user] = "www-data"
+ default[:nginx][:binary] = "/usr/sbin/nginx"
+ default[:nginx][:init_style] = "runit"
+else
+ default[:nginx][:dir] = "/etc/nginx"
+ default[:nginx][:log_dir] = "/var/log/nginx"
+ default[:nginx][:user] = "www-data"
+ default[:nginx][:binary] = "/usr/sbin/nginx"
+ default[:nginx][:init_style] = "init"
+end
+
+default[:nginx][:pid] = "/var/run/nginx.pid"
+
+default[:nginx][:gzip] = "on"
+default[:nginx][:gzip_http_version] = "1.0"
+default[:nginx][:gzip_comp_level] = "2"
+default[:nginx][:gzip_proxied] = "any"
+default[:nginx][:gzip_types] = [
+ "text/plain",
+ "text/html",
+ "text/css",
+ "application/x-javascript",
+ "text/xml",
+ "application/xml",
+ "application/xml+rss",
+ "text/javascript",
+ "application/javascript",
+ "application/json"
+]
+
+default[:nginx][:keepalive] = "on"
+default[:nginx][:keepalive_timeout] = 65
+default[:nginx][:worker_processes] = cpu[:total]
+default[:nginx][:worker_connections] = 1024
+default[:nginx][:server_names_hash_bucket_size] = 64
+
+default[:nginx][:disable_access_log] = false
View
30 episode-339/chef/cookbooks/nginx/attributes/geoip.rb
@@ -0,0 +1,30 @@
+#
+# Cookbook Name:: nginx
+# Attributes:: geoip
+#
+# Author:: Jamie Winsor (<jamie@vialstudios.com>)
+#
+# Copyright 2012, Riot Games
+#
+# 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.
+#
+
+default[:nginx][:geoip][:path] = "/srv/geoip"
+default[:nginx][:geoip][:enable_city] = true
+default[:nginx][:geoip][:country_dat_url] = "http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz"
+default[:nginx][:geoip][:country_dat_checksum] = "a8c1ffeea5edae7e89150f83029a71bb"
+default[:nginx][:geoip][:city_dat_url] = "http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz"
+default[:nginx][:geoip][:city_dat_checksum] = "1075c5dcd106d937c29879330713b8e5"
+default[:nginx][:geoip][:lib_version] = "1.4.8"
+default[:nginx][:geoip][:lib_url] = "http://geolite.maxmind.com/download/geoip/api/c/GeoIP-#{node[:nginx][:geoip][:lib_version]}.tar.gz"
+default[:nginx][:geoip][:lib_checksum] = "05b7300435336231b556df5ab36f326d"
View
34 episode-339/chef/cookbooks/nginx/attributes/source.rb
@@ -0,0 +1,34 @@
+#
+# Cookbook Name:: nginx
+# Attributes:: source
+#
+# Author:: Jamie Winsor (<jamie@vialstudios.com>)
+#
+# Copyright 2012, Riot Games
+#
+# 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.
+#
+
+set[:nginx][:source][:prefix] = "/opt/nginx-#{node[:nginx][:version]}"
+set[:nginx][:source][:conf_path] = "#{node[:nginx][:dir]}/nginx.conf"
+set[:nginx][:source][:default_configure_flags] = [
+ "--prefix=#{node[:nginx][:source][:prefix]}",
+ "--conf-path=#{node[:nginx][:dir]}/nginx.conf"
+]
+
+default[:nginx][:configure_flags] = Array.new
+default[:nginx][:source][:url] = "http://nginx.org/download/nginx-#{node[:nginx][:version]}.tar.gz"
+default[:nginx][:source][:modules] = [
+ "http_ssl_module",
+ "http_gzip_static_module"
+]
View
23 episode-339/chef/cookbooks/nginx/attributes/upload_progress.rb
@@ -0,0 +1,23 @@
+#
+# Cookbook Name:: nginx
+# Attributes:: upload_progress
+#
+# Author:: Jamie Winsor (<jamie@vialstudios.com>)
+#
+# Copyright 2012, Riot Games
+#
+# 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.
+#
+
+default[:nginx][:upload_progress][:url] = "https://github.com/masterzen/nginx-upload-progress-module/tarball/v0.8.4"
+default[:nginx][:upload_progress][:checksum] = "9a6acb984d81f5d7e04214d63ae94273"
View
35 episode-339/chef/cookbooks/nginx/definitions/nginx_site.rb
@@ -0,0 +1,35 @@
+#
+# Cookbook Name:: nginx
+# Definition:: nginx_site
+# Author:: AJ Christensen <aj@junglist.gen.nz>
+#
+# Copyright 2008-2009, Opscode, Inc.
+#
+# 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.
+#
+
+define :nginx_site, :enable => true do
+ if params[:enable]
+ execute "nxensite #{params[:name]}" do
+ command "/usr/sbin/nxensite #{params[:name]}"
+ notifies :reload, resources(:service => "nginx")
+ not_if do ::File.symlink?("#{node[:nginx][:dir]}/sites-enabled/#{params[:name]}") end
+ end
+ else
+ execute "nxdissite #{params[:name]}" do
+ command "/usr/sbin/nxdissite #{params[:name]}"
+ notifies :reload, resources(:service => "nginx")
+ only_if do ::File.symlink?("#{node[:nginx][:dir]}/sites-enabled/#{params[:name]}") end
+ end
+ end
+end
View
73 episode-339/chef/cookbooks/nginx/files/default/mime.types
@@ -0,0 +1,73 @@
+types {
+ text/html html htm shtml;
+ text/css css;
+ text/xml xml;
+ image/gif gif;
+ image/jpeg jpeg jpg;
+ application/x-javascript js;
+ application/json json;
+ application/atom+xml atom;
+ application/rss+xml rss;
+
+ text/mathml mml;
+ text/plain txt;
+ text/vnd.sun.j2me.app-descriptor jad;
+ text/vnd.wap.wml wml;
+ text/x-component htc;
+
+ image/png png;
+ image/tiff tif tiff;
+ image/vnd.wap.wbmp wbmp;
+ image/x-icon ico;
+ image/x-jng jng;
+ image/x-ms-bmp bmp;
+ image/svg+xml svg;
+
+ application/java-archive jar war ear;
+ application/mac-binhex40 hqx;
+ application/msword doc;
+ application/pdf pdf;
+ application/postscript ps eps ai;
+ application/rtf rtf;
+ application/vnd.ms-excel xls;
+ application/vnd.ms-powerpoint ppt;
+ application/vnd.wap.wmlc wmlc;
+ application/vnd.wap.xhtml+xml xhtml;
+ application/vnd.google-earth.kml+xml kml;
+ application/vnd.google-earth.kmz kmz;
+ application/x-cocoa cco;
+ application/x-java-archive-diff jardiff;
+ application/x-java-jnlp-file jnlp;
+ application/x-makeself run;
+ application/x-perl pl pm;
+ application/x-pilot prc pdb;
+ application/x-rar-compressed rar;
+ application/x-redhat-package-manager rpm;
+ application/x-sea sea;
+ application/x-shockwave-flash swf;
+ application/x-stuffit sit;
+ application/x-tcl tcl tk;
+ application/x-x509-ca-cert der pem crt;
+ application/x-xpinstall xpi;
+ application/zip zip;
+
+ application/octet-stream bin exe dll;
+ application/octet-stream deb;
+ application/octet-stream dmg;
+ application/octet-stream eot;
+ application/octet-stream iso img;
+ application/octet-stream msi msp msm;
+
+ audio/midi mid midi kar;
+ audio/mpeg mp3;
+ audio/x-realaudio ra;
+
+ video/3gpp 3gpp 3gp;
+ video/mpeg mpeg mpg;
+ video/quicktime mov;
+ video/x-flv flv;
+ video/x-mng mng;
+ video/x-ms-asf asx asf;
+ video/x-ms-wmv wmv;
+ video/x-msvideo avi;
+}
View
256 episode-339/chef/cookbooks/nginx/metadata.json
@@ -0,0 +1,256 @@
+{
+ "name": "nginx",
+ "description": "Installs and configures nginx",
+ "long_description": "",
+ "maintainer": "Opscode, Inc.",
+ "maintainer_email": "cookbooks@opscode.com",
+ "license": "Apache 2.0",
+ "platforms": {
+ "ubuntu": ">= 0.0.0",
+ "debian": ">= 0.0.0",
+ "centos": ">= 0.0.0",
+ "redhat": ">= 0.0.0",
+ "fedora": ">= 0.0.0"
+ },
+ "dependencies": {
+ "build-essential": ">= 0.0.0",
+ "runit": ">= 0.0.0",
+ "bluepill": ">= 0.0.0",
+ "ohai": "~> 1.0.2"
+ },
+ "recommendations": {
+ },
+ "suggestions": {
+ },
+ "conflicting": {
+ },
+ "providing": {
+ },
+ "replacing": {
+ },
+ "attributes": {
+ "nginx/dir": {
+ "display_name": "Nginx Directory",
+ "description": "Location of nginx configuration files",
+ "default": "/etc/nginx",
+ "choice": [
+
+ ],
+ "calculated": false,
+ "type": "string",
+ "required": "optional",
+ "recipes": [
+
+ ]
+ },
+ "nginx/log_dir": {
+ "display_name": "Nginx Log Directory",
+ "description": "Location for nginx logs",
+ "default": "/var/log/nginx",
+ "choice": [
+
+ ],
+ "calculated": false,
+ "type": "string",
+ "required": "optional",
+ "recipes": [
+
+ ]
+ },
+ "nginx/user": {
+ "display_name": "Nginx User",
+ "description": "User nginx will run as",
+ "default": "www-data",
+ "choice": [
+
+ ],
+ "calculated": false,
+ "type": "string",
+ "required": "optional",
+ "recipes": [
+
+ ]
+ },
+ "nginx/binary": {
+ "display_name": "Nginx Binary",
+ "description": "Location of the nginx server binary",
+ "default": "/usr/sbin/nginx",
+ "choice": [
+
+ ],
+ "calculated": false,
+ "type": "string",
+ "required": "optional",
+ "recipes": [
+
+ ]
+ },
+ "nginx/gzip": {
+ "display_name": "Nginx Gzip",
+ "description": "Whether gzip is enabled",
+ "default": "on",
+ "choice": [
+
+ ],
+ "calculated": false,
+ "type": "string",
+ "required": "optional",
+ "recipes": [
+
+ ]
+ },
+ "nginx/gzip_http_version": {
+ "display_name": "Nginx Gzip HTTP Version",
+ "description": "Version of HTTP Gzip",
+ "default": "1.0",
+ "choice": [
+
+ ],
+ "calculated": false,
+ "type": "string",
+ "required": "optional",
+ "recipes": [
+
+ ]
+ },
+ "nginx/gzip_comp_level": {
+ "display_name": "Nginx Gzip Compression Level",
+ "description": "Amount of compression to use",
+ "default": "2",
+ "choice": [
+
+ ],
+ "calculated": false,
+ "type": "string",
+ "required": "optional",
+ "recipes": [
+
+ ]
+ },
+ "nginx/gzip_proxied": {
+ "display_name": "Nginx Gzip Proxied",
+ "description": "Whether gzip is proxied",
+ "default": "any",
+ "choice": [
+
+ ],
+ "calculated": false,
+ "type": "string",
+ "required": "optional",
+ "recipes": [
+
+ ]
+ },
+ "nginx/gzip_types": {
+ "display_name": "Nginx Gzip Types",
+ "description": "Supported MIME-types for gzip",
+ "type": "array",
+ "default": [
+ "text/plain",
+ "text/html",
+ "text/css",
+ "application/x-javascript",
+ "text/xml",
+ "application/xml",
+ "application/xml+rss",
+ "text/javascript"
+ ],
+ "choice": [
+
+ ],
+ "calculated": false,
+ "required": "optional",
+ "recipes": [
+
+ ]
+ },
+ "nginx/keepalive": {
+ "display_name": "Nginx Keepalive",
+ "description": "Whether to enable keepalive",
+ "default": "on",
+ "choice": [
+
+ ],
+ "calculated": false,
+ "type": "string",
+ "required": "optional",
+ "recipes": [
+
+ ]
+ },
+ "nginx/keepalive_timeout": {
+ "display_name": "Nginx Keepalive Timeout",
+ "default": "65",
+ "choice": [
+
+ ],
+ "calculated": false,
+ "type": "string",
+ "required": "optional",
+ "recipes": [
+
+ ]
+ },
+ "nginx/worker_processes": {
+ "display_name": "Nginx Worker Processes",
+ "description": "Number of worker processes",
+ "default": "1",
+ "choice": [
+
+ ],
+ "calculated": false,
+ "type": "string",
+ "required": "optional",
+ "recipes": [
+
+ ]
+ },
+ "nginx/worker_connections": {
+ "display_name": "Nginx Worker Connections",
+ "description": "Number of connections per worker",
+ "default": "1024",
+ "choice": [
+
+ ],
+ "calculated": false,
+ "type": "string",
+ "required": "optional",
+ "recipes": [
+
+ ]
+ },
+ "nginx/server_names_hash_bucket_size": {
+ "display_name": "Nginx Server Names Hash Bucket Size",
+ "default": "64",
+ "choice": [
+
+ ],
+ "calculated": false,
+ "type": "string",
+ "required": "optional",
+ "recipes": [
+
+ ]
+ },
+ "nginx/disable_access_log": {
+ "display_name": "Disable Access Log",
+ "default": "false",
+ "choice": [
+
+ ],
+ "calculated": false,
+ "type": "string",
+ "required": "optional",
+ "recipes": [
+
+ ]
+ }
+ },
+ "groupings": {
+ },
+ "recipes": {
+ "nginx": "Installs nginx package and sets up configuration with Debian apache style with sites-enabled/sites-available",
+ "nginx::source": "Installs nginx from source and sets up configuration with Debian apache style with sites-enabled/sites-available"
+ },
+ "version": "0.101.0"
+}
View
91 episode-339/chef/cookbooks/nginx/metadata.rb
@@ -0,0 +1,91 @@
+maintainer "Opscode, Inc."
+maintainer_email "cookbooks@opscode.com"
+license "Apache 2.0"
+description "Installs and configures nginx"
+version "0.101.0"
+
+recipe "nginx", "Installs nginx package and sets up configuration with Debian apache style with sites-enabled/sites-available"
+recipe "nginx::source", "Installs nginx from source and sets up configuration with Debian apache style with sites-enabled/sites-available"
+
+%w{ ubuntu debian centos redhat fedora }.each do |os|
+ supports os
+end
+
+%w{ build-essential runit bluepill }.each do |cb|
+ depends cb
+end
+
+depends 'ohai', '~> 1.0.2'
+
+attribute "nginx/dir",
+ :display_name => "Nginx Directory",
+ :description => "Location of nginx configuration files",
+ :default => "/etc/nginx"
+
+attribute "nginx/log_dir",
+ :display_name => "Nginx Log Directory",
+ :description => "Location for nginx logs",
+ :default => "/var/log/nginx"
+
+attribute "nginx/user",
+ :display_name => "Nginx User",
+ :description => "User nginx will run as",
+ :default => "www-data"
+
+attribute "nginx/binary",
+ :display_name => "Nginx Binary",
+ :description => "Location of the nginx server binary",
+ :default => "/usr/sbin/nginx"
+
+attribute "nginx/gzip",
+ :display_name => "Nginx Gzip",
+ :description => "Whether gzip is enabled",
+ :default => "on"
+
+attribute "nginx/gzip_http_version",
+ :display_name => "Nginx Gzip HTTP Version",
+ :description => "Version of HTTP Gzip",
+ :default => "1.0"
+
+attribute "nginx/gzip_comp_level",
+ :display_name => "Nginx Gzip Compression Level",
+ :description => "Amount of compression to use",
+ :default => "2"
+
+attribute "nginx/gzip_proxied",
+ :display_name => "Nginx Gzip Proxied",
+ :description => "Whether gzip is proxied",
+ :default => "any"
+
+attribute "nginx/gzip_types",
+ :display_name => "Nginx Gzip Types",
+ :description => "Supported MIME-types for gzip",
+ :type => "array",
+ :default => [ "text/plain", "text/html", "text/css", "application/x-javascript", "text/xml", "application/xml", "application/xml+rss", "text/javascript" ]
+
+attribute "nginx/keepalive",
+ :display_name => "Nginx Keepalive",
+ :description => "Whether to enable keepalive",
+ :default => "on"
+
+attribute "nginx/keepalive_timeout",
+ :display_name => "Nginx Keepalive Timeout",
+ :default => "65"
+
+attribute "nginx/worker_processes",
+ :display_name => "Nginx Worker Processes",
+ :description => "Number of worker processes",
+ :default => "1"
+
+attribute "nginx/worker_connections",
+ :display_name => "Nginx Worker Connections",
+ :description => "Number of connections per worker",
+ :default => "1024"
+
+attribute "nginx/server_names_hash_bucket_size",
+ :display_name => "Nginx Server Names Hash Bucket Size",
+ :default => "64"
+
+attribute "nginx/disable_access_log",
+ :display_name => "Disable Access Log",
+ :default => "false"
View
41 episode-339/chef/cookbooks/nginx/recipes/authorized_ips.rb
@@ -0,0 +1,41 @@
+#
+# Cookbook Name:: nginx
+# Recipe:: http_stub_status_module
+#
+# Author:: Jamie Winsor (<jamie@vialstudios.com>)
+#
+# Copyright 2012, Riot Games
+#
+# 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.
+#
+
+node.default[:nginx][:remote_ip_var] = "remote_addr"
+node.default[:nginx][:authorized_ips] = ["127.0.0.1/32"]
+
+service "nginx" do
+ supports :status => true, :restart => true, :reload => true
+end
+
+template "authorized_ip" do
+ path "#{node[:nginx][:dir]}/authorized_ip"
+ source "modules/authorized_ip.erb"
+ owner "root"
+ group "root"
+ mode "0644"
+ variables(
+ :remote_ip_var => node[:nginx][:remote_ip_var],
+ :authorized_ips => node[:nginx][:authorized_ips]
+ )
+
+ notifies :reload, resources(:service => "nginx")
+end
View
64 episode-339/chef/cookbooks/nginx/recipes/default.rb
@@ -0,0 +1,64 @@
+#
+# Cookbook Name:: nginx
+# Recipe:: default
+# Author:: AJ Christensen <aj@junglist.gen.nz>
+#
+# Copyright 2008-2012, Opscode, Inc.
+#
+# 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.
+#
+
+include_recipe "nginx::ohai_plugin"
+
+package "nginx"
+
+service "nginx" do
+ supports :status => true, :restart => true, :reload => true
+ action :enable
+end
+
+directory node[:nginx][:log_dir] do
+ mode 0755
+ owner node[:nginx][:user]
+ action :create
+end
+
+%w{nxensite nxdissite}.each do |nxscript|
+ template "/usr/sbin/#{nxscript}" do
+ source "#{nxscript}.erb"
+ mode 0755
+ owner "root"
+ group "root"
+ end
+end
+
+template "nginx.conf" do
+ path "#{node[:nginx][:dir]}/nginx.conf"
+ source "nginx.conf.erb"
+ owner "root"
+ group "root"
+ mode 0644
+ notifies :reload, "service[nginx]"
+end
+
+template "#{node[:nginx][:dir]}/sites-available/default" do
+ source "default-site.erb"
+ owner "root"
+ group "root"
+ mode 0644
+ notifies :reload, "service[nginx]"
+end
+
+service "nginx" do
+ action :start
+end
View
103 episode-339/chef/cookbooks/nginx/recipes/http_geoip_module.rb
@@ -0,0 +1,103 @@
+#
+# Cookbook Name:: nginx
+# Recipe:: http_geoip_module
+#
+# Author:: Jamie Winsor (<jamie@vialstudios.com>)
+#
+# Copyright 2012, Riot Games
+#
+# 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.
+#
+
+country_dat = "#{node[:nginx][:geoip][:path]}/GeoIP.dat"
+country_src_filename = ::File.basename(node[:nginx][:geoip][:country_dat_url])
+country_src_filepath = "#{Chef::Config[:file_cache_path]}/#{country_src_filename}"
+city_dat = nil
+city_src_filename = ::File.basename(node[:nginx][:geoip][:city_dat_url])
+city_src_filepath = "#{Chef::Config[:file_cache_path]}/#{city_src_filename}"
+geolib_filename = ::File.basename(node[:nginx][:geoip][:lib_url])
+geolib_filepath = "#{Chef::Config[:file_cache_path]}/#{geolib_filename}"
+
+remote_file geolib_filepath do
+ source node[:nginx][:geoip][:lib_url]
+ checksum node[:nginx][:geoip][:lib_checksum]
+ owner "root"
+ group "root"
+ mode 0644
+end
+
+bash "extract_geolib" do
+ cwd ::File.dirname(geolib_filepath)
+ code <<-EOH
+ tar xzvf #{geolib_filepath} -C #{::File.dirname(geolib_filepath)}
+ cd GeoIP-#{node[:nginx][:geoip][:lib_version]} && ./configure
+ make && make install
+ EOH
+
+ creates "/usr/local/lib/libGeoIP.so.#{node[:nginx][:geoip][:lib_version]}"
+ subscribes :run, resources(:remote_file => geolib_filepath)
+end
+
+directory "#{node[:nginx][:geoip][:path]}" do
+ owner "root"
+ group "root"
+ mode 0755
+end
+
+remote_file country_src_filepath do
+ source node[:nginx][:geoip][:country_dat_url]
+ checksum node[:nginx][:geoip][:country_dat_checksum]
+ owner "root"
+ group "root"
+ mode 0644
+end
+
+bash "gunzip_geo_lite_country_dat" do
+ code <<-EOH
+ gunzip -c #{country_src_filepath} > #{country_dat}
+ EOH
+ creates country_dat
+end
+
+if node[:nginx][:geoip][:enable_city]
+ city_dat = "#{node[:nginx][:geoip][:path]}/GeoLiteCity.dat"
+
+ remote_file city_src_filepath do
+ source node[:nginx][:geoip][:city_dat_url]
+ checksum node[:nginx][:geoip][:city_dat_checksum]
+ owner "root"
+ group "root"
+ mode 0644
+ end
+
+ bash "gunzip_geo_lite_city_dat" do
+ code <<-EOH
+ gunzip -c #{city_src_filepath} > #{city_dat}
+ EOH
+ creates city_dat
+ end
+end
+
+template "#{node[:nginx][:dir]}/conf.d/http_geoip.conf" do
+ source "modules/http_geoip.conf.erb"
+ owner "root"
+ group "root"
+ mode "0644"
+ variables(
+ :country_dat => country_dat,
+ :city_dat => city_dat
+ )
+end
+
+node.run_state[:nginx_configure_flags] =
+ node.run_state[:nginx_configure_flags] | ["--with-http_geoip_module", "--with-ld-opt='-Wl,-R,/usr/local/lib -L /usr/local/lib'"]
View
23 episode-339/chef/cookbooks/nginx/recipes/http_gzip_static_module.rb
@@ -0,0 +1,23 @@
+#
+# Cookbook Name:: nginx
+# Recipe:: http_gzip_static_module
+#
+# Author:: Jamie Winsor (<jamie@vialstudios.com>)
+#
+# Copyright 2012, Riot Games
+#
+# 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.
+#
+
+node.run_state[:nginx_configure_flags] =
+ node.run_state[:nginx_configure_flags] | ["--with-http_gzip_static_module"]
View
46 episode-339/chef/cookbooks/nginx/recipes/http_realip_module.rb
@@ -0,0 +1,46 @@
+#
+# Cookbook Name:: nginx
+# Recipe:: http_realip_module
+#
+# Author:: Jamie Winsor (<jamie@vialstudios.com>)
+#
+# Copyright 2012, Riot Games
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file exc