├── .chef └── knife.rb ├── .gitignore ├── .rspec ├── .travis.yml ├── Berksfile ├── Berksfile.lock ├── Gemfile ├── LICENSE.txt ├── README.md ├── Rakefile ├── Thorfile ├── bin └── scratchify ├── chefignore ├── cookbooks ├── apt │ ├── CHANGELOG.md │ ├── README.md │ ├── attributes │ │ └── default.rb │ ├── files │ │ └── default │ │ │ ├── 15update-stamp │ │ │ └── apt-proxy-v2.conf │ ├── libraries │ │ ├── helpers.rb │ │ ├── matchers.rb │ │ └── network.rb │ ├── metadata.json │ ├── providers │ │ ├── preference.rb │ │ └── repository.rb │ ├── recipes │ │ ├── cacher-client.rb │ │ ├── cacher-ng.rb │ │ ├── default.rb │ │ └── unattended-upgrades.rb │ ├── resources │ │ ├── preference.rb │ │ └── repository.rb │ └── templates │ │ ├── debian-6.0 │ │ └── acng.conf.erb │ │ ├── default │ │ ├── 01proxy.erb │ │ ├── 10recommends.erb │ │ ├── 20auto-upgrades.erb │ │ ├── 50unattended-upgrades.erb │ │ ├── acng.conf.erb │ │ └── unattended-upgrades.seed.erb │ │ └── ubuntu-10.04 │ │ └── acng.conf.erb ├── bluepill │ ├── CHANGELOG.md │ ├── README.md │ ├── attributes │ │ └── default.rb │ ├── metadata.json │ ├── providers │ │ └── service.rb │ ├── recipes │ │ ├── default.rb │ │ └── rsyslog.rb │ ├── resources │ │ └── service.rb │ └── templates │ │ └── default │ │ ├── bluepill_init.fedora.erb │ │ ├── bluepill_init.freebsd.erb │ │ ├── bluepill_init.lsb.erb │ │ ├── bluepill_init.rhel.erb │ │ └── bluepill_rsyslog.conf.erb ├── build-essential │ ├── CHANGELOG.md │ ├── README.md │ ├── attributes │ │ └── default.rb │ ├── libraries │ │ ├── matchers.rb │ │ ├── timing.rb │ │ └── xcode_command_line_tools.rb │ ├── metadata.json │ └── recipes │ │ ├── _debian.rb │ │ ├── _fedora.rb │ │ ├── _freebsd.rb │ │ ├── _mac_os_x.rb │ │ ├── _omnios.rb │ │ ├── _rhel.rb │ │ ├── _smartos.rb │ │ ├── _solaris2.rb │ │ ├── _suse.rb │ │ └── default.rb ├── chef-sugar │ ├── CHANGELOG.md │ ├── README.md │ ├── metadata.json │ └── recipes │ │ └── default.rb ├── chef_gem │ ├── CHANGELOG.md │ ├── README.md │ ├── libraries │ │ └── chef_gem.rb │ ├── metadata.json │ └── recipes │ │ └── default.rb ├── java │ ├── .gitignore │ ├── .kitchen.docker.yml │ ├── .kitchen.yml │ ├── .travis.yml │ ├── Berksfile │ ├── CHANGELOG.md │ ├── CONTRIBUTING.md │ ├── Gemfile │ ├── ISSUES.md │ ├── LICENSE │ ├── README.md │ ├── Rakefile │ ├── TESTING.md │ ├── attributes │ │ └── default.rb │ ├── libraries │ │ ├── helpers.rb │ │ └── matchers.rb │ ├── metadata.json │ ├── providers │ │ ├── alternatives.rb │ │ └── ark.rb │ ├── recipes │ │ ├── default.rb │ │ ├── default_java_symlink.rb │ │ ├── homebrew.rb │ │ ├── ibm.rb │ │ ├── ibm_tar.rb │ │ ├── openjdk.rb │ │ ├── oracle.rb │ │ ├── oracle_i386.rb │ │ ├── oracle_jce.rb │ │ ├── oracle_rpm.rb │ │ ├── purge_packages.rb │ │ ├── set_attributes_from_version.rb │ │ ├── set_java_home.rb │ │ └── windows.rb │ ├── resources │ │ ├── alternatives.rb │ │ └── ark.rb │ └── templates │ │ └── default │ │ ├── ibm_jdk.installer.properties.erb │ │ └── oracle.jinfo.erb ├── nginx │ ├── CHANGELOG.md │ ├── README.md │ ├── attributes │ │ ├── auth_request.rb │ │ ├── default.rb │ │ ├── devel.rb │ │ ├── echo.rb │ │ ├── geoip.rb │ │ ├── headers_more.rb │ │ ├── lua.rb │ │ ├── naxsi.rb │ │ ├── openssl_source.rb │ │ ├── pagespeed.rb │ │ ├── passenger.rb │ │ ├── rate_limiting.rb │ │ ├── repo.rb │ │ ├── set_misc.rb │ │ ├── socketproxy.rb │ │ ├── source.rb │ │ ├── status.rb │ │ ├── syslog.rb │ │ └── upload_progress.rb │ ├── definitions │ │ └── nginx_site.rb │ ├── files │ │ └── default │ │ │ ├── mime.types │ │ │ └── naxsi_core.rules │ ├── libraries │ │ └── matchers.rb │ ├── metadata.json │ ├── recipes │ │ ├── authorized_ips.rb │ │ ├── commons.rb │ │ ├── commons_conf.rb │ │ ├── commons_dir.rb │ │ ├── commons_script.rb │ │ ├── default.rb │ │ ├── headers_more_module.rb │ │ ├── http_auth_request_module.rb │ │ ├── http_echo_module.rb │ │ ├── http_geoip_module.rb │ │ ├── http_gzip_static_module.rb │ │ ├── http_mp4_module.rb │ │ ├── http_perl_module.rb │ │ ├── http_realip_module.rb │ │ ├── http_spdy_module.rb │ │ ├── http_ssl_module.rb │ │ ├── http_stub_status_module.rb │ │ ├── ipv6.rb │ │ ├── lua.rb │ │ ├── naxsi_module.rb │ │ ├── ngx_devel_module.rb │ │ ├── ngx_lua_module.rb │ │ ├── ohai_plugin.rb │ │ ├── openssl_source.rb │ │ ├── package.rb │ │ ├── pagespeed_module.rb │ │ ├── passenger.rb │ │ ├── repo.rb │ │ ├── repo_passenger.rb │ │ ├── set_misc.rb │ │ ├── socketproxy.rb │ │ ├── source.rb │ │ ├── syslog_module.rb │ │ └── upload_progress_module.rb │ └── templates │ │ ├── debian │ │ └── nginx.init.erb │ │ ├── default │ │ ├── default-site.erb │ │ ├── modules │ │ │ ├── authorized_ip.erb │ │ │ ├── http_geoip.conf.erb │ │ │ ├── http_gzip_static.conf.erb │ │ │ ├── http_realip.conf.erb │ │ │ ├── nginx_status.erb │ │ │ ├── passenger.conf.erb │ │ │ ├── socketproxy.conf.erb │ │ │ └── upload_progress.erb │ │ ├── nginx-upstart.conf.erb │ │ ├── nginx.conf.erb │ │ ├── nginx.init.erb │ │ ├── nginx.pill.erb │ │ ├── nginx.sysconfig.erb │ │ ├── nxdissite.erb │ │ ├── nxensite.erb │ │ ├── plugins │ │ │ └── nginx.rb.erb │ │ ├── sv-nginx-log-run.erb │ │ └── sv-nginx-run.erb │ │ ├── gentoo │ │ └── nginx.init.erb │ │ ├── suse │ │ └── nginx.init.erb │ │ └── ubuntu │ │ └── nginx.init.erb ├── ohai │ ├── CHANGELOG.md │ ├── README.md │ ├── attributes │ │ └── default.rb │ ├── files │ │ └── default │ │ │ └── plugins │ │ │ └── README │ ├── libraries │ │ └── matchers.rb │ ├── metadata.json │ ├── providers │ │ └── hint.rb │ ├── recipes │ │ └── default.rb │ └── resources │ │ └── hint.rb ├── openssl │ ├── CHANGELOG.md │ ├── README.md │ ├── attributes │ │ └── default.rb │ ├── libraries │ │ ├── helpers.rb │ │ ├── matchers.rb │ │ ├── random_password.rb │ │ └── secure_password.rb │ ├── metadata.json │ ├── providers │ │ ├── dhparam.rb │ │ ├── rsa_key.rb │ │ └── x509.rb │ ├── recipes │ │ ├── default.rb │ │ └── upgrade.rb │ └── resources │ │ ├── dhparam.rb │ │ ├── rsa_key.rb │ │ └── x509.rb ├── packagecloud │ ├── CHANGELOG.md │ ├── README.md │ ├── attributes │ │ └── default.rb │ ├── libraries │ │ ├── helper.rb │ │ └── matcher.rb │ ├── metadata.json │ ├── providers │ │ └── repo.rb │ ├── resources │ │ └── repo.rb │ └── templates │ │ ├── .kitchen │ │ └── logs │ │ │ └── kitchen.log │ │ └── default │ │ ├── apt.erb │ │ └── yum.erb ├── postgresql │ ├── .gitignore │ ├── .kitchen.yml │ ├── .rspec │ ├── CHANGELOG.md │ ├── CONTRIBUTING.md │ ├── Cheffile │ ├── Gemfile │ ├── LICENSE │ ├── README.md │ ├── Rakefile │ ├── TESTING.md │ ├── attributes │ │ └── default.rb │ ├── files │ │ └── default │ │ │ └── tests │ │ │ └── minitest │ │ │ ├── apt_pgdg_postgresql_test.rb │ │ │ ├── default_test.rb │ │ │ ├── ruby_test.rb │ │ │ ├── server_test.rb │ │ │ └── support │ │ │ └── helpers.rb │ ├── libraries │ │ └── default.rb │ ├── metadata.json │ ├── providers │ │ ├── database.rb │ │ └── user.rb │ ├── recipes │ │ ├── apt_pgdg_postgresql.rb │ │ ├── client.rb │ │ ├── config_initdb.rb │ │ ├── config_pgtune.rb │ │ ├── contrib.rb │ │ ├── default.rb │ │ ├── ruby.rb │ │ ├── server.rb │ │ ├── server_conf.rb │ │ ├── server_debian.rb │ │ ├── server_redhat.rb │ │ ├── setup_databases.rb │ │ ├── setup_users.rb │ │ └── yum_pgdg_postgresql.rb │ ├── resources │ │ ├── database.rb │ │ └── user.rb │ ├── templates │ │ └── default │ │ │ ├── pg_hba.conf.erb │ │ │ ├── pgsql.sysconfig.erb │ │ │ └── postgresql.conf.erb │ └── test │ │ └── unit │ │ ├── debian_server_spec.rb │ │ ├── default_spec.rb │ │ ├── server_spec.rb │ │ └── spec_helper.rb ├── rsyslog │ ├── CHANGELOG.md │ ├── README.md │ ├── attributes │ │ └── default.rb │ ├── libraries │ │ └── helpers.rb │ ├── metadata.json │ ├── providers │ │ └── file_input.rb │ ├── recipes │ │ ├── client.rb │ │ ├── default.rb │ │ └── server.rb │ ├── resources │ │ └── file_input.rb │ └── templates │ │ ├── default │ │ ├── 35-server-per-host.conf.erb │ │ ├── 49-relp.conf.erb │ │ ├── 49-remote.conf.erb │ │ ├── 50-default.conf.erb │ │ ├── file-input.conf.erb │ │ ├── omnios-manifest.xml.erb │ │ └── rsyslog.conf.erb │ │ └── smartos │ │ └── 50-default.conf.erb ├── ruby_build │ ├── CHANGELOG.md │ ├── README.md │ ├── attributes │ │ └── default.rb │ ├── libraries │ │ └── ruby_build_recipe_helpers.rb │ ├── metadata.json │ ├── providers │ │ └── ruby.rb │ ├── recipes │ │ └── default.rb │ └── resources │ │ └── ruby.rb ├── ruby_rbenv │ ├── CHANGELOG.md │ ├── README.md │ ├── attributes │ │ └── default.rb │ ├── libraries │ │ ├── chef_provider_package_rbenvrubygems.rb │ │ ├── chef_rbenv_mixin.rb │ │ ├── chef_rbenv_recipe_helpers.rb │ │ ├── chef_rbenv_script_helpers.rb │ │ └── matchers.rb │ ├── metadata.json │ ├── providers │ │ ├── global.rb │ │ ├── plugin.rb │ │ ├── rehash.rb │ │ ├── ruby.rb │ │ └── script.rb │ ├── recipes │ │ ├── default.rb │ │ ├── system.rb │ │ ├── system_install.rb │ │ ├── user.rb │ │ └── user_install.rb │ ├── resources │ │ ├── gem.rb │ │ ├── global.rb │ │ ├── plugin.rb │ │ ├── rehash.rb │ │ ├── ruby.rb │ │ └── script.rb │ └── templates │ │ └── default │ │ └── rbenv.sh.erb ├── runit │ ├── .kitchen.cloud.yml │ ├── .kitchen.yml │ ├── .rspec │ ├── .rubocop.yml │ ├── Berksfile.disabled │ ├── CHANGELOG.md │ ├── CONTRIBUTING.md │ ├── Cheffile │ ├── Gemfile │ ├── LICENSE │ ├── README.md │ ├── Rakefile │ ├── TESTING.md │ ├── attributes │ │ └── default.rb │ ├── files │ │ ├── default │ │ │ ├── runit.seed │ │ │ └── runsvdir │ │ ├── ubuntu-6.10 │ │ │ └── runsvdir │ │ ├── ubuntu-7.04 │ │ │ └── runsvdir │ │ ├── ubuntu-7.10 │ │ │ └── runsvdir │ │ └── ubuntu-8.04 │ │ │ └── runsvdir │ ├── libraries │ │ ├── default.rb │ │ ├── helpers.rb │ │ ├── matchers.rb │ │ ├── provider_runit_service.rb │ │ └── resource_runit_service.rb │ ├── metadata.json │ ├── recipes │ │ └── default.rb │ └── templates │ │ ├── debian │ │ └── init.d.erb │ │ ├── default │ │ └── log-config.erb │ │ └── gentoo │ │ └── runit-start.sh.erb ├── rvm │ ├── .foodcritic │ ├── .gitignore │ ├── .kitchen.yml │ ├── .travis.yml │ ├── Berksfile │ ├── CHANGELOG.md │ ├── CODE_OF_CONDUCT.md │ ├── CONTRIBUTING.md │ ├── Gemfile │ ├── Guardfile │ ├── README.md │ ├── Rakefile │ ├── attributes │ │ ├── .gitkeep │ │ ├── default.rb │ │ ├── gem_package.rb │ │ └── vagrant.rb │ ├── libraries │ │ ├── chef_rvm_environment_helpers.rb │ │ ├── chef_rvm_gemset_helpers.rb │ │ ├── chef_rvm_recipe_helpers.rb │ │ ├── chef_rvm_ruby_helpers.rb │ │ ├── chef_rvm_set_helpers.rb │ │ ├── chef_rvm_shell_helpers.rb │ │ ├── chef_rvm_string_cache.rb │ │ ├── chef_rvm_string_helpers.rb │ │ ├── chef_rvm_version_helpers.rb │ │ ├── gem_package_monkeypatch.rb │ │ ├── provider_rvm_installation.rb │ │ ├── resource_rvm_installation.rb │ │ ├── rvm_chef_user_environment.rb │ │ ├── rvm_rubygems_package.rb │ │ └── rvm_shell_chef_wrapper.rb │ ├── metadata.json │ ├── providers │ │ ├── default_ruby.rb │ │ ├── environment.rb │ │ ├── gemset.rb │ │ ├── global_gem.rb │ │ ├── ruby.rb │ │ ├── shell.rb │ │ └── wrapper.rb │ ├── recipes │ │ ├── .gitkeep │ │ ├── default.rb │ │ ├── gem_package.rb │ │ ├── system.rb │ │ ├── system_install.rb │ │ ├── user.rb │ │ ├── user_install.rb │ │ └── vagrant.rb │ ├── resources │ │ ├── default_ruby.rb │ │ ├── environment.rb │ │ ├── gem.rb │ │ ├── gemset.rb │ │ ├── global_gem.rb │ │ ├── ruby.rb │ │ ├── shell.rb │ │ └── wrapper.rb │ ├── templates │ │ └── default │ │ │ ├── rvmrc.erb │ │ │ ├── vagrant-chef-client-wrapper.erb │ │ │ └── vagrant-chef-solo-wrapper.erb │ └── test │ │ ├── integration │ │ ├── data_bags │ │ │ └── users │ │ │ │ ├── virgil1.json │ │ │ │ ├── virgil2.json │ │ │ │ └── wigglebottom.json │ │ ├── installs │ │ │ └── bats │ │ │ │ └── version_pinning.bats │ │ ├── rubies │ │ │ └── bats │ │ │ │ ├── _common.bash │ │ │ │ ├── verify_1.9.3.bats │ │ │ │ ├── verify_jruby.bats │ │ │ │ ├── verify_patch_support.bats │ │ │ │ ├── verify_ree.bats │ │ │ │ └── verify_rubygems_version_support.bats │ │ └── stock_system_and_user │ │ │ └── bats │ │ │ └── system.bats │ │ └── unit │ │ ├── libraries │ │ ├── provider_rvm_installation_spec.rb │ │ └── resource_rvm_installation_spec.rb │ │ └── spec_helper.rb ├── scratchify │ ├── Berksfile │ ├── Berksfile.lock │ ├── LICENSE.txt │ ├── README.md │ ├── Thorfile │ ├── chefignore │ ├── from-scratch.gemspec │ ├── metadata.json │ ├── recipes │ │ ├── default.rb │ │ ├── nginx_site.rb │ │ └── pre_rvm.rb │ └── templates │ │ ├── database.yml.erb │ │ ├── nginx.erb │ │ ├── node.json.erb │ │ ├── secrets.yml.erb │ │ └── user.json.erb ├── user │ ├── .gitignore │ ├── .kitchen.yml │ ├── .travis.yml │ ├── Berksfile │ ├── CHANGELOG.md │ ├── Gemfile │ ├── README.md │ ├── Rakefile │ ├── attributes │ │ └── default.rb │ ├── libraries │ │ └── matchers.rb │ ├── metadata.json │ ├── providers │ │ └── account.rb │ ├── recipes │ │ ├── data_bag.rb │ │ └── default.rb │ ├── resources │ │ └── account.rb │ └── templates │ │ └── default │ │ └── authorized_keys.erb ├── yum-epel │ ├── CHANGELOG.md │ ├── README.md │ ├── attributes │ │ ├── default.rb │ │ ├── epel-debuginfo.rb │ │ ├── epel-source.rb │ │ ├── epel-testing-debuginfo.rb │ │ ├── epel-testing-source.rb │ │ ├── epel-testing.rb │ │ └── epel.rb │ ├── metadata.json │ └── recipes │ │ └── default.rb └── yum │ ├── CHANGELOG.md │ ├── README.md │ ├── attributes │ └── main.rb │ ├── libraries │ └── matchers.rb │ ├── metadata.json │ ├── providers │ ├── globalconfig.rb │ └── repository.rb │ ├── recipes │ └── default.rb │ ├── resources │ ├── globalconfig.rb │ └── repository.rb │ └── templates │ └── default │ ├── main.erb │ └── repo.erb ├── from-scratch.gemspec ├── lib ├── from-scratch.rb └── from-scratch │ └── version.rb ├── metadata.rb ├── recipes ├── default.rb ├── nginx_site.rb └── pre_rvm.rb ├── spec ├── from_scratch_spec.rb └── spec_helper.rb └── templates ├── database.yml.erb ├── nginx.erb ├── node.json.erb ├── secrets.yml.erb └── user.json.erb /.chef/knife.rb: -------------------------------------------------------------------------------- 1 | cookbook_path "cookbooks" 2 | node_path "tmp/nodes" 3 | data_bag_path "tmp/data_bags" 4 | 5 | knife[:berkshelf_path] = "cookbooks" 6 | Chef::Config[:ssl_verify_mode] = :verify_peer if defined? ::Chef 7 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /.bundle/ 2 | /.yardoc 3 | /Gemfile.lock 4 | /_yardoc/ 5 | /coverage/ 6 | /doc/ 7 | /pkg/ 8 | /spec/reports/ 9 | /tmp/ 10 | *.gem 11 | -------------------------------------------------------------------------------- /.rspec: -------------------------------------------------------------------------------- 1 | --format documentation 2 | --color 3 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: ruby 2 | rvm: 3 | - 2.2.2 4 | before_install: gem install bundler -v 1.10.6 5 | -------------------------------------------------------------------------------- /Berksfile: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | #^syntax detection 3 | 4 | source "https://supermarket.chef.io" 5 | 6 | metadata 7 | 8 | cookbook 'user' 9 | cookbook 'rvm', github: 'martinisoft/chef-rvm' 10 | cookbook 'postgresql', github: 'sandrew/postgresql', branch: 'develop' 11 | cookbook 'nginx' 12 | cookbook 'ruby_rbenv' 13 | -------------------------------------------------------------------------------- /Berksfile.lock: -------------------------------------------------------------------------------- 1 | DEPENDENCIES 2 | nginx 3 | postgresql 4 | git: git://github.com/sandrew/postgresql.git 5 | revision: a1f3ce3e2e22515bc175011a3e3faa0af98dd8db 6 | branch: develop 7 | ruby_rbenv 8 | rvm 9 | git: git://github.com/martinisoft/chef-rvm.git 10 | revision: 08ec265f277e112a5a2e4b201bd32ddfe1bb968c 11 | scratchify 12 | path: . 13 | metadata: true 14 | user 15 | 16 | GRAPH 17 | apt (2.9.2) 18 | bluepill (2.4.0) 19 | rsyslog (>= 0.0.0) 20 | build-essential (2.2.4) 21 | chef-sugar (3.1.1) 22 | chef_gem (0.1.0) 23 | java (1.35.0) 24 | nginx (2.7.6) 25 | apt (~> 2.2) 26 | bluepill (~> 2.3) 27 | build-essential (~> 2.0) 28 | ohai (~> 2.0) 29 | runit (~> 1.2) 30 | yum-epel (~> 0.3) 31 | ohai (2.0.3) 32 | openssl (4.4.0) 33 | chef-sugar (>= 3.1.1) 34 | packagecloud (0.1.0) 35 | postgresql (3.4.21) 36 | apt (>= 1.9.0) 37 | build-essential (>= 0.0.0) 38 | openssl (~> 4.0) 39 | rsyslog (2.2.0) 40 | ruby_build (0.8.0) 41 | ruby_rbenv (1.0.1) 42 | java (> 1.4.0) 43 | ruby_build (>= 0.0.0) 44 | runit (1.7.4) 45 | packagecloud (>= 0.0.0) 46 | rvm (0.10.1) 47 | chef_gem (>= 0.0.0) 48 | java (>= 0.0.0) 49 | scratchify (0.1.0) 50 | nginx (>= 0.0.0) 51 | postgresql (>= 0.0.0) 52 | ruby_rbenv (>= 0.0.0) 53 | rvm (>= 0.0.0) 54 | user (>= 0.0.0) 55 | user (0.4.2) 56 | yum (3.8.1) 57 | yum-epel (0.6.4) 58 | yum (~> 3.2) 59 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | 3 | # Specify your gem's dependencies in from-scratch.gemspec 4 | gemspec 5 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Andrew Shaydurov 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | require "bundler/gem_tasks" 2 | require "rspec/core/rake_task" 3 | 4 | RSpec::Core::RakeTask.new(:spec) 5 | 6 | task :default => :spec 7 | -------------------------------------------------------------------------------- /Thorfile: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require 'bundler' 4 | require 'bundler/setup' 5 | require 'berkshelf/thor' 6 | -------------------------------------------------------------------------------- /bin/scratchify: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | require "bundler/setup" 4 | require "from-scratch" 5 | 6 | FromScratch.new.run! 7 | -------------------------------------------------------------------------------- /cookbooks/apt/files/default/15update-stamp: -------------------------------------------------------------------------------- 1 | APT::Update::Post-Invoke-Success {"touch /var/lib/apt/periodic/update-success-stamp 2>/dev/null || true";}; 2 | -------------------------------------------------------------------------------- /cookbooks/apt/files/default/apt-proxy-v2.conf: -------------------------------------------------------------------------------- 1 | [DEFAULT] 2 | ;; All times are in seconds, but you can add a suffix 3 | ;; for minutes(m), hours(h) or days(d) 4 | 5 | ;; commented out address so apt-proxy will listen on all IPs 6 | ;; address = 127.0.0.1 7 | port = 9999 8 | cache_dir = /var/cache/apt-proxy 9 | 10 | ;; Control files (Packages/Sources/Contents) refresh rate 11 | min_refresh_delay = 1s 12 | complete_clientless_downloads = 1 13 | 14 | ;; Debugging settings. 15 | debug = all:4 db:0 16 | 17 | time = 30 18 | passive_ftp = on 19 | 20 | ;;-------------------------------------------------------------- 21 | ;; Cache housekeeping 22 | 23 | cleanup_freq = 1d 24 | max_age = 120d 25 | max_versions = 3 26 | 27 | ;;--------------------------------------------------------------- 28 | ;; Backend servers 29 | ;; 30 | ;; Place each server in its own [section] 31 | 32 | [ubuntu] 33 | ; Ubuntu archive 34 | backends = 35 | http://us.archive.ubuntu.com/ubuntu 36 | 37 | [ubuntu-security] 38 | ; Ubuntu security updates 39 | backends = http://security.ubuntu.com/ubuntu 40 | 41 | [debian] 42 | ;; Backend servers, in order of preference 43 | backends = 44 | http://debian.osuosl.org/debian/ 45 | 46 | [security] 47 | ;; Debian security archive 48 | backends = 49 | http://security.debian.org/debian-security 50 | http://ftp2.de.debian.org/debian-security 51 | -------------------------------------------------------------------------------- /cookbooks/apt/libraries/matchers.rb: -------------------------------------------------------------------------------- 1 | if defined?(ChefSpec) 2 | def add_apt_preference(resource_name) 3 | ChefSpec::Matchers::ResourceMatcher.new(:apt_preference, :add, resource_name) 4 | end 5 | 6 | def remove_apt_preference(resource_name) 7 | ChefSpec::Matchers::ResourceMatcher.new(:apt_preference, :remove, resource_name) 8 | end 9 | 10 | def add_apt_repository(resource_name) 11 | ChefSpec::Matchers::ResourceMatcher.new(:apt_repository, :add, resource_name) 12 | end 13 | 14 | def remove_apt_repository(resource_name) 15 | ChefSpec::Matchers::ResourceMatcher.new(:apt_repository, :remove, resource_name) 16 | end 17 | end 18 | -------------------------------------------------------------------------------- /cookbooks/apt/libraries/network.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: apt 3 | # library:: network 4 | # 5 | # Copyright 2013, Chef Software, Inc. 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # 19 | 20 | module ::Apt 21 | def interface_ipaddress(host, interface) 22 | if interface 23 | addresses = host['network']['interfaces'][interface]['addresses'] 24 | addresses.select do |ip, data| 25 | return ip if data['family'].eql?('inet') 26 | end 27 | else 28 | return host.ipaddress 29 | end 30 | end 31 | end 32 | -------------------------------------------------------------------------------- /cookbooks/apt/metadata.json: -------------------------------------------------------------------------------- 1 | {"name":"apt","version":"2.9.2","description":"Configures apt and apt services. Ships resources for managing apt repositories","long_description":"","maintainer":"Chef Software, Inc.","maintainer_email":"cookbooks@chef.io","license":"Apache 2.0","platforms":{"ubuntu":">= 0.0.0","debian":">= 0.0.0"},"dependencies":{},"recommendations":{},"suggestions":{},"conflicting":{},"providing":{},"replacing":{},"attributes":{},"groupings":{},"recipes":{"apt::default":"Runs apt-get update during compile phase and sets up preseed directories","apt::cacher-ng":"Set up an apt-cacher-ng caching proxy","apt::cacher-client":"Client for the apt::cacher-ng caching proxy"}} -------------------------------------------------------------------------------- /cookbooks/apt/recipes/cacher-ng.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: apt 3 | # Recipe:: cacher-ng 4 | # 5 | # Copyright 2008-2013, Chef Software, Inc. 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the 'License'); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an 'AS IS' BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # 19 | 20 | node.set['apt']['caching_server'] = true 21 | 22 | package 'apt-cacher-ng' do 23 | action :install 24 | end 25 | 26 | directory node['apt']['cacher_dir'] do 27 | owner 'apt-cacher-ng' 28 | group 'apt-cacher-ng' 29 | mode 0755 30 | end 31 | 32 | template '/etc/apt-cacher-ng/acng.conf' do 33 | source 'acng.conf.erb' 34 | owner 'root' 35 | group 'root' 36 | mode 00644 37 | notifies :restart, 'service[apt-cacher-ng]', :immediately 38 | end 39 | 40 | service 'apt-cacher-ng' do 41 | supports restart: true, status: false 42 | action [:enable, :start] 43 | end 44 | -------------------------------------------------------------------------------- /cookbooks/apt/resources/preference.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: apt 3 | # Resource:: preference 4 | # 5 | # Copyright 2010-2013, Chef Software, Inc. 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # 19 | 20 | actions :add, :remove 21 | default_action :add if defined?(default_action) # Chef > 10.8 22 | 23 | # Needed for Chef versions < 0.10.10 24 | def initialize(*args) 25 | super 26 | @action = :add 27 | end 28 | 29 | state_attrs :glob, 30 | :package_name, 31 | :pin, 32 | :pin_priority 33 | 34 | attribute :package_name, kind_of: String, name_attribute: true, regex: [/^([a-z]|[A-Z]|[0-9]|_|-|\.|\*)+$/] 35 | attribute :glob, kind_of: String 36 | attribute :pin, kind_of: String 37 | attribute :pin_priority, kind_of: String 38 | -------------------------------------------------------------------------------- /cookbooks/apt/templates/default/01proxy.erb: -------------------------------------------------------------------------------- 1 | Acquire::http::Proxy "http://<%= @proxy %>:<%= @port %>"; 2 | <% if @proxy_ssl %> 3 | Acquire::https::Proxy "http://<%= @proxy %>:<%= @port %>"; 4 | <% else %> 5 | Acquire::https::Proxy "DIRECT"; 6 | <% end %> 7 | <% @bypass.each do |bypass, type| %> 8 | Acquire::<%= type %>::Proxy::<%= bypass %> "DIRECT"; 9 | <% end %> 10 | -------------------------------------------------------------------------------- /cookbooks/apt/templates/default/10recommends.erb: -------------------------------------------------------------------------------- 1 | # Managed by Chef 2 | APT::Install-Recommends "<%= node['apt']['confd']['install_recommends'] ? 1 : 0 %>"; 3 | APT::Install-Suggests "<%= node['apt']['confd']['install_suggests'] ? 1 : 0 %>"; 4 | -------------------------------------------------------------------------------- /cookbooks/apt/templates/default/20auto-upgrades.erb: -------------------------------------------------------------------------------- 1 | APT::Periodic::Update-Package-Lists "<%= node['apt']['unattended_upgrades']['update_package_lists'] ? 1 : 0 %>"; 2 | APT::Periodic::Unattended-Upgrade "<%= node['apt']['unattended_upgrades']['enable'] ? 1 : 0 %>"; 3 | -------------------------------------------------------------------------------- /cookbooks/apt/templates/default/unattended-upgrades.seed.erb: -------------------------------------------------------------------------------- 1 | unattended-upgrades unattended-upgrades/enable_auto_updates boolean <%= node['apt']['unattended_upgrades']['enable'] ? 'true' : 'false' %> 2 | -------------------------------------------------------------------------------- /cookbooks/bluepill/recipes/default.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: bluepill 3 | # Recipe:: default 4 | # 5 | # Copyright 2010-2015, Chef Software, Inc. 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # 19 | 20 | gem_package 'i18n' do 21 | action :install 22 | end 23 | 24 | gem_package 'bluepill' do 25 | version node['bluepill']['version'] if node['bluepill']['version'] 26 | action :install 27 | end 28 | 29 | [ 30 | node['bluepill']['conf_dir'], 31 | node['bluepill']['pid_dir'], 32 | node['bluepill']['state_dir'] 33 | ].each do |dir| 34 | directory dir do 35 | recursive true 36 | owner 'root' 37 | group node['bluepill']['group'] 38 | end 39 | end 40 | 41 | file node['bluepill']['logfile'] do 42 | owner 'root' 43 | group node['bluepill']['group'] 44 | mode '0755' 45 | action :create_if_missing 46 | end 47 | 48 | include_recipe 'bluepill::rsyslog' if node['bluepill']['use_rsyslog'] 49 | -------------------------------------------------------------------------------- /cookbooks/bluepill/recipes/rsyslog.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: bluepill 3 | # Recipe:: rsyslog 4 | # 5 | # Copyright 2010-2015, Chef Software, Inc. 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # 19 | 20 | include_recipe 'rsyslog' 21 | 22 | template '/etc/rsyslog.d/bluepill.conf' do 23 | owner 'root' 24 | group 'root' 25 | mode '0644' 26 | source 'bluepill_rsyslog.conf.erb' 27 | notifies :restart, 'service[rsyslog]' 28 | end 29 | -------------------------------------------------------------------------------- /cookbooks/bluepill/resources/service.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: bluepill 3 | # Resource:: service 4 | # 5 | # Copyright 2010-2015, Chef Software, Inc. 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # 19 | 20 | actions :start, :stop, :enable, :disable, :load, :restart, :reload 21 | default_action :start 22 | 23 | attribute :service_name, name_attribute: true 24 | attribute :enabled, default: false 25 | attribute :running, default: false 26 | attribute :variables, kind_of: Hash 27 | attribute :supports, default: { restart: true, status: true } 28 | -------------------------------------------------------------------------------- /cookbooks/bluepill/templates/default/bluepill_init.fedora.erb: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Author: Jamie Winsor () 4 | # 5 | # chkconfig: 345 99 1 6 | # Description: Bluepill loader for <%= @service_name %> 7 | # Provides: <%= @service_name %> 8 | # Default-Start: 3 4 5 9 | # Default-Stop: 0 1 2 6 10 | 11 | BLUEPILL_BIN=<%= node['bluepill']['bin'] %> 12 | BLUEPILL_CONFIG=<%= @config_file %> 13 | SERVICE_NAME=<%= @service_name %> 14 | 15 | [ -r <%= node['bluepill']['defaults_dir'] %>/$SERVICE_NAME ] && . <%= node['bluepill']['defaults_dir'] %>/$SERVICE_NAME 16 | 17 | case "$1" in 18 | start) 19 | echo "Loading bluepill configuration for $SERVICE_NAME " 20 | $BLUEPILL_BIN load $BLUEPILL_CONFIG 21 | ;; 22 | stop) 23 | $BLUEPILL_BIN $SERVICE_NAME stop 24 | $BLUEPILL_BIN $SERVICE_NAME quit 25 | ;; 26 | restart) 27 | $0 stop 28 | $0 start 29 | ;; 30 | *) 31 | echo "Usage: $0 {start|stop|restart}" 32 | exit 1 33 | ;; 34 | esac 35 | -------------------------------------------------------------------------------- /cookbooks/bluepill/templates/default/bluepill_init.freebsd.erb: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | ## 3 | # PROVIDE: named 4 | # REQUIRE: SERVERS cleanvar 5 | # KEYWORD: shutdown 6 | # 7 | 8 | . /etc/rc.subr 9 | 10 | name="<%= @service_name %>" 11 | rcvar=`set_rcvar` 12 | 13 | # Set some defaults 14 | <%= @service_name %>_enable=${<%= @service_name %>_enable:-"NO"} 15 | 16 | pidfile="/var/run/<%= @service_name %>.pid" 17 | command="/usr/local/bin/bluepill" 18 | 19 | start_precmd="${command} load <%= node['bluepill']['conf_dir'] %>/<%= @service_name %>.pill" 20 | start_cmd="${command} ${name} start" 21 | 22 | status_cmd="${command} ${name} status" 23 | 24 | stop_cmd="${command} ${name} stop" 25 | stop_postcmd="${command} ${name} quit" 26 | 27 | [ -r <%= node['bluepill']['defaults_dir'] %>/$name ] && . <%= node['bluepill']['defaults_dir'] %>/$name 28 | load_rc_config ${name} 29 | 30 | PATH="${PATH}:/usr/local/bin" 31 | 32 | run_rc_command "$1" 33 | -------------------------------------------------------------------------------- /cookbooks/bluepill/templates/default/bluepill_init.lsb.erb: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | ### BEGIN INIT INFO 4 | # Provides: <%= @service_name %> 5 | # Required-Start: 6 | # Required-Stop: 7 | # Defalt-Start: 2 3 4 5 8 | # Default-Stop: 0 1 2 6 9 | # Description: Bluepill loader for <%= @service_name %> 10 | ### END INIT INFO 11 | 12 | BLUEPILL_BIN=<%= node['bluepill']['bin'] %> 13 | BLUEPILL_CONFIG=<%= @config_file %> 14 | SERVICE_NAME=<%= @service_name %> 15 | 16 | [ -r <%= node['bluepill']['defaults_dir'] %>/$SERVICE_NAME ] && . <%= node['bluepill']['defaults_dir'] %>/$SERVICE_NAME 17 | 18 | case "$1" in 19 | start) 20 | echo "Loading bluepill configuration for $SERVICE_NAME " 21 | $BLUEPILL_BIN load $BLUEPILL_CONFIG 22 | ;; 23 | stop) 24 | $BLUEPILL_BIN $SERVICE_NAME stop 25 | $BLUEPILL_BIN $SERVICE_NAME quit 26 | ;; 27 | restart) 28 | $BLUEPILL_BIN $SERVICE_NAME restart 29 | ;; 30 | status) 31 | $BLUEPILL_BIN $SERVICE_NAME status 32 | ;; 33 | *) 34 | echo "Usage: $0 {start|stop|restart}" 35 | exit 1 36 | ;; 37 | esac 38 | -------------------------------------------------------------------------------- /cookbooks/bluepill/templates/default/bluepill_init.rhel.erb: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Author: Jamie Winsor () 4 | # 5 | # chkconfig: 345 99 1 6 | # Description: Bluepill loader for <%= @service_name %> 7 | # Provides: <%= @service_name %> 8 | # Default-Start: 3 4 5 9 | # Default-Stop: 0 1 2 6 10 | 11 | BLUEPILL_BIN=<%= node['bluepill']['bin'] %> 12 | BLUEPILL_CONFIG=<%= @config_file %> 13 | SERVICE_NAME=<%= @service_name %> 14 | 15 | [ -r <%= node['bluepill']['defaults_dir'] %>/$SERVICE_NAME ] && . <%= node['bluepill']['defaults_dir'] %>/$SERVICE_NAME 16 | 17 | case "$1" in 18 | start) 19 | echo "Loading bluepill configuration for $SERVICE_NAME " 20 | $BLUEPILL_BIN load $BLUEPILL_CONFIG 21 | ;; 22 | stop) 23 | $BLUEPILL_BIN $SERVICE_NAME stop 24 | $BLUEPILL_BIN $SERVICE_NAME quit 25 | ;; 26 | restart) 27 | $0 stop 28 | $0 start 29 | ;; 30 | *) 31 | echo "Usage: $0 {start|stop|restart}" 32 | exit 1 33 | ;; 34 | esac 35 | -------------------------------------------------------------------------------- /cookbooks/bluepill/templates/default/bluepill_rsyslog.conf.erb: -------------------------------------------------------------------------------- 1 | local6.* <%= node["bluepill"]["logfile"] %> 2 | -------------------------------------------------------------------------------- /cookbooks/build-essential/attributes/default.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: build-essential 3 | # Attributes:: default 4 | # 5 | # Copyright 2008-2012, Chef Software, Inc. 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # 19 | 20 | default['build-essential']['compile_time'] = false 21 | -------------------------------------------------------------------------------- /cookbooks/build-essential/libraries/matchers.rb: -------------------------------------------------------------------------------- 1 | if defined?(ChefSpec) 2 | def install_xcode_command_line_tools(resource_name) 3 | ChefSpec::Matchers::ResourceMatcher.new(:xcode_command_line_tools, :install, resource_name) 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /cookbooks/build-essential/metadata.json: -------------------------------------------------------------------------------- 1 | {"name":"build-essential","version":"2.2.4","description":"Installs C compiler / build tools","long_description":"","maintainer":"Chef Software, Inc.","maintainer_email":"cookbooks@chef.io","license":"Apache 2.0","platforms":{"amazon":">= 0.0.0","centos":">= 0.0.0","debian":">= 0.0.0","fedora":">= 0.0.0","freebsd":">= 0.0.0","mac_os_x":">= 10.7.0","mac_os_x_server":">= 10.7.0","oracle":">= 0.0.0","redhat":">= 0.0.0","scientific":">= 0.0.0","smartos":">= 0.0.0","suse":">= 0.0.0","ubuntu":">= 0.0.0"},"dependencies":{},"recommendations":{},"suggestions":{"pkgutil":">= 0.0.0"},"conflicting":{},"providing":{},"replacing":{},"attributes":{"build-essential/compile_time":{"display_name":"Build Essential Compile Time Execution","description":"Execute resources at compile time.","default":"false","recipes":["build-essential::default"]}},"groupings":{},"recipes":{"build-essential":"Installs packages required for compiling C software from source."},"source_url":"https://github.com/chef-cookbooks/build-essential","issues_url":"https://github.com/chef-cookbooks/build-essential/issues"} -------------------------------------------------------------------------------- /cookbooks/build-essential/recipes/_debian.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: build-essential 3 | # Recipe:: debian 4 | # 5 | # Copyright 2008-2013, Chef Software, Inc. 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # 19 | 20 | potentially_at_compile_time do 21 | package 'autoconf' 22 | package 'binutils-doc' 23 | package 'bison' 24 | package 'build-essential' 25 | package 'flex' 26 | package 'gettext' 27 | package 'ncurses-dev' 28 | end 29 | -------------------------------------------------------------------------------- /cookbooks/build-essential/recipes/_fedora.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: build-essential 3 | # Recipe:: fedora 4 | # 5 | # Copyright 2008-2015, Chef Software, Inc. 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # 19 | 20 | potentially_at_compile_time do 21 | package 'autoconf' 22 | package 'bison' 23 | package 'flex' 24 | package 'gcc' 25 | package 'gcc-c++' 26 | package 'gettext' 27 | package 'kernel-devel' 28 | package 'make' 29 | package 'm4' 30 | package 'ncurses-devel' 31 | package 'patch' 32 | end 33 | -------------------------------------------------------------------------------- /cookbooks/build-essential/recipes/_freebsd.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: build-essential 3 | # Recipe:: freebsd 4 | # 5 | # Copyright 2014, Chef Software, Inc. 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # 19 | 20 | potentially_at_compile_time do 21 | package 'devel/gmake' 22 | package 'devel/autoconf' 23 | package 'devel/m4' 24 | end 25 | -------------------------------------------------------------------------------- /cookbooks/build-essential/recipes/_mac_os_x.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: build-essential 3 | # Recipe:: mac_os_x 4 | # 5 | # Copyright 2008-2013, Chef Software, Inc. 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # 19 | 20 | potentially_at_compile_time do 21 | xcode_command_line_tools 'install' 22 | end 23 | -------------------------------------------------------------------------------- /cookbooks/build-essential/recipes/_omnios.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: build-essential 3 | # Recipe:: omnios 4 | # 5 | # Copyright 2013, Chef Software, Inc. 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # 19 | 20 | potentially_at_compile_time do 21 | package 'developer/gcc47' 22 | package 'developer/object-file' 23 | package 'developer/linker' 24 | package 'developer/library/lint' 25 | package 'developer/build/gnu-make' 26 | package 'system/header' 27 | package 'system/library/math/header-math' 28 | end 29 | 30 | # Per OmniOS documentation, the gcc bin dir isn't in the default 31 | # $PATH, so add it to the running process environment 32 | # http://omnios.omniti.com/wiki.php/DevEnv 33 | ENV['PATH'] = "#{ENV['PATH']}:/opt/gcc-4.7.2/bin" 34 | -------------------------------------------------------------------------------- /cookbooks/build-essential/recipes/_rhel.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: build-essential 3 | # Recipe:: rhel 4 | # 5 | # Copyright 2008-2013, Chef Software, Inc. 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # 19 | 20 | potentially_at_compile_time do 21 | package 'autoconf' 22 | package 'bison' 23 | package 'flex' 24 | package 'gcc' 25 | package 'gcc-c++' 26 | package 'kernel-devel' 27 | package 'make' 28 | package 'm4' 29 | package 'patch' 30 | 31 | # Ensure GCC 4 is available on older pre-6 EL 32 | if node['platform_version'].to_i < 6 33 | package 'gcc44' 34 | package 'gcc44-c++' 35 | end 36 | end 37 | -------------------------------------------------------------------------------- /cookbooks/build-essential/recipes/_smartos.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: build-essential 3 | # Recipe:: smartos 4 | # 5 | # Copyright 2008-2013, Chef Software, Inc. 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # 19 | 20 | potentially_at_compile_time do 21 | package 'autoconf' 22 | package 'binutils' 23 | package 'build-essential' 24 | package 'gcc47' 25 | package 'gmake' 26 | package 'pkg-config' 27 | end 28 | -------------------------------------------------------------------------------- /cookbooks/build-essential/recipes/_solaris2.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: build-essential 3 | # Recipe:: solaris2 4 | # 5 | # Copyright 2013, Chef Software, Inc. 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # 19 | 20 | case node['platform_version'].to_f 21 | when 5.10 22 | # You should install the following packages from the Solaris 10 DVD: 23 | # 24 | # SUNWbison 25 | # SUNWgcc 26 | # SUNWggrp 27 | # SUNWgmake 28 | # SUNWgtar 29 | # 30 | when 5.11 31 | potentially_at_compile_time do 32 | package 'autoconf' 33 | package 'automake' 34 | package 'bison' 35 | package 'gnu-coreutils' 36 | package 'flex' 37 | package 'gcc' 38 | package 'gcc-3' 39 | package 'gnu-grep' 40 | package 'gnu-make' 41 | package 'gnu-patch' 42 | package 'gnu-tar' 43 | package 'pkg-config' 44 | package 'ucb' 45 | end 46 | else 47 | fail "Sorry, we don't support Solaris version #{node['platform_version']} at this juncture." 48 | end 49 | -------------------------------------------------------------------------------- /cookbooks/build-essential/recipes/_suse.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: build-essential 3 | # Recipe:: suse 4 | # 5 | # Copyright 2008-2013, Chef Software, Inc. 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # 19 | 20 | potentially_at_compile_time do 21 | package 'autoconf' 22 | package 'bison' 23 | package 'flex' 24 | package 'gcc' 25 | package 'gcc-c++' 26 | package 'kernel-default-devel' 27 | package 'make' 28 | package 'm4' 29 | end 30 | -------------------------------------------------------------------------------- /cookbooks/build-essential/recipes/default.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: build-essential 3 | # Recipe:: default 4 | # 5 | # Copyright 2008-2009, Chef Software, Inc. 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # 19 | 20 | begin 21 | include_recipe "build-essential::_#{node['platform_family']}" 22 | rescue Chef::Exceptions::RecipeNotFound 23 | Chef::Log.warn <<-EOH 24 | A build-essential recipe does not exist for '#{node['platform_family']}'. This 25 | means the build-essential cookbook does not have support for the 26 | #{node['platform_family']} family. If you are not compiling gems with native 27 | extensions or building packages from source, this will likely not affect you. 28 | EOH 29 | end 30 | -------------------------------------------------------------------------------- /cookbooks/chef-sugar/metadata.json: -------------------------------------------------------------------------------- 1 | {"name":"chef-sugar","version":"3.1.1","description":"Installs chef-sugar. Please see the chef-sugar Ruby gem for more information.","long_description":"Chef Sugar is a Gem & Chef Recipe that includes series of helpful syntactic\nsugars on top of the Chef core and other resources to make a cleaner, more lean\nrecipe DSL, enforce DRY principles, and make writing Chef recipes an awesome and\nfun experience!\n\nFor the most up-to-date information and documentation, please visit the [Chef\nSugar project page on GitHub](https://github.com/sethvargo/chef-sugar).\n","maintainer":"Seth Vargo","maintainer_email":"sethvargo@gmail.com","license":"Apache 2.0","platforms":{},"dependencies":{},"recommendations":{},"suggestions":{},"conflicting":{},"providing":{},"replacing":{},"attributes":{},"groupings":{},"recipes":{}} -------------------------------------------------------------------------------- /cookbooks/chef-sugar/recipes/default.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: chef-sugar 3 | # Recipe:: default 4 | # 5 | # Copyright 2013-2015, Seth Vargo 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # 19 | 20 | gem_version = run_context.cookbook_collection[cookbook_name].metadata.version 21 | 22 | if Chef::Resource::ChefGem.instance_methods(false).include?(:compile_time) 23 | chef_gem 'chef-sugar' do 24 | version gem_version 25 | compile_time true 26 | end 27 | else 28 | chef_gem 'chef-sugar' do 29 | version gem_version 30 | action :nothing 31 | end.run_action(:install) 32 | end 33 | 34 | require 'chef/sugar' 35 | -------------------------------------------------------------------------------- /cookbooks/chef_gem/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | v0.1.0 2 | ------ 3 | * Add name to metadata.rb (thanks [Eli Klein](https://github.com/eklein)) 4 | 5 | v0.0.5 6 | ------ 7 | * Applies backport of CHEF-3164 to _all_ versions under 10.14.0 (thanks [cgriego](https://github.com/cgriego)) 8 | 9 | v0.0.4 10 | ------ 11 | * Backports CHEF-3164 (thanks [cgriego](https://github.com/cgriego)) 12 | 13 | v0.0.3 14 | ------ 15 | * Default node in overrides if it is unavailable 16 | 17 | v0.0.2 18 | ------ 19 | * Add omnibus fixes for installs < 0.10.12 20 | * Add conditional patching based on chef version 21 | 22 | v0.0.1 23 | ------ 24 | * Initial release 25 | -------------------------------------------------------------------------------- /cookbooks/chef_gem/README.md: -------------------------------------------------------------------------------- 1 | ChefGem 2 | ======= 3 | 4 | This cookbook is a transition cookbook aimed at helping move from the 5 | pre-chef_gem era to the post chef_gem era. The chef_gem resource was 6 | introducde in Chef 0.10.9, providing an easy mechanism for installing 7 | and using gems required by Chef internally. When used within an omnibus 8 | installation, chef_gems are installed within the embedded Ruby. 9 | 10 | What this cookbook provides 11 | ---------------------------- 12 | 13 | For pre 0.10.9 Chef installations, it provides a chef_gem compatible resouce 14 | allowing cookbooks to be updated but not requiring full conversions. For installations 15 | under 0.10.12, some patches are added to aid in proper omnibus functionality allowing 16 | chef_gem to work as expected. For Chef installations of 0.10.12 and beyond, this 17 | cookbook provides nothing. This means you will get consistent and expected behavior 18 | across Chef versions. 19 | 20 | Configuration 21 | ------------- 22 | 23 | Notable attributes (note that these should only be required for special cases): 24 | 25 | * `node[:gem_binary] = '/usr/local/bin/gem'` 26 | * `node[:chef_gem_binary] = '/opt/opscode/embedded/bin/gem'` 27 | 28 | Notes 29 | ----- 30 | 31 | With the release of 0.10.12 this cookbook should be considered deprecated and used 32 | only for compatibility with older installations. 33 | 34 | Repository 35 | ---------- 36 | 37 | * https://github.com/hw-cookbooks/chef_gem 38 | * IRC: Freenode @ #heavywater -------------------------------------------------------------------------------- /cookbooks/chef_gem/recipes/default.rb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sandrew/from-scratch/832d4c525c99a471b38c9c515bac9e0555e97736/cookbooks/chef_gem/recipes/default.rb -------------------------------------------------------------------------------- /cookbooks/java/.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | *# 3 | .#* 4 | \#*# 5 | .*.sw[a-z] 6 | *.un~ 7 | *.tmp 8 | *.bk 9 | *.bkup 10 | .kitchen.local.yml 11 | Berksfile.lock 12 | Gemfile.lock 13 | 14 | .bundle/ 15 | .cache/ 16 | .kitchen/ 17 | .vagrant/ 18 | .vagrant.d/ 19 | bin/ 20 | tmp/ 21 | vendor/ 22 | -------------------------------------------------------------------------------- /cookbooks/java/.kitchen.docker.yml: -------------------------------------------------------------------------------- 1 | --- 2 | driver: 3 | name: docker 4 | socket: tcp://192.168.59.103:2375 5 | 6 | platforms: 7 | - name: ubuntu 8 | run_list: 9 | - recipe[apt] 10 | - name: centos 11 | driver_config: 12 | image: centos 13 | platform: rhel 14 | run_list: 15 | - recipe[yum] 16 | -------------------------------------------------------------------------------- /cookbooks/java/.travis.yml: -------------------------------------------------------------------------------- 1 | language: ruby 2 | bundler_args: --without integration 3 | rvm: 4 | - 2.1.4 5 | script: 6 | - bundle exec rake travis 7 | -------------------------------------------------------------------------------- /cookbooks/java/Berksfile: -------------------------------------------------------------------------------- 1 | source "https://supermarket.getchef.com" 2 | metadata 3 | 4 | group :integration do 5 | cookbook 'apt', '~> 2.0' 6 | cookbook 'yum', '~> 3.3' 7 | cookbook 'windows', '~> 1.12' 8 | cookbook 'homebrew', '~> 1.12' 9 | cookbook 'test_java', path: 'test/fixtures/cookbooks/test_java' 10 | end 11 | -------------------------------------------------------------------------------- /cookbooks/java/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | Contributing 2 | ============ 3 | 1. Fork it 4 | 2. Create your feature branch (`git checkout -b my-new-feature`) 5 | 3. Commit your changes (`git commit -am 'Add some feature'`) 6 | 4. [**Add tests!**](https://github.com/agileorbit-cookbooks/java/blob/master/TESTING.md) 7 | 5. Push to the branch (`git push origin my-new-feature`) 8 | 6. Create new Pull Request 9 | 10 | As this cookbook is no longer maintained by Chef, you **do not** need to sign any sort of contributor agreement. Simply make your change and open a pull request. 11 | 12 | Contributions will only be accepted if they are fully tested as specified in [TESTING.md](https://github.com/agileorbit-cookbooks/java/blob/master/TESTING.md) 13 | -------------------------------------------------------------------------------- /cookbooks/java/Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | 3 | gem 'rake' 4 | gem 'berkshelf', '~> 3.2.1' 5 | 6 | group :test do 7 | gem 'foodcritic', '~> 4.0.0' 8 | gem 'rubocop', '~> 0.27.1' 9 | gem 'chefspec', '~> 4.1.1' 10 | end 11 | 12 | group :integration do 13 | gem 'test-kitchen', '~> 1.2.1' 14 | gem 'kitchen-vagrant', '~> 0.15' 15 | end 16 | -------------------------------------------------------------------------------- /cookbooks/java/libraries/matchers.rb: -------------------------------------------------------------------------------- 1 | if defined?(ChefSpec) 2 | def set_java_alternatives(resource_name) 3 | ChefSpec::Matchers::ResourceMatcher.new(:java_alternatives, :set, resource_name) 4 | end 5 | end -------------------------------------------------------------------------------- /cookbooks/java/recipes/default.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Author:: Seth Chisamore () 3 | # Cookbook Name:: java 4 | # Recipe:: default 5 | # 6 | # Copyright 2008-2011, Opscode, Inc. 7 | # 8 | # Licensed under the Apache License, Version 2.0 (the "License"); 9 | # you may not use this file except in compliance with the License. 10 | # You may obtain a copy of the License at 11 | # 12 | # http://www.apache.org/licenses/LICENSE-2.0 13 | # 14 | # Unless required by applicable law or agreed to in writing, software 15 | # distributed under the License is distributed on an "AS IS" BASIS, 16 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | # See the License for the specific language governing permissions and 18 | # limitations under the License. 19 | # 20 | 21 | include_recipe "java::set_attributes_from_version" 22 | include_recipe "java::#{node['java']['install_flavor']}" 23 | -------------------------------------------------------------------------------- /cookbooks/java/recipes/default_java_symlink.rb: -------------------------------------------------------------------------------- 1 | # Cookbook Name:: java 2 | # Recipe:: default_java_symlink 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | link '/usr/lib/jvm/default-java' do 17 | to node['java']['java_home'] 18 | not_if { node['java']['java_home'] == '/usr/lib/jvm/default-java' } 19 | end 20 | -------------------------------------------------------------------------------- /cookbooks/java/recipes/homebrew.rb: -------------------------------------------------------------------------------- 1 | include_recipe 'homebrew' 2 | include_recipe 'homebrew::cask' 3 | homebrew_cask 'java' -------------------------------------------------------------------------------- /cookbooks/java/recipes/purge_packages.rb: -------------------------------------------------------------------------------- 1 | # Cookbook Name:: java 2 | # Recipe:: purge_packages 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | %w[sun-java6-jdk sun-java6-bin sun-java6-jre].each do |pkg| 17 | package pkg do 18 | action :purge 19 | end 20 | end 21 | -------------------------------------------------------------------------------- /cookbooks/java/resources/alternatives.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: java 3 | # Provider:: alternatives 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | actions :set, :unset 18 | 19 | attribute :java_location, :kind_of => String, :default => nil 20 | attribute :bin_cmds, :kind_of => Array, :default => nil 21 | attribute :default, :equal_to => [true, false], :default => true 22 | attribute :priority, :kind_of => Integer, :default => 1061 23 | attribute :reset_alternatives, :equal_to => [true, false], :default => true 24 | 25 | # we have to set default for the supports attribute 26 | # in initializer since it is a 'reserved' attribute name 27 | def initialize(*args) 28 | super 29 | @action = :set 30 | end 31 | -------------------------------------------------------------------------------- /cookbooks/java/templates/default/ibm_jdk.installer.properties.erb: -------------------------------------------------------------------------------- 1 | INSTALLER_UI=silent 2 | USER_INSTALL_DIR=<%= node['java']['java_home'] %> 3 | -fileOverwrite_<%= node['java']['java_home'] %>_uninstall/uninstall.lax=Yes 4 | -------------------------------------------------------------------------------- /cookbooks/java/templates/default/oracle.jinfo.erb: -------------------------------------------------------------------------------- 1 | name=<%= @name %> 2 | priority=<%= @priority %> 3 | section=main 4 | 5 | <% @bin_cmds.each do |cmd| -%>jdk <%= cmd %> <%= @app_dir %>/bin/<%= cmd %> 6 | <% end -%> 7 | -------------------------------------------------------------------------------- /cookbooks/nginx/attributes/auth_request.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: nginx 3 | # Attributes:: auth_request 4 | # 5 | # Author:: David Radcliffe () 6 | # 7 | # Copyright 2013, David Radcliffe 8 | # 9 | # Licensed under the Apache License, Version 2.0 (the "License"); 10 | # you may not use this file except in compliance with the License. 11 | # You may obtain a copy of the License at 12 | # 13 | # http://www.apache.org/licenses/LICENSE-2.0 14 | # 15 | # Unless required by applicable law or agreed to in writing, software 16 | # distributed under the License is distributed on an "AS IS" BASIS, 17 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | # See the License for the specific language governing permissions and 19 | # limitations under the License. 20 | # 21 | 22 | default['nginx']['auth_request']['url'] = 'http://mdounin.ru/hg/ngx_http_auth_request_module/archive/ee8ff54f9b66.tar.gz' 23 | default['nginx']['auth_request']['checksum'] = '7ab85e1c350c5a9c60ed1319c45fed144cc3c3e1' 24 | -------------------------------------------------------------------------------- /cookbooks/nginx/attributes/devel.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: nginx 3 | # Attributes:: devel 4 | # 5 | # Author:: Arthur Freyman () 6 | # 7 | # Copyright 2013, Riot Games 8 | # 9 | # Licensed under the Apache License, Version 2.0 (the "License"); 10 | # you may not use this file except in compliance with the License. 11 | # You may obtain a copy of the License at 12 | # 13 | # http://www.apache.org/licenses/LICENSE-2.0 14 | # 15 | # Unless required by applicable law or agreed to in writing, software 16 | # distributed under the License is distributed on an "AS IS" BASIS, 17 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | # See the License for the specific language governing permissions and 19 | # limitations under the License. 20 | # 21 | 22 | default['nginx']['devel']['version'] = '0.2.18' 23 | default['nginx']['devel']['url'] = "https://github.com/simpl/ngx_devel_kit/archive/v#{node['nginx']['devel']['version']}.tar.gz" 24 | default['nginx']['devel']['checksum'] = 'c9c9f0a1b068d38c6c45b15d9605f1b2344dbcd45abf0764cd8e2ba92d6a3d2c' 25 | -------------------------------------------------------------------------------- /cookbooks/nginx/attributes/echo.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: nginx 3 | # Attributes:: echo 4 | # 5 | # Author:: Danial Pearce () 6 | # 7 | # Copyright 2013, Danial Pearce 8 | # 9 | # Licensed under the Apache License, Version 2.0 (the "License"); 10 | # you may not use this file except in compliance with the License. 11 | # You may obtain a copy of the License at 12 | # 13 | # http://www.apache.org/licenses/LICENSE-2.0 14 | # 15 | # Unless required by applicable law or agreed to in writing, software 16 | # distributed under the License is distributed on an "AS IS" BASIS, 17 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | # See the License for the specific language governing permissions and 19 | # limitations under the License. 20 | # 21 | 22 | default['nginx']['echo']['version'] = '0.57' 23 | default['nginx']['echo']['url'] = "https://github.com/openresty/echo-nginx-module/archive/v#{node['nginx']['echo']['version']}.tar.gz" 24 | default['nginx']['echo']['checksum'] = '8467237ca0fae74ca7a32fbd34fc6044df307098415d48068214c9c235695a07' 25 | -------------------------------------------------------------------------------- /cookbooks/nginx/attributes/headers_more.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: nginx 3 | # Attributes:: headers_more 4 | # 5 | # Author:: Lucas Jandrew () 6 | # 7 | # Copyright 2012-2013, Riot Games 8 | # 9 | # Licensed under the Apache License, Version 2.0 (the "License"); 10 | # you may not use this file except in compliance with the License. 11 | # You may obtain a copy of the License at 12 | # 13 | # http://www.apache.org/licenses/LICENSE-2.0 14 | # 15 | # Unless required by applicable law or agreed to in writing, software 16 | # distributed under the License is distributed on an "AS IS" BASIS, 17 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | # See the License for the specific language governing permissions and 19 | # limitations under the License. 20 | # 21 | 22 | default['nginx']['headers_more']['version'] = '0.25' 23 | default['nginx']['headers_more']['source_url'] = "https://github.com/openresty/headers-more-nginx-module/archive/v#{node['nginx']['headers_more']['version']}.tar.gz" 24 | default['nginx']['headers_more']['source_checksum'] = '1473f96f59dcec9d83ce65d691559993c1f80da8c0a4c0c0a30dae9f969eeabf' 25 | -------------------------------------------------------------------------------- /cookbooks/nginx/attributes/lua.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: nginx 3 | # Attributes:: lua 4 | # 5 | # Author:: Arthur Freyman () 6 | # 7 | # Copyright 2013, Riot Games 8 | # 9 | # Licensed under the Apache License, Version 2.0 (the "License"); 10 | # you may not use this file except in compliance with the License. 11 | # You may obtain a copy of the License at 12 | # 13 | # http://www.apache.org/licenses/LICENSE-2.0 14 | # 15 | # Unless required by applicable law or agreed to in writing, software 16 | # distributed under the License is distributed on an "AS IS" BASIS, 17 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | # See the License for the specific language governing permissions and 19 | # limitations under the License. 20 | # 21 | 22 | default['nginx']['lua']['version'] = '0.8.7' 23 | default['nginx']['lua']['url'] = "https://github.com/chaoslawful/lua-nginx-module/archive/v#{node['nginx']['lua']['version']}.tar.gz" 24 | default['nginx']['lua']['checksum'] = '4b9be3c159b9c884a38e044e07aaf4d06bd2893977d0b0dae02c124d8e907f93' 25 | 26 | default['nginx']['luajit']['version'] = '2.0.2' 27 | default['nginx']['luajit']['url'] = "http://luajit.org/download/LuaJIT-#{node['nginx']['luajit']['version']}.tar.gz" 28 | default['nginx']['luajit']['checksum'] = 'c05202974a5890e777b181908ac237625b499aece026654d7cc33607e3f46c38' 29 | -------------------------------------------------------------------------------- /cookbooks/nginx/attributes/naxsi.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: nginx 3 | # Attributes:: naxsi 4 | # 5 | # Author:: Artiom Lunev () 6 | # 7 | # Copyright 2012-2013, Artiom Lunev 8 | # 9 | # Licensed under the Apache License, Version 2.0 (the "License"); 10 | # you may not use this file except in compliance with the License. 11 | # You may obtain a copy of the License at 12 | # 13 | # http://www.apache.org/licenses/LICENSE-2.0 14 | # 15 | # Unless required by applicable law or agreed to in writing, software 16 | # distributed under the License is distributed on an "AS IS" BASIS, 17 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | # See the License for the specific language governing permissions and 19 | # limitations under the License. 20 | # 21 | 22 | default['nginx']['naxsi']['version'] = '0.53-2' 23 | default['nginx']['naxsi']['url'] = "https://github.com/nbs-system/naxsi/archive/#{node['nginx']['naxsi']['version']}.tar.gz" 24 | default['nginx']['naxsi']['checksum'] = '3eadff1d91995beae41b92733ade28091c2075a24ae37058f4d6aa90b0f4b660' 25 | -------------------------------------------------------------------------------- /cookbooks/nginx/attributes/openssl_source.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: nginx 3 | # Attributes:: openssl_source 4 | # 5 | # Author:: David Radcliffe () 6 | # 7 | # Copyright 2013, David Radcliffe 8 | # 9 | # Licensed under the Apache License, Version 2.0 (the "License"); 10 | # you may not use this file except in compliance with the License. 11 | # You may obtain a copy of the License at 12 | # 13 | # http://www.apache.org/licenses/LICENSE-2.0 14 | # 15 | # Unless required by applicable law or agreed to in writing, software 16 | # distributed under the License is distributed on an "AS IS" BASIS, 17 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | # See the License for the specific language governing permissions and 19 | # limitations under the License. 20 | # 21 | 22 | default['nginx']['openssl_source']['version'] = '1.0.1h' 23 | default['nginx']['openssl_source']['url'] = "http://www.openssl.org/source/openssl-#{node['nginx']['openssl_source']['version']}.tar.gz" 24 | -------------------------------------------------------------------------------- /cookbooks/nginx/attributes/pagespeed.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: nginx 3 | # Recipe:: pagespeed_module 4 | # 5 | default['nginx']['pagespeed']['version'] = '1.8.31.4' 6 | default['nginx']['pagespeed']['url'] = "https://github.com/pagespeed/ngx_pagespeed/archive/release-#{node['nginx']['pagespeed']['version']}-beta.tar.gz" 7 | default['nginx']['psol']['url'] = "https://dl.google.com/dl/page-speed/psol/#{node['nginx']['pagespeed']['version']}.tar.gz" 8 | default['nginx']['pagespeed']['packages']['rhel'] = %w(gcc-c++ pcre-dev pcre-devel zlib-devel make) 9 | default['nginx']['pagespeed']['packages']['debian'] = %w(build-essential zlib1g-dev libpcre3 libpcre3-dev) 10 | -------------------------------------------------------------------------------- /cookbooks/nginx/attributes/rate_limiting.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: nginx 3 | # Attribute:: rate_limiting 4 | # 5 | # Copyright 2013, Chef Software, Inc. 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # 19 | 20 | default['nginx']['enable_rate_limiting'] = false 21 | default['nginx']['rate_limiting_zone_name'] = 'default' 22 | default['nginx']['rate_limiting_backoff'] = '10m' 23 | default['nginx']['rate_limit'] = '1r/s' 24 | -------------------------------------------------------------------------------- /cookbooks/nginx/attributes/repo.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: nginx 3 | # Recipe:: repo 4 | # 5 | # Author:: Nick Rycar 6 | # 7 | # Copyright 2008-2013, Chef Software, Inc. 8 | # 9 | # Licensed under the Apache License, Version 2.0 (the "License"); 10 | # you may not use this file except in compliance with the License. 11 | # You may obtain a copy of the License at 12 | # 13 | # http://www.apache.org/licenses/LICENSE-2.0 14 | # 15 | # Unless required by applicable law or agreed to in writing, software 16 | # distributed under the License is distributed on an "AS IS" BASIS, 17 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | # See the License for the specific language governing permissions and 19 | # limitations under the License. 20 | # 21 | 22 | case node['platform_family'] 23 | when 'rhel', 'fedora' 24 | case node['platform'] 25 | when 'centos' 26 | # See http://wiki.nginx.org/Install 27 | default['nginx']['upstream_repository'] = "http://nginx.org/packages/centos/#{node['platform_version'].to_i}/$basearch/" 28 | when 'amazon' 29 | default['nginx']['upstream_repository'] = 'http://nginx.org/packages/rhel/6/$basearch/' 30 | else 31 | default['nginx']['upstream_repository'] = "http://nginx.org/packages/rhel/#{node['platform_version'].to_i}/$basearch/" 32 | end 33 | when 'debian' 34 | default['nginx']['upstream_repository'] = "http://nginx.org/packages/#{node['platform']}" 35 | end 36 | -------------------------------------------------------------------------------- /cookbooks/nginx/attributes/set_misc.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: nginx 3 | # Attributes:: set_misc 4 | # 5 | 6 | default['nginx']['set_misc']['version'] = '0.24' 7 | default['nginx']['set_misc']['url'] = "https://github.com/agentzh/set-misc-nginx-module/archive/v#{node['nginx']['set_misc']['version']}.tar.gz" 8 | default['nginx']['set_misc']['checksum'] = 'da404a7dac5fa4a0a86f42b4ec7648b607f4cd66' 9 | -------------------------------------------------------------------------------- /cookbooks/nginx/attributes/socketproxy.rb: -------------------------------------------------------------------------------- 1 | default['nginx']['socketproxy']['root'] = '/usr/share/nginx/apps' 2 | default['nginx']['socketproxy']['app_owner'] = 'root' 3 | default['nginx']['socketproxy']['logname'] = 'socketproxy' 4 | default['nginx']['socketproxy']['log_level'] = 'error' 5 | # default['nginx']['socketproxy']['default_app'] = 'default' 6 | # default['nginx']['socketproxy']['apps'] = { 7 | # 'default' => { 8 | # 'prepend_slash' => false, 9 | # 'context_name' => '', 10 | # 'subdir' => 'current', 11 | # 'socket_path' => 'shared/sockets/unicorn.sock' 12 | # } 13 | # } 14 | -------------------------------------------------------------------------------- /cookbooks/nginx/attributes/status.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: nginx 3 | # Attributes:: status 4 | # 5 | # Author:: David Radcliffe () 6 | # 7 | # Copyright 2013, David Radcliffe 8 | # 9 | # Licensed under the Apache License, Version 2.0 (the "License"); 10 | # you may not use this file except in compliance with the License. 11 | # You may obtain a copy of the License at 12 | # 13 | # http://www.apache.org/licenses/LICENSE-2.0 14 | # 15 | # Unless required by applicable law or agreed to in writing, software 16 | # distributed under the License is distributed on an "AS IS" BASIS, 17 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | # See the License for the specific language governing permissions and 19 | # limitations under the License. 20 | # 21 | 22 | default['nginx']['status']['port'] = '8090' 23 | -------------------------------------------------------------------------------- /cookbooks/nginx/attributes/syslog.rb: -------------------------------------------------------------------------------- 1 | 2 | # 3 | # Cookbook Name:: nginx 4 | # Attributes:: syslog 5 | # 6 | # Author:: Bob Ziuchkovski () 7 | # 8 | # Copyright 2014, UserTesting 9 | # 10 | # Licensed under the Apache License, Version 2.0 (the "License"); 11 | # you may not use this file except in compliance with the License. 12 | # You may obtain a copy of the License at 13 | # 14 | # http://www.apache.org/licenses/LICENSE-2.0 15 | # 16 | # Unless required by applicable law or agreed to in writing, software 17 | # distributed under the License is distributed on an "AS IS" BASIS, 18 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | # See the License for the specific language governing permissions and 20 | # limitations under the License. 21 | # 22 | 23 | default['nginx']['syslog']['git_repo'] = 'https://github.com/yaoweibin/nginx_syslog_patch.git' 24 | default['nginx']['syslog']['git_revision'] = 'master' 25 | -------------------------------------------------------------------------------- /cookbooks/nginx/attributes/upload_progress.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: nginx 3 | # Attributes:: upload_progress 4 | # 5 | # Author:: Jamie Winsor () 6 | # 7 | # Copyright 2012, Riot Games 8 | # 9 | # Licensed under the Apache License, Version 2.0 (the "License"); 10 | # you may not use this file except in compliance with the License. 11 | # You may obtain a copy of the License at 12 | # 13 | # http://www.apache.org/licenses/LICENSE-2.0 14 | # 15 | # Unless required by applicable law or agreed to in writing, software 16 | # distributed under the License is distributed on an "AS IS" BASIS, 17 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | # See the License for the specific language governing permissions and 19 | # limitations under the License. 20 | # 21 | 22 | default['nginx']['upload_progress']['url'] = 'https://github.com/masterzen/nginx-upload-progress-module/tarball/v0.9.0' 23 | default['nginx']['upload_progress']['checksum'] = '3fb903dab595cf6656fa0fc5743a48daffbba2f6b5c554836be630800eaad4e2' 24 | default['nginx']['upload_progress']['javascript_output'] = true 25 | default['nginx']['upload_progress']['zone_name'] = 'proxied' 26 | default['nginx']['upload_progress']['zone_size'] = '1m' 27 | -------------------------------------------------------------------------------- /cookbooks/nginx/libraries/matchers.rb: -------------------------------------------------------------------------------- 1 | if defined?(ChefSpec) 2 | # Custom ChefSpec matchers 3 | module ChefSpec::Matchers 4 | RSpec::Matchers.define :enable_nginx_site do |site| 5 | match do |chef_run| 6 | chef_run.resource_collection.all_resources.any? do |resource| 7 | resource.resource_name == :execute && resource.name =~ /.*nxensite.*#{site}/ 8 | end 9 | end 10 | end 11 | 12 | RSpec::Matchers.define :disable_nginx_site do |site| 13 | match do |chef_run| 14 | chef_run.resource_collection.all_resources.any? do |resource| 15 | resource.resource_name == :execute && resource.name =~ /.*nxdissite.*#{site}/ 16 | end 17 | end 18 | end 19 | end 20 | end 21 | -------------------------------------------------------------------------------- /cookbooks/nginx/recipes/authorized_ips.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: nginx 3 | # Recipe:: authorized_ips 4 | # 5 | # Author:: Jamie Winsor () 6 | # 7 | # Copyright 2012-2013, Riot Games 8 | # 9 | # Licensed under the Apache License, Version 2.0 (the "License"); 10 | # you may not use this file except in compliance with the License. 11 | # You may obtain a copy of the License at 12 | # 13 | # http://www.apache.org/licenses/LICENSE-2.0 14 | # 15 | # Unless required by applicable law or agreed to in writing, software 16 | # distributed under the License is distributed on an "AS IS" BASIS, 17 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | # See the License for the specific language governing permissions and 19 | # limitations under the License. 20 | # 21 | 22 | node.default['nginx']['remote_ip_var'] = 'remote_addr' 23 | node.default['nginx']['authorized_ips'] = ['127.0.0.1/32'] 24 | 25 | template 'authorized_ip' do 26 | path "#{node['nginx']['dir']}/authorized_ip" 27 | source 'modules/authorized_ip.erb' 28 | owner 'root' 29 | group node['root_group'] 30 | mode '0644' 31 | notifies :reload, 'service[nginx]', :delayed 32 | end 33 | -------------------------------------------------------------------------------- /cookbooks/nginx/recipes/commons.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: nginx 3 | # Recipe:: commons 4 | # 5 | # Author:: AJ Christensen 6 | # 7 | # Copyright 2008-2013, Chef Software, Inc. 8 | # 9 | # Licensed under the Apache License, Version 2.0 (the "License"); 10 | # you may not use this file except in compliance with the License. 11 | # You may obtain a copy of the License at 12 | # 13 | # http://www.apache.org/licenses/LICENSE-2.0 14 | # 15 | # Unless required by applicable law or agreed to in writing, software 16 | # distributed under the License is distributed on an "AS IS" BASIS, 17 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | # See the License for the specific language governing permissions and 19 | # limitations under the License. 20 | # 21 | 22 | include_recipe 'nginx::commons_dir' 23 | include_recipe 'nginx::commons_script' 24 | include_recipe 'nginx::commons_conf' 25 | -------------------------------------------------------------------------------- /cookbooks/nginx/recipes/commons_conf.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: nginx 3 | # Recipe:: common/conf 4 | # 5 | # Author:: AJ Christensen 6 | # 7 | # Copyright 2008-2013, Chef Software, Inc. 8 | # 9 | # Licensed under the Apache License, Version 2.0 (the "License"); 10 | # you may not use this file except in compliance with the License. 11 | # You may obtain a copy of the License at 12 | # 13 | # http://www.apache.org/licenses/LICENSE-2.0 14 | # 15 | # Unless required by applicable law or agreed to in writing, software 16 | # distributed under the License is distributed on an "AS IS" BASIS, 17 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | # See the License for the specific language governing permissions and 19 | # limitations under the License. 20 | # 21 | 22 | template 'nginx.conf' do 23 | path "#{node['nginx']['dir']}/nginx.conf" 24 | source node['nginx']['conf_template'] 25 | cookbook node['nginx']['conf_cookbook'] 26 | owner 'root' 27 | group node['root_group'] 28 | mode '0644' 29 | notifies :reload, 'service[nginx]', :delayed 30 | end 31 | 32 | template "#{node['nginx']['dir']}/sites-available/default" do 33 | source 'default-site.erb' 34 | owner 'root' 35 | group node['root_group'] 36 | mode '0644' 37 | notifies :reload, 'service[nginx]', :delayed 38 | end 39 | 40 | nginx_site 'default' do 41 | enable node['nginx']['default_site_enabled'] 42 | end 43 | -------------------------------------------------------------------------------- /cookbooks/nginx/recipes/commons_script.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: nginx 3 | # Recipe:: common/script 4 | # 5 | # Author:: AJ Christensen 6 | # 7 | # Copyright 2008-2013, Chef Software, Inc. 8 | # 9 | # Licensed under the Apache License, Version 2.0 (the "License"); 10 | # you may not use this file except in compliance with the License. 11 | # You may obtain a copy of the License at 12 | # 13 | # http://www.apache.org/licenses/LICENSE-2.0 14 | # 15 | # Unless required by applicable law or agreed to in writing, software 16 | # distributed under the License is distributed on an "AS IS" BASIS, 17 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | # See the License for the specific language governing permissions and 19 | # limitations under the License. 20 | # 21 | 22 | %w(nxensite nxdissite).each do |nxscript| 23 | template "#{node['nginx']['script_dir']}/#{nxscript}" do 24 | source "#{nxscript}.erb" 25 | mode '0755' 26 | owner 'root' 27 | group node['root_group'] 28 | end 29 | end 30 | -------------------------------------------------------------------------------- /cookbooks/nginx/recipes/default.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: nginx 3 | # Recipe:: default 4 | # 5 | # Author:: AJ Christensen 6 | # 7 | # Copyright 2008-2013, Chef Software, Inc. 8 | # 9 | # Licensed under the Apache License, Version 2.0 (the "License"); 10 | # you may not use this file except in compliance with the License. 11 | # You may obtain a copy of the License at 12 | # 13 | # http://www.apache.org/licenses/LICENSE-2.0 14 | # 15 | # Unless required by applicable law or agreed to in writing, software 16 | # distributed under the License is distributed on an "AS IS" BASIS, 17 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | # See the License for the specific language governing permissions and 19 | # limitations under the License. 20 | # 21 | 22 | include_recipe "nginx::#{node['nginx']['install_method']}" 23 | 24 | service 'nginx' do 25 | supports :status => true, :restart => true, :reload => true 26 | action :start 27 | end 28 | 29 | node['nginx']['default']['modules'].each do |ngx_module| 30 | include_recipe "nginx::#{ngx_module}" 31 | end 32 | -------------------------------------------------------------------------------- /cookbooks/nginx/recipes/http_gzip_static_module.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: nginx 3 | # Recipe:: http_gzip_static_module 4 | # 5 | # Author:: Jamie Winsor () 6 | # 7 | # Copyright 2012-2013, Riot Games 8 | # 9 | # Licensed under the Apache License, Version 2.0 (the "License"); 10 | # you may not use this file except in compliance with the License. 11 | # You may obtain a copy of the License at 12 | # 13 | # http://www.apache.org/licenses/LICENSE-2.0 14 | # 15 | # Unless required by applicable law or agreed to in writing, software 16 | # distributed under the License is distributed on an "AS IS" BASIS, 17 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | # See the License for the specific language governing permissions and 19 | # limitations under the License. 20 | # 21 | 22 | template "#{node['nginx']['dir']}/conf.d/http_gzip_static.conf" do 23 | source 'modules/http_gzip_static.conf.erb' 24 | owner 'root' 25 | group node['root_group'] 26 | mode '0644' 27 | end 28 | 29 | node.run_state['nginx_configure_flags'] = 30 | node.run_state['nginx_configure_flags'] | ['--with-http_gzip_static_module'] 31 | -------------------------------------------------------------------------------- /cookbooks/nginx/recipes/http_mp4_module.rb: -------------------------------------------------------------------------------- 1 | node.run_state['nginx_configure_flags'] = 2 | node.run_state['nginx_configure_flags'] | ['--with-http_mp4_module'] 3 | -------------------------------------------------------------------------------- /cookbooks/nginx/recipes/http_perl_module.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: nginx 3 | # Recipe:: http_perl_module 4 | # 5 | # Author:: Akzhan Abdulin () 6 | # 7 | # Copyright 2012-2013, REG.RU 8 | # 9 | # Licensed under the Apache License, Version 2.0 (the "License"); 10 | # you may not use this file except in compliance with the License. 11 | # You may obtain a copy of the License at 12 | # 13 | # http://www.apache.org/licenses/LICENSE-2.0 14 | # 15 | # Unless required by applicable law or agreed to in writing, software 16 | # distributed under the License is distributed on an "AS IS" BASIS, 17 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | # See the License for the specific language governing permissions and 19 | # limitations under the License. 20 | # 21 | 22 | node.run_state['nginx_configure_flags'] = 23 | node.run_state['nginx_configure_flags'] | ['--with-http_perl_module'] 24 | -------------------------------------------------------------------------------- /cookbooks/nginx/recipes/http_spdy_module.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: nginx 3 | # Recipe:: http_spdy_module 4 | # 5 | # Author:: Christoph Buente () 6 | # 7 | # Copyright 2013, MeinekleineFarm.org 8 | # 9 | # Licensed under the Apache License, Version 2.0 (the "License"); 10 | # you may not use this file except in compliance with the License. 11 | # You may obtain a copy of the License at 12 | # 13 | # http://www.apache.org/licenses/LICENSE-2.0 14 | # 15 | # Unless required by applicable law or agreed to in writing, software 16 | # distributed under the License is distributed on an "AS IS" BASIS, 17 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | # See the License for the specific language governing permissions and 19 | # limitations under the License. 20 | # 21 | 22 | node.run_state['nginx_configure_flags'] = 23 | node.run_state['nginx_configure_flags'] | ['--with-http_spdy_module'] 24 | -------------------------------------------------------------------------------- /cookbooks/nginx/recipes/http_ssl_module.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: nginx 3 | # Recipe:: http_ssl_module 4 | # 5 | # Author:: Jamie Winsor () 6 | # 7 | # Copyright 2012-2013, Riot Games 8 | # 9 | # Licensed under the Apache License, Version 2.0 (the "License"); 10 | # you may not use this file except in compliance with the License. 11 | # You may obtain a copy of the License at 12 | # 13 | # http://www.apache.org/licenses/LICENSE-2.0 14 | # 15 | # Unless required by applicable law or agreed to in writing, software 16 | # distributed under the License is distributed on an "AS IS" BASIS, 17 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | # See the License for the specific language governing permissions and 19 | # limitations under the License. 20 | # 21 | 22 | node.run_state['nginx_configure_flags'] = 23 | node.run_state['nginx_configure_flags'] | ['--with-http_ssl_module'] 24 | -------------------------------------------------------------------------------- /cookbooks/nginx/recipes/http_stub_status_module.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: nginx 3 | # Recipe:: http_stub_status_module 4 | # 5 | # Author:: Jamie Winsor () 6 | # 7 | # Copyright 2012-2013, Riot Games 8 | # 9 | # Licensed under the Apache License, Version 2.0 (the "License"); 10 | # you may not use this file except in compliance with the License. 11 | # You may obtain a copy of the License at 12 | # 13 | # http://www.apache.org/licenses/LICENSE-2.0 14 | # 15 | # Unless required by applicable law or agreed to in writing, software 16 | # distributed under the License is distributed on an "AS IS" BASIS, 17 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | # See the License for the specific language governing permissions and 19 | # limitations under the License. 20 | # 21 | 22 | include_recipe 'nginx::authorized_ips' 23 | 24 | template 'nginx_status' do 25 | path "#{node['nginx']['dir']}/sites-available/nginx_status" 26 | source 'modules/nginx_status.erb' 27 | owner 'root' 28 | group node['root_group'] 29 | mode '0644' 30 | notifies :reload, 'service[nginx]', :delayed 31 | end 32 | 33 | nginx_site 'nginx_status' 34 | 35 | node.run_state['nginx_configure_flags'] = 36 | node.run_state['nginx_configure_flags'] | ['--with-http_stub_status_module'] 37 | -------------------------------------------------------------------------------- /cookbooks/nginx/recipes/ipv6.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: nginx 3 | # Recipe:: ipv6 4 | # 5 | # Author:: Alan Harper (alan@sct.com.au) 6 | # 7 | # Copyright 2013 Alan Harper 8 | # 9 | # Licensed under the Apache License, Version 2.0 (the "License"); 10 | # you may not use this file except in compliance with the License. 11 | # You may obtain a copy of the License at 12 | # 13 | # http://www.apache.org/licenses/LICENSE-2.0 14 | # 15 | # Unless required by applicable law or agreed to in writing, software 16 | # distributed under the License is distributed on an "AS IS" BASIS, 17 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | # See the License for the specific language governing permissions and 19 | # limitations under the License. 20 | # 21 | 22 | node.run_state['nginx_configure_flags'] = 23 | node.run_state['nginx_configure_flags'] | ['--with-ipv6'] 24 | -------------------------------------------------------------------------------- /cookbooks/nginx/recipes/ohai_plugin.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: nginx 3 | # Recipe:: ohai_plugin 4 | # 5 | # Author:: Jamie Winsor () 6 | # 7 | # Copyright 2012-2013, Riot Games 8 | # 9 | # Licensed under the Apache License, Version 2.0 (the "License"); 10 | # you may not use this file except in compliance with the License. 11 | # You may obtain a copy of the License at 12 | # 13 | # http://www.apache.org/licenses/LICENSE-2.0 14 | # 15 | # Unless required by applicable law or agreed to in writing, software 16 | # distributed under the License is distributed on an "AS IS" BASIS, 17 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | # See the License for the specific language governing permissions and 19 | # limitations under the License. 20 | # 21 | 22 | ohai 'reload_nginx' do 23 | plugin 'nginx' 24 | action :nothing 25 | end 26 | 27 | template "#{node['ohai']['plugin_path']}/nginx.rb" do 28 | source 'plugins/nginx.rb.erb' 29 | owner 'root' 30 | group node['root_group'] 31 | mode '0755' 32 | notifies :reload, 'ohai[reload_nginx]', :immediately 33 | end 34 | 35 | include_recipe 'ohai::default' 36 | -------------------------------------------------------------------------------- /cookbooks/nginx/recipes/repo.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: nginx 3 | # Recipe:: repo 4 | # Author:: Nick Rycar 5 | # 6 | # Copyright 2008-2013, Chef Software, Inc. 7 | # 8 | # Licensed under the Apache License, Version 2.0 (the "License"); 9 | # you may not use this file except in compliance with the License. 10 | # You may obtain a copy of the License at 11 | # 12 | # http://www.apache.org/licenses/LICENSE-2.0 13 | # 14 | # Unless required by applicable law or agreed to in writing, software 15 | # distributed under the License is distributed on an "AS IS" BASIS, 16 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | # See the License for the specific language governing permissions and 18 | # limitations under the License. 19 | # 20 | 21 | case node['platform_family'] 22 | when 'rhel', 'fedora' 23 | 24 | yum_repository 'nginx' do 25 | description 'Nginx.org Repository' 26 | baseurl node['nginx']['upstream_repository'] 27 | gpgkey 'http://nginx.org/keys/nginx_signing.key' 28 | action :create 29 | end 30 | 31 | when 'debian' 32 | include_recipe 'apt::default' 33 | 34 | apt_repository 'nginx' do 35 | uri node['nginx']['upstream_repository'] 36 | distribution node['lsb']['codename'] 37 | components %w(nginx) 38 | deb_src true 39 | key 'http://nginx.org/keys/nginx_signing.key' 40 | end 41 | end 42 | -------------------------------------------------------------------------------- /cookbooks/nginx/recipes/repo_passenger.rb: -------------------------------------------------------------------------------- 1 | # Cookbook Name:: nginx 2 | # Recipe:: repo_passenger 3 | # Author:: Jose Alberto Suarez Lopez 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | 18 | case node['platform_family'] 19 | when 'rhel', 'fedora' 20 | 21 | log 'There is not official phusion passenger repo for redhat based systems.' do 22 | level :info 23 | end 24 | 25 | when 'debian' 26 | include_recipe 'apt::default' 27 | package 'apt-transport-https' 28 | 29 | apt_repository 'phusionpassenger' do 30 | uri 'https://oss-binaries.phusionpassenger.com/apt/passenger' 31 | distribution node['lsb']['codename'] 32 | components %w(main) 33 | deb_src true 34 | keyserver 'keyserver.ubuntu.com' 35 | key '561F9B9CAC40B2F7' 36 | end 37 | 38 | include_recipe 'nginx::passenger' 39 | end 40 | -------------------------------------------------------------------------------- /cookbooks/nginx/recipes/set_misc.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: nginx 3 | # Recipes:: set_misc 4 | # 5 | 6 | set_misc_src_filename = ::File.basename(node['nginx']['set_misc']['url']) 7 | set_misc_src_filepath = "#{Chef::Config['file_cache_path']}/#{set_misc_src_filename}" 8 | set_misc_extract_path = "#{Chef::Config['file_cache_path']}/nginx-set_misc-#{node['nginx']['set_misc']['version']}" 9 | 10 | remote_file set_misc_src_filepath do 11 | source node['nginx']['set_misc']['url'] 12 | checksum node['nginx']['set_misc']['checksum'] 13 | owner 'root' 14 | group 'root' 15 | mode '0644' 16 | end 17 | 18 | bash 'extract_set_misc_module' do 19 | cwd ::File.dirname(set_misc_src_filepath) 20 | code <<-EOH 21 | mkdir -p #{set_misc_extract_path} 22 | tar xzf #{set_misc_src_filename} -C #{set_misc_extract_path} 23 | EOH 24 | not_if { ::File.exist?(set_misc_extract_path) } 25 | end 26 | 27 | node.run_state['nginx_configure_flags'] = 28 | node.run_state['nginx_configure_flags'] | ["--add-module=#{set_misc_extract_path}/set-misc-nginx-module-#{node['nginx']['set_misc']['version']}"] 29 | 30 | include_recipe 'nginx::ngx_devel_module' 31 | -------------------------------------------------------------------------------- /cookbooks/nginx/recipes/socketproxy.rb: -------------------------------------------------------------------------------- 1 | include_recipe 'nginx::commons_dir' 2 | 3 | directory node['nginx']['socketproxy']['root'] do 4 | owner node['nginx']['socketproxy']['app_owner'] 5 | group node['nginx']['socketproxy']['app_owner'] 6 | mode 00755 7 | action :create 8 | end 9 | 10 | context_names = node['nginx']['socketproxy']['apps'].map do |_app, app_conf| 11 | app_conf['context_name'] 12 | end 13 | 14 | fail 'More than one app has the same context_name configured.' if context_names.uniq.length != context_names.length 15 | 16 | template node['nginx']['dir'] + '/sites-available/socketproxy.conf' do 17 | source 'modules/socketproxy.conf.erb' 18 | owner 'root' 19 | group 'root' 20 | mode 00644 21 | notifies :reload, 'service[nginx]', :delayed 22 | end 23 | 24 | link node['nginx']['dir'] + '/sites-enabled/socketproxy.conf' do 25 | to node['nginx']['dir'] + '/sites-available/socketproxy.conf' 26 | end 27 | -------------------------------------------------------------------------------- /cookbooks/nginx/templates/default/default-site.erb: -------------------------------------------------------------------------------- 1 | server { 2 | listen <%= node['nginx']['port'] -%>; 3 | server_name <%= node['hostname'] %>; 4 | 5 | access_log <%= node['nginx']['log_dir'] %>/localhost.access.log; 6 | 7 | location / { 8 | root <%= node['nginx']['default_root'] %>; 9 | index index.html index.htm; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /cookbooks/nginx/templates/default/modules/authorized_ip.erb: -------------------------------------------------------------------------------- 1 | geo $<%= node['nginx']['remote_ip_var'] %> $authorized_ip { 2 | default no; 3 | <% node['nginx']['authorized_ips'].each do |ip| %> 4 | <%= "#{ip} yes;" %> 5 | <% end %> 6 | } 7 | -------------------------------------------------------------------------------- /cookbooks/nginx/templates/default/modules/http_geoip.conf.erb: -------------------------------------------------------------------------------- 1 | geoip_country <%= @country_dat %>; 2 | <% if @city_dat -%> 3 | geoip_city <%= @city_dat %>; 4 | <% end -%> 5 | -------------------------------------------------------------------------------- /cookbooks/nginx/templates/default/modules/http_gzip_static.conf.erb: -------------------------------------------------------------------------------- 1 | gzip_static <%= node['nginx']['gzip_static'] %>; 2 | -------------------------------------------------------------------------------- /cookbooks/nginx/templates/default/modules/http_realip.conf.erb: -------------------------------------------------------------------------------- 1 | <% node['nginx']['realip']['addresses'].each do |address| %> 2 | set_real_ip_from <%= address %>; 3 | <% end %> 4 | real_ip_header <%= node['nginx']['realip']['header'] %>; 5 | <% if node['nginx']['version'] >= '1.2.1' -%> 6 | real_ip_recursive <%= node['nginx']['realip']['real_ip_recursive'] %>; 7 | <% end -%> 8 | -------------------------------------------------------------------------------- /cookbooks/nginx/templates/default/modules/nginx_status.erb: -------------------------------------------------------------------------------- 1 | include authorized_ip; 2 | 3 | server { 4 | listen <%= node['nginx']['status']['port'] %>; 5 | server_name _; 6 | 7 | location /nginx_status { 8 | if ($authorized_ip = no) { 9 | return 404; 10 | } 11 | stub_status on; 12 | access_log off; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /cookbooks/nginx/templates/default/modules/passenger.conf.erb: -------------------------------------------------------------------------------- 1 | passenger_root <%= node['nginx']['passenger']['root'] %>; 2 | passenger_ruby <%= node['nginx']['passenger']['ruby'] %>; 3 | passenger_max_pool_size <%= node['nginx']['passenger']['max_pool_size'] %>; 4 | passenger_spawn_method <%= node['nginx']['passenger']['spawn_method'] %>; 5 | passenger_buffer_response <%= node['nginx']['passenger']['buffer_response'] %>; 6 | passenger_min_instances <%= node['nginx']['passenger']['min_instances'] %>; 7 | passenger_max_instances_per_app <%= node['nginx']['passenger']['max_instances_per_app'] %>; 8 | passenger_pool_idle_time <%= node['nginx']['passenger']['pool_idle_time'] %>; 9 | passenger_max_requests <%= node['nginx']['passenger']['max_requests'] %>; 10 | 11 | <%- if node['nginx']['passenger']['nodejs'] %> 12 | passenger_nodejs <%= node['nginx']['passenger']['nodejs'] %>; 13 | <% end %> 14 | -------------------------------------------------------------------------------- /cookbooks/nginx/templates/default/modules/upload_progress.erb: -------------------------------------------------------------------------------- 1 | upload_progress <%= node['nginx']['upload_progress']['zone_name'] -%> <%= node['nginx']['upload_progress']['zone_size'] -%>; 2 | <% if node['nginx']['upload_progress']['javascript_output'] -%> 3 | upload_progress_java_output; 4 | <% end -%> 5 | -------------------------------------------------------------------------------- /cookbooks/nginx/templates/default/nginx-upstart.conf.erb: -------------------------------------------------------------------------------- 1 | # nginx 2 | 3 | description "nginx http daemon" 4 | 5 | start on (local-filesystems and net-device-up IFACE=lo and runlevel [<%= node['nginx']['upstart']['runlevels'] %>]) 6 | stop on runlevel [!<%= node['nginx']['upstart']['runlevels'] %>] 7 | 8 | env DAEMON=<%= node['nginx']['binary'] %> 9 | env PID=<%= node['nginx']['pid'] %> 10 | env CONFIG=<%= node['nginx']['source']['conf_path'] %> 11 | 12 | respawn 13 | <% if node['nginx']['upstart']['respawn_limit'] %> 14 | respawn limit <%= node['nginx']['upstart']['respawn_limit'] %> 15 | <% end %> 16 | 17 | pre-start script 18 | ${DAEMON} -t 19 | if [ $? -ne 0 ]; then 20 | exit $? 21 | fi 22 | end script 23 | 24 | <% unless node['nginx']['upstart']['foreground'] %> 25 | expect fork 26 | <% else %> 27 | console output 28 | <% end %> 29 | 30 | exec ${DAEMON} -c "${CONFIG}" 31 | 32 | <% if node.recipe?('nginx::passenger') and not node['nginx']['upstart']['foreground'] %> 33 | # classic example of why pidfiles should have gone away 34 | # with the advent of fork(). we missed that bus a long 35 | # time ago so hack around it. 36 | post-stop script 37 | start-stop-daemon --stop --pidfile ${PID} --name nginx --exec ${DAEMON} --signal QUIT 38 | end script 39 | <% end %> 40 | -------------------------------------------------------------------------------- /cookbooks/nginx/templates/default/nginx.pill.erb: -------------------------------------------------------------------------------- 1 | Bluepill.application("nginx", :log_file => "<%= node['nginx']['log_dir'] %>/bluepill-nginx.log") do |app| 2 | app.process("nginx") do |process| 3 | process.pid_file = "<%= node['nginx']['pid'] %>" 4 | process.working_dir = "<%= node['nginx']['source']['prefix'] %>" 5 | process.start_command = "<%= node['nginx']['binary'] %> -c <%= node['nginx']['dir'] %>/nginx.conf" 6 | process.stop_command = "kill -QUIT {{PID}}" 7 | process.restart_command = "kill -HUP {{PID}}" 8 | process.daemonize = true 9 | process.stdout = process.stderr = "<%= node['nginx']['log_dir'] %>/nginx.log" 10 | 11 | process.monitor_children do |child_process| 12 | child_process.stop_command = "kill -QUIT {{PID}}" 13 | end 14 | end 15 | end 16 | -------------------------------------------------------------------------------- /cookbooks/nginx/templates/default/nginx.sysconfig.erb: -------------------------------------------------------------------------------- 1 | NGINX_GLOBAL=<%= node['nginx']['global'] %> 2 | -------------------------------------------------------------------------------- /cookbooks/nginx/templates/default/nxdissite.erb: -------------------------------------------------------------------------------- 1 | #!/bin/sh -e 2 | 3 | SYSCONFDIR='<%= node['nginx']['dir'] %>' 4 | 5 | if [ -z $1 ]; then 6 | echo "Which site would you like to disable?" 7 | echo -n "Your choices are: " 8 | ls $SYSCONFDIR/sites-enabled/* | \ 9 | sed -e "s,$SYSCONFDIR/sites-enabled/,,g" | xargs echo 10 | echo -n "Site name? " 11 | read SITENAME 12 | else 13 | SITENAME=$1 14 | fi 15 | 16 | if [ $SITENAME = "default" ]; then 17 | PRIORITY="000" 18 | fi 19 | 20 | if ! [ -e $SYSCONFDIR/sites-enabled/$SITENAME -o \ 21 | -e $SYSCONFDIR/sites-enabled/"$PRIORITY"-"$SITENAME" ]; then 22 | echo "This site is already disabled, or does not exist!" 23 | exit 1 24 | fi 25 | 26 | if ! rm $SYSCONFDIR/sites-enabled/$SITENAME 2>/dev/null; then 27 | rm -f $SYSCONFDIR/sites-enabled/"$PRIORITY"-"$SITENAME" 28 | fi 29 | echo "Site $SITENAME disabled; reload nginx to disable." 30 | -------------------------------------------------------------------------------- /cookbooks/nginx/templates/default/nxensite.erb: -------------------------------------------------------------------------------- 1 | #!/bin/sh -e 2 | 3 | SYSCONFDIR='<%= node['nginx']['dir'] %>' 4 | 5 | if [ -z $1 ]; then 6 | echo "Which site would you like to enable?" 7 | echo -n "Your choices are: " 8 | ls $SYSCONFDIR/sites-available/* | \ 9 | sed -e "s,$SYSCONFDIR/sites-available/,,g" | xargs echo 10 | echo -n "Site name? " 11 | read SITENAME 12 | else 13 | SITENAME=$1 14 | fi 15 | 16 | if [ $SITENAME = "default" ]; then 17 | PRIORITY="000" 18 | fi 19 | 20 | if [ -e $SYSCONFDIR/sites-enabled/$SITENAME -o \ 21 | -e $SYSCONFDIR/sites-enabled/"$PRIORITY"-"$SITENAME" ]; then 22 | echo "This site is already enabled!" 23 | exit 0 24 | fi 25 | 26 | if ! [ -e $SYSCONFDIR/sites-available/$SITENAME ]; then 27 | echo "This site does not exist!" 28 | exit 1 29 | fi 30 | 31 | if [ $SITENAME = "default" ]; then 32 | ln -sf $SYSCONFDIR/sites-available/$SITENAME \ 33 | $SYSCONFDIR/sites-enabled/"$PRIORITY"-"$SITENAME" 34 | else 35 | ln -sf $SYSCONFDIR/sites-available/$SITENAME $SYSCONFDIR/sites-enabled/$SITENAME 36 | fi 37 | 38 | echo "Site $SITENAME installed; reload nginx to enable." 39 | -------------------------------------------------------------------------------- /cookbooks/nginx/templates/default/sv-nginx-log-run.erb: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | exec svlogd -tt ./main 3 | -------------------------------------------------------------------------------- /cookbooks/nginx/templates/default/sv-nginx-run.erb: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | ulimit -n <%= node['nginx']['ulimit'] %> 3 | exec 2>&1 4 | exec <%= node['nginx']['src_binary'] %> -c <%= node['nginx']['dir'] %>/nginx.conf 5 | -------------------------------------------------------------------------------- /cookbooks/ohai/attributes/default.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: ohai 3 | # Attribute:: default 4 | # 5 | # Copyright 2010-2015, Chef Software, Inc 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # 19 | 20 | # FHS location would be /var/lib/chef/ohai_plugins or similar. 21 | case node['platform_family'] 22 | when 'windows' 23 | default['ohai']['plugin_path'] = 'C:/chef/ohai_plugins' 24 | default['ohai']['hints_path'] = 'C:/chef/ohai/hints' 25 | else 26 | default['ohai']['plugin_path'] = '/etc/chef/ohai_plugins' 27 | default['ohai']['hints_path'] = '/etc/chef/ohai/hints' 28 | end 29 | 30 | # The list of plugins and their respective file locations 31 | default['ohai']['plugins']['ohai'] = 'plugins' 32 | -------------------------------------------------------------------------------- /cookbooks/ohai/files/default/plugins/README: -------------------------------------------------------------------------------- 1 | This directory contains custom plugins for Ohai. 2 | -------------------------------------------------------------------------------- /cookbooks/ohai/libraries/matchers.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | if defined?(ChefSpec) 4 | ChefSpec::Runner.define_runner_method(:ohai_hint) 5 | 6 | def create_ohai_hint(resource) 7 | ChefSpec::Matchers::ResourceMatcher.new(:ohai_hint, :create, resource) 8 | end 9 | 10 | def delete_ohai_hint(resource) 11 | ChefSpec::Matchers::ResourceMatcher.new(:ohai_hint, :delete, resource) 12 | end 13 | 14 | end 15 | -------------------------------------------------------------------------------- /cookbooks/ohai/providers/hint.rb: -------------------------------------------------------------------------------- 1 | def why_run_supported? 2 | true 3 | end 4 | 5 | def build_ohai_hint_path 6 | ::File.join(node['ohai']['hints_path'], "#{new_resource.name}.json") 7 | end 8 | 9 | use_inline_resources 10 | 11 | action :create do 12 | if @current_resource.content != new_resource.content 13 | directory node['ohai']['hints_path'] do 14 | action :create 15 | recursive true 16 | end 17 | 18 | file build_ohai_hint_path do 19 | action :create 20 | content JSON.pretty_generate(new_resource.content) 21 | end 22 | end 23 | end 24 | 25 | def load_current_resource 26 | @current_resource = Chef::Resource::OhaiHint.new(new_resource.name) 27 | if ::File.exist?(build_ohai_hint_path) 28 | begin 29 | @current_resource.content(JSON.parse(::File.read(build_ohai_hint_path))) 30 | rescue JSON::ParserError 31 | @current_resource.content(nil) 32 | end 33 | else 34 | @current_resource.content(nil) 35 | end 36 | 37 | @current_resource 38 | end 39 | -------------------------------------------------------------------------------- /cookbooks/ohai/resources/hint.rb: -------------------------------------------------------------------------------- 1 | actions :create, :delete 2 | default_action :create 3 | 4 | attribute :hint_name, kind_of: String, name_attribute: true 5 | attribute :content, kind_of: Hash, default: {} 6 | -------------------------------------------------------------------------------- /cookbooks/openssl/attributes/default.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: openssl 3 | # Attributes:: default 4 | # 5 | # Copyright 2014, Chef Software, Inc. 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # 19 | 20 | default['openssl']['packages'] = [] 21 | default['openssl']['restart_services'] = [] 22 | -------------------------------------------------------------------------------- /cookbooks/openssl/libraries/matchers.rb: -------------------------------------------------------------------------------- 1 | if defined?(ChefSpec) 2 | def create_x509_certificate(name) 3 | ChefSpec::Matchers::ResourceMatcher.new(:openssl_x509, :create, name) 4 | end 5 | 6 | def create_dhparam_pem(name) 7 | ChefSpec::Matchers::ResourceMatcher.new(:openssl_dhparam, :create, name) 8 | end 9 | 10 | def create_rsa_key(name) 11 | ChefSpec::Matchers::ResourceMatcher.new(:openssl_rsa_key, :create, name) 12 | end 13 | end 14 | -------------------------------------------------------------------------------- /cookbooks/openssl/libraries/secure_password.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: openssl 3 | # Library:: secure_password 4 | # Author:: Joshua Timberman 5 | # 6 | # Copyright 2009, Chef Software, Inc. 7 | # 8 | # Licensed under the Apache License, Version 2.0 (the "License"); 9 | # you may not use this file except in compliance with the License. 10 | # You may obtain a copy of the License at 11 | # 12 | # http://www.apache.org/licenses/LICENSE-2.0 13 | # 14 | # Unless required by applicable law or agreed to in writing, software 15 | # distributed under the License is distributed on an "AS IS" BASIS, 16 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | # See the License for the specific language governing permissions and 18 | # limitations under the License. 19 | # 20 | 21 | include OpenSSLCookbook::Helpers 22 | 23 | module Opscode 24 | module OpenSSL 25 | # Generate secure passwords with OpenSSL 26 | module Password 27 | def secure_password(length = 20) 28 | pw = '' 29 | 30 | while pw.length < length 31 | pw << ::OpenSSL::Random.random_bytes(1).gsub(/\W/, '') 32 | end 33 | 34 | pw 35 | end 36 | end 37 | end 38 | end 39 | -------------------------------------------------------------------------------- /cookbooks/openssl/providers/dhparam.rb: -------------------------------------------------------------------------------- 1 | # 2 | # dhparam.pem provider 3 | # 4 | # Author:: Charles Johnson 5 | # 6 | 7 | include OpenSSLCookbook::Helpers 8 | 9 | use_inline_resources 10 | 11 | def whyrun_supported? 12 | true 13 | end 14 | 15 | action :create do 16 | converge_by("Create a dhparam file #{@new_resource}") do 17 | unless dhparam_pem_valid?(new_resource.name) 18 | dhparam_content = gen_dhparam(new_resource.key_length, new_resource.generator).to_pem 19 | 20 | log "Generating #{new_resource.key_length} bit "\ 21 | "dhparam file at #{new_resource.name}, this may take some time" 22 | 23 | file new_resource.name do 24 | action :create 25 | owner new_resource.owner 26 | group new_resource.group 27 | mode new_resource.mode 28 | sensitive true 29 | content dhparam_content 30 | end 31 | end 32 | end 33 | end 34 | -------------------------------------------------------------------------------- /cookbooks/openssl/providers/rsa_key.rb: -------------------------------------------------------------------------------- 1 | # 2 | # dhparam.pem provider 3 | # 4 | # Author:: Charles Johnson 5 | # 6 | 7 | include OpenSSLCookbook::Helpers 8 | 9 | use_inline_resources 10 | 11 | def whyrun_supported? 12 | true 13 | end 14 | 15 | action :create do 16 | converge_by("Create an RSA key #{@new_resource}") do 17 | unless key_file_valid?(new_resource.name, new_resource.key_pass) 18 | 19 | log "Generating #{new_resource.key_length} bit "\ 20 | "RSA key file at #{new_resource.name}, this may take some time" 21 | 22 | if new_resource.key_pass 23 | unencrypted_rsa_key = gen_rsa_key(new_resource.key_length) 24 | rsa_key_content = encrypt_rsa_key(unencrypted_rsa_key, new_resource.key_pass) 25 | else 26 | rsa_key_content = gen_rsa_key(new_resource.key_length).to_pem 27 | end 28 | 29 | file new_resource.name do 30 | action :create 31 | owner new_resource.owner 32 | group new_resource.group 33 | mode new_resource.mode 34 | sensitive true 35 | content rsa_key_content 36 | end 37 | end 38 | end 39 | end 40 | -------------------------------------------------------------------------------- /cookbooks/openssl/recipes/default.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: openssl 3 | # Recipe:: default 4 | # 5 | # Copyright 2009, Chef Software, Inc. 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # 19 | -------------------------------------------------------------------------------- /cookbooks/openssl/resources/dhparam.rb: -------------------------------------------------------------------------------- 1 | 2 | actions [:create] 3 | default_action :create 4 | 5 | attribute :name, :kind_of => String, :name_attribute => true 6 | attribute :key_length, :equal_to => [1024, 2048, 4096, 8192], :default => 2048 7 | attribute :generator, :equal_to => [2, 5], :default => 2 8 | attribute :owner, :kind_of => String 9 | attribute :group, :kind_of => String 10 | attribute :mode, :kind_of => [Integer, String] 11 | -------------------------------------------------------------------------------- /cookbooks/openssl/resources/rsa_key.rb: -------------------------------------------------------------------------------- 1 | 2 | actions [:create] 3 | default_action :create 4 | 5 | attribute :name, :kind_of => String, :name_attribute => true 6 | attribute :key_length, :equal_to => [1024, 2048, 4096, 8192], :default => 2048 7 | attribute :key_pass, :kind_of => String, :default => nil 8 | attribute :owner, :kind_of => String 9 | attribute :group, :kind_of => String 10 | attribute :mode, :kind_of => [Integer, String] 11 | -------------------------------------------------------------------------------- /cookbooks/openssl/resources/x509.rb: -------------------------------------------------------------------------------- 1 | 2 | actions [:create] 3 | default_action :create 4 | 5 | attribute :name, :kind_of => String, :name_attribute => true 6 | attribute :owner, :kind_of => String 7 | attribute :group, :kind_of => String 8 | attribute :expire, :kind_of => Integer 9 | attribute :mode, :kind_of => [Integer, String] 10 | attribute :org, :kind_of => String, :required => true 11 | attribute :org_unit, :kind_of => String, :required => true 12 | attribute :country, :kind_of => String, :required => true 13 | attribute :common_name, :kind_of => String, :required => true 14 | attribute :key_file, :kind_of => String, :default => nil 15 | attribute :key_pass, :kind_of => String, :default => nil 16 | attribute :key_length, :equal_to => [1024, 2048, 4096, 8192], :default => 2048 17 | -------------------------------------------------------------------------------- /cookbooks/packagecloud/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | packagecloud 2 | =============== 3 | This is the Changelog for the packagecloud cookbook 4 | 5 | v0.0.1 (2014-06-05) 6 | ------------------- 7 | Initial release. 8 | 9 | 10 | v0.0.1 (2014-06-05) 11 | ------------------- 12 | Initial release! 13 | -------------------------------------------------------------------------------- /cookbooks/packagecloud/attributes/default.rb: -------------------------------------------------------------------------------- 1 | default['packagecloud']['base_repo_path'] = "/install/repositories/" 2 | default['packagecloud']['gpg_key_path'] = "/gpg.key" 3 | default['packagecloud']['hostname_override'] = nil 4 | 5 | default['packagecloud']['default_type'] = value_for_platform_family( 6 | 'debian' => 'deb', 7 | ['rhel', 'fedora'] => 'rpm' 8 | ) 9 | -------------------------------------------------------------------------------- /cookbooks/packagecloud/libraries/helper.rb: -------------------------------------------------------------------------------- 1 | require 'net/https' 2 | 3 | module PackageCloud 4 | module Helper 5 | def get(uri, params) 6 | uri.query = URI.encode_www_form(params) 7 | req = Net::HTTP::Get.new(uri.request_uri) 8 | 9 | req.basic_auth uri.user, uri.password if uri.user 10 | 11 | http = Net::HTTP.new(uri.hostname, uri.port) 12 | http.use_ssl = true 13 | 14 | resp = http.start { |h| h.request(req) } 15 | 16 | case resp 17 | when Net::HTTPSuccess 18 | resp 19 | else 20 | raise resp.inspect 21 | end 22 | end 23 | 24 | def post(uri, params) 25 | req = Net::HTTP::Post.new(uri.request_uri) 26 | req.form_data = params 27 | 28 | req.basic_auth uri.user, uri.password if uri.user 29 | 30 | http = Net::HTTP.new(uri.hostname, uri.port) 31 | http.use_ssl = true 32 | 33 | resp = http.start { |h| h.request(req) } 34 | 35 | case resp 36 | when Net::HTTPSuccess 37 | resp 38 | else 39 | raise resp.inspect 40 | end 41 | end 42 | end 43 | end 44 | -------------------------------------------------------------------------------- /cookbooks/packagecloud/libraries/matcher.rb: -------------------------------------------------------------------------------- 1 | if defined?(ChefSpec) 2 | 3 | def create_packagecloud_repo(resource_name) 4 | ChefSpec::Matchers::ResourceMatcher.new(:packagecloud_repo, :add, resource_name) 5 | end 6 | 7 | end 8 | -------------------------------------------------------------------------------- /cookbooks/packagecloud/metadata.json: -------------------------------------------------------------------------------- 1 | {"name":"packagecloud","version":"0.1.0","description":"Installs/Configures packagecloud.io repositories.","long_description":"Installs/Configures packagecloud.io repositories.","maintainer":"Joe Damato","maintainer_email":"joe@packagecloud.io","license":"Apache 2.0","platforms":{},"dependencies":{},"recommendations":{},"suggestions":{},"conflicting":{},"providing":{},"replacing":{},"attributes":{},"groupings":{},"recipes":{}} -------------------------------------------------------------------------------- /cookbooks/packagecloud/resources/repo.rb: -------------------------------------------------------------------------------- 1 | actions :add 2 | default_action :add 3 | 4 | attribute :repository, :kind_of => String, :name_attribute => true 5 | attribute :master_token, :kind_of => String 6 | attribute :type, :kind_of => String, :equal_to => ['deb', 'rpm', 'gem'], :default => node['packagecloud']['default_type'] 7 | attribute :base_url, :kind_of => String, :default => "https://packagecloud.io" 8 | attribute :gpg_key_url, :kind_of => String, :default => node['packagecloud']['gpg_key_url'] 9 | attribute :priority, :kind_of => [Fixnum, TrueClass, FalseClass], :default => false 10 | attribute :metadata_expire, :kind_of => String, :regex => [/^\d+[d|h|m]?$/], :default => nil 11 | -------------------------------------------------------------------------------- /cookbooks/packagecloud/templates/default/apt.erb: -------------------------------------------------------------------------------- 1 | deb <%= @base_url %> <%= @distribution %> <%= @component %> 2 | deb-src <%= @base_url %> <%= @distribution %> <%= @component %> 3 | -------------------------------------------------------------------------------- /cookbooks/packagecloud/templates/default/yum.erb: -------------------------------------------------------------------------------- 1 | [<%= @name %>] 2 | name=<%= @description %> 3 | baseurl=<%= @base_url %> 4 | repo_gpgcheck=<%= @repo_gpgcheck %> 5 | <% if @priority -%> 6 | priority=<%=@priority %> 7 | <% end -%> 8 | gpgcheck=0 9 | enabled=1 10 | gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-<%= @gpg_filename %> 11 | sslverify=1 12 | sslcacert=/etc/pki/tls/certs/ca-bundle.crt 13 | <% if @metadata_expire %> 14 | metadata_expire=<%= @metadata_expire %> 15 | <% end %> 16 | -------------------------------------------------------------------------------- /cookbooks/postgresql/.gitignore: -------------------------------------------------------------------------------- 1 | .vagrant 2 | Berksfile.lock 3 | Cheffile.lock 4 | Gemfile.lock 5 | *~ 6 | *# 7 | .#* 8 | \#*# 9 | .*.sw[a-z] 10 | *.un~ 11 | .bundle 12 | .cache 13 | .kitchen 14 | bin 15 | .kitchen.local.yml 16 | .kitchen/ 17 | .librarian/ 18 | tmp/ 19 | -------------------------------------------------------------------------------- /cookbooks/postgresql/.rspec: -------------------------------------------------------------------------------- 1 | --default-path test/unit 2 | --color 3 | --format documentation 4 | -------------------------------------------------------------------------------- /cookbooks/postgresql/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | 1. Fork the repository using Github. 2 | 1. Checkout a named feature branch created from the `develop` branch. 3 | 1. Write tests using chefspec or serverspec as appropriate. 4 | 1. Complete modifications or corrections. 5 | 1. Run the tests, ensuring they all pass. 6 | 1. Submit a Pull Request to the `develop` branch using Github. 7 | -------------------------------------------------------------------------------- /cookbooks/postgresql/Cheffile: -------------------------------------------------------------------------------- 1 | site "https://supermarket.getchef.com/api/v1" 2 | 3 | cookbook 'postgresql', :path => '.' 4 | 5 | cookbook 'build-essential' 6 | cookbook 'minitest-handler' 7 | -------------------------------------------------------------------------------- /cookbooks/postgresql/Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | 3 | gem 'emeril', :group => :release 4 | gem 'rake' 5 | 6 | group :integration do 7 | gem 'test-kitchen' 8 | gem 'kitchen-vagrant' 9 | gem 'kitchen-docker' 10 | end 11 | gem 'chefspec', '~> 4.2.0' 12 | gem 'librarian-chef' 13 | -------------------------------------------------------------------------------- /cookbooks/postgresql/Rakefile: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env rake 2 | 3 | begin 4 | require 'rspec/core/rake_task' 5 | RSpec::Core::RakeTask.new(:spec) do |t| 6 | t.pattern = [ 'test/unit/**{,/*/**}/*_spec.rb' ] 7 | end 8 | rescue LoadError 9 | end 10 | 11 | begin 12 | require 'kitchen/rake_tasks' 13 | Kitchen::RakeTasks.new 14 | rescue LoadError 15 | puts '>>>>> Kitchen gem not loaded, omitting tasks' unless ENV['CI'] 16 | end 17 | 18 | begin 19 | require 'emeril/rake' 20 | rescue LoadError 21 | puts ">>>>> Emeril gem not loaded, omitting tasks" unless ENV['CI'] 22 | end 23 | -------------------------------------------------------------------------------- /cookbooks/postgresql/TESTING.md: -------------------------------------------------------------------------------- 1 | This cookbook includes support for running unit tests under ChefSpec and integration tests under Test Kitchen. 2 | 3 | Before you can run these tests: 4 | 5 | 1. You must be using the Git repository, rather than the downloaded cookbook from the Chef Community Site. 6 | 2. You must have Vagrant 1.1 installed. 7 | 3. You must have a "sane" Ruby 1.9.3 environment with `bundler` 8 | 9 | Once the above requirements are met, install the gem dependenies: 10 | 11 | bundle install 12 | 13 | With the bundle installed, you should be able to run Test Kitchen: 14 | 15 | bundle exec kitchen list 16 | bundle exec kitchen test 17 | 18 | You can use the tasks defined in the Rakefile for running tests. For example, the following commands will run 19 | the ChefSpec unit tests and all of the configured Test Kitchen platform/suite permuations: 20 | 21 | bundle exec rake spec 22 | bundle exec rake kitchen:all 23 | -------------------------------------------------------------------------------- /cookbooks/postgresql/files/default/tests/minitest/default_test.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2012, Opscode, Inc. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | 17 | require File.expand_path('../support/helpers', __FILE__) 18 | 19 | describe 'postgresql::default' do 20 | include Helpers::Postgresql 21 | 22 | it 'installs the postgresql client packages' do 23 | node['postgresql']['client']['packages'].each do |pkg| 24 | package(pkg).must_be_installed 25 | end 26 | end 27 | end 28 | -------------------------------------------------------------------------------- /cookbooks/postgresql/files/default/tests/minitest/ruby_test.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: postgresql_test 3 | # Recipe:: default 4 | # 5 | # Copyright 2012, Opscode, Inc. 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # 19 | 20 | require File.expand_path('../support/helpers', __FILE__) 21 | 22 | describe 'postgresql::ruby' do 23 | include Helpers::Postgresql 24 | 25 | it 'installs the pg gem in Chefs ruby environment' do 26 | assert Gem::Specification.all_names.grep("pg-.*") 27 | end 28 | end 29 | -------------------------------------------------------------------------------- /cookbooks/postgresql/files/default/tests/minitest/support/helpers.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: postgresql_test 3 | # Recipe:: default 4 | # 5 | # Copyright 2012, Opscode, Inc. 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # 19 | 20 | module Helpers 21 | module Postgresql 22 | require 'chef/mixin/shell_out' 23 | include Chef::Mixin::ShellOut 24 | include MiniTest::Chef::Assertions 25 | include MiniTest::Chef::Context 26 | include MiniTest::Chef::Resources 27 | 28 | end 29 | end 30 | -------------------------------------------------------------------------------- /cookbooks/postgresql/recipes/apt_pgdg_postgresql.rb: -------------------------------------------------------------------------------- 1 | if not %w(jessie squeeze wheezy sid lucid precise saucy trusty utopic).include? node['postgresql']['pgdg']['release_apt_codename'] 2 | raise "Not supported release by PGDG apt repository" 3 | end 4 | 5 | include_recipe 'apt' 6 | 7 | file "remove deprecated Pitti PPA apt repository" do 8 | action :delete 9 | path "/etc/apt/sources.list.d/pitti-postgresql-ppa" 10 | end 11 | 12 | apt_repository 'apt.postgresql.org' do 13 | uri 'http://apt.postgresql.org/pub/repos/apt' 14 | distribution "#{node['postgresql']['pgdg']['release_apt_codename']}-pgdg" 15 | components ['main', node['postgresql']['version']] 16 | key 'https://www.postgresql.org/media/keys/ACCC4CF8.asc' 17 | action :add 18 | end 19 | -------------------------------------------------------------------------------- /cookbooks/postgresql/recipes/client.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: postgresql 3 | # Recipe:: client 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | 18 | if platform_family?('debian') && node['postgresql']['version'].to_f > 9.3 19 | node.default['postgresql']['enable_pgdg_apt'] = true 20 | end 21 | 22 | if(node['postgresql']['enable_pgdg_apt']) and platform_family?('debian') 23 | include_recipe 'postgresql::apt_pgdg_postgresql' 24 | end 25 | 26 | if(node['postgresql']['enable_pgdg_yum']) and platform_family?('rhel') 27 | include_recipe 'postgresql::yum_pgdg_postgresql' 28 | end 29 | 30 | node['postgresql']['client']['packages'].each do |pg_pack| 31 | package pg_pack 32 | end 33 | -------------------------------------------------------------------------------- /cookbooks/postgresql/recipes/default.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: postgresql 3 | # Recipe:: default 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | 18 | include_recipe "postgresql::client" 19 | -------------------------------------------------------------------------------- /cookbooks/postgresql/recipes/server_conf.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: postgresql 3 | # Recipe:: server 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | 18 | change_notify = node['postgresql']['server']['config_change_notify'] 19 | 20 | template "#{node['postgresql']['dir']}/postgresql.conf" do 21 | source "postgresql.conf.erb" 22 | owner "postgres" 23 | group "postgres" 24 | mode 0600 25 | notifies change_notify, 'service[postgresql]', :immediately 26 | end 27 | 28 | template "#{node['postgresql']['dir']}/pg_hba.conf" do 29 | source "pg_hba.conf.erb" 30 | owner "postgres" 31 | group "postgres" 32 | mode 00600 33 | notifies change_notify, 'service[postgresql]', :immediately 34 | end 35 | -------------------------------------------------------------------------------- /cookbooks/postgresql/recipes/server_debian.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: postgresql 3 | # Recipe:: server 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | 18 | include_recipe "postgresql::client" 19 | 20 | node['postgresql']['server']['packages'].each do |pg_pack| 21 | 22 | package pg_pack 23 | 24 | end 25 | 26 | include_recipe "postgresql::server_conf" 27 | 28 | service "postgresql" do 29 | service_name node['postgresql']['server']['service_name'] 30 | supports :restart => true, :status => true, :reload => true 31 | action [:enable, :start] 32 | end 33 | 34 | execute 'Set locale and Create cluster' do 35 | command 'export LC_ALL=C; /usr/bin/pg_createcluster --start ' + node['postgresql']['version'] + ' main' 36 | action :run 37 | not_if { ::File.directory?('/etc/postgresql/' + node['postgresql']['version'] + '/main') } 38 | end 39 | -------------------------------------------------------------------------------- /cookbooks/postgresql/recipes/setup_databases.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: postgresql 3 | # Recipe:: setup_databases 4 | # 5 | 6 | databases = node["postgresql"]["databases"] 7 | 8 | # setup databases 9 | databases.each do |db| 10 | db_action = (db["action"] || "create").to_sym 11 | db_extensions = Array(db["extensions"]) 12 | db_languages = Array(db["languages"]) 13 | 14 | postgresql_database db["name"] do 15 | owner db["owner"] 16 | encoding db["encoding"] 17 | template db["template"] 18 | locale db["locale"] 19 | action db_action 20 | end 21 | 22 | # check for extensions/languages to install from `databases` attribute key 23 | next unless db_action == :create 24 | 25 | db_extensions.each do |extension| 26 | postgresql_extension extension do 27 | database db["name"] 28 | end 29 | end 30 | 31 | db_languages.each do |language| 32 | postgresql_language language do 33 | database db["name"] 34 | end 35 | end 36 | end 37 | -------------------------------------------------------------------------------- /cookbooks/postgresql/recipes/setup_users.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: postgresql 3 | # Recipe:: setup_users 4 | # 5 | 6 | # setup users 7 | 8 | node["postgresql"]["users"].each do |user| 9 | postgresql_user user["username"] do 10 | superuser user["superuser"] 11 | createdb user["createdb"] 12 | login user["login"] 13 | password user["password"] 14 | encrypted_password user["encrypted_password"] 15 | action Array(user["action"] || "create").map(&:to_sym) 16 | end 17 | end 18 | -------------------------------------------------------------------------------- /cookbooks/postgresql/resources/database.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: postgresql 3 | # Resource:: database 4 | # 5 | 6 | actions :create, :drop 7 | 8 | default_action :create 9 | 10 | attribute :name, kind_of: String, name_attribute: true 11 | attribute :user, kind_of: String, default: "postgres" 12 | attribute :username, kind_of: String 13 | attribute :host, kind_of: String 14 | attribute :port, kind_of: Integer 15 | attribute :encoding, kind_of: String, default: "UTF-8" 16 | attribute :locale, kind_of: String, default: "en_US.UTF-8" 17 | attribute :template, kind_of: String, default: "template0" 18 | attribute :owner, kind_of: String 19 | 20 | attr_accessor :exists 21 | -------------------------------------------------------------------------------- /cookbooks/postgresql/resources/user.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: postgresql 3 | # Resource:: user 4 | # 5 | 6 | actions :create, :update, :drop 7 | 8 | default_action :create 9 | 10 | attribute :name, kind_of: String, name_attribute: true 11 | attribute :superuser, kind_of: [TrueClass, FalseClass], default: false 12 | attribute :createdb, kind_of: [TrueClass, FalseClass], default: false 13 | attribute :createrole, kind_of: [TrueClass, FalseClass], default: false 14 | attribute :inherit, kind_of: [TrueClass, FalseClass], default: true 15 | attribute :replication, kind_of: [TrueClass, FalseClass], default: false 16 | attribute :login, kind_of: [TrueClass, FalseClass], default: true 17 | attribute :password, kind_of: String 18 | attribute :encrypted_password, kind_of: String 19 | 20 | attr_accessor :exists 21 | -------------------------------------------------------------------------------- /cookbooks/postgresql/templates/default/pgsql.sysconfig.erb: -------------------------------------------------------------------------------- 1 | PGDATA=<%= node['postgresql']['dir'] %> 2 | <% if node['postgresql']['config'].attribute?("port") -%> 3 | PGPORT=<%= node['postgresql']['config']['port'] %> 4 | <% end -%> 5 | -------------------------------------------------------------------------------- /cookbooks/postgresql/templates/default/postgresql.conf.erb: -------------------------------------------------------------------------------- 1 | # PostgreSQL configuration file 2 | # This file was automatically generated and dropped off by chef! 3 | # Please refer to the PostgreSQL documentation for details on 4 | # configuration settings. 5 | 6 | <% node['postgresql']['config'].sort.each do |key, value| %> 7 | <% next if value.nil? -%> 8 | <% next if node['postgresql']['version'].to_f < 9.2 && /ssl_.*._file/.match(key) -%> 9 | <%= key %> = <%= 10 | case value 11 | when String 12 | "'#{value}'" 13 | when TrueClass 14 | 'on' 15 | when FalseClass 16 | 'off' 17 | else 18 | value 19 | end 20 | %> 21 | <% end %> 22 | -------------------------------------------------------------------------------- /cookbooks/postgresql/test/unit/default_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe 'postgresql::default' do 4 | platforms = { 5 | 'ubuntu' => { 6 | 'versions' => ['10.04', '12.04', '14.04'] 7 | }, 8 | 'centos' => { 9 | 'versions' => ['6.4', '7.0'] 10 | }, 11 | 'redhat' => { 12 | 'versions' => ['6.5', '7.0'] 13 | }, 14 | 'debian' => { 15 | 'versions' => ['7.6'] 16 | } 17 | } 18 | 19 | platforms.each do |platform, config| 20 | config['versions'].each do |version| 21 | context "on #{platform} #{version}" do 22 | let(:chef_run) { 23 | ChefSpec::SoloRunner.new( 24 | :platform => platform.to_s, 25 | :version => version.to_s 26 | ) do |node| 27 | node.set['postgresql']['password']['postgres'] = 'ilikewaffles' 28 | end.converge(described_recipe) 29 | } 30 | 31 | it 'runs no tests' do 32 | expect(chef_run) 33 | end 34 | end 35 | end 36 | end 37 | end 38 | -------------------------------------------------------------------------------- /cookbooks/postgresql/test/unit/server_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe 'postgresql::server' do 4 | platforms = { 5 | 'ubuntu' => { 6 | 'versions' => ['10.04', '12.04', '14.04'] 7 | }, 8 | 'centos' => { 9 | 'versions' => ['6.4', '7.0'] 10 | }, 11 | 'redhat' => { 12 | 'versions' => ['6.5', '7.0'] 13 | }, 14 | 'debian' => { 15 | 'versions' => ['7.6'] 16 | } 17 | } 18 | 19 | platforms.each do |platform, config| 20 | config['versions'].each do |version| 21 | context "on #{platform} #{version}" do 22 | let(:chef_run) { 23 | ChefSpec::SoloRunner.new( 24 | :platform => platform.to_s, 25 | :version => version.to_s 26 | ) do |node| 27 | node.set['postgresql']['password']['postgres'] = 'ilikewaffles' 28 | end.converge(described_recipe) 29 | } 30 | 31 | before do 32 | stub_command(/ls \/.*\/recovery.conf/).and_return(false) 33 | end 34 | 35 | it 'runs no tests' do 36 | expect(chef_run) 37 | end 38 | end 39 | end 40 | end 41 | end 42 | -------------------------------------------------------------------------------- /cookbooks/postgresql/test/unit/spec_helper.rb: -------------------------------------------------------------------------------- 1 | COOKBOOK_RESOLVERS = { 2 | 'batali' => ['Batali', 'batali/chefspec'], 3 | 'berkshelf' => ['Berksfile', 'chefspec/berkshelf'], 4 | 'librarian' => ['Cheffile', 'chefspec/librarian'] 5 | } 6 | 7 | require 'chefspec' 8 | 9 | if ENV['COOKBOOK_RESOLVER'] 10 | require COOKBOOK_RESOLVERS[ENV['COOKBOOK_RESOLVER']] 11 | else 12 | resolver_lib = COOKBOOK_RESOLVERS.values.detect do |r_file, _r_lib| 13 | File.exist?(File.join(File.dirname(__FILE__), '..', '..', r_file)) 14 | end 15 | fail 'Failed to locate valid cookbook resolver files!' unless resolver_lib 16 | puts "Resolving cookbooks from #{resolver_lib.first}" 17 | require resolver_lib.last 18 | end 19 | 20 | at_exit { ChefSpec::Coverage.report! } 21 | -------------------------------------------------------------------------------- /cookbooks/rsyslog/libraries/helpers.rb: -------------------------------------------------------------------------------- 1 | module RsyslogCookbook 2 | # helpers for the various service providers on Ubuntu systems 3 | module Helpers 4 | def find_provider 5 | if Chef::VersionConstraint.new('>= 15.04').include?(node['platform_version']) 6 | service_provider = Chef::Provider::Service::Systemd 7 | elsif Chef::VersionConstraint.new('>= 12.04').include?(node['platform_version']) 8 | service_provider = Chef::Provider::Service::Upstart 9 | else 10 | service_provider = nil 11 | end 12 | service_provider 13 | end 14 | 15 | def declare_rsyslog_service 16 | service_provider = 'ubuntu' == node['platform'] ? find_provider : nil 17 | 18 | service node['rsyslog']['service_name'] do 19 | supports restart: true, status: true 20 | action [:enable, :start] 21 | provider service_provider 22 | end 23 | end 24 | end 25 | end 26 | -------------------------------------------------------------------------------- /cookbooks/rsyslog/resources/file_input.rb: -------------------------------------------------------------------------------- 1 | # Cookbook Name:: rsyslog 2 | # Resource:: file_input 3 | # 4 | # Copyright 2012-2015, Joseph Holsten 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | 19 | actions :create 20 | default_action :create 21 | 22 | attribute :name, kind_of: String, name_attribute: true, required: true 23 | attribute :file, kind_of: String, required: true 24 | attribute :priority, kind_of: Integer, default: 99 25 | attribute :severity, kind_of: String 26 | attribute :facility, kind_of: String 27 | attribute :cookbook, kind_of: String, default: 'rsyslog' 28 | attribute :source, kind_of: String, default: 'file-input.conf.erb' 29 | -------------------------------------------------------------------------------- /cookbooks/rsyslog/templates/default/49-relp.conf.erb: -------------------------------------------------------------------------------- 1 | # Generated by Chef 2 | $ModLoad omrelp 3 | $ActionQueueType LinkedList # use asynchronous processing 4 | $ActionQueueFileName srvrfwd # set file name, also enables disk mode 5 | $ActionResumeRetryCount -1 # infinite retries on insert failure 6 | $ActionQueueSaveOnShutdown on # save in-memory data if rsyslog shuts down 7 | 8 | <% @servers.each do |server| -%> 9 | <%= node['rsyslog']['logs_to_forward'] %> :omrelp:<%= "#{server}:#{node['rsyslog']['relp_port']}" %><%= node['rsyslog']['default_remote_template'] ? ';' + node['rsyslog']['default_remote_template'] : nil %> 10 | <% end -%> 11 | -------------------------------------------------------------------------------- /cookbooks/rsyslog/templates/default/50-default.conf.erb: -------------------------------------------------------------------------------- 1 | # Generated by Chef 2 | # For more information see rsyslog.conf(5) and /etc/rsyslog.conf 3 | 4 | <% node['rsyslog']['default_facility_logs'].each do |key, value| %> 5 | <%= key %> <%= value %> 6 | <% end %> 7 | -------------------------------------------------------------------------------- /cookbooks/rsyslog/templates/default/file-input.conf.erb: -------------------------------------------------------------------------------- 1 | # <%= @tag %>.conf - Syslog file inputs for <%= @tag %> 2 | # 3 | # Generated by Chef for <%= node['fqdn'] %> 4 | # Local modifications will be overwritten. 5 | $ModLoad imfile 6 | $InputFileName <%= @file_name %> 7 | $InputFileTag <%= @tag %>: 8 | $InputFileStateFile <%= @state_file %> 9 | <% if @severity %> 10 | $InputFileSeverity <%= @severity %> 11 | <% end %> 12 | <% if @facility %> 13 | $InputFileFacility <%= @facility %> 14 | <% end %> 15 | $InputRunFileMonitor 16 | -------------------------------------------------------------------------------- /cookbooks/rsyslog/templates/smartos/50-default.conf.erb: -------------------------------------------------------------------------------- 1 | # Dropped of by Chef. Modifications will be lost. 2 | # 3 | # Default rules for rsyslog. 4 | # 5 | # For more information see rsyslog.conf(5) and <%= node['rsyslog']['config_prefix'] %>/rsyslog.conf 6 | 7 | *.err;kern.notice;auth.notice /dev/sysmsg 8 | *.err;kern.debug;daemon.notice;mail.crit /var/adm/messages 9 | 10 | *.alert;kern.err;daemon.err operator 11 | *.alert root 12 | 13 | *.emerg * 14 | 15 | mail.debug /var/log/syslog 16 | 17 | auth.info /var/log/auth.log 18 | mail.info /var/log/postfix.log 19 | -------------------------------------------------------------------------------- /cookbooks/ruby_build/libraries/ruby_build_recipe_helpers.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: ruby_build 3 | # Library:: Chef::RubyBuild::RecipeHelpers 4 | # 5 | # Author:: Fletcher Nichol 6 | # 7 | # Copyright 2011, Fletcher Nichol 8 | # 9 | # Licensed under the Apache License, Version 2.0 (the "License"); 10 | # you may not use this file except in compliance with the License. 11 | # You may obtain a copy of the License at 12 | # 13 | # http://www.apache.org/licenses/LICENSE-2.0 14 | # 15 | # Unless required by applicable law or agreed to in writing, software 16 | # distributed under the License is distributed on an "AS IS" BASIS, 17 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | # See the License for the specific language governing permissions and 19 | # limitations under the License. 20 | # 21 | 22 | class Chef 23 | module RubyBuild 24 | module RecipeHelpers 25 | def build_upgrade_strategy(strategy) 26 | if strategy.nil? || strategy == false 27 | "none" 28 | else 29 | strategy 30 | end 31 | end 32 | 33 | def mac_with_no_homebrew 34 | node['platform'] == 'mac_os_x' && 35 | Chef::Platform.find_provider_for_node(node, :package) != 36 | Chef::Provider::Package::Homebrew 37 | end 38 | end 39 | end 40 | end 41 | -------------------------------------------------------------------------------- /cookbooks/ruby_build/resources/ruby.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: ruby_build 3 | # Resource:: ruby 4 | # 5 | # Author:: Fletcher Nichol 6 | # 7 | # Copyright 2011, Fletcher Nichol 8 | # 9 | # Licensed under the Apache License, Version 2.0 (the "License"); 10 | # you may not use this file except in compliance with the License. 11 | # You may obtain a copy of the License at 12 | # 13 | # http://www.apache.org/licenses/LICENSE-2.0 14 | # 15 | # Unless required by applicable law or agreed to in writing, software 16 | # distributed under the License is distributed on an "AS IS" BASIS, 17 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | # See the License for the specific language governing permissions and 19 | # limitations under the License. 20 | # 21 | 22 | actions :install, :reinstall 23 | 24 | attribute :definition, :kind_of => String, :name_attribute => true 25 | attribute :prefix_path, :kind_of => String 26 | attribute :user, :kind_of => String 27 | attribute :group, :kind_of => String 28 | attribute :environment, :kind_of => Hash 29 | 30 | def initialize(*args) 31 | super 32 | @action = :install 33 | end 34 | -------------------------------------------------------------------------------- /cookbooks/ruby_rbenv/libraries/matchers.rb: -------------------------------------------------------------------------------- 1 | if defined?(ChefSpec) 2 | def install_rbenv_plugin(name) 3 | ChefSpec::Matchers::ResourceMatcher.new(:rbenv_plugin, :install, name) 4 | end 5 | 6 | def run_rbenv_script(name) 7 | ChefSpec::Matchers::ResourceMatcher.new(:rbenv_script, :run, name) 8 | end 9 | 10 | def install_rbenv_gem(name) 11 | ChefSpec::Matchers::ResourceMatcher.new(:rbenv_gem, :install, name) 12 | end 13 | 14 | def upgrade_rbenv_gem(name) 15 | ChefSpec::Matchers::ResourceMatcher.new(:rbenv_gem, :upgrade, name) 16 | end 17 | 18 | def remove_rbenv_gem(name) 19 | ChefSpec::Matchers::ResourceMatcher.new(:rbenv_gem, :remove, name) 20 | end 21 | 22 | def purge_rbenv_gem(name) 23 | ChefSpec::Matchers::ResourceMatcher.new(:rbenv_gem, :purge, name) 24 | end 25 | end 26 | -------------------------------------------------------------------------------- /cookbooks/ruby_rbenv/metadata.json: -------------------------------------------------------------------------------- 1 | {"name":"ruby_rbenv","version":"1.0.1","description":"Manages rbenv and its installed rubies. Several LWRPs are also defined.","long_description":"Please refer to README.md (it's long).","maintainer":"Fletcher Nichol","maintainer_email":"fnichol@nichol.ca","license":"Apache 2.0","platforms":{"ubuntu":">= 0.0.0","linuxmint":">= 0.0.0","debian":">= 0.0.0","freebsd":">= 0.0.0","redhat":">= 0.0.0","centos":">= 0.0.0","fedora":">= 0.0.0","amazon":">= 0.0.0","scientific":">= 0.0.0","suse":">= 0.0.0","mac_os_x":">= 0.0.0","gentoo":">= 0.0.0","arch":">= 0.0.0"},"dependencies":{"ruby_build":">= 0.0.0"},"recommendations":{"java":"> 1.4.0"},"suggestions":{},"conflicting":{},"providing":{},"replacing":{},"attributes":{},"groupings":{},"recipes":{}} -------------------------------------------------------------------------------- /cookbooks/ruby_rbenv/providers/rehash.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: ruby_rbenv 3 | # Provider:: rehash 4 | # 5 | # Author:: Fletcher Nichol 6 | # 7 | # Copyright 2011, 2014, Fletcher Nichol 8 | # 9 | # Licensed under the Apache License, Version 2.0 (the "License"); 10 | # you may not use this file except in compliance with the License. 11 | # You may obtain a copy of the License at 12 | # 13 | # http://www.apache.org/licenses/LICENSE-2.0 14 | # 15 | # Unless required by applicable law or agreed to in writing, software 16 | # distributed under the License is distributed on an "AS IS" BASIS, 17 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | # See the License for the specific language governing permissions and 19 | # limitations under the License. 20 | # 21 | 22 | def whyrun_supported? 23 | true 24 | end 25 | 26 | use_inline_resources 27 | 28 | provides :rbenv_rehash 29 | 30 | include Chef::Rbenv::ScriptHelpers 31 | 32 | action :run do 33 | set_updated { run_script } 34 | end 35 | 36 | def run_script 37 | command = %(rbenv rehash) 38 | 39 | rbenv_script "#{command} #{which_rbenv}" do 40 | code command 41 | user new_resource.user if new_resource.user 42 | root_path new_resource.root_path if new_resource.root_path 43 | action :run 44 | end 45 | end 46 | -------------------------------------------------------------------------------- /cookbooks/ruby_rbenv/recipes/default.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: ruby_rbenv 3 | # Recipe:: default 4 | # 5 | # Copyright 2011, Fletcher Nichol 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # 19 | 20 | class Chef::Recipe 21 | # mix in recipe helpers 22 | include Chef::Rbenv::RecipeHelpers 23 | end 24 | -------------------------------------------------------------------------------- /cookbooks/ruby_rbenv/resources/global.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: ruby_rbenv 3 | # Resource:: global 4 | # 5 | # Author:: Fletcher Nichol 6 | # 7 | # Copyright 2011, Fletcher Nichol 8 | # 9 | # Licensed under the Apache License, Version 2.0 (the "License"); 10 | # you may not use this file except in compliance with the License. 11 | # You may obtain a copy of the License at 12 | # 13 | # http://www.apache.org/licenses/LICENSE-2.0 14 | # 15 | # Unless required by applicable law or agreed to in writing, software 16 | # distributed under the License is distributed on an "AS IS" BASIS, 17 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | # See the License for the specific language governing permissions and 19 | # limitations under the License. 20 | # 21 | 22 | actions :create 23 | default_action :create 24 | 25 | provides :rbenv_global 26 | 27 | attribute :rbenv_version, kind_of: String, name_attribute: true 28 | attribute :user, kind_of: String 29 | attribute :root_path, kind_of: String 30 | 31 | def to_s 32 | "#{super} (#{@user || 'system'})" 33 | end 34 | -------------------------------------------------------------------------------- /cookbooks/ruby_rbenv/resources/plugin.rb: -------------------------------------------------------------------------------- 1 | actions :install 2 | 3 | default_action :install 4 | 5 | provides :rbenv_plugin 6 | 7 | attribute :name, kind_of: String, name_attribute: true 8 | attribute :git_url, kind_of: String 9 | attribute :git_ref, kind_of: String 10 | attribute :user, kind_of: String 11 | attribute :root_path, kind_of: String 12 | 13 | def to_s 14 | "#{super} (#{@user || 'system'})" 15 | end 16 | -------------------------------------------------------------------------------- /cookbooks/ruby_rbenv/resources/rehash.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: ruby_rbenv 3 | # Resource:: rehash 4 | # 5 | # Author:: Fletcher Nichol 6 | # 7 | # Copyright 2011, Fletcher Nichol 8 | # 9 | # Licensed under the Apache License, Version 2.0 (the "License"); 10 | # you may not use this file except in compliance with the License. 11 | # You may obtain a copy of the License at 12 | # 13 | # http://www.apache.org/licenses/LICENSE-2.0 14 | # 15 | # Unless required by applicable law or agreed to in writing, software 16 | # distributed under the License is distributed on an "AS IS" BASIS, 17 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | # See the License for the specific language governing permissions and 19 | # limitations under the License. 20 | # 21 | 22 | actions :run 23 | default_action :run 24 | 25 | provides :rbenv_rehash 26 | 27 | attribute :name, kind_of: String, name_attribute: true 28 | attribute :user, kind_of: String 29 | attribute :root_path, kind_of: String 30 | -------------------------------------------------------------------------------- /cookbooks/ruby_rbenv/resources/ruby.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: ruby_rbenv 3 | # Resource:: ruby 4 | # 5 | # Author:: Fletcher Nichol 6 | # 7 | # Copyright 2011, Fletcher Nichol 8 | # 9 | # Licensed under the Apache License, Version 2.0 (the "License"); 10 | # you may not use this file except in compliance with the License. 11 | # You may obtain a copy of the License at 12 | # 13 | # http://www.apache.org/licenses/LICENSE-2.0 14 | # 15 | # Unless required by applicable law or agreed to in writing, software 16 | # distributed under the License is distributed on an "AS IS" BASIS, 17 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | # See the License for the specific language governing permissions and 19 | # limitations under the License. 20 | # 21 | 22 | actions :install, :reinstall 23 | default_action :install 24 | 25 | provides :rbenv_ruby 26 | 27 | attribute :definition, kind_of: String, name_attribute: true 28 | attribute :definition_file, kind_of: String 29 | attribute :root_path, kind_of: String 30 | attribute :user, kind_of: String 31 | attribute :environment, kind_of: Hash 32 | attribute :patch_url, kind_of: String 33 | attribute :patch_file, kind_of: String 34 | attribute :rbenv_action, kind_of: String, default: 'install' 35 | 36 | def initialize(*args) 37 | super 38 | @rbenv_version = @definition 39 | end 40 | 41 | def to_s 42 | "#{super} (#{@user || 'system'})" 43 | end 44 | -------------------------------------------------------------------------------- /cookbooks/ruby_rbenv/resources/script.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: ruby_rbenv 3 | # Resource:: script 4 | # 5 | # Author:: Fletcher Nichol 6 | # 7 | # Copyright 2011, Fletcher Nichol 8 | # 9 | # Licensed under the Apache License, Version 2.0 (the "License"); 10 | # you may not use this file except in compliance with the License. 11 | # You may obtain a copy of the License at 12 | # 13 | # http://www.apache.org/licenses/LICENSE-2.0 14 | # 15 | # Unless required by applicable law or agreed to in writing, software 16 | # distributed under the License is distributed on an "AS IS" BASIS, 17 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | # See the License for the specific language governing permissions and 19 | # limitations under the License. 20 | # 21 | 22 | actions :run 23 | default_action :run 24 | 25 | provides :rbenv_script 26 | 27 | attribute :name, kind_of: String, name_attribute: true 28 | attribute :rbenv_version, kind_of: String 29 | attribute :root_path, kind_of: String 30 | attribute :code, kind_of: String 31 | attribute :creates, kind_of: String 32 | attribute :cwd, kind_of: String 33 | attribute :environment, kind_of: Hash 34 | attribute :group, kind_of: String 35 | attribute :path, kind_of: Array 36 | attribute :returns, kind_of: Array, default: [0] 37 | attribute :timeout, kind_of: Integer 38 | attribute :user, kind_of: String 39 | attribute :umask, kind_of: [String, Integer] 40 | -------------------------------------------------------------------------------- /cookbooks/ruby_rbenv/templates/default/rbenv.sh.erb: -------------------------------------------------------------------------------- 1 | # Generated by Chef for <%= node['fqdn'] %> 2 | # Local modifications will be overridden 3 | 4 | # prefer a user rbenv over a system wide install 5 | if [ -s "${HOME}/.rbenv/bin" ]; then 6 | rbenv_root="${HOME}/.rbenv" 7 | elif [ -s "<%= node['rbenv']['root_path'] %>" ]; then 8 | rbenv_root="<%= node['rbenv']['root_path'] %>" 9 | export RBENV_ROOT="$rbenv_root" 10 | fi 11 | 12 | if [ -n "$rbenv_root" ]; then 13 | export PATH="${rbenv_root}/bin:$PATH" 14 | eval "$(rbenv init -)" 15 | fi 16 | -------------------------------------------------------------------------------- /cookbooks/runit/.kitchen.yml: -------------------------------------------------------------------------------- 1 | driver: 2 | name: vagrant 3 | 4 | provisioner: 5 | name: chef_zero 6 | 7 | platforms: 8 | - name: centos-5.11 9 | run_list: 10 | - recipe[yum-epel] 11 | - name: centos-6.6 12 | run_list: 13 | - recipe[yum-epel] 14 | - name: centos-7.0 15 | - name: fedora-21 16 | - name: ubuntu-10.04 17 | run_list: 18 | - recipe[apt] 19 | - name: ubuntu-12.04 20 | run_list: 21 | - recipe[apt] 22 | - name: ubuntu-14.04 23 | run_list: 24 | - recipe[apt] 25 | - name: debian-7.8 26 | run_list: 27 | - recipe[apt] 28 | 29 | suites: 30 | - name: default 31 | run_list: 32 | - recipe[runit_test] 33 | attributes: {} 34 | 35 | - name: service 36 | run_list: 37 | - recipe[runit_test::service] 38 | attributes: {} 39 | -------------------------------------------------------------------------------- /cookbooks/runit/.rspec: -------------------------------------------------------------------------------- 1 | --default-path test/unit 2 | --color 3 | --format documentation 4 | -------------------------------------------------------------------------------- /cookbooks/runit/.rubocop.yml: -------------------------------------------------------------------------------- 1 | AlignParameters: 2 | Enabled: false 3 | 4 | Encoding: 5 | Enabled: false 6 | 7 | ClassLength: 8 | Enabled: false 9 | 10 | MethodLength: 11 | Enabled: false 12 | 13 | LineLength: 14 | Enabled: false 15 | 16 | # HashSyntax: 17 | # EnforcedStyle: hash_rockets 18 | 19 | Documentation: 20 | Enabled: false 21 | 22 | PerceivedComplexity: 23 | Enabled: false 24 | 25 | CyclomaticComplexity: 26 | Enabled: false 27 | 28 | Style/FileName: 29 | Enabled: false 30 | 31 | Metrics/AbcSize: 32 | Enabled: false 33 | 34 | AllCops: 35 | Exclude: 36 | - 'Guardfile' 37 | - 'tmp/**/*' 38 | - 'cookbooks/**/*' 39 | 40 | Style/GuardClause: 41 | Enabled: false 42 | 43 | # TODO: remove override for ModuleLength once RunitCookbook::Helpers has been refactored 44 | Metrics/ModuleLength: 45 | Max: 150 46 | -------------------------------------------------------------------------------- /cookbooks/runit/Berksfile.disabled: -------------------------------------------------------------------------------- 1 | source 'https://supermarket.chef.io' 2 | 3 | metadata 4 | 5 | group :integration do 6 | cookbook 'apt' 7 | cookbook 'yum-epel' 8 | end 9 | 10 | cookbook 'runit_test', path: 'test/cookbooks/runit_test' 11 | cookbook 'runit_other_test', path: 'test/cookbooks/runit_other_test' -------------------------------------------------------------------------------- /cookbooks/runit/Cheffile: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | site 'https://supermarket.chef.io/api/v1' 4 | 5 | # loosely coupled prerequisites for test-kitchen 6 | cookbook 'apt' 7 | cookbook 'yum-epel' 8 | 9 | cookbook 'runit', path: '.' 10 | cookbook 'runit_test', path: './test/cookbooks/runit_test' 11 | cookbook 'runit_other_test', path: './test/cookbooks/runit_other_test' 12 | -------------------------------------------------------------------------------- /cookbooks/runit/Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | 3 | gem 'berkshelf', '~> 3.0' 4 | gem 'chefspec', '~> 4.0' 5 | gem 'foodcritic', '~> 3.0' 6 | gem 'rubocop' 7 | 8 | group :integration do 9 | gem 'test-kitchen' 10 | gem 'kitchen-vagrant' 11 | gem 'librarian-chef' 12 | end 13 | 14 | group :release do 15 | gem 'emeril' 16 | gem 'rake' 17 | end 18 | -------------------------------------------------------------------------------- /cookbooks/runit/Rakefile: -------------------------------------------------------------------------------- 1 | require 'rubygems' 2 | require 'bundler' 3 | Bundler.setup 4 | 5 | require 'rake' 6 | require 'foodcritic' 7 | require 'rspec/core/rake_task' 8 | 9 | task default: [:spec] 10 | 11 | RSpec::Core::RakeTask.new(:spec) do |t| 12 | t.pattern = './test/unit{,/*/**}/*_spec.rb' 13 | end 14 | 15 | FoodCritic::Rake::LintTask.new do |t| 16 | t.options = { fail_tags: ['correctness'] } 17 | end 18 | 19 | begin 20 | require 'emeril/rake' 21 | rescue LoadError 22 | puts '>>>>> Emerial gem not loaded, omitting taskes' unless ENV['CI'] 23 | end 24 | -------------------------------------------------------------------------------- /cookbooks/runit/TESTING.md: -------------------------------------------------------------------------------- 1 | Testing 2 | ======= 3 | This cookbook has tests in the GitHub repository. To run the tests: 4 | 5 | git clone git://github.com/hw-cookbooks/runit.git 6 | cd runit 7 | bundle install 8 | 9 | There are two kinds of tests, unit tests and integration tests. 10 | 11 | ## Unit Tests 12 | 13 | The resource/provider code is unit tested with rspec. To run these 14 | tests, use rake: 15 | 16 | bundle exec rake spec 17 | 18 | ## Integration Tests 19 | 20 | Integration tests are setup to run under minitest-chef. They are 21 | automatically run under test kitchen. 22 | 23 | bundle exec kitchen test 24 | 25 | This tests the default recipe ("default" configuration), and various 26 | uses of the `runit_service` resource ("service" configuration). 27 | -------------------------------------------------------------------------------- /cookbooks/runit/files/default/runit.seed: -------------------------------------------------------------------------------- 1 | runit runit/signalinit boolean true 2 | -------------------------------------------------------------------------------- /cookbooks/runit/files/default/runsvdir: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sandrew/from-scratch/832d4c525c99a471b38c9c515bac9e0555e97736/cookbooks/runit/files/default/runsvdir -------------------------------------------------------------------------------- /cookbooks/runit/files/ubuntu-6.10/runsvdir: -------------------------------------------------------------------------------- 1 | start on runlevel-2 2 | start on runlevel-3 3 | start on runlevel-4 4 | start on runlevel-5 5 | stop on shutdown 6 | respawn /usr/sbin/runsvdir-start 7 | -------------------------------------------------------------------------------- /cookbooks/runit/files/ubuntu-7.04/runsvdir: -------------------------------------------------------------------------------- 1 | start on runlevel 2 2 | start on runlevel 3 3 | start on runlevel 4 4 | start on runlevel 5 5 | stop on shutdown 6 | respawn 7 | exec /usr/sbin/runsvdir-start 8 | -------------------------------------------------------------------------------- /cookbooks/runit/files/ubuntu-7.10/runsvdir: -------------------------------------------------------------------------------- 1 | start on runlevel 2 2 | start on runlevel 3 3 | start on runlevel 4 4 | start on runlevel 5 5 | stop on shutdown 6 | respawn 7 | exec /usr/sbin/runsvdir-start 8 | -------------------------------------------------------------------------------- /cookbooks/runit/files/ubuntu-8.04/runsvdir: -------------------------------------------------------------------------------- 1 | start on runlevel 2 2 | start on runlevel 3 3 | start on runlevel 4 4 | start on runlevel 5 5 | stop on shutdown 6 | respawn 7 | exec /usr/sbin/runsvdir-start 8 | -------------------------------------------------------------------------------- /cookbooks/runit/libraries/default.rb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sandrew/from-scratch/832d4c525c99a471b38c9c515bac9e0555e97736/cookbooks/runit/libraries/default.rb -------------------------------------------------------------------------------- /cookbooks/runit/templates/default/log-config.erb: -------------------------------------------------------------------------------- 1 | <% if @config.log_size -%> 2 | s<%= @config.log_size %> 3 | <% end -%> 4 | <% if @config.log_num -%> 5 | n<%= @config.log_num %> 6 | <% end -%> 7 | <% if @config.log_min -%> 8 | N<%= @config.log_min %> 9 | <% end -%> 10 | <% if @config.log_timeout -%> 11 | t<%= @config.log_timeout %> 12 | <% end -%> 13 | <% if @config.log_processor -%> 14 | !<%= @config.log_processor %> 15 | <% end -%> 16 | <% if @config.log_socket -%> 17 | u<%= @config.log_socket %> 18 | <% end -%> 19 | <% if @config.log_prefix -%> 20 | p<%= @config.log_prefix %> 21 | <% end -%> 22 | <% if @config.log_config_append -%> 23 | <%= @config.log_config_append %> 24 | <% end -%> 25 | -------------------------------------------------------------------------------- /cookbooks/runit/templates/gentoo/runit-start.sh.erb: -------------------------------------------------------------------------------- 1 | #!/sbin/runscript 2 | # Copyright 1999-2006 Gentoo Foundation 3 | # Distributed under the terms of the GNU General Public License v2 4 | # $Header: $ 5 | 6 | depend() { 7 | after net 8 | } 9 | 10 | start() { 11 | ebegin "Starting runsvdir" 12 | start-stop-daemon --start --exec /usr/bin/runsvdir \ 13 | --background --make-pidfile \ 14 | --pidfile /var/run/runsvdir.pid -- <%= node.runit.sv_dir %> 15 | eend $? 16 | } 17 | 18 | stop() { 19 | local ret1 ret2 20 | ebegin "Stopping runsvdir" 21 | start-stop-daemon --stop --oknodo --pidfile /var/run/runsvdir.pid 22 | ret1=$? 23 | eend ${ret1} 24 | 25 | ebegin "Stopping services and logging" 26 | sv shutdown -w 10 <%= node.runit.sv_dir %>/* 27 | ret2=$? 28 | eend ${ret2} 29 | 30 | return $((ret1+ret2)) 31 | } 32 | 33 | -------------------------------------------------------------------------------- /cookbooks/rvm/.foodcritic: -------------------------------------------------------------------------------- 1 | any 2 | -------------------------------------------------------------------------------- /cookbooks/rvm/.gitignore: -------------------------------------------------------------------------------- 1 | Gemfile.lock 2 | Berksfile.lock 3 | .vagrant 4 | .kitchen/ 5 | .kitchen.local.yml 6 | .bundle/ 7 | tmp/ 8 | -------------------------------------------------------------------------------- /cookbooks/rvm/.kitchen.yml: -------------------------------------------------------------------------------- 1 | --- 2 | driver_plugin: vagrant 3 | driver_config: 4 | require_chef_omnibus: true 5 | 6 | platforms: 7 | - name: ubuntu-14.04 8 | run_list: 9 | - recipe[apt] 10 | - name: ubuntu-12.04 11 | run_list: 12 | - recipe[apt] 13 | - name: ubuntu-10.04 14 | run_list: 15 | - recipe[apt] 16 | - name: debian-7.6 17 | - name: centos-6.4 18 | 19 | suites: 20 | - name: stock_system_and_user 21 | run_list: 22 | - recipe[user::data_bag] 23 | - recipe[rvm::system] 24 | - recipe[rvm::user] 25 | attributes: 26 | users: 27 | - wigglebottom 28 | rvm: 29 | user_installs: 30 | - user: wigglebottom 31 | default_ruby: 1.9.3-p484 32 | - name: rubies 33 | run_list: 34 | - recipe[java] 35 | - recipe[rvm::system] 36 | attributes: 37 | rvm: 38 | default_ruby: system 39 | rubies: 40 | - 1.9.3 41 | - version: 1.9.3-p327 42 | patch: railsexpress 43 | - version: 1.8.7 44 | rubygems_version: 1.6.0 45 | - jruby 46 | - ree 47 | - name: rbx 48 | run_list: 49 | - recipe[rvm::system] 50 | attributes: 51 | rvm: 52 | default_ruby: rbx 53 | - name: installs 54 | run_list: 55 | - recipe[user::data_bag] 56 | - recipe[rvm::user_install] 57 | attributes: 58 | users: 59 | - virgil1 60 | - virgil2 61 | rvm: 62 | installs: 63 | virgil1: 64 | installer_flags: --version 1.19.6 65 | virgil2: 66 | installer_flags: --version 1.21.20 67 | -------------------------------------------------------------------------------- /cookbooks/rvm/.travis.yml: -------------------------------------------------------------------------------- 1 | language: ruby 2 | rvm: 3 | - 2.0.0 4 | - 2.1.2 5 | - 2.2.0 6 | bundler_args: --without integration development 7 | script: 8 | - bundle exec rake unit 9 | - bundle exec rake foodcritic 10 | -------------------------------------------------------------------------------- /cookbooks/rvm/Berksfile: -------------------------------------------------------------------------------- 1 | source "https://supermarket.getchef.com" 2 | 3 | metadata 4 | 5 | group :integration do 6 | cookbook 'apt' 7 | cookbook 'yum' 8 | cookbook 'java' 9 | cookbook 'user' 10 | end 11 | -------------------------------------------------------------------------------- /cookbooks/rvm/CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Code of Conduct 2 | ## Version 0.4 3 | 4 | As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities. 5 | 6 | If any participant in this project has issues or takes exception with a contribution, they are obligated to provide constructive feedback and never resort to personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct. 7 | 8 | Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team. 9 | 10 | Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers. 11 | 12 | We promise to extend courtesy and respect to everyone involved in this project regardless of gender, gender identity, sexual orientation, ability or disability, ethnicity, religion, age, location, native language, or level of experience. 13 | -------------------------------------------------------------------------------- /cookbooks/rvm/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing to chef-rvm 2 | 3 | Source is hosted at [GitHub][repo] 4 | Report issues/Questions/Feature requests on [GitHub Issues][issues] 5 | 6 | ## Please don't 7 | 8 | * Modify the version in the metadata.rb file (we'll handle that for releases) 9 | * Modify the CHANGELOG (we'll also handle that for releases) 10 | 11 | ## Please do 12 | 13 | * Follow the guidelines in the `CODE_OF_CONDUCT.md` file 14 | * Document as much as possible, even for simple changes. This will help with understanding your patch and reasoning. 15 | * Add test coverage for changes where applicable 16 | 17 | ## Steps to contributing 18 | 19 | 1. Fork it 20 | 2. Create your feature branch (git checkout -b my-new-feature) 21 | 3. Commit your changes (git commit -am 'Added some feature') 22 | 4. Push to the branch (git push origin my-new-feature) 23 | 5. Create new Pull Request 24 | 25 | [repo]: https://github.com/fnichol/chef-rvm 26 | [issues]: https://github.com/fnichol/chef-rvm/issues 27 | -------------------------------------------------------------------------------- /cookbooks/rvm/Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | 3 | gem 'foodcritic', '~> 3.0.3' 4 | gem 'minitest' 5 | gem 'rake' 6 | gem 'rspec', '= 3.0.0' 7 | gem 'guard-rspec' 8 | 9 | # allow CI to override the version of Chef for matrix testing 10 | gem 'chef', (ENV['CHEF_VERSION'] || '>= 0.10.10') 11 | 12 | group :development do 13 | gem 'emeril' 14 | end 15 | 16 | group :integration do 17 | gem 'berkshelf', '~> 3.1.5' 18 | gem 'test-kitchen', '~> 1.2.1' 19 | gem 'kitchen-vagrant', '~> 0.15.0' 20 | end 21 | -------------------------------------------------------------------------------- /cookbooks/rvm/Guardfile: -------------------------------------------------------------------------------- 1 | guard :rspec, spec_paths: "test/unit" do 2 | watch(%r{^test/unit/.+_spec\.rb$}) 3 | watch(%r{^libraries/(.+)\.rb$}) { |m| "test/unit/libraries/#{m[1]}_spec.rb" } 4 | watch('test/unit/spec_helper.rb') { "spec" } 5 | end 6 | 7 | # guard :rspec do 8 | # watch(%r{^spec/.+_spec\.rb$}) 9 | # watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" } 10 | # watch('spec/spec_helper.rb') { "spec" } 11 | # end 12 | 13 | -------------------------------------------------------------------------------- /cookbooks/rvm/Rakefile: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env rake 2 | 3 | require 'foodcritic' 4 | require 'rspec/core/rake_task' 5 | 6 | RSpec::Core::RakeTask.new(:unit) do |t| 7 | t.pattern = "test/unit/**/*_spec.rb" 8 | end 9 | 10 | begin 11 | require 'kitchen/rake_tasks' 12 | Kitchen::RakeTasks.new 13 | rescue LoadError 14 | puts ">>>>> Kitchen gem not loaded, omitting tasks" unless ENV['CI'] 15 | end 16 | 17 | task :default => [:foodcritic, :unit] 18 | FoodCritic::Rake::LintTask.new 19 | -------------------------------------------------------------------------------- /cookbooks/rvm/attributes/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sandrew/from-scratch/832d4c525c99a471b38c9c515bac9e0555e97736/cookbooks/rvm/attributes/.gitkeep -------------------------------------------------------------------------------- /cookbooks/rvm/attributes/gem_package.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: rvm 3 | # Attributes:: gem_package 4 | # 5 | # Author:: Fletcher Nichol 6 | # 7 | # Copyright 2010, 2011, Fletcher Nichol 8 | # 9 | # Licensed under the Apache License, Version 2.0 (the "License"); 10 | # you may not use this file except in compliance with the License. 11 | # You may obtain a copy of the License at 12 | # 13 | # http://www.apache.org/licenses/LICENSE-2.0 14 | # 15 | # Unless required by applicable law or agreed to in writing, software 16 | # distributed under the License is distributed on an "AS IS" BASIS, 17 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | # See the License for the specific language governing permissions and 19 | # limitations under the License. 20 | # 21 | 22 | # rvm ruby that will be used for gem_package resources 23 | default['rvm']['gem_package']['rvm_string'] = node['rvm']['default_ruby'] 24 | -------------------------------------------------------------------------------- /cookbooks/rvm/attributes/vagrant.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: rvm 3 | # Attributes:: vagrant 4 | # 5 | # Author:: Fletcher Nichol 6 | # 7 | # Copyright 2010, 2011, Fletcher Nichol 8 | # 9 | # Licensed under the Apache License, Version 2.0 (the "License"); 10 | # you may not use this file except in compliance with the License. 11 | # You may obtain a copy of the License at 12 | # 13 | # http://www.apache.org/licenses/LICENSE-2.0 14 | # 15 | # Unless required by applicable law or agreed to in writing, software 16 | # distributed under the License is distributed on an "AS IS" BASIS, 17 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | # See the License for the specific language governing permissions and 19 | # limitations under the License. 20 | # 21 | 22 | default['rvm']['vagrant']['system_chef_client'] = "/opt/vagrant_ruby/bin/chef-client" 23 | default['rvm']['vagrant']['system_chef_solo'] = "/opt/vagrant_ruby/bin/chef-solo" 24 | -------------------------------------------------------------------------------- /cookbooks/rvm/libraries/chef_rvm_set_helpers.rb: -------------------------------------------------------------------------------- 1 | class Chef 2 | module RVM 3 | module SetHelpers 4 | def rvm_do(user = nil) 5 | # Use Gem's version comparing code to compare the two strings 6 | rvm_version = VersionCache.fetch_version(user).gsub(/(-|_|#)/, '.') 7 | if Gem::Version.new(rvm_version) < Gem::Version.new("1.8.6") 8 | "exec" 9 | else 10 | "do" 11 | end 12 | end 13 | 14 | end 15 | end 16 | end 17 | -------------------------------------------------------------------------------- /cookbooks/rvm/libraries/chef_rvm_version_helpers.rb: -------------------------------------------------------------------------------- 1 | class Chef 2 | module RVM 3 | module ShellHelpers 4 | # stub to satisfy VersionCache (library load order not guarenteed) 5 | end 6 | 7 | module VersionHelpers 8 | def rvm_version(user = nil) 9 | VersionCache.fetch_version(user) 10 | end 11 | end 12 | 13 | class VersionCache 14 | class << self 15 | include Chef::Mixin::ShellOut 16 | include Chef::RVM::ShellHelpers 17 | end 18 | 19 | def self.fetch_version(user = nil) 20 | @@versions ||= Hash.new 21 | rvm_install = user || "system" 22 | @@versions[rvm_install] ||= rvm_version(user) 23 | end 24 | 25 | def self.rvm_version(user = nil) 26 | cmd = "rvm version | cut -d ' ' -f 2" 27 | 28 | if user 29 | user_dir = Etc.getpwnam(user).dir 30 | environment = { 'USER' => user, 'HOME' => user_dir } 31 | else 32 | user_dir = nil 33 | environment = nil 34 | end 35 | 36 | version = shell_out!( 37 | rvm_wrap_cmd(cmd, user_dir), :env => environment).stdout.strip 38 | 39 | Chef::Log.debug "RVM version = #{version} (#{user || 'system'})" 40 | 41 | version 42 | end 43 | end 44 | end 45 | end 46 | -------------------------------------------------------------------------------- /cookbooks/rvm/libraries/gem_package_monkeypatch.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: rvm 3 | # Library: gem_package resource monkey patch 4 | # 5 | # Author:: Fletcher Nichol 6 | # 7 | # Copyright 2011, Fletcher Nichol 8 | # 9 | # Licensed under the Apache License, Version 2.0 (the "License"); 10 | # you may not use this file except in compliance with the License. 11 | # You may obtain a copy of the License at 12 | # 13 | # http://www.apache.org/licenses/LICENSE-2.0 14 | # 15 | # Unless required by applicable law or agreed to in writing, software 16 | # distributed under the License is distributed on an "AS IS" BASIS, 17 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | # See the License for the specific language governing permissions and 19 | # limitations under the License. 20 | # 21 | 22 | ## 23 | # Patch Chef::Resource::GemPackage resource to use the RVMRubygems provider. 24 | # This has potentially dangerous side effects and should be considered 25 | # experimental. You have been warned. 26 | def patch_gem_package 27 | ::Chef::Resource::GemPackage.class_eval do 28 | def initialize(name, run_context=nil) 29 | super 30 | @resource_name = :gem_package 31 | @provider = Chef::Provider::Package::RVMRubygems 32 | end 33 | end 34 | end 35 | -------------------------------------------------------------------------------- /cookbooks/rvm/recipes/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sandrew/from-scratch/832d4c525c99a471b38c9c515bac9e0555e97736/cookbooks/rvm/recipes/.gitkeep -------------------------------------------------------------------------------- /cookbooks/rvm/recipes/default.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: rvm 3 | # Recipe:: default 4 | # 5 | # Copyright 2010, 2011, Fletcher Nichol 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # 19 | 20 | # install rvm api gem during chef compile phase 21 | chef_gem 'rvm' do 22 | action :install 23 | version '>= 1.11.3.6' 24 | end 25 | require 'rvm' 26 | 27 | create_rvm_shell_chef_wrapper 28 | create_rvm_chef_user_environment 29 | 30 | class Chef::Resource 31 | # mix in #rvm_cmd_wrap helper into resources 32 | include Chef::RVM::ShellHelpers 33 | end 34 | 35 | class Chef::Recipe 36 | # mix in recipe helpers 37 | include Chef::RVM::ShellHelpers 38 | include Chef::RVM::RecipeHelpers 39 | include Chef::RVM::StringHelpers 40 | end 41 | -------------------------------------------------------------------------------- /cookbooks/rvm/recipes/gem_package.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: rvm 3 | # Recipe:: gem_package 4 | # 5 | # Copyright 2011, Fletcher Nichol 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # 19 | 20 | node_val = node['rvm']['gem_package']['rvm_string'] 21 | case node_val 22 | when String 23 | rvm_descriptor = node_val + " RVM Ruby" 24 | when Array 25 | last = node_val.pop 26 | rvm_descriptor = [ node_val.join(', '), last ].join(' & ') + " RVM Rubies" 27 | end 28 | 29 | patch_gem_package 30 | 31 | ::Chef::Log.info "gem_package resource has been patched to use provider " << 32 | "Chef::Provider::Package::RVMRubygems and will install gems to " << 33 | "the #{rvm_descriptor}." 34 | -------------------------------------------------------------------------------- /cookbooks/rvm/recipes/system.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: rvm 3 | # Recipe:: system 4 | # 5 | # Copyright 2010, 2011 Fletcher Nichol 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # 19 | 20 | include_recipe "rvm::system_install" 21 | 22 | perform_install_rubies = node['rvm']['install_rubies'] == true || 23 | node['rvm']['install_rubies'] == "true" 24 | 25 | if perform_install_rubies 26 | install_rubies :rubies => node['rvm']['rubies'], 27 | :default_ruby => node['rvm']['default_ruby'], 28 | :global_gems => node['rvm']['global_gems'], 29 | :gems => node['rvm']['gems'] 30 | end 31 | 32 | # add users to rvm group 33 | group 'rvm' do 34 | members node['rvm']['group_users'] 35 | 36 | only_if { node['rvm']['group_users'].any? } 37 | end 38 | -------------------------------------------------------------------------------- /cookbooks/rvm/recipes/vagrant.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: rvm 3 | # Recipe:: vagrant 4 | # 5 | # Copyright 2011, Fletcher Nichol 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # 19 | 20 | template "/usr/local/bin/chef-client" do 21 | source "vagrant-chef-client-wrapper.erb" 22 | owner "root" 23 | group "root" 24 | mode "0755" 25 | end 26 | 27 | template "/usr/local/bin/chef-solo" do 28 | source "vagrant-chef-solo-wrapper.erb" 29 | owner "root" 30 | group "root" 31 | mode "0755" 32 | end 33 | 34 | group "rvm" do 35 | members ["vagrant"] 36 | append true 37 | end 38 | -------------------------------------------------------------------------------- /cookbooks/rvm/resources/default_ruby.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: rvm 3 | # Resource:: default_ruby 4 | # 5 | # Author:: Fletcher Nichol 6 | # 7 | # Copyright 2011, Fletcher Nichol 8 | # 9 | # Licensed under the Apache License, Version 2.0 (the "License"); 10 | # you may not use this file except in compliance with the License. 11 | # You may obtain a copy of the License at 12 | # 13 | # http://www.apache.org/licenses/LICENSE-2.0 14 | # 15 | # Unless required by applicable law or agreed to in writing, software 16 | # distributed under the License is distributed on an "AS IS" BASIS, 17 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | # See the License for the specific language governing permissions and 19 | # limitations under the License. 20 | # 21 | 22 | actions :create 23 | 24 | attribute :ruby_string, :kind_of => String, :name_attribute => true 25 | attribute :user, :kind_of => String 26 | attribute :patch, :kind_of => String 27 | 28 | def initialize(*args) 29 | super 30 | @action = :create 31 | end 32 | -------------------------------------------------------------------------------- /cookbooks/rvm/resources/environment.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: rvm 3 | # Resource:: environment 4 | # 5 | # Author:: Fletcher Nichol 6 | # 7 | # Copyright 2011, Fletcher Nichol 8 | # 9 | # Licensed under the Apache License, Version 2.0 (the "License"); 10 | # you may not use this file except in compliance with the License. 11 | # You may obtain a copy of the License at 12 | # 13 | # http://www.apache.org/licenses/LICENSE-2.0 14 | # 15 | # Unless required by applicable law or agreed to in writing, software 16 | # distributed under the License is distributed on an "AS IS" BASIS, 17 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | # See the License for the specific language governing permissions and 19 | # limitations under the License. 20 | # 21 | 22 | actions :create 23 | 24 | attribute :ruby_string, :kind_of => String, :name_attribute => true 25 | attribute :user, :kind_of => String 26 | attribute :patch, :kind_of => String 27 | 28 | def initialize(*args) 29 | super 30 | @action = :create 31 | end 32 | -------------------------------------------------------------------------------- /cookbooks/rvm/resources/gem.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: rvm 3 | # Resource:: gem 4 | # 5 | # Author:: Fletcher Nichol 6 | # 7 | # Copyright 2011, Fletcher Nichol 8 | # 9 | # Licensed under the Apache License, Version 2.0 (the "License"); 10 | # you may not use this file except in compliance with the License. 11 | # You may obtain a copy of the License at 12 | # 13 | # http://www.apache.org/licenses/LICENSE-2.0 14 | # 15 | # Unless required by applicable law or agreed to in writing, software 16 | # distributed under the License is distributed on an "AS IS" BASIS, 17 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | # See the License for the specific language governing permissions and 19 | # limitations under the License. 20 | # 21 | 22 | actions :install, :upgrade, :remove, :purge 23 | 24 | attribute :package_name, :kind_of => String, :name_attribute => true 25 | attribute :version, :kind_of => String 26 | attribute :ruby_string, :kind_of => String, :default => "default" 27 | attribute :response_file, :kind_of => String 28 | attribute :source, :kind_of => String 29 | attribute :options, :kind_of => Hash 30 | attribute :gem_binary, :kind_of => String 31 | attribute :user, :kind_of => String 32 | 33 | def initialize(*args) 34 | super 35 | @action = :install 36 | @provider = Chef::Provider::Package::RVMRubygems 37 | end 38 | -------------------------------------------------------------------------------- /cookbooks/rvm/resources/gemset.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: rvm 3 | # Resource:: gemset 4 | # 5 | # Author:: Fletcher Nichol 6 | # 7 | # Copyright 2011, Fletcher Nichol 8 | # 9 | # Licensed under the Apache License, Version 2.0 (the "License"); 10 | # you may not use this file except in compliance with the License. 11 | # You may obtain a copy of the License at 12 | # 13 | # http://www.apache.org/licenses/LICENSE-2.0 14 | # 15 | # Unless required by applicable law or agreed to in writing, software 16 | # distributed under the License is distributed on an "AS IS" BASIS, 17 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | # See the License for the specific language governing permissions and 19 | # limitations under the License. 20 | # 21 | 22 | actions :create, :delete, :empty, :update 23 | 24 | attribute :gemset, :kind_of => String, :name_attribute => true 25 | attribute :ruby_string, :kind_of => String, :regex => /^[^@]+$/ 26 | attribute :user, :kind_of => String 27 | attribute :patch, :kind_of => String 28 | 29 | def initialize(*args) 30 | super 31 | @action = :create 32 | end 33 | -------------------------------------------------------------------------------- /cookbooks/rvm/resources/global_gem.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: rvm 3 | # Resource:: global_gem 4 | # 5 | # Author:: Fletcher Nichol 6 | # 7 | # Copyright 2011, Fletcher Nichol 8 | # 9 | # Licensed under the Apache License, Version 2.0 (the "License"); 10 | # you may not use this file except in compliance with the License. 11 | # You may obtain a copy of the License at 12 | # 13 | # http://www.apache.org/licenses/LICENSE-2.0 14 | # 15 | # Unless required by applicable law or agreed to in writing, software 16 | # distributed under the License is distributed on an "AS IS" BASIS, 17 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | # See the License for the specific language governing permissions and 19 | # limitations under the License. 20 | # 21 | 22 | actions :install, :upgrade, :remove, :purge 23 | 24 | attribute :package_name, :kind_of => String, :name_attribute => true 25 | attribute :version, :kind_of => String 26 | attribute :source, :kind_of => String 27 | attribute :options, :kind_of => Hash 28 | attribute :gem_binary, :kind_of => String 29 | attribute :user, :kind_of => String 30 | 31 | def initialize(*args) 32 | super 33 | @action = :install 34 | end 35 | -------------------------------------------------------------------------------- /cookbooks/rvm/resources/ruby.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: rvm 3 | # Resource:: ruby 4 | # 5 | # Author:: Fletcher Nichol 6 | # 7 | # Copyright 2011, Fletcher Nichol 8 | # 9 | # Licensed under the Apache License, Version 2.0 (the "License"); 10 | # you may not use this file except in compliance with the License. 11 | # You may obtain a copy of the License at 12 | # 13 | # http://www.apache.org/licenses/LICENSE-2.0 14 | # 15 | # Unless required by applicable law or agreed to in writing, software 16 | # distributed under the License is distributed on an "AS IS" BASIS, 17 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | # See the License for the specific language governing permissions and 19 | # limitations under the License. 20 | # 21 | 22 | actions :install, :uninstall, :remove 23 | 24 | attribute :ruby_string, :kind_of => String, :name_attribute => true 25 | attribute :user, :kind_of => String 26 | attribute :patch, :kind_of => String 27 | attribute :rubygems_version, :kind_of => String 28 | 29 | def initialize(*args) 30 | super 31 | @action = :install 32 | end 33 | -------------------------------------------------------------------------------- /cookbooks/rvm/resources/wrapper.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: rvm 3 | # Resource:: wrapper 4 | # 5 | # Author:: Fletcher Nichol 6 | # 7 | # Copyright 2011, Fletcher Nichol 8 | # 9 | # Licensed under the Apache License, Version 2.0 (the "License"); 10 | # you may not use this file except in compliance with the License. 11 | # You may obtain a copy of the License at 12 | # 13 | # http://www.apache.org/licenses/LICENSE-2.0 14 | # 15 | # Unless required by applicable law or agreed to in writing, software 16 | # distributed under the License is distributed on an "AS IS" BASIS, 17 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | # See the License for the specific language governing permissions and 19 | # limitations under the License. 20 | # 21 | 22 | actions :create 23 | 24 | attribute :prefix, :kind_of => String, :name_attribute => true 25 | attribute :ruby_string, :kind_of => String 26 | attribute :binary, :kind_of => String 27 | attribute :binaries, :kind_of => Array 28 | attribute :user, :kind_of => String 29 | attribute :patch, :kind_of => String 30 | 31 | def initialize(*args) 32 | super 33 | @action = :create 34 | end 35 | -------------------------------------------------------------------------------- /cookbooks/rvm/templates/default/rvmrc.erb: -------------------------------------------------------------------------------- 1 | # rvm configuration 2 | # 3 | # Generated by Chef for <%= @user %>@<%= node['fqdn'] %> 4 | # Local modifications will be overwritten. 5 | # 6 | <% if @user == "root" -%> 7 | umask u=rwx,g=rwx,o=rx 8 | <% end -%> 9 | export rvm_path="<%= @rvm_path %>" 10 | 11 | <% @rvmrc_env.each_pair do |k,v| -%> 12 | <% next unless v -%> 13 | export <%= k %>="<%= v %>" 14 | <% end -%> 15 | -------------------------------------------------------------------------------- /cookbooks/rvm/templates/default/vagrant-chef-client-wrapper.erb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # RVM-aware chef-client wrapper 4 | # 5 | # Generated by Chef for <%= node['fqdn'] %> 6 | # Local modifications will be overridden 7 | 8 | if [[ -d "<%= node['rvm']['root_path'] %>" ]] ; then 9 | export PATH="/bin:<%= node['rvm']['root_path'] %>:$PATH" 10 | rvm_path='<%= node['rvm']['root_path'] %>' 11 | export rvm_path 12 | unset RUBY_VERSION 13 | unset GEM_HOME 14 | unset GEM_PATH 15 | unset MY_RUBY_HOME 16 | unset IRBRC 17 | rvm_ruby_string='system' 18 | export rvm_ruby_string 19 | unset rvm_gemset_name 20 | unset MAGLEV_HOME 21 | fi 22 | 23 | exec <%= node['rvm']['vagrant']['system_chef_client'] %> "$@" 24 | -------------------------------------------------------------------------------- /cookbooks/rvm/templates/default/vagrant-chef-solo-wrapper.erb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # RVM-aware chef-solo wrapper 4 | # 5 | # Generated by Chef for <%= node['fqdn'] %> 6 | # Local modifications will be overridden 7 | 8 | if [[ -d "<%= node['rvm']['root_path'] %>" ]] ; then 9 | export PATH="/bin:<%= node['rvm']['root_path'] %>:$PATH" 10 | rvm_path='<%= node['rvm']['root_path'] %>' 11 | export rvm_path 12 | unset RUBY_VERSION 13 | unset GEM_HOME 14 | unset GEM_PATH 15 | unset MY_RUBY_HOME 16 | unset IRBRC 17 | rvm_ruby_string='system' 18 | export rvm_ruby_string 19 | unset rvm_gemset_name 20 | unset MAGLEV_HOME 21 | fi 22 | 23 | exec <%= node['rvm']['vagrant']['system_chef_solo'] %> "$@" 24 | -------------------------------------------------------------------------------- /cookbooks/rvm/test/integration/data_bags/users/virgil1.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "virgil1" 3 | } 4 | 5 | -------------------------------------------------------------------------------- /cookbooks/rvm/test/integration/data_bags/users/virgil2.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "virgil2" 3 | } 4 | 5 | -------------------------------------------------------------------------------- /cookbooks/rvm/test/integration/data_bags/users/wigglebottom.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "wigglebottom" 3 | } 4 | -------------------------------------------------------------------------------- /cookbooks/rvm/test/integration/installs/bats/version_pinning.bats: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bats 2 | 3 | @test "virgil1 user has rvm-1.19.6" { 4 | run sudo -u virgil1 -i rvm version 5 | [ $status -eq 0 ] 6 | [ "$(echo $output | awk '{print $2}')" = "1.19.6" ] 7 | } 8 | 9 | @test "virgil2 user has rvm-1.21.20" { 10 | run sudo -u virgil2 -i rvm version 11 | [ $status -eq 0 ] 12 | [ "$(echo $output | awk '{print $2}')" = "1.21.20" ] 13 | } 14 | -------------------------------------------------------------------------------- /cookbooks/rvm/test/integration/rubies/bats/_common.bash: -------------------------------------------------------------------------------- 1 | setup() { 2 | source /etc/profile.d/rvm.sh 3 | } 4 | 5 | run_nokogiri_openssl_test() { 6 | local rubie="$1" 7 | local https_url="https://google.com" 8 | local requires="require 'nokogiri';" 9 | local script="$requires puts Nokogiri::HTML(open('$https_url')).css('input')" 10 | 11 | run rvm $rubie do gem install nokogiri --no-ri --no-rdoc 12 | [ "$status" -eq 0 ] 13 | 14 | run rvm $rubie do ruby -rrubygems -ropen-uri -e "$script" 15 | [ "$status" -eq 0 ] 16 | } 17 | -------------------------------------------------------------------------------- /cookbooks/rvm/test/integration/rubies/bats/verify_1.9.3.bats: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bats 2 | 3 | rubie="1.9.3" 4 | 5 | load _common 6 | 7 | @test "RVM $rubie can use nokogiri with openssl" { 8 | run_nokogiri_openssl_test $rubie 9 | } 10 | -------------------------------------------------------------------------------- /cookbooks/rvm/test/integration/rubies/bats/verify_jruby.bats: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bats 2 | 3 | rubie="jruby" 4 | 5 | load _common 6 | 7 | @test "RVM $rubie can use nokogiri with openssl" { 8 | run rvm $rubie do gem install jruby-openssl --no-ri --no-rdoc 9 | [ $status -eq 0 ] 10 | 11 | run_nokogiri_openssl_test $rubie 12 | } 13 | -------------------------------------------------------------------------------- /cookbooks/rvm/test/integration/rubies/bats/verify_patch_support.bats: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bats 2 | 3 | rubie="1.9.3-p327-railsexpress" 4 | 5 | load _common 6 | 7 | @test "RVM $rubie can use nokogiri with openssl" { 8 | run_nokogiri_openssl_test $rubie 9 | } 10 | 11 | # For more details, please see: 12 | # https://github.com/fnichol/chef-rvm/pull/137#issuecomment-12258247 13 | @test "RVM $rubie can use patched functionality" { 14 | script="puts Thread.current.thread_variable_set :foo, 'bar'" 15 | 16 | run rvm $rubie do ruby -e "$script" 17 | [ "$status" -eq 0 ] 18 | [ "$output" = "bar" ] 19 | } 20 | -------------------------------------------------------------------------------- /cookbooks/rvm/test/integration/rubies/bats/verify_ree.bats: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bats 2 | 3 | export rubie="ree" 4 | 5 | load _common 6 | 7 | @test "RVM $rubie can use nokogiri with openssl" { 8 | run_nokogiri_openssl_test $rubie 9 | } 10 | -------------------------------------------------------------------------------- /cookbooks/rvm/test/integration/rubies/bats/verify_rubygems_version_support.bats: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bats 2 | 3 | rubie="1.8.7" 4 | 5 | load _common 6 | 7 | @test "RVM $rubie can use nokogiri with openssl" { 8 | run_nokogiri_openssl_test $rubie 9 | } 10 | 11 | @test "Installs RubyGems 1.6.0 in RVM $rubie" { 12 | run rvm 1.8.7 do gem --version 13 | [ "$status" -eq 0 ] 14 | [ "$output" = "1.6.0" ] 15 | } 16 | -------------------------------------------------------------------------------- /cookbooks/rvm/test/integration/stock_system_and_user/bats/system.bats: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bats 2 | 3 | default_ruby="ruby-1.9.3-p484" 4 | https_url="https://google.com" 5 | 6 | setup() { 7 | source /etc/profile.d/rvm.sh 8 | } 9 | 10 | @test "creates system install RVM directory" { 11 | [ -d "/usr/local/rvm" ] 12 | } 13 | 14 | @test "sources into environment" { 15 | [ "$(type rvm | head -1)" = "rvm is a function" ] 16 | } 17 | 18 | @test "installs $default_ruby" { 19 | run sudo -u wigglebottom -i rvm list strings 20 | [ "$status" -eq 0 ] 21 | [ "$output" = "$default_ruby" ] 22 | } 23 | 24 | @test "sets $default_ruby as the default" { 25 | run sudo -u wigglebottom -i rvm list default string 26 | [ "$status" -eq 0 ] 27 | [ "${lines[0]}" = "$default_ruby" ] 28 | } 29 | 30 | @test "default Ruby can use openssl from stdlib" { 31 | expr="puts OpenSSL::PKey::RSA.new(32).to_pem" 32 | run sudo -u wigglebottom -i rvm $default_ruby do ruby -ropenssl -e "$expr" 33 | [ "$status" -eq 0 ] 34 | } 35 | 36 | @test "default Ruby can install nokogiri gem" { 37 | run sudo -u wigglebottom -i rvm $default_ruby do gem install nokogiri --no-ri --no-rdoc 38 | [ "$status" -eq 0 ] 39 | } 40 | 41 | @test "default Ruby can use nokogiri with openssl" { 42 | expr="puts Nokogiri::HTML(open('$https_url')).css('input')" 43 | run sudo -u wigglebottom -i rvm $default_ruby do ruby -ropen-uri -rnokogiri -e "$expr" 44 | [ "$status" -eq 0 ] 45 | } 46 | -------------------------------------------------------------------------------- /cookbooks/rvm/test/unit/spec_helper.rb: -------------------------------------------------------------------------------- 1 | require "chef/platform" 2 | require "chef/run_context" 3 | require "chef/resource" 4 | require "chef/event_dispatch/base" 5 | require "chef/event_dispatch/dispatcher" 6 | 7 | $:.unshift(File.join(File.dirname(__FILE__), "..", "..", "libraries")) 8 | 9 | module Helpers 10 | 11 | def events 12 | @events ||= Chef::EventDispatch::Dispatcher.new 13 | end 14 | 15 | def run_context 16 | @run_context ||= Chef::RunContext.new(node, {}, events) 17 | end 18 | end 19 | 20 | RSpec.configure do |config| 21 | config.include Helpers 22 | config.formatter = :documentation 23 | end 24 | -------------------------------------------------------------------------------- /cookbooks/scratchify/Berksfile: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | #^syntax detection 3 | 4 | source "https://supermarket.chef.io" 5 | 6 | metadata 7 | 8 | cookbook 'user' 9 | cookbook 'rvm', github: 'martinisoft/chef-rvm' 10 | cookbook 'postgresql', github: 'sandrew/postgresql', branch: 'develop' 11 | cookbook 'nginx' 12 | cookbook 'ruby_rbenv' 13 | -------------------------------------------------------------------------------- /cookbooks/scratchify/Berksfile.lock: -------------------------------------------------------------------------------- 1 | DEPENDENCIES 2 | nginx 3 | postgresql 4 | git: git://github.com/sandrew/postgresql.git 5 | revision: a1f3ce3e2e22515bc175011a3e3faa0af98dd8db 6 | branch: develop 7 | ruby_rbenv 8 | rvm 9 | git: git://github.com/martinisoft/chef-rvm.git 10 | revision: 08ec265f277e112a5a2e4b201bd32ddfe1bb968c 11 | scratchify 12 | path: . 13 | metadata: true 14 | user 15 | 16 | GRAPH 17 | apt (2.9.2) 18 | bluepill (2.4.0) 19 | rsyslog (>= 0.0.0) 20 | build-essential (2.2.4) 21 | chef-sugar (3.1.1) 22 | chef_gem (0.1.0) 23 | java (1.35.0) 24 | nginx (2.7.6) 25 | apt (~> 2.2) 26 | bluepill (~> 2.3) 27 | build-essential (~> 2.0) 28 | ohai (~> 2.0) 29 | runit (~> 1.2) 30 | yum-epel (~> 0.3) 31 | ohai (2.0.3) 32 | openssl (4.4.0) 33 | chef-sugar (>= 3.1.1) 34 | packagecloud (0.1.0) 35 | postgresql (3.4.21) 36 | apt (>= 1.9.0) 37 | build-essential (>= 0.0.0) 38 | openssl (~> 4.0) 39 | rsyslog (2.2.0) 40 | ruby_build (0.8.0) 41 | ruby_rbenv (1.0.1) 42 | java (> 1.4.0) 43 | ruby_build (>= 0.0.0) 44 | runit (1.7.4) 45 | packagecloud (>= 0.0.0) 46 | rvm (0.10.1) 47 | chef_gem (>= 0.0.0) 48 | java (>= 0.0.0) 49 | scratchify (0.1.0) 50 | nginx (>= 0.0.0) 51 | postgresql (>= 0.0.0) 52 | ruby_rbenv (>= 0.0.0) 53 | rvm (>= 0.0.0) 54 | user (>= 0.0.0) 55 | user (0.4.2) 56 | yum (3.8.1) 57 | yum-epel (0.6.4) 58 | yum (~> 3.2) 59 | -------------------------------------------------------------------------------- /cookbooks/scratchify/LICENSE.txt: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Andrew Shaydurov 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /cookbooks/scratchify/Thorfile: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require 'bundler' 4 | require 'bundler/setup' 5 | require 'berkshelf/thor' 6 | -------------------------------------------------------------------------------- /cookbooks/scratchify/from-scratch.gemspec: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | lib = File.expand_path('../lib', __FILE__) 3 | $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) 4 | require 'from-scratch/version' 5 | 6 | Gem::Specification.new do |spec| 7 | spec.name = "from-scratch" 8 | spec.version = FromScratch::VERSION 9 | spec.authors = ["Andrew Shaydurov"] 10 | spec.email = ["gearhead@it-primorye.ru"] 11 | 12 | spec.summary = "Your last command to bootstrap the whole Rails app" 13 | spec.description = "Makes all the stuff usually you or your DevOps does before first deploy" 14 | spec.homepage = "https://github.com/sandrew/from-scratch" 15 | spec.license = "MIT" 16 | 17 | spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) } 18 | spec.executables = %w(scratchify) 19 | spec.require_paths = %w(lib) 20 | 21 | spec.add_development_dependency "bundler", "~> 1.10" 22 | spec.add_development_dependency "rake", "~> 10.0" 23 | spec.add_development_dependency 'rspec', "~> 3.3" 24 | spec.add_development_dependency 'rspec-its', "~> 1.2" 25 | spec.add_development_dependency 'pry', "~> 0.10" 26 | 27 | spec.add_dependency 'knife-solo' 28 | spec.add_dependency 'knife-solo_data_bag' 29 | spec.add_dependency 'chef', "~> 12.5" 30 | spec.add_dependency 'berkshelf' 31 | 32 | 33 | spec.required_ruby_version = '>= 1.9.3' 34 | end 35 | -------------------------------------------------------------------------------- /cookbooks/scratchify/metadata.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "scratchify", 3 | "description": "Cookbook for FromScratch gem", 4 | "long_description": "", 5 | "maintainer": "Andrew Shaydurov", 6 | "maintainer_email": "gearhead@it-primorye.ru", 7 | "license": "MIT", 8 | "platforms": { 9 | "ubuntu": ">= 0.0.0", 10 | "debian": ">= 0.0.0" 11 | }, 12 | "dependencies": { 13 | "user": ">= 0.0.0", 14 | "rvm": ">= 0.0.0", 15 | "postgresql": ">= 0.0.0", 16 | "nginx": ">= 0.0.0", 17 | "ruby_rbenv": ">= 0.0.0" 18 | }, 19 | "recommendations": { 20 | }, 21 | "suggestions": { 22 | }, 23 | "conflicting": { 24 | }, 25 | "providing": { 26 | }, 27 | "replacing": { 28 | }, 29 | "attributes": { 30 | }, 31 | "groupings": { 32 | }, 33 | "recipes": { 34 | "scratchify": "sets up some user directories and files", 35 | "scratchify::pre_rvm": "workaround for RVM recipe bug", 36 | "scratchify::nginx_site": "loads nginx site config" 37 | }, 38 | "version": "0.1.0", 39 | "source_url": "", 40 | "issues_url": "" 41 | } -------------------------------------------------------------------------------- /cookbooks/scratchify/recipes/default.rb: -------------------------------------------------------------------------------- 1 | ["#{node['scratchify']['app_name']}", "#{node['scratchify']['app_name']}/shared", "#{node['scratchify']['app_name']}/shared/config", "#{node['scratchify']['app_name']}/shared/log"].each do |path| 2 | directory "/home/deploy/#{path}" do 3 | owner 'deploy' 4 | group 'deploy' 5 | mode '0755' 6 | recursive true 7 | end 8 | end 9 | 10 | directory "/home/deploy/#{node['scratchify']['app_name']}/shared/log" do 11 | owner 'deploy' 12 | group 'deploy' 13 | mode '0755' 14 | recursive true 15 | end 16 | 17 | template "/home/deploy/#{node['scratchify']['app_name']}/shared/config/database.yml" do 18 | source 'database.yml.erb' 19 | owner 'deploy' 20 | group 'deploy' 21 | mode '0600' 22 | end 23 | 24 | template "/home/deploy/#{node['scratchify']['app_name']}/shared/config/secrets.yml" do 25 | source 'secrets.yml.erb' 26 | owner 'deploy' 27 | group 'deploy' 28 | mode '0600' 29 | end 30 | 31 | # required for json gem 32 | if node['platform_family'] == 'debian' 33 | package 'libgmp-dev' 34 | end 35 | -------------------------------------------------------------------------------- /cookbooks/scratchify/recipes/nginx_site.rb: -------------------------------------------------------------------------------- 1 | nginx_site node['scratchify']['app_name'] do 2 | enable true 3 | template 'nginx.erb' 4 | end 5 | -------------------------------------------------------------------------------- /cookbooks/scratchify/recipes/pre_rvm.rb: -------------------------------------------------------------------------------- 1 | execute 'download RVM GPG key' do 2 | user "deploy" 3 | command "gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3" 4 | environment 'HOME' => '/home/deploy' 5 | end 6 | -------------------------------------------------------------------------------- /cookbooks/scratchify/templates/database.yml.erb: -------------------------------------------------------------------------------- 1 | production: 2 | adapter: postgresql 3 | database: '<%= node['postgresql']['databases'][0]['name'] %>' 4 | username: '<%= node['postgresql']['users'][0]['username'] %>' 5 | password: '<%= node['postgresql']['users'][0]['password'] %>' 6 | encoding: unicode 7 | host: localhost 8 | -------------------------------------------------------------------------------- /cookbooks/scratchify/templates/nginx.erb: -------------------------------------------------------------------------------- 1 | upstream <%= node['scratchify']['app_name'] %>_upstream { 2 | server unix:/home/deploy/<%= node['scratchify']['app_name'] %>/shared/tmp/sockets/application.sock fail_timeout=0; 3 | } 4 | 5 | server { 6 | listen 80 default_server; 7 | server_name localhost; 8 | 9 | client_max_body_size 10M; 10 | keepalive_timeout 10; 11 | 12 | root /home/deploy/<%= node['scratchify']['app_name'] %>/current/public; 13 | error_page 500 503 502 504 /500.html; 14 | try_files $uri/index.html $uri @<%= node['scratchify']['app_name'] %>_location; 15 | 16 | location @<%= node['scratchify']['app_name'] %>_location { 17 | proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 18 | proxy_set_header Host $http_host; 19 | proxy_redirect off; 20 | 21 | proxy_pass http://<%= node['scratchify']['app_name'] %>_upstream; 22 | access_log /home/deploy/<%= node['scratchify']['app_name'] %>/shared/log/nginx.access.log; 23 | error_log /home/deploy/<%= node['scratchify']['app_name'] %>/shared/log/nginx.error.log; 24 | } 25 | 26 | location ^~ /assets/ { 27 | gzip_static on; 28 | expires max; 29 | add_header Cache-Control public; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /cookbooks/scratchify/templates/secrets.yml.erb: -------------------------------------------------------------------------------- 1 | production: 2 | secret_key_base: '<%= SecureRandom.hex(64) %>' 3 | -------------------------------------------------------------------------------- /cookbooks/scratchify/templates/user.json.erb: -------------------------------------------------------------------------------- 1 | { 2 | "id": "deploy", 3 | "name": "deploy", 4 | "groups": ["deploy"], 5 | "ssh_keys": ["<%= @options.ssh_pub_key %>"] 6 | } 7 | -------------------------------------------------------------------------------- /cookbooks/user/.gitignore: -------------------------------------------------------------------------------- 1 | Gemfile.lock 2 | Berksfile.lock 3 | tmp/ 4 | .kitchen/ 5 | .kitchen.local.yml 6 | -------------------------------------------------------------------------------- /cookbooks/user/.kitchen.yml: -------------------------------------------------------------------------------- 1 | --- 2 | driver_plugin: vagrant 3 | driver_config: 4 | require_chef_omnibus: true 5 | 6 | platforms: 7 | - name: ubuntu-12.04 8 | driver_config: 9 | box: opscode-ubuntu-12.04 10 | box_url: https://opscode-vm.s3.amazonaws.com/vagrant/opscode_ubuntu-12.04_provisionerless.box 11 | - name: ubuntu-10.04 12 | driver_config: 13 | box: opscode-ubuntu-10.04 14 | box_url: https://opscode-vm.s3.amazonaws.com/vagrant/opscode_ubuntu-10.04_provisionerless.box 15 | - name: centos-6.4 16 | driver_config: 17 | box: opscode-centos-6.4 18 | box_url: https://opscode-vm.s3.amazonaws.com/vagrant/opscode_centos-6.4_provisionerless.box 19 | - name: centos-5.9 20 | driver_config: 21 | box: opscode-centos-5.9 22 | box_url: https://opscode-vm.s3.amazonaws.com/vagrant/opscode_centos-5.9_provisionerless.box 23 | 24 | suites: 25 | - name: lwrp 26 | run_list: 27 | - recipe[user_test::lwrp] 28 | attributes: {} 29 | - name: data_bag 30 | run_list: 31 | - recipe[user::data_bag] 32 | attributes: 33 | users: 34 | - hsolo 35 | - lando 36 | - luke.skywalker 37 | - name: data_bag_no_users 38 | run_list: 39 | - recipe[user::data_bag] 40 | attributes: {} 41 | - name: home_dir_mode 42 | run_list: 43 | - recipe[user_test::lwrp] 44 | attributes: 45 | user: 46 | home_dir_mode: "0700" 47 | -------------------------------------------------------------------------------- /cookbooks/user/.travis.yml: -------------------------------------------------------------------------------- 1 | language: ruby 2 | rvm: 3 | - 1.9.3 4 | bundler_args: --without integration 5 | -------------------------------------------------------------------------------- /cookbooks/user/Berksfile: -------------------------------------------------------------------------------- 1 | site :opscode 2 | 3 | metadata 4 | 5 | group :integration do 6 | cookbook 'user_test', :path => './test/cookbooks/user_test' 7 | end 8 | -------------------------------------------------------------------------------- /cookbooks/user/Gemfile: -------------------------------------------------------------------------------- 1 | source "https://rubygems.org" 2 | 3 | gem 'rake' 4 | gem 'minitest', '~> 4.7' 5 | gem 'foodcritic' 6 | 7 | # allow CI to override the version of Chef for matrix testing 8 | gem 'chef', (ENV['CHEF_VERSION'] || '>= 0.10.10') 9 | 10 | group :integration do 11 | gem 'berkshelf' 12 | gem 'test-kitchen', '~> 1.0.0.alpha.7' 13 | gem 'kitchen-vagrant' 14 | end 15 | -------------------------------------------------------------------------------- /cookbooks/user/Rakefile: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env rake 2 | require 'rake/testtask' 3 | require 'foodcritic' 4 | 5 | Rake::TestTask.new do |t| 6 | t.test_files = FileList['test/unit/**/*_spec.rb'] 7 | t.verbose = true 8 | end 9 | 10 | FoodCritic::Rake::LintTask.new do |t| 11 | t.options = { :tags => ['~FC048'], :fail_tags => ['any'] } 12 | end 13 | 14 | begin 15 | require 'kitchen/rake_tasks' 16 | Kitchen::RakeTasks.new 17 | rescue LoadError 18 | puts ">>>>> Kitchen gem not loaded, omitting tasks" unless ENV['CI'] 19 | end 20 | 21 | task :default => [:foodcritic, :test] 22 | -------------------------------------------------------------------------------- /cookbooks/user/libraries/matchers.rb: -------------------------------------------------------------------------------- 1 | if defined?(ChefSpec) 2 | if Gem::Version.new(ChefSpec::VERSION) < Gem::Version.new('4.1.0') 3 | ChefSpec::Runner.define_runner_method :user_account 4 | else 5 | ChefSpec.define_matcher :user_account 6 | end 7 | 8 | def create_user_account(user) 9 | ChefSpec::Matchers::ResourceMatcher.new(:user_account, :create, user) 10 | end 11 | def remove_user_account(user) 12 | ChefSpec::Matchers::ResourceMatcher.new(:user_account, :remove, user) 13 | end 14 | def modify_user_account(user) 15 | ChefSpec::Matchers::ResourceMatcher.new(:user_account, :modify, user) 16 | end 17 | def manage_user_account(user) 18 | ChefSpec::Matchers::ResourceMatcher.new(:user_account, :manage, user) 19 | end 20 | def lock_user_account(user) 21 | ChefSpec::Matchers::ResourceMatcher.new(:user_account, :lock, user) 22 | end 23 | def unlock_user_account(user) 24 | ChefSpec::Matchers::ResourceMatcher.new(:user_account, :unlock, user) 25 | end 26 | end 27 | -------------------------------------------------------------------------------- /cookbooks/user/recipes/default.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: user 3 | # Recipe:: default 4 | # 5 | # Copyright 2011, Fletcher Nichol 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # 19 | -------------------------------------------------------------------------------- /cookbooks/user/templates/default/authorized_keys.erb: -------------------------------------------------------------------------------- 1 | # 2 | # Generated by Chef for <%= @user %>@<%= @fqdn %>. 3 | # Local modifications will be overwritten. 4 | # 5 | <% @ssh_keys.each do |key| -%> 6 | <%= key %> 7 | <% end -%> 8 | -------------------------------------------------------------------------------- /cookbooks/yum-epel/attributes/default.rb: -------------------------------------------------------------------------------- 1 | default['yum-epel']['repositories'] = %w(epel epel-debuginfo epel-source epel-testing epel-testing-debuginfo epel-testing-source) 2 | -------------------------------------------------------------------------------- /cookbooks/yum-epel/metadata.json: -------------------------------------------------------------------------------- 1 | {"name":"yum-epel","version":"0.6.4","description":"Installs and configures the EPEL Yum repository","long_description":"","maintainer":"Chef Software, Inc.","maintainer_email":"cookbooks@chef.io","license":"Apache 2.0","platforms":{"amazon":">= 0.0.0","centos":">= 0.0.0","fedora":">= 0.0.0","oracle":">= 0.0.0","redhat":">= 0.0.0","scientific":">= 0.0.0"},"dependencies":{"yum":"~> 3.2"},"recommendations":{},"suggestions":{},"conflicting":{},"providing":{},"replacing":{},"attributes":{},"groupings":{},"recipes":{}} -------------------------------------------------------------------------------- /cookbooks/yum/libraries/matchers.rb: -------------------------------------------------------------------------------- 1 | # Matchers for chefspec 3 2 | 3 | if defined?(ChefSpec) 4 | def create_yum_repository(resource_name) 5 | ChefSpec::Matchers::ResourceMatcher.new(:yum_repository, :create, resource_name) 6 | end 7 | 8 | def add_yum_repository(resource_name) 9 | ChefSpec::Matchers::ResourceMatcher.new(:yum_repository, :add, resource_name) 10 | end 11 | 12 | def delete_yum_repository(resource_name) 13 | ChefSpec::Matchers::ResourceMatcher.new(:yum_repository, :delete, resource_name) 14 | end 15 | 16 | def remove_yum_repository(resource_name) 17 | ChefSpec::Matchers::ResourceMatcher.new(:yum_repository, :remove, resource_name) 18 | end 19 | 20 | def create_yum_globalconfig(resource_name) 21 | ChefSpec::Matchers::ResourceMatcher.new(:yum_globalconfig, :create, resource_name) 22 | end 23 | 24 | def delete_yum_globalconfig(resource_name) 25 | ChefSpec::Matchers::ResourceMatcher.new(:yum_globalconfig, :delete, resource_name) 26 | end 27 | end 28 | -------------------------------------------------------------------------------- /cookbooks/yum/metadata.json: -------------------------------------------------------------------------------- 1 | {"name":"yum","version":"3.8.1","description":"Configures various yum components on Red Hat-like systems","long_description":"","maintainer":"Chef Software, Inc.","maintainer_email":"cookbooks@chef.io","license":"Apache 2.0","platforms":{"amazon":">= 0.0.0","centos":">= 0.0.0","fedora":">= 0.0.0","oracle":">= 0.0.0","redhat":">= 0.0.0","scientific":">= 0.0.0"},"dependencies":{},"recommendations":{},"suggestions":{},"conflicting":{},"providing":{},"replacing":{},"attributes":{},"groupings":{},"recipes":{}} -------------------------------------------------------------------------------- /cookbooks/yum/providers/globalconfig.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: yum 3 | # Provider:: repository 4 | # 5 | # Author:: Sean OMeara 6 | # Copyright 2013, Chef 7 | # 8 | # Licensed under the Apache License, Version 2.0 (the "License"); 9 | # you may not use this file except in compliance with the License. 10 | # You may obtain a copy of the License at 11 | # 12 | # http://www.apache.org/licenses/LICENSE-2.0 13 | # 14 | # Unless required by applicable law or agreed to in writing, software 15 | # distributed under the License is distributed on an "AS IS" BASIS, 16 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | # See the License for the specific language governing permissions and 18 | # limitations under the License. 19 | # 20 | 21 | # Allow for Chef 10 support 22 | use_inline_resources if defined?(use_inline_resources) 23 | 24 | def whyrun_supported? 25 | true 26 | end 27 | 28 | action :create do 29 | template new_resource.path do 30 | source 'main.erb' 31 | cookbook 'yum' 32 | mode '0644' 33 | variables(config: new_resource) 34 | end 35 | end 36 | 37 | action :delete do 38 | file new_resource.path do 39 | action :delete 40 | end 41 | end 42 | -------------------------------------------------------------------------------- /cookbooks/yum/recipes/default.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Author:: Sean OMeara () 3 | # Author:: Joshua Timberman () 4 | # Recipe:: yum::default 5 | # 6 | # Copyright 2013-2014, Chef Software, Inc () 7 | # 8 | # Licensed under the Apache License, Version 2.0 (the "License"); 9 | # you may not use this file except in compliance with the License. 10 | # You may obtain a copy of the License at 11 | # 12 | # http://www.apache.org/licenses/LICENSE-2.0 13 | # 14 | # Unless required by applicable law or agreed to in writing, software 15 | # distributed under the License is distributed on an "AS IS" BASIS, 16 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | # See the License for the specific language governing permissions and 18 | # limitations under the License. 19 | 20 | yum_globalconfig '/etc/yum.conf' do 21 | node['yum']['main'].each do |config, value| 22 | send(config.to_sym, value) unless value.nil? 23 | end 24 | 25 | action :create 26 | end 27 | -------------------------------------------------------------------------------- /from-scratch.gemspec: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | lib = File.expand_path('../lib', __FILE__) 3 | $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) 4 | require 'from-scratch/version' 5 | 6 | Gem::Specification.new do |spec| 7 | spec.name = "from-scratch" 8 | spec.version = FromScratch::VERSION 9 | spec.authors = ["Andrew Shaydurov"] 10 | spec.email = ["gearhead@it-primorye.ru"] 11 | 12 | spec.summary = "Your last command to bootstrap the whole Rails app" 13 | spec.description = "Makes all the stuff usually you or your DevOps does before first deploy" 14 | spec.homepage = "https://github.com/sandrew/from-scratch" 15 | spec.license = "MIT" 16 | 17 | spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) } 18 | spec.executables = %w(scratchify) 19 | spec.require_paths = %w(lib) 20 | 21 | spec.add_development_dependency "bundler", "~> 1.10" 22 | spec.add_development_dependency "rake", "~> 10.0" 23 | spec.add_development_dependency 'rspec', "~> 3.3" 24 | spec.add_development_dependency 'rspec-its', "~> 1.2" 25 | spec.add_development_dependency 'pry', "~> 0.10" 26 | 27 | spec.add_dependency 'knife-solo' 28 | spec.add_dependency 'knife-solo_data_bag' 29 | spec.add_dependency 'chef', "~> 12.5" 30 | spec.add_dependency 'berkshelf' 31 | 32 | 33 | spec.required_ruby_version = '>= 1.9.3' 34 | end 35 | -------------------------------------------------------------------------------- /lib/from-scratch/version.rb: -------------------------------------------------------------------------------- 1 | class FromScratch 2 | VERSION = "0.7.0" 3 | end 4 | -------------------------------------------------------------------------------- /metadata.rb: -------------------------------------------------------------------------------- 1 | name "scratchify" 2 | maintainer "Andrew Shaydurov" 3 | maintainer_email "gearhead@it-primorye.ru" 4 | license "MIT" 5 | description "Cookbook for FromScratch gem" 6 | version "0.1.0" 7 | 8 | recipe "scratchify", "sets up some user directories and files" 9 | recipe "scratchify::pre_rvm", "workaround for RVM recipe bug" 10 | recipe "scratchify::nginx_site", "loads nginx site config" 11 | 12 | 13 | supports 'ubuntu' 14 | supports 'debian' 15 | 16 | depends 'user' 17 | depends 'rvm' 18 | depends 'postgresql' 19 | depends 'nginx' 20 | depends 'ruby_rbenv' 21 | -------------------------------------------------------------------------------- /recipes/default.rb: -------------------------------------------------------------------------------- 1 | ["#{node['scratchify']['app_name']}", "#{node['scratchify']['app_name']}/shared", "#{node['scratchify']['app_name']}/shared/config", "#{node['scratchify']['app_name']}/shared/log"].each do |path| 2 | directory "/home/deploy/#{path}" do 3 | owner 'deploy' 4 | group 'deploy' 5 | mode '0755' 6 | recursive true 7 | end 8 | end 9 | 10 | directory "/home/deploy/#{node['scratchify']['app_name']}/shared/log" do 11 | owner 'deploy' 12 | group 'deploy' 13 | mode '0755' 14 | recursive true 15 | end 16 | 17 | template "/home/deploy/#{node['scratchify']['app_name']}/shared/config/database.yml" do 18 | source 'database.yml.erb' 19 | owner 'deploy' 20 | group 'deploy' 21 | mode '0600' 22 | end 23 | 24 | template "/home/deploy/#{node['scratchify']['app_name']}/shared/config/secrets.yml" do 25 | source 'secrets.yml.erb' 26 | owner 'deploy' 27 | group 'deploy' 28 | mode '0600' 29 | end 30 | 31 | # required for json gem 32 | if node['platform_family'] == 'debian' 33 | package 'libgmp-dev' 34 | end 35 | -------------------------------------------------------------------------------- /recipes/nginx_site.rb: -------------------------------------------------------------------------------- 1 | nginx_site node['scratchify']['app_name'] do 2 | enable true 3 | template 'nginx.erb' 4 | end 5 | -------------------------------------------------------------------------------- /recipes/pre_rvm.rb: -------------------------------------------------------------------------------- 1 | execute 'download RVM GPG key' do 2 | user "deploy" 3 | command "gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3" 4 | environment 'HOME' => '/home/deploy' 5 | end 6 | -------------------------------------------------------------------------------- /spec/spec_helper.rb: -------------------------------------------------------------------------------- 1 | $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__) 2 | require 'rspec/its' 3 | require 'from-scratch' 4 | require 'pry' 5 | 6 | RSpec.configure do |c| 7 | c.filter_run focus: true 8 | c.run_all_when_everything_filtered = true 9 | end 10 | -------------------------------------------------------------------------------- /templates/database.yml.erb: -------------------------------------------------------------------------------- 1 | production: 2 | adapter: postgresql 3 | database: '<%= node['postgresql']['databases'][0]['name'] %>' 4 | username: '<%= node['postgresql']['users'][0]['username'] %>' 5 | password: '<%= node['postgresql']['users'][0]['password'] %>' 6 | encoding: unicode 7 | host: localhost 8 | -------------------------------------------------------------------------------- /templates/nginx.erb: -------------------------------------------------------------------------------- 1 | upstream <%= node['scratchify']['app_name'] %>_upstream { 2 | server unix:/home/deploy/<%= node['scratchify']['app_name'] %>/shared/tmp/sockets/application.sock fail_timeout=0; 3 | } 4 | 5 | server { 6 | listen 80 default_server; 7 | server_name localhost; 8 | 9 | client_max_body_size 10M; 10 | keepalive_timeout 10; 11 | 12 | root /home/deploy/<%= node['scratchify']['app_name'] %>/current/public; 13 | error_page 500 503 502 504 /500.html; 14 | try_files $uri/index.html $uri @<%= node['scratchify']['app_name'] %>_location; 15 | 16 | location @<%= node['scratchify']['app_name'] %>_location { 17 | proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 18 | proxy_set_header Host $http_host; 19 | proxy_redirect off; 20 | 21 | proxy_pass http://<%= node['scratchify']['app_name'] %>_upstream; 22 | access_log /home/deploy/<%= node['scratchify']['app_name'] %>/shared/log/nginx.access.log; 23 | error_log /home/deploy/<%= node['scratchify']['app_name'] %>/shared/log/nginx.error.log; 24 | } 25 | 26 | location ^~ /assets/ { 27 | gzip_static on; 28 | expires max; 29 | add_header Cache-Control public; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /templates/secrets.yml.erb: -------------------------------------------------------------------------------- 1 | production: 2 | secret_key_base: '<%= SecureRandom.hex(64) %>' 3 | -------------------------------------------------------------------------------- /templates/user.json.erb: -------------------------------------------------------------------------------- 1 | { 2 | "id": "deploy", 3 | "name": "deploy", 4 | "groups": ["deploy"], 5 | "ssh_keys": ["<%= @options.ssh_pub_key %>"] 6 | } 7 | --------------------------------------------------------------------------------