├── nginx-fastcgi ├── recipes │ └── default.rb ├── features │ ├── resource │ │ ├── _workaround.feature │ │ └── validate_input_params.feature │ ├── install_site │ │ ├── _workaround.feature │ │ ├── create_config_file.feature │ │ ├── with-default-fastcgi-location.feature │ │ ├── set-fastcgi_read_timeout.feature │ │ ├── with-document-root.feature │ │ ├── set-fastcgi_intercept_errors.feature │ │ ├── with-alternative-fastcgi-location.feature │ │ ├── log_file_paths.feature │ │ ├── with-additional-fastcgi-params.feature │ │ ├── with-static-files.feature │ │ ├── with-error-page.feature │ │ ├── http_to_https_redirect.feature │ │ ├── with-many-static-files.feature │ │ ├── without_ip_adress.feature │ │ ├── pass_socket.feature │ │ ├── apply_default_settings.feature │ │ └── ssl_enabled.feature │ ├── support │ │ └── env.rb │ └── steps │ │ └── shef.rb ├── metadata.rb ├── changes.md ├── definitions │ └── nginx_fastcgi.rb ├── templates │ └── default │ │ └── nginx-site.erb └── README.md ├── psgi ├── test │ ├── files │ │ └── default │ │ │ ├── test.conf │ │ │ ├── test.psgi │ │ │ ├── tests │ │ │ └── minitest │ │ │ │ ├── install-dancer-app_test.rb │ │ │ │ ├── install-catalyst-app_test.rb │ │ │ │ ├── install-default-app_test.rb │ │ │ │ ├── run-starman-app_test.rb │ │ │ │ ├── run-twiggy-app_test.rb │ │ │ │ └── run-fcgi-app_test.rb │ │ │ └── app_nginx.conf │ ├── recipes │ │ ├── default.rb │ │ ├── install-default-app.rb │ │ ├── install-dancer-app.rb │ │ ├── install-catalyst-app.rb │ │ ├── run-twiggy-app.rb │ │ ├── run-starman-app.rb │ │ ├── run-fcgi-app.rb │ │ └── bootstrap.rb │ ├── metadata.rb │ ├── CHANGELOG.md │ └── README.md ├── Gemfile ├── .gitignore ├── Berksfile ├── metadata.rb ├── attributes │ └── default.rb ├── chefignore ├── templates │ ├── centos │ │ └── init-script │ ├── ubuntu │ │ └── init-script │ └── debian │ │ └── init-script ├── CHANGELOG.md ├── Vagrantfile ├── definitions │ └── psgi_application.rb └── README.md ├── dry-run ├── ignore ├── attributes │ └── default.rb ├── changes.md ├── recipes │ └── default.rb ├── metadata.rb ├── README.md └── definitions │ └── dry-run-template.rb ├── cpan ├── Gemfile ├── files │ └── default │ │ └── .modulebuildrc ├── Berksfile.lock ├── test │ ├── recipes │ │ ├── bootstrap.rb │ │ ├── default.rb │ │ ├── install-fail.rb │ │ ├── install-cpan-module.rb │ │ ├── reload-index.rb │ │ ├── install-archive-from-cookbook.rb │ │ ├── install-cpan-module-by-url.rb │ │ ├── install-cpan-module-into-cwd-with-installbase.rb │ │ ├── install-archive-from-cookbook-version-specify.rb │ │ ├── install-cpan-module-by-version.rb │ │ └── install-cpan-module-by-url-version-specify.rb │ ├── files │ │ └── default │ │ │ └── tests │ │ │ └── minitest │ │ │ └── reload-index_test.rb │ ├── metadata.rb │ ├── CHANGELOG.md │ └── README.md ├── to-do-list.md ├── Berksfile ├── .gitignore ├── recipes │ ├── default.rb │ └── bootstrap.rb ├── metadata.rb ├── attributes │ └── default.rb ├── libraries │ └── matchers.rb ├── resources │ └── client.rb ├── chefignore ├── Vagrantfile ├── CHANGELOG.md ├── README.md └── providers │ └── client.rb ├── pinto ├── Gemfile ├── Berksfile.lock ├── recipes │ ├── default.rb │ ├── server.rb │ └── application.rb ├── Berksfile ├── .gitignore ├── metadata.rb ├── attributes │ └── default.rb ├── pinto_repos_managed_by_chef.txt ├── templates │ ├── centos │ │ └── init.erb │ ├── debian │ │ └── init.erb │ └── ubuntu │ │ └── init.erb ├── chefignore ├── libraries │ └── pinto_library.rb ├── files │ └── default │ │ └── tests │ │ └── minitest │ │ ├── server_test.rb │ │ └── application_test.rb ├── CHANGELOG.md ├── README.md └── Vagrantfile ├── cpanminus ├── Gemfile ├── Berksfile.lock ├── Berksfile ├── README.md ├── recipes │ └── default.rb ├── .gitignore ├── attributes │ └── default.rb ├── files │ └── default │ │ └── tests │ │ └── minitest │ │ └── default_test.rb ├── metadata.rb ├── CHANGELOG.md ├── chefignore └── Vagrantfile ├── catalyst ├── recipes │ └── default.rb ├── metadata.rb ├── attributes │ └── default.rb ├── CHANGES.md ├── resources │ └── application.rb ├── templates │ ├── gentoo │ │ ├── catalyst_application.erb │ │ └── catalyst_application │ ├── debian │ │ └── catalyst_application.erb │ └── ubuntu │ │ └── catalyst_application.erb ├── README.md └── providers │ └── application.rb ├── catalyst-fastcgi ├── CHANGES.md ├── metadata.rb ├── attributes │ └── default.rb ├── recipes │ └── default.rb └── README.md └── README.md /nginx-fastcgi/recipes/default.rb: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /psgi/test/files/default/test.conf: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /dry-run/ignore: -------------------------------------------------------------------------------- 1 | \.svn 2 | 3 | 4 | -------------------------------------------------------------------------------- /cpan/Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | 3 | gem 'berkshelf' 4 | -------------------------------------------------------------------------------- /pinto/Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | 3 | gem 'berkshelf' 4 | -------------------------------------------------------------------------------- /psgi/Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | 3 | gem 'berkshelf' 4 | -------------------------------------------------------------------------------- /cpan/files/default/.modulebuildrc: -------------------------------------------------------------------------------- 1 | * --verbose 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /cpanminus/Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | 3 | gem 'berkshelf' 4 | -------------------------------------------------------------------------------- /dry-run/attributes/default.rb: -------------------------------------------------------------------------------- 1 | node.default.dryrun.dir = '/tmp/.chef/dryrun/' -------------------------------------------------------------------------------- /dry-run/changes.md: -------------------------------------------------------------------------------- 1 | # 0.0.3 2 | - update documentation 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /cpan/Berksfile.lock: -------------------------------------------------------------------------------- 1 | cookbook 'cpan', :path => '/home/melezhik/GitHub/cookbooks/cpan' -------------------------------------------------------------------------------- /pinto/Berksfile.lock: -------------------------------------------------------------------------------- 1 | cookbook 'pinto', :path => '/home/melezhik/GitHub/cookbooks/pinto' -------------------------------------------------------------------------------- /cpan/test/recipes/bootstrap.rb: -------------------------------------------------------------------------------- 1 | package 'make' 2 | 3 | include_recipe 'cpan::bootstrap' 4 | -------------------------------------------------------------------------------- /cpanminus/Berksfile.lock: -------------------------------------------------------------------------------- 1 | cookbook 'cpanminus', :path => '/home/melezhik/GitHub/cookbooks/cpanminus' -------------------------------------------------------------------------------- /pinto/recipes/default.rb: -------------------------------------------------------------------------------- 1 | include_recipe 'pinto::application' 2 | include_recipe 'pinto::server' 3 | 4 | -------------------------------------------------------------------------------- /cpanminus/Berksfile: -------------------------------------------------------------------------------- 1 | site :opscode 2 | 3 | metadata 4 | 5 | group :integration do 6 | cookbook "minitest-handler" 7 | end 8 | 9 | -------------------------------------------------------------------------------- /cpan/test/recipes/default.rb: -------------------------------------------------------------------------------- 1 | include_recipe 'test::bootstrap' 2 | include_recipe 'test::reload-index' 3 | #include_recipe 'test::install-fail' 4 | -------------------------------------------------------------------------------- /pinto/Berksfile: -------------------------------------------------------------------------------- 1 | site :opscode 2 | 3 | metadata 4 | 5 | group :integration do 6 | cookbook "minitest-handler" 7 | end 8 | 9 | 10 | -------------------------------------------------------------------------------- /cpan/to-do-list.md: -------------------------------------------------------------------------------- 1 | # to do in future releases 2 | - add cpan cache clean up after install 3 | - add /tmp/local-lib/ clean up by request or with recipe 4 | 5 | -------------------------------------------------------------------------------- /cpanminus/README.md: -------------------------------------------------------------------------------- 1 | # cpanminus Cookbook 2 | installs cpanminus client 3 | 4 | # recipes 5 | default - installs cpanminus client 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /cpan/test/recipes/install-fail.rb: -------------------------------------------------------------------------------- 1 | cpan_client 'Math::Currency' do 2 | install_type 'cpan_module' 3 | user 'root' 4 | group 'root' 5 | action 'install' 6 | end 7 | 8 | -------------------------------------------------------------------------------- /cpan/test/recipes/install-cpan-module.rb: -------------------------------------------------------------------------------- 1 | cpan_client 'Bundler' do 2 | install_type 'cpan_module' 3 | user 'root' 4 | group 'root' 5 | action 'install' 6 | end 7 | 8 | 9 | -------------------------------------------------------------------------------- /catalyst/recipes/default.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: catalyst 3 | # Recipe:: default 4 | # 5 | # Copyright 2011, YOUR_COMPANY_NAME 6 | # 7 | # All rights reserved - Do Not Redistribute 8 | # 9 | -------------------------------------------------------------------------------- /cpan/test/recipes/reload-index.rb: -------------------------------------------------------------------------------- 1 | cpan_client 'index reload' do 2 | install_type 'cpan_module' 3 | user 'root' 4 | group 'root' 5 | action 'reload_cpan_index' 6 | end 7 | 8 | -------------------------------------------------------------------------------- /cpan/Berksfile: -------------------------------------------------------------------------------- 1 | site :opscode 2 | 3 | metadata 4 | 5 | 6 | cookbook 'test', path: "#{Dir.pwd}/test" 7 | 8 | group :integration do 9 | cookbook "minitest-handler" 10 | end 11 | 12 | -------------------------------------------------------------------------------- /cpan/.gitignore: -------------------------------------------------------------------------------- 1 | .vagrant 2 | Berksfile.lock 3 | *~ 4 | *# 5 | .#* 6 | \#*# 7 | .*.sw[a-z] 8 | *.un~ 9 | /cookbooks 10 | 11 | # Bundler 12 | Gemfile.lock 13 | bin/* 14 | .bundle/* 15 | cache/ 16 | -------------------------------------------------------------------------------- /cpanminus/recipes/default.rb: -------------------------------------------------------------------------------- 1 | node.cpanminus.bootstrap.packages.each do |p| 2 | package p 3 | end 4 | execute "curl -L #{node.cpanminus.bootstrap.download_url} | perl - --sudo App::cpanminus" 5 | 6 | 7 | -------------------------------------------------------------------------------- /cpanminus/.gitignore: -------------------------------------------------------------------------------- 1 | .vagrant 2 | Berksfile.lock 3 | *~ 4 | *# 5 | .#* 6 | \#*# 7 | .*.sw[a-z] 8 | *.un~ 9 | /cookbooks 10 | 11 | # Bundler 12 | Gemfile.lock 13 | bin/* 14 | .bundle/* 15 | cache/ 16 | -------------------------------------------------------------------------------- /psgi/.gitignore: -------------------------------------------------------------------------------- 1 | .vagrant 2 | Berksfile.lock 3 | *~ 4 | *# 5 | .#* 6 | \#*# 7 | .*.sw[a-z] 8 | *.un~ 9 | /cookbooks 10 | 11 | # Bundler 12 | Gemfile.lock 13 | bin/* 14 | .bundle/* 15 | cache/ 16 | *.box 17 | 18 | -------------------------------------------------------------------------------- /pinto/.gitignore: -------------------------------------------------------------------------------- 1 | .vagrant 2 | Berksfile.lock 3 | *~ 4 | *# 5 | .#* 6 | \#*# 7 | .*.sw[a-z] 8 | *.un~ 9 | /cookbooks 10 | 11 | # Bundler 12 | Gemfile.lock 13 | bin/* 14 | .bundle/* 15 | cache/ 16 | 17 | baseboxes/ 18 | -------------------------------------------------------------------------------- /cpan/test/recipes/install-archive-from-cookbook.rb: -------------------------------------------------------------------------------- 1 | cpan_client 'Bundler-v0.0.30.tar.gz' do 2 | from_cookbook 'cpan-test' 3 | install_type 'cpan_module' 4 | user 'root' 5 | group 'root' 6 | action 'install' 7 | end 8 | 9 | -------------------------------------------------------------------------------- /cpan/test/files/default/tests/minitest/reload-index_test.rb: -------------------------------------------------------------------------------- 1 | class CpanClientSpec < MiniTest::Chef::Spec 2 | it "updates Metadata file" do 3 | file("/root/.cpan/Metadata").must_be_modified_after(run_status.start_time) 4 | end 5 | end 6 | 7 | -------------------------------------------------------------------------------- /cpan/test/recipes/install-cpan-module-by-url.rb: -------------------------------------------------------------------------------- 1 | cpan_client 'http://search.cpan.org/CPAN/authors/id/M/ME/MELEZHIK/Bundler-v0.0.29.tar.gz' do 2 | install_type 'cpan_module' 3 | user 'root' 4 | group 'root' 5 | action 'install' 6 | end 7 | -------------------------------------------------------------------------------- /nginx-fastcgi/features/resource/_workaround.feature: -------------------------------------------------------------------------------- 1 | Feature: Workaround for strange Segmentation fault bug of cucumber-nagios 2 | 3 | Scenario: just meaningless command 4 | 5 | When I run 'echo 100' 6 | Then 'stdout' should have '100' 7 | 8 | -------------------------------------------------------------------------------- /catalyst-fastcgi/CHANGES.md: -------------------------------------------------------------------------------- 1 | # 0.0.4 2 | - replace rdoc by markdown document 3 | 4 | # 0.0.3 5 | - proper default proc manager 6 | 7 | # 0.0.2 8 | - support for ssl 9 | - new attributes : start_service, server_alias, apache logs 10 | 11 | 12 | -------------------------------------------------------------------------------- /nginx-fastcgi/features/install_site/_workaround.feature: -------------------------------------------------------------------------------- 1 | Feature: Workaround for strange Segmentation fault bug of cucumber-nagios 2 | 3 | Scenario: just meaningless command 4 | 5 | When I run 'echo 100' 6 | Then 'stdout' should have '100' 7 | 8 | -------------------------------------------------------------------------------- /cpanminus/attributes/default.rb: -------------------------------------------------------------------------------- 1 | default.cpanminus.bootstrap.download_url = 'http://cpanmin.us' 2 | default.cpanminus.bootstrap.packages = %w[ curl ] 3 | case platform 4 | when 'centos' 5 | default.cpanminus.bootstrap.packages << 'perl-devel' 6 | end 7 | -------------------------------------------------------------------------------- /cpan/test/recipes/install-cpan-module-into-cwd-with-installbase.rb: -------------------------------------------------------------------------------- 1 | cpan_client 'Bundler' do 2 | install_type 'cpan_module' 3 | user 'root' 4 | group 'root' 5 | action 'install' 6 | install_base 'bar' 7 | cwd '/tmp/foo/' 8 | end 9 | 10 | -------------------------------------------------------------------------------- /dry-run/recipes/default.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: dry-run 3 | # Recipe:: default 4 | # 5 | 6 | directory node.dryrun.dir do 7 | action :delete 8 | recursive true 9 | end 10 | 11 | 12 | directory node.dryrun.dir do 13 | action :create 14 | recursive true 15 | end -------------------------------------------------------------------------------- /psgi/Berksfile: -------------------------------------------------------------------------------- 1 | site :opscode 2 | 3 | metadata 4 | 5 | cookbook 'cpan', git: 'https://github.com/melezhik/cookbooks.git', rel: 'cpan' 6 | 7 | cookbook 'test', path: "#{Dir.pwd}/test" 8 | 9 | group :integration do 10 | cookbook "minitest-handler" 11 | end 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /cpan/test/recipes/install-archive-from-cookbook-version-specify.rb: -------------------------------------------------------------------------------- 1 | cpan_client 'Bundler-v0.0.29.tar.gz' do 2 | from_cookbook 'cpan-test' 3 | version '=0.0.29' 4 | install_type 'cpan_module' 5 | user 'root' 6 | group 'root' 7 | action 'install' 8 | end 9 | 10 | -------------------------------------------------------------------------------- /cpan/recipes/default.rb: -------------------------------------------------------------------------------- 1 | directory '/tmp/local-lib/' do 2 | action :delete 3 | recursive true 4 | end 5 | 6 | directory '/tmp/local-lib/' do 7 | action :create 8 | mode '0777' 9 | end 10 | 11 | directory '/tmp/local-lib/install' do 12 | action :create 13 | mode '0777' 14 | end 15 | 16 | 17 | -------------------------------------------------------------------------------- /cpanminus/files/default/tests/minitest/default_test.rb: -------------------------------------------------------------------------------- 1 | class CpanMinusSpec < MiniTest::Chef::Spec 2 | describe 'installs cpanminus client' do 3 | it 'installs cpanm script' do 4 | result = assert_sh('cpanm --version') 5 | assert_includes result, 'App::cpanminus' 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /psgi/test/recipes/default.rb: -------------------------------------------------------------------------------- 1 | include_recipe 'test::bootstrap' 2 | include_recipe 'test::install-catalyst-app' 3 | include_recipe 'test::install-dancer-app' 4 | include_recipe 'test::install-default-app' 5 | include_recipe 'test::run-fcgi-app' 6 | include_recipe 'test::run-starman-app' 7 | include_recipe 'test::run-twiggy-app' 8 | -------------------------------------------------------------------------------- /cpan/test/metadata.rb: -------------------------------------------------------------------------------- 1 | name 'test' 2 | maintainer 'YOUR_COMPANY_NAME' 3 | maintainer_email 'YOUR_EMAIL' 4 | license 'Apache-2.0' 5 | description 'Installs/Configures test' 6 | long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) 7 | version '0.1.0' 8 | depends 'cpan' 9 | -------------------------------------------------------------------------------- /cpan/test/recipes/install-cpan-module-by-version.rb: -------------------------------------------------------------------------------- 1 | cpan_client 'Bundler' do 2 | install_type 'cpan_module' 3 | user 'root' 4 | group 'root' 5 | action 'install' 6 | end 7 | cpan_client 'Bundler' do 8 | install_type 'cpan_module' 9 | user 'root' 10 | group 'root' 11 | version '0.0.29' 12 | action 'install' 13 | end 14 | -------------------------------------------------------------------------------- /dry-run/metadata.rb: -------------------------------------------------------------------------------- 1 | maintainer "Alexey Melezhik" 2 | maintainer_email "melezhik@gmail.com" 3 | license 'Apache-2.0' 4 | description "run chef templates in dryrun mode" 5 | long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) 6 | version "0.0.3" 7 | 8 | %w{ ubuntu gentoo }.each do |os| 9 | supports os 10 | end 11 | 12 | -------------------------------------------------------------------------------- /psgi/test/files/default/test.psgi: -------------------------------------------------------------------------------- 1 | my $app = sub { 2 | my $env = shift; 3 | my @data; 4 | for my $id (%ENV) { 5 | push @data, "$id:$ENV{$id}" 6 | } 7 | return [ 8 | '200', 9 | [ 'Content-Type' => 'text/plain' ], 10 | [ "Hello World", join "\n", @data ], # or IO::Handle-like object 11 | ]; 12 | }; 13 | 14 | -------------------------------------------------------------------------------- /psgi/metadata.rb: -------------------------------------------------------------------------------- 1 | maintainer "Alexey Melezhik" 2 | maintainer_email "melezhik@gmail.com" 3 | license 'Apache-2.0' 4 | description "Configures and runs psgi application" 5 | long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) 6 | version "0.1.2" 7 | 8 | %w{ ubuntu debian centos }.each do |os| 9 | supports os 10 | end 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /cpanminus/metadata.rb: -------------------------------------------------------------------------------- 1 | name 'cpanminus' 2 | maintainer 'Alexey Melezhik' 3 | maintainer_email 'melezhik@gmail.com' 4 | license 'Apache-2.0' 5 | description 'Installs cpanminus client' 6 | long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) 7 | version '0.1.1' 8 | 9 | %w{ ubuntu debian centos }.each do |os| 10 | supports os 11 | end 12 | -------------------------------------------------------------------------------- /catalyst/metadata.rb: -------------------------------------------------------------------------------- 1 | name "catalyst" 2 | maintainer "melezhik" 3 | maintainer_email "melezhik@gmail.com" 4 | license 'Apache-2.0' 5 | description "catalyst application resource provider (LWRP)" 6 | long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) 7 | version "0.1.0" 8 | %w{ gentoo ubuntu debian}.each do |os| 9 | supports os 10 | end 11 | -------------------------------------------------------------------------------- /psgi/test/metadata.rb: -------------------------------------------------------------------------------- 1 | name 'test' 2 | maintainer 'YOUR_COMPANY_NAME' 3 | maintainer_email 'YOUR_EMAIL' 4 | license 'All rights reserved' 5 | description 'Installs/Configures test' 6 | long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) 7 | version '0.1.0' 8 | depends 'cpan' 9 | depends 'psgi' 10 | depends 'nginx' 11 | -------------------------------------------------------------------------------- /pinto/metadata.rb: -------------------------------------------------------------------------------- 1 | name 'pinto' 2 | maintainer 'Alexey Melezhik' 3 | maintainer_email 'melezhik@gmail.com' 4 | license 'Apache-2.0' 5 | description 'Installs/Configures pinto' 6 | long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) 7 | version '0.1.11' 8 | 9 | 10 | %w{ ubuntu debian centos }.each do |os| 11 | supports os 12 | end 13 | 14 | 15 | -------------------------------------------------------------------------------- /cpan/metadata.rb: -------------------------------------------------------------------------------- 1 | name "cpan" 2 | maintainer "Alexey Melezhik" 3 | maintainer_email "melezhik@gmail.com" 4 | license 'Apache-2.0' 5 | description "CPAN modules provider (cpan_client provider LWRP)" 6 | long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) 7 | version "0.1.0" 8 | %w{ debian ubuntu centos gentoo }.each do |os| 9 | supports os 10 | end 11 | 12 | -------------------------------------------------------------------------------- /nginx-fastcgi/features/support/env.rb: -------------------------------------------------------------------------------- 1 | require 'cucumber/nagios/steps' 2 | 3 | module KnownsDomain 4 | 5 | CACHE_DIR = '/tmp/cucumber/shef/nginx-fastcgi/cache' 6 | def cache_dir 7 | CACHE_DIR 8 | end 9 | 10 | def set_before_cmd cmd 11 | @cmd = cmd 12 | end 13 | 14 | def before_cmd 15 | @cmd 16 | end 17 | 18 | end 19 | 20 | World KnownsDomain 21 | 22 | `mkdir -p #{KnownsDomain::CACHE_DIR}` 23 | -------------------------------------------------------------------------------- /psgi/test/files/default/tests/minitest/install-dancer-app_test.rb: -------------------------------------------------------------------------------- 1 | class PsgiSpec < MiniTest::Chef::Spec 2 | describe 'psgi_application action install' do 3 | it 'creates proper init script file' do 4 | file_path = "/tmp/psgi/dancer/app#{node[:psgi][:install][:extention]}" 5 | file(file_path).must_exist 6 | file(file_path).must_include 'DANCER_CONFDIR=/home/user/app/MyApplication' 7 | end 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /catalyst/attributes/default.rb: -------------------------------------------------------------------------------- 1 | case platform 2 | when 'gentoo' 3 | set[:catalyst][:initscript][:template][:dir] = '/etc/conf.d' 4 | when 'ubuntu', 'debian' 5 | set[:catalyst][:initscript][:template][:dir] = '/etc/init.d' 6 | end 7 | 8 | 9 | case platform 10 | when 'gentoo' 11 | set[:catalyst][:initscript][:template][:mode] = '0664' 12 | when 'ubuntu', 'debian' 13 | set[:catalyst][:initscript][:template][:mode] = '0755' 14 | end 15 | -------------------------------------------------------------------------------- /nginx-fastcgi/metadata.rb: -------------------------------------------------------------------------------- 1 | name "nginx-fastcgi" 2 | maintainer "Alexey Melezhik" 3 | maintainer_email "melezhik@gmail.com" 4 | license 'Apache-2.0' 5 | description "create nginx site to run your fastcgi application under nginx frontend" 6 | long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) 7 | version "0.0.11" 8 | 9 | %w{ ubuntu debian }.each do |os| 10 | supports os 11 | end 12 | 13 | -------------------------------------------------------------------------------- /psgi/test/files/default/app_nginx.conf: -------------------------------------------------------------------------------- 1 | server { 2 | 3 | listen 8888; 4 | server_name 127.0.0.1; 5 | 6 | location / { 7 | include fastcgi_params; 8 | fastcgi_pass unix:/tmp/app_fcgi.socket; 9 | fastcgi_param SCRIPT_NAME ""; 10 | } 11 | access_log /var/log/nginx/app_fcgi.log; 12 | error_log /var/log/nginx/app_fcgi.error.log; 13 | 14 | } 15 | 16 | 17 | -------------------------------------------------------------------------------- /psgi/test/recipes/install-default-app.rb: -------------------------------------------------------------------------------- 1 | psgi_application 'fcgi application' do 2 | application_user 'psgi-default-user' 3 | application_home '/home/user/app/MyApplication' 4 | script '/home/user/app/MyApplication/scripts/app.psgi' 5 | config '/home/user/app/MyApplication/app.conf' 6 | install_dir '/tmp/psgi/default' 7 | enable_service 'off' 8 | action 'install' 9 | end 10 | -------------------------------------------------------------------------------- /catalyst-fastcgi/metadata.rb: -------------------------------------------------------------------------------- 1 | maintainer "YOUR_COMPANY_NAME" 2 | maintainer_email "YOUR_EMAIL" 3 | license 'Apache-2.0' 4 | description "1) Configures catalyst as fastcgi server 2) Configure apache virtual host for it" 5 | long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) 6 | version "0.0.4" 7 | depends "catalyst", ">= 0.0.4" 8 | depends "apache" , ">= 0.0.3" 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /cpan/test/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # CHANGELOG for test 2 | 3 | This file is used to list changes made in each version of test. 4 | 5 | ## 0.1.0: 6 | 7 | * Initial release of test 8 | 9 | - - - 10 | Check the [Markdown Syntax Guide](http://daringfireball.net/projects/markdown/syntax) for help with Markdown. 11 | 12 | The [Github Flavored Markdown page](http://github.github.com/github-flavored-markdown/) describes the differences between markdown on github and standard markdown. 13 | -------------------------------------------------------------------------------- /psgi/test/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # CHANGELOG for test 2 | 3 | This file is used to list changes made in each version of test. 4 | 5 | ## 0.1.0: 6 | 7 | * Initial release of test 8 | 9 | - - - 10 | Check the [Markdown Syntax Guide](http://daringfireball.net/projects/markdown/syntax) for help with Markdown. 11 | 12 | The [Github Flavored Markdown page](http://github.github.com/github-flavored-markdown/) describes the differences between markdown on github and standard markdown. 13 | -------------------------------------------------------------------------------- /cpan/test/recipes/install-cpan-module-by-url-version-specify.rb: -------------------------------------------------------------------------------- 1 | cpan_client 'http://search.cpan.org/CPAN/authors/id/M/ME/MELEZHIK/Bundler-v0.0.30.tar.gz' do 2 | install_type 'cpan_module' 3 | user 'root' 4 | group 'root' 5 | action 'install' 6 | end 7 | cpan_client 'http://search.cpan.org/CPAN/authors/id/M/ME/MELEZHIK/Bundler-v0.0.29.tar.gz' do 8 | install_type 'cpan_module' 9 | module_name 'Bundler' 10 | user 'root' 11 | group 'root' 12 | action 'install' 13 | end 14 | 15 | -------------------------------------------------------------------------------- /psgi/test/recipes/install-dancer-app.rb: -------------------------------------------------------------------------------- 1 | psgi_application 'dancer fcgi application' do 2 | application_user 'psgi-dancer-user' 3 | application_home '/home/user/app/MyApplication' 4 | script '/home/user/app/MyApplication/scripts/app.psgi' 5 | config '/home/user/app/MyApplication/app.conf' 6 | install_dir '/tmp/psgi/dancer' 7 | operator 'Dancer' 8 | enable_service 'off' 9 | action 'install' 10 | end 11 | 12 | -------------------------------------------------------------------------------- /psgi/test/files/default/tests/minitest/install-catalyst-app_test.rb: -------------------------------------------------------------------------------- 1 | class PsgiSpec < MiniTest::Chef::Spec 2 | describe 'psgi_application action install' do 3 | it 'creates proper init script file' do 4 | file_path = "/tmp/psgi/catalyst/app#{node[:psgi][:install][:extention]}" 5 | file(file_path).must_exist 6 | file(file_path).must_include "FOO='100' CATALYST_CONFIG=/home/user/app/MyApplication/app.conf CATALYST_DEBUG=1 PERL5LIB=$PERL5LIB:cpanlib/lib/perl5" 7 | end 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /cpan/attributes/default.rb: -------------------------------------------------------------------------------- 1 | default['cpan_client']['bootstrap']['packages'] = ['curl'] 2 | 3 | case node['platform'] 4 | when 'centos' 5 | default['cpan_client']['bootstrap']['packages'] << 'perl-devel' 6 | default['cpan_client']['bootstrap']['packages'] << 'perl-CPAN' 7 | end 8 | 9 | default['cpan_client']['bootstrap']['cpan_packages'] = ['Time::HiRes', 'CPAN::Meta', 'CPAN', 'local::lib', 'App::pmuninstall'] 10 | 11 | default['cpan_client']['default_inc'] = [] 12 | 13 | default['cpan_client']['bootstrap']['keep_uptodate'] = true 14 | -------------------------------------------------------------------------------- /cpanminus/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # CHANGELOG for cpanminus 2 | 3 | This file is used to list changes made in each version of cpanminus. 4 | 5 | ## 0.1.1: 6 | * has been tested for debian 7 | 8 | ## 0.1.0: 9 | 10 | * Initial release of cpanminus 11 | 12 | - - - 13 | Check the [Markdown Syntax Guide](http://daringfireball.net/projects/markdown/syntax) for help with Markdown. 14 | 15 | The [Github Flavored Markdown page](http://github.github.com/github-flavored-markdown/) describes the differences between markdown on github and standard markdown. 16 | -------------------------------------------------------------------------------- /psgi/test/files/default/tests/minitest/install-default-app_test.rb: -------------------------------------------------------------------------------- 1 | class PsgiSpec < MiniTest::Chef::Spec 2 | describe 'psgi_application action install' do 3 | it 'creates proper init script file' do 4 | file_path = "/tmp/psgi/dancer/app#{node[:psgi][:install][:extention]}" 5 | file(file_path).must_exist 6 | file(file_path).must_include '-s FCGI --listen /tmp/app_fcgi.socket -E development -a /home/user/app/MyApplication/scripts/app.psgi --manager FCGI::ProcManager --proc_title app --path / --nproc 1' 7 | end 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /cpan/libraries/matchers.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: cpan 3 | # Library:: matchers 4 | # 5 | 6 | if defined?(ChefSpec) 7 | def install_cpan_module(resource_name) 8 | ChefSpec::Matchers::ResourceMatcher.new(:cpan_client, :install, resource_name) 9 | end 10 | 11 | def test_cpan_module(resource_name) 12 | ChefSpec::Matchers::ResourceMatcher.new(:cpan_client, :test, resource_name) 13 | end 14 | 15 | def reload_cpan_index(resource_name) 16 | ChefSpec::Matchers::ResourceMatcher.new(:cpan_client, :reload_cpan_index, resource_name) 17 | end 18 | end 19 | -------------------------------------------------------------------------------- /catalyst/CHANGES.md: -------------------------------------------------------------------------------- 1 | # 0.1.0 2 | 3 | - Update license #33 4 | 5 | # 0.0.8 6 | - checks if daemon already running before start 7 | 8 | # 0.0.7 9 | - --proc-title parameter (only works with Catalyst 5.90015) 10 | 11 | # 0.0.6 12 | - bug fixes for 'Provides:' header in ubuntu/debian init scripts 13 | 14 | # 0.0.5 15 | - service enabled bug fix 16 | - support for debian platrform 17 | - bug fix in config templates for ubuntu and debian 18 | 19 | # 0.0.4 20 | - ... actually I don't remember the diferrence b/w version 0.0.32 , but it does exist ((: 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /catalyst/resources/application.rb: -------------------------------------------------------------------------------- 1 | actions :install 2 | attribute :application_home, :kind_of => String 3 | attribute :application_user, :kind_of => String 4 | attribute :application_group, :kind_of => String 5 | attribute :application_script, :kind_of => String 6 | attribute :catalyst_config, :kind_of => String 7 | attribute :perl5lib, :kind_of => Array, :default => [] 8 | attribute :envvars, :kind_of => Hash, :default => {} 9 | attribute :socket, :kind_of => String 10 | attribute :nproc, :kind_of => Integer, :default => 1 11 | attribute :proc_manager, :kind_of => String, :default => 'FCGI::ProcManager' 12 | attribute :start_service, :kind_of => [TrueClass,FalseClass], :default => true 13 | 14 | -------------------------------------------------------------------------------- /nginx-fastcgi/features/install_site/create_config_file.feature: -------------------------------------------------------------------------------- 1 | Feature: nginx-fastcgi should be able to install nginx site config 2 | 3 | Scenario: install nginx site config 4 | Given I run 'rm -rf /tmp/foo.site.conf' 5 | Then a file named '/tmp/foo.site.conf' should not exist 6 | And I have chef recipe: 7 | """ 8 | nginx_fastcgi '/tmp/foo.site.conf' do 9 | servers [ 10 | { 11 | :ip => '127.0.0.1', 12 | :server_name => 'foo.site.x' 13 | } 14 | ] 15 | socket '/tmp/application.socket' 16 | end 17 | """ 18 | When I run chef recipe on my node 19 | Then a file named '/tmp/foo.site.conf' should exist 20 | 21 | -------------------------------------------------------------------------------- /psgi/attributes/default.rb: -------------------------------------------------------------------------------- 1 | default[:psgi][:plack][:version] = '1.0024' 2 | 3 | 4 | case platform 5 | when 'centos' 6 | default[:psgi][:install][:dir] = '/etc/init/' 7 | default[:psgi][:install][:extention] = '.conf' 8 | default[:psgi][:service][:provider] = Chef::Provider::Service::Upstart 9 | when 'ubuntu' 10 | default[:psgi][:install][:dir] = '/etc/init/' 11 | default[:psgi][:install][:extention] = '.conf' 12 | default[:psgi][:service][:provider] = Chef::Provider::Service::Upstart 13 | when 'debian' 14 | default[:psgi][:install][:dir] = '/etc/init.d/' 15 | default[:psgi][:install][:extention] = nil 16 | default[:psgi][:service][:provider] = Chef::Provider::Service::Debian 17 | end 18 | 19 | -------------------------------------------------------------------------------- /psgi/test/recipes/install-catalyst-app.rb: -------------------------------------------------------------------------------- 1 | psgi_application 'catalyst fcgi application' do 2 | operator 'Catalyst' 3 | enable_service false 4 | application_user 'psgi-catalyst-user' 5 | application_home '/home/user/app/MyApplication' 6 | script '/home/user/app/MyApplication/scripts/app.psgi' 7 | perl5lib [ 'cpanlib/lib/perl5' ] 8 | nproc 2 9 | proc_title 'my-app' 10 | mount '/' 11 | config '/home/user/app/MyApplication/app.conf' 12 | debug 1 13 | plackup_environment 'deployment' 14 | install_dir '/tmp/psgi/catalyst' 15 | environment({ "FOO" => "100" }) 16 | action 'install' 17 | end 18 | 19 | 20 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | DESCRIPTION 2 | === 3 | 4 | collection of chef cookbooks written by me, check out stable versions at http://community.opscode.com/users/melezhik 5 | 6 | - *apache* - various apache related resources providers (LWRP) 7 | - *catalyst* - catalyst application provider (LWRP) 8 | - *catalyst-fastcgi* - configures catalyst as fastcgi server and configure apache virtual host for it 9 | - *cpan* - cpan modules provider (LWRP) 10 | - *dry-run* - run chef templates in dry-run mode 11 | - *nginx-fastcgi* - create nginx site to run your fastcgi application under nginx front-end 12 | - *psgi* - configures and runs psgi application 13 | - *cpanminus* - installs cpanminus client 14 | - *pinto* - installs, configures pinto 15 | 16 | LINKs 17 | ==== 18 | - [Cooking Perl with Chef site](http://perlchef.com/) 19 | 20 | -------------------------------------------------------------------------------- /cpan/recipes/bootstrap.rb: -------------------------------------------------------------------------------- 1 | include_recipe 'cpan' 2 | 3 | node.cpan_client.bootstrap.packages.each { |p| package p } 4 | 5 | execute 'curl -L http://cpanmin.us | perl - --sudo App::cpanminus' do 6 | only_if do 7 | exe_run = true 8 | unless node.cpan_client.bootstrap.keep_uptodate 9 | if system("which cpanm > /dev/null 2>&1") 10 | exe_run = false 11 | end 12 | end 13 | exe_run 14 | end 15 | end 16 | 17 | node.cpan_client.bootstrap.cpan_packages.each do |m| 18 | skip_satisfied = unless node.cpan_client.bootstrap.keep_uptodate 19 | '--skip-satisfied ' 20 | else 21 | '' 22 | end 23 | execute "cpanm #{skip_satisfied}#{m}" do 24 | user 'root' 25 | group 'root' 26 | end 27 | end 28 | 29 | -------------------------------------------------------------------------------- /dry-run/README.md: -------------------------------------------------------------------------------- 1 | DESCRIPTION 2 | =========== 3 | run [chef templates](http://wiki.opscode.com/display/chef/Resources#Resources-Template) in dryrun mode 4 | 5 | USAGE 6 | ===== 7 | 8 | include_recipe 'dry-run' 9 | 10 | dry_run_template "/home/user/file.conf" do 11 | source "file.erb" 12 | mode '0644' 13 | owner 'root' 14 | group 'root' 15 | variables({ :email => 'melezhik@gmail.com' }) 16 | end 17 | 18 | PARAMETERS 19 | ========== 20 | well, this is [chef definition](http://wiki.opscode.com/display/chef/Definitions) so you can pass 21 | arbitrary parametes here: 22 | 23 | * `source` 24 | * `mode` 25 | * `owner` 26 | * `group` 27 | * `variables` 28 | 29 | see explanations for them in http://wiki.opscode.com/display/chef/Resources#Resources-Template 30 | 31 | 32 | -------------------------------------------------------------------------------- /nginx-fastcgi/features/install_site/with-default-fastcgi-location.feature: -------------------------------------------------------------------------------- 1 | Feature: nginx-fastcgi should be able to set default fastcgi location 2 | 3 | Scenario: install nginx site config 4 | Given I run 'rm -rf /tmp/foo.site.conf' 5 | Then a file named '/tmp/foo.site.conf' should not exist 6 | And I have chef recipe: 7 | """ 8 | nginx_fastcgi '/tmp/foo.site.conf' do 9 | servers [ 10 | { 11 | :ip => '127.0.0.1', 12 | :server_name => 'foo.site.x', 13 | } 14 | ] 15 | socket '/tmp/application.socket' 16 | end 17 | """ 18 | When I run chef recipe on my node 19 | Then a file named '/tmp/foo.site.conf' should exist 20 | And a file named '/tmp/foo.site.conf' should contain 'location \/' 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /nginx-fastcgi/features/install_site/set-fastcgi_read_timeout.feature: -------------------------------------------------------------------------------- 1 | Feature: nginx-fastcgi should be able to set fastcgi read timeout 2 | 3 | Scenario: install nginx site config 4 | Given I run 'rm -rf /tmp/foo.site.conf' 5 | Then a file named '/tmp/foo.site.conf' should not exist 6 | And I have chef recipe: 7 | """ 8 | nginx_fastcgi '/tmp/foo.site.conf' do 9 | socket '/tmp/application.socket' 10 | servers [ 11 | { 12 | :server_name => 'foo.site.x', 13 | } 14 | ] 15 | fastcgi_read_timeout '15m' 16 | end 17 | """ 18 | When I run chef recipe on my node 19 | Then a file named '/tmp/foo.site.conf' should exist 20 | And a file named '/tmp/foo.site.conf' should contain 'fastcgi_read_timeout 15m;' 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /nginx-fastcgi/features/install_site/with-document-root.feature: -------------------------------------------------------------------------------- 1 | Feature: nginx-fastcgi should be able to set document root 2 | 3 | Scenario: install nginx site config 4 | Given I run 'rm -rf /tmp/foo.site.conf' 5 | Then a file named '/tmp/foo.site.conf' should not exist 6 | And I have chef recipe: 7 | """ 8 | nginx_fastcgi '/tmp/foo.site.conf' do 9 | servers [ 10 | { 11 | :server_name => 'foo.site.x', 12 | } 13 | ] 14 | socket '/tmp/application.socket' 15 | root '/var/www/foo/bar/baz/' 16 | end 17 | """ 18 | When I run chef recipe on my node 19 | Then a file named '/tmp/foo.site.conf' should exist 20 | And a file named '/tmp/foo.site.conf' should contain 'root \/var\/www\/foo\/bar\/baz\/;' 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /psgi/test/recipes/run-twiggy-app.rb: -------------------------------------------------------------------------------- 1 | psgi_application 'twiggy application' do 2 | server 'Twiggy' 3 | enable_service 'off' 4 | application_user 'psgi-twiggy-user' 5 | application_home '/tmp/psgi/twiggy' 6 | script 'app.psgi' 7 | daemon_name 'twiggy-psgi' 8 | socket ':5001' 9 | action 'install' 10 | end 11 | 12 | psgi_application 'test twiggy application' do 13 | application_user 'psgi-twiggy-user' 14 | application_home '/tmp/psgi/twiggy' 15 | script 'app.psgi' 16 | action 'test' 17 | end 18 | 19 | service 'twiggy-psgi' do 20 | action :restart 21 | provider node[:psgi][:service][:provider] 22 | end 23 | 24 | 25 | service 'twiggy-psgi' do 26 | action :start 27 | provider node[:psgi][:service][:provider] 28 | end 29 | 30 | -------------------------------------------------------------------------------- /nginx-fastcgi/features/install_site/set-fastcgi_intercept_errors.feature: -------------------------------------------------------------------------------- 1 | Feature: nginx-fastcgi should be able to set additional fastcgi params 2 | 3 | Scenario: install nginx site config 4 | Given I run 'rm -rf /tmp/foo.site.conf' 5 | Then a file named '/tmp/foo.site.conf' should not exist 6 | And I have chef recipe: 7 | """ 8 | nginx_fastcgi '/tmp/foo.site.conf' do 9 | socket '/tmp/application.socket' 10 | servers [ 11 | { 12 | :server_name => 'foo.site.x', 13 | } 14 | ] 15 | fastcgi_intercept_errors true 16 | end 17 | """ 18 | When I run chef recipe on my node 19 | Then a file named '/tmp/foo.site.conf' should exist 20 | And a file named '/tmp/foo.site.conf' should contain 'fastcgi_intercept_errors on;' only '1' time 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /nginx-fastcgi/features/steps/shef.rb: -------------------------------------------------------------------------------- 1 | Given /^I have chef recipe:$/ do |resource| 2 | resource.gsub! "'", '"' 3 | `(echo 'recipe'; echo '#{resource}'; echo 'run_chef' ) > #{cache_dir}/shef.cmd` 4 | end 5 | 6 | Given /^I run chef recipe on my node$/ do 7 | cmd = "cat #{cache_dir}/shef.cmd | " 8 | 9 | if before_cmd.nil? 10 | cmd << "shef -z -c ~/etc/chef/client.rb" 11 | else 12 | cmd << "(#{before_cmd}; shef -z -c ~/etc/chef/client.rb)" 13 | end 14 | 15 | puts cmd if ENV['debug'] 16 | 17 | step "I run '#{cmd}'" 18 | end 19 | 20 | Given /^I run command (.*) on my node$/ do |cmd| 21 | set_before_cmd cmd 22 | end 23 | 24 | Then /^web_application resource should have following parameters:$/ do |table| 25 | table.hashes.each do |row| 26 | k = row['Name'] 27 | v = row['Value'] 28 | step "'stdout' should have '#{k}:\"#{v}\"'" 29 | end 30 | end 31 | -------------------------------------------------------------------------------- /nginx-fastcgi/features/install_site/with-alternative-fastcgi-location.feature: -------------------------------------------------------------------------------- 1 | Feature: nginx-fastcgi should be able to set alternative fastcgi location 2 | 3 | Scenario: install nginx site config 4 | Given I run 'rm -rf /tmp/foo.site.conf' 5 | Then a file named '/tmp/foo.site.conf' should not exist 6 | And I have chef recipe: 7 | """ 8 | nginx_fastcgi '/tmp/foo.site.conf' do 9 | servers [ 10 | { 11 | :ip => '127.0.0.1', 12 | :server_name => 'foo.site.x', 13 | :location => '=~ foo-bar ' 14 | } 15 | ] 16 | socket '/tmp/application.socket' 17 | end 18 | """ 19 | When I run chef recipe on my node 20 | Then a file named '/tmp/foo.site.conf' should exist 21 | And a file named '/tmp/foo.site.conf' should contain 'location =~ foo-bar' 22 | 23 | 24 | -------------------------------------------------------------------------------- /psgi/test/recipes/run-starman-app.rb: -------------------------------------------------------------------------------- 1 | psgi_application 'psgi starman application' do 2 | server 'Starman' 3 | enable_service 'off' 4 | application_user 'psgi-starman-user' 5 | application_home '/tmp/psgi/starman' 6 | script 'app.psgi' 7 | daemon_name 'starman-psgi' 8 | socket ':5000' 9 | nproc '2' 10 | action 'install' 11 | end 12 | 13 | psgi_application 'test starman application' do 14 | application_user 'psgi-starman-user' 15 | application_home '/tmp/psgi/starman' 16 | script 'app.psgi' 17 | action 'test' 18 | end 19 | 20 | service 'starman-psgi' do 21 | action :restart 22 | provider node[:psgi][:service][:provider] 23 | end 24 | 25 | service 'starman-psgi' do 26 | action :start 27 | provider node[:psgi][:service][:provider] 28 | end 29 | 30 | 31 | -------------------------------------------------------------------------------- /pinto/attributes/default.rb: -------------------------------------------------------------------------------- 1 | default.pinto.user = 'pinto' 2 | default.pinto.group = 'pinto' 3 | default.pinto.user_shell = '/bin/bash' 4 | 5 | default.pinto.installer_url = 'http://getpinto.stratopan.com' 6 | 7 | default.pinto.cpanminus_url = 'http://xrl.us/cpanm' 8 | 9 | default.pinto.packages = %w[ curl ] 10 | 11 | case platform 12 | when 'centos' 13 | default.pinto.packages << 'zlib-devel' 14 | default.pinto.packages << 'perl-devel' 15 | when 'ubuntu' 16 | default.pinto.packages << 'make' 17 | when 'debian' 18 | default.pinto.packages << 'make' 19 | end 20 | 21 | 22 | default.pinto.server.host = '0.0.0.0' 23 | default.pinto.server.port = '3111' 24 | default.pinto.server.workers = '3' 25 | 26 | 27 | # these are 'non-public' attributes: 28 | 29 | default.pinto.slow_tests = '0'# is used in mini tests only 30 | default.pinto.version = '0.094' # is used in mini tests only 31 | 32 | -------------------------------------------------------------------------------- /pinto/pinto_repos_managed_by_chef.txt: -------------------------------------------------------------------------------- 1 | 13:29 melezhik Hi Jeffrey! How r u? 2 | 13:30 melezhik How it's going with pinto? 3 | 14:38 melezhik Just one idea about pinto. May be it makes a sense , may be not. What about automatic deploy of pinto repositories? Let's say we have a certain pinto repository on given host and we want to distribute this repository (the same stacks, modules, pins etc) to another host? 4 | 14:41 melezhik Or another use case. Let's say we have described pinto repo structure (stacks, modules, pins) and we want to apply this "pinto environment" to multiple hosts. For example when developing things ... share the same environment b/w developers is make a sense. 5 | 14:42 melezhik If these use case are real, this is where chef may help, because it's about repeating infrastructures and storing them as code, making available to re-apply them as many time as we need. 6 | 14:43 melezhik Just my thoughts , what do you think about it? 7 | -------------------------------------------------------------------------------- /psgi/test/recipes/run-fcgi-app.rb: -------------------------------------------------------------------------------- 1 | psgi_application 'psgi fcgi application' do 2 | operator 'Catalyst' 3 | enable_service 'off' 4 | application_user 'psgi-fcgi-user' 5 | application_home '/tmp/psgi/fcgi' 6 | script 'app.psgi' 7 | proc_title 'app' 8 | nproc '2' 9 | proc_manager 'FCGI::ProcManager' 10 | config '/tmp/psgi/fcgi/app.conf' 11 | action 'install' 12 | end 13 | 14 | psgi_application 'test fcgi application' do 15 | application_user 'psgi-fcgi-user' 16 | application_home '/tmp/psgi/fcgi' 17 | script 'app.psgi' 18 | action 'test' 19 | end 20 | 21 | service 'app' do 22 | action :restart 23 | provider node[:psgi][:service][:provider] 24 | end 25 | 26 | service 'app' do 27 | action :start 28 | provider node[:psgi][:service][:provider] 29 | end 30 | 31 | 32 | -------------------------------------------------------------------------------- /nginx-fastcgi/features/install_site/log_file_paths.feature: -------------------------------------------------------------------------------- 1 | Feature: nginx-fastcgi should create proper log/error_log files paths 2 | 3 | Scenario: install nginx site config 4 | Given I run 'rm -rf /tmp/my.site.conf' 5 | Then a file named '/tmp/my.site.conf' should not exist 6 | And I have chef recipe: 7 | """ 8 | nginx_fastcgi '/tmp/my.site.conf' do 9 | servers [ 10 | { 11 | :ip => '127.0.0.1', 12 | :server_name => 'foo.site.x' 13 | } 14 | ] 15 | socket '/tmp/application.socket' 16 | end 17 | """ 18 | When I run chef recipe on my node 19 | Then a file named '/tmp/my.site.conf' should exist 20 | And a file named '/tmp/my.site.conf' should contain 'access_log /var/log/nginx/my.site.access.log;' 21 | And a file named '/tmp/my.site.conf' should contain 'error_log /var/log/nginx/my.site.error.log;' 22 | -------------------------------------------------------------------------------- /cpan/resources/client.rb: -------------------------------------------------------------------------------- 1 | actions :install, :test, :reload_cpan_index 2 | attribute :cpan_home, :kind_of => String 3 | attribute :cwd , :kind_of => String, :default => '/tmp/' 4 | attribute :dry_run, :kind_of => [TrueClass, FalseClass], :default => false 5 | attribute :environment , :kind_of => Hash, :default => Hash.new 6 | attribute :force, :kind_of => [TrueClass, FalseClass], :default => false 7 | attribute :from_cookbook, :kind_of => String 8 | attribute :group , :kind_of => String 9 | attribute :inc, :default => [], :kind_of => Array 10 | attribute :install_base, :kind_of => String 11 | attribute :install_path, :default => [], :kind_of => Array 12 | attribute :install_type, :kind_of => String, :default => 'application' 13 | attribute :module_name , :kind_of => String 14 | attribute :name , :kind_of => String 15 | attribute :reload_cpan_index, :kind_of => [TrueClass, FalseClass], :default => false 16 | attribute :user , :kind_of => String 17 | attribute :version , :kind_of => String 18 | 19 | -------------------------------------------------------------------------------- /nginx-fastcgi/features/install_site/with-additional-fastcgi-params.feature: -------------------------------------------------------------------------------- 1 | Feature: nginx-fastcgi should be able to set additional fastcgi params 2 | 3 | Scenario: install nginx site config 4 | Given I run 'rm -rf /tmp/foo.site.conf' 5 | Then a file named '/tmp/foo.site.conf' should not exist 6 | And I have chef recipe: 7 | """ 8 | nginx_fastcgi '/tmp/foo.site.conf' do 9 | socket '/tmp/application.socket' 10 | fastcgi_param [ 11 | { :name => 'SCRIPT_NAME', :value => "\"\"" }, 12 | { :name => 'PATH_INFO' , :value => '$uri' } 13 | ] 14 | servers [ 15 | { 16 | :server_name => 'foo.site.x', 17 | } 18 | ] 19 | end 20 | """ 21 | When I run chef recipe on my node 22 | Then a file named '/tmp/foo.site.conf' should exist 23 | And a file named '/tmp/foo.site.conf' should contain 'fastcgi_param SCRIPT_NAME "";' 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /nginx-fastcgi/features/install_site/with-static-files.feature: -------------------------------------------------------------------------------- 1 | Feature: nginx-fastcgi should be able to set static files location 2 | 3 | Scenario: install nginx site config 4 | Given I run 'rm -rf /tmp/foo.site.conf' 5 | Then a file named '/tmp/foo.site.conf' should not exist 6 | And I have chef recipe: 7 | """ 8 | nginx_fastcgi '/tmp/foo.site.conf' do 9 | socket '/tmp/application.socket' 10 | static( 11 | :location => 'static/', 12 | :root => '/var/www/foo/bar/baz/' 13 | ) 14 | servers [ 15 | { 16 | :server_name => 'foo.site.x', 17 | } 18 | ] 19 | end 20 | """ 21 | When I run chef recipe on my node 22 | Then a file named '/tmp/foo.site.conf' should exist 23 | And a file named '/tmp/foo.site.conf' should contain 'root \/var\/www\/foo\/bar\/baz\/;' 24 | And a file named '/tmp/foo.site.conf' should contain 'location static\/ \{' 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /nginx-fastcgi/changes.md: -------------------------------------------------------------------------------- 1 | 0.0.11 2 | === 3 | - bug fix : duplicate fastcgi_intercept_errors 4 | 5 | 0.0.10 6 | === 7 | - support for inet sockets (https://github.com/melezhik/cookbooks/issues/4) 8 | 9 | 0.0.9 10 | === 11 | - new parameter `fastcgi_read_timeout` 12 | 13 | 0.0.8 14 | === 15 | - new parameter - `error_page` 16 | - new parameter `fastcgi_intercept_errors` 17 | - `static` may be an Array 18 | 19 | 0.0.7 20 | === 21 | now nginx site config mode is `0664` 22 | 23 | 0.0.6 24 | === 25 | now `ssl;` is appended for ssl enabled ips according to http://nginx.org/ru/docs/http/ngx_http_core_module.html#listen 26 | 27 | 0.0.5 28 | === 29 | - changes in interface: 30 | - new parameters: 31 | - `fastcgi_param` 32 | - `root` 33 | - removed parameters: 34 | - `:expire` 35 | - modified parameters: 36 | - `static` is not array now and not in servers list 37 | 38 | 0.0.4 39 | === 40 | - now one may set alternative location for fastcgi application, default one is '/' 41 | 42 | 0.0.3 43 | === 44 | - handling empty ips 45 | 46 | 0.0.2 47 | === 48 | - bug fix for 'fastcgi_param HTTPS on;' in template 49 | -------------------------------------------------------------------------------- /catalyst-fastcgi/attributes/default.rb: -------------------------------------------------------------------------------- 1 | default.catalyst_fastcgi.service_name 'foo' 2 | default.catalyst_fastcgi.server_name 'foo.x' 3 | default.catalyst_fastcgi.server_alias [] 4 | 5 | default.catalyst_fastcgi.application.user = 'foo' 6 | default.catalyst_fastcgi.application.group = 'foo' 7 | default.catalyst_fastcgi.application.home = '/tmp/foo' 8 | default.catalyst_fastcgi.application.script = 'foo_fastcgi.pl' 9 | default.catalyst_fastcgi.application.perl5lib = [] 10 | 11 | default.catalyst_fastcgi.catalyst_config = '/tmp/foo/foo.conf' 12 | default.catalyst_fastcgi.socket = '/tmp/foo.socket' 13 | default.catalyst_fastcgi.envvars = { :CATALYST_DEBUG => 1 } 14 | default.catalyst_fastcgi.nproc = 2 15 | default.catalyst_fastcgi.proc_manager = 'FCGI::ProcManager' 16 | 17 | default.catalyst_fastcgi.apache.access_log = nil 18 | default.catalyst_fastcgi.apache.error_log = nil 19 | 20 | 21 | default.catalyst_fastcgi.start_service = false 22 | 23 | default.catalyst_fastcgi.ssl = false 24 | default.catalyst_fastcgi.ssl_cipher_suite = nil 25 | default.catalyst_fastcgi.ssl_certificate_file = nil 26 | default.catalyst_fastcgi.ssl_certificate_key_file = nil 27 | 28 | 29 | -------------------------------------------------------------------------------- /pinto/templates/centos/init.erb: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # chkconfig: 345 80 20 3 | # description: Pinto server daemon 4 | 5 | . /etc/init.d/functions 6 | 7 | PIDFILE=/var/run/pintod.pid 8 | 9 | start() { 10 | echo -n Starting Pinto server: 11 | export PERL5LIB=PERL5LIB:<%= @home %>/lib/perl5 12 | export PATH=$PATH:<%= @home %>/bin/ 13 | pintod --daemonize --pid $PIDFILE --root <%= @repo_root %> --server Starman --workers <%= @workers %> --host <%= @host %> --port <%= @port %> --user <%= @user %> --group <%= @group %> --access-log /var/log/pintod.log 14 | retval=$? 15 | echo 16 | [ "$retval" = 0 ] && touch /var/lock/subsys/pintod 17 | return $retval 18 | } 19 | 20 | stop() { 21 | echo -n Stopping Pinto server: 22 | killproc -p $PIDFILE pintod 23 | retval=$? 24 | echo 25 | [ "$retval" = 0 ] && rm -f /var/lock/subsys/pintod 26 | return $retval 27 | } 28 | 29 | case "$1" in 30 | start) 31 | start 32 | ;; 33 | stop) 34 | stop 35 | ;; 36 | status) 37 | status -p $PIDFILE pintod 38 | ;; 39 | restart) 40 | stop 41 | start 42 | ;; 43 | *) 44 | echo "Usage: pintod {start|stop|status|restart}" 45 | exit 1 46 | ;; 47 | esac 48 | 49 | exit 0 50 | -------------------------------------------------------------------------------- /pinto/recipes/server.rb: -------------------------------------------------------------------------------- 1 | class Chef::Recipe 2 | include PintoLibrary 3 | end 4 | 5 | pinto_home = pinto_home() 6 | repo_root = repo_root() 7 | 8 | log "pinto_home: #{pinto_home}" 9 | log "repo_root: #{repo_root}" 10 | 11 | 12 | template '/etc/init.d/pintod' do 13 | owner 'root' 14 | group 'root' 15 | source 'init.erb' 16 | variables({ 17 | :home => pinto_home, 18 | :workers => node.pinto.server.workers, 19 | :host => node.pinto.server.host, 20 | :port => node.pinto.server.port, 21 | :user => node.pinto.user, 22 | :group => node.pinto.group, 23 | :repo_root => repo_root 24 | }) 25 | mode '755' 26 | notifies :restart, "service[pintod]", :delayed 27 | end 28 | 29 | 30 | log 'init pinto repo' 31 | 32 | execute "bash -c 'source #{pinto_home}/etc/bashrc; pinto -r #{repo_root} init'" do 33 | user node[:pinto][:user] 34 | group node[:pinto][:group] 35 | not_if { ::File.exists? repo_root } 36 | notifies :restart, "service[pintod]", :delayed 37 | end 38 | 39 | service 'pintod' do 40 | action :start 41 | end 42 | 43 | 44 | service 'pintod' do 45 | action :enable 46 | end 47 | 48 | -------------------------------------------------------------------------------- /nginx-fastcgi/features/install_site/with-error-page.feature: -------------------------------------------------------------------------------- 1 | Feature: nginx-fastcgi should be able to set error_page parameter 2 | 3 | Scenario: install nginx site config with error_page 4 | Given I run 'rm -rf /tmp/foo.site.conf' 5 | Then a file named '/tmp/foo.site.conf' should not exist 6 | And I have chef recipe: 7 | """ 8 | nginx_fastcgi '/tmp/foo.site.conf' do 9 | servers [ 10 | { 11 | :server_name => 'foo.site.x' 12 | } 13 | ] 14 | socket '/tmp/application.socket' 15 | error_page [ 16 | { 17 | :code => 400, 18 | :handler => '/400.html' 19 | }, 20 | { 21 | :code => 500, 22 | :handler => '/500.html' 23 | } 24 | ] 25 | end 26 | """ 27 | When I run chef recipe on my node 28 | Then a file named '/tmp/foo.site.conf' should exist 29 | And a file named '/tmp/foo.site.conf' should contain 'error_page 400 /400.html;' 30 | And a file named '/tmp/foo.site.conf' should contain 'error_page 500 /500.html;' 31 | 32 | 33 | -------------------------------------------------------------------------------- /psgi/test/files/default/tests/minitest/run-starman-app_test.rb: -------------------------------------------------------------------------------- 1 | class PsgiSpec < MiniTest::Chef::Spec 2 | 3 | describe 'installs and runs psgi application as starman server' do 4 | 5 | it 'creates init script file' do 6 | file_path = "#{node[:psgi][:install][:dir]}/starman-psgi#{node[:psgi][:install][:extention]}" 7 | file(file_path).must_exist 8 | file(file_path).must_have(:owner,"root") 9 | file(file_path).must_have(:group,"root") 10 | file(file_path).must_have(:mode,"755") 11 | 12 | end 13 | 14 | it 'CGI script returns 200 OK and Hello World' do 15 | result = assert_sh("sudo bash -c 'cd /tmp/psgi/starman && SERVER_PORT=80 SERVER_NAME=127.0.0.1 SCRIPT_NAME=/ REQUEST_METHOD=GET /usr/local/bin/plackup -s CGI app.psgi'") 16 | assert_includes result, 'Status: 200' 17 | assert_includes result, 'Hello World' 18 | end 19 | 20 | it 'runs server' do 21 | 22 | result = assert_sh('ps -u psgi-starman-user --no-headers | wc -l') 23 | assert_includes result, '3' 24 | 25 | end 26 | 27 | it 'application index page returns Hello World' do 28 | result = assert_sh("curl 127.0.0.1:5000") 29 | assert_includes result, 'Hello World' 30 | end 31 | 32 | end 33 | end 34 | -------------------------------------------------------------------------------- /psgi/test/files/default/tests/minitest/run-twiggy-app_test.rb: -------------------------------------------------------------------------------- 1 | class PsgiSpec < MiniTest::Chef::Spec 2 | 3 | describe 'installs and runs psgi application as starman server' do 4 | 5 | it 'creates init script file' do 6 | file_path = "#{node[:psgi][:install][:dir]}/twiggy-psgi#{node[:psgi][:install][:extention]}" 7 | file(file_path).must_exist 8 | file(file_path).must_have(:owner,"root") 9 | file(file_path).must_have(:group,"root") 10 | file(file_path).must_have(:mode,"755") 11 | 12 | 13 | end 14 | 15 | it 'CGI script returns 200 OK and Hello World' do 16 | result = assert_sh("sudo bash -c 'cd /tmp/psgi/twiggy && SERVER_PORT=80 SERVER_NAME=127.0.0.1 SCRIPT_NAME=/ REQUEST_METHOD=GET /usr/local/bin/plackup -s CGI app.psgi'") 17 | assert_includes result, 'Status: 200' 18 | assert_includes result, 'Hello World' 19 | end 20 | it 'runs server' do 21 | 22 | result = assert_sh('ps -u psgi-twiggy-user --no-headers | wc -l') 23 | assert_includes result, '1' 24 | 25 | end 26 | 27 | 28 | it 'application index page returns Hello World' do 29 | result = assert_sh("curl 127.0.0.1:5001") 30 | assert_includes result, 'Hello World' 31 | end 32 | 33 | end 34 | end 35 | -------------------------------------------------------------------------------- /nginx-fastcgi/features/install_site/http_to_https_redirect.feature: -------------------------------------------------------------------------------- 1 | Feature: nginx-fastcgi should be able to install ssl enabled nginx site config 2 | 3 | Backgound: delete old configs 4 | Given I run 'rm -rf /tmp/foo.site.conf' 5 | Then a file named '/tmp/foo.site.conf' should not exist 6 | 7 | Scenario: install nginx ssl site config 8 | And I have chef recipe: 9 | """ 10 | nginx_fastcgi '/tmp/foo.site.conf' do 11 | servers [ 12 | { 13 | :ip => '127.0.0.1', 14 | :server_name => 'bar.site.x', 15 | :redirect => 'https' 16 | }, 17 | { 18 | :ip => '127.0.0.1', 19 | :server_name => 'bar.site.x', 20 | :ssl => true, 21 | :ssl_include_path => 'nginx_ssl_settings.conf' 22 | 23 | } 24 | ] 25 | socket '/tmp/application.socket' 26 | end 27 | """ 28 | When I run chef recipe on my node 29 | Then a file named '/tmp/foo.site.conf' should exist 30 | And a file named '/tmp/foo.site.conf' should contain 'rewrite \^ https://\$server_name\$request_uri\? permanent' 31 | 32 | 33 | -------------------------------------------------------------------------------- /catalyst/templates/gentoo/catalyst_application.erb: -------------------------------------------------------------------------------- 1 | # 2 | # don't edit manually, any changes will be replaced by chef 3 | # 4 | 5 | # OBLIGATORY PARAMETERS 6 | # home dir for your catalyst application 7 | APPLICATION_HOME="<%= @application_home %>" 8 | 9 | # application will be run under user APPLICATION_USER: 10 | APPLICATION_USER=<%= @application_user %> 11 | 12 | # name of script, willbe looked in $APPLICATION_HOME/script/ 13 | SCRIPT="<%= @application_script %>" 14 | 15 | # path to config application 16 | # could be overriden by MYAPP_CONFIG env var, see Catalyst::Plugin::ConfigLoader for details 17 | CATALYST_CONFIG="<%= @catalyst_config %>" 18 | 19 | # OPTIONS 20 | <%- unless @socket.nil? %> 21 | SOCKET="<%= @socket %>" 22 | <%- end %> 23 | 24 | <%- unless @nproc.nil? %> 25 | # number or child fastcgi processes 26 | NPROC="<%= @nproc %>" 27 | <%- end %> 28 | 29 | <%- unless @perl5lib.empty? %> 30 | PERL5LIB="<%= @perl5lib.join(':') %>" 31 | <%- end %> 32 | 33 | <%- unless @proc_manager.nil? %> 34 | PROC_MANAGER="<%= @proc_manager %>" 35 | <%- end %> 36 | 37 | <%- unless @envvars.keys.empty? %> 38 | <%- vars = [] %> 39 | <%- @envvars.each do |k,v| %> 40 | <%- vars << "#{k}=#{v}" %> 41 | <%- end %> 42 | ENVVARS='<%= vars.join(" ") %>' 43 | <%- end %> 44 | 45 | -------------------------------------------------------------------------------- /psgi/test/files/default/tests/minitest/run-fcgi-app_test.rb: -------------------------------------------------------------------------------- 1 | class PsgiSpec < MiniTest::Chef::Spec 2 | 3 | describe 'installs and runs psgi application as fcgi server' do 4 | it 'creates init script file' do 5 | file_path = "#{node[:psgi][:install][:dir]}/app#{node[:psgi][:install][:extention]}" 6 | file(file_path).must_exist 7 | file(file_path).must_have(:owner,"root") 8 | file(file_path).must_have(:group,"root") 9 | file(file_path).must_have(:mode,"755") 10 | 11 | end 12 | 13 | it 'CGI script returns 200 OK and Hello World' do 14 | result = assert_sh("sudo bash -c 'cd /tmp/psgi/fcgi && SERVER_PORT=80 SERVER_NAME=127.0.0.1 SCRIPT_NAME=/ REQUEST_METHOD=GET /usr/local/bin/plackup -s CGI app.psgi'") 15 | assert_includes result, 'Status: 200' 16 | assert_includes result, 'Hello World' 17 | end 18 | 19 | it 'runs server' do 20 | 21 | result = assert_sh('ps -u psgi-fcgi-user --no-headers | wc -l') 22 | assert_includes result, '3' 23 | 24 | assert_sh("stat /tmp/app_fcgi.socket") 25 | 26 | end 27 | 28 | it 'application index page returns Hello World' do 29 | result = assert_sh("curl 127.0.0.1:8888") 30 | assert_includes result, 'Hello World' 31 | end 32 | 33 | end 34 | end 35 | -------------------------------------------------------------------------------- /nginx-fastcgi/features/install_site/with-many-static-files.feature: -------------------------------------------------------------------------------- 1 | Feature: nginx-fastcgi should be able to set static files locations 2 | 3 | Scenario: install nginx site config 4 | Given I run 'rm -rf /tmp/foo.site.conf' 5 | Then a file named '/tmp/foo.site.conf' should not exist 6 | And I have chef recipe: 7 | """ 8 | nginx_fastcgi '/tmp/foo.site.conf' do 9 | socket '/tmp/application.socket' 10 | static [ 11 | { 12 | :location => 'static/foo', 13 | :root => '/var/www/foo' 14 | }, 15 | { 16 | :location => 'static/bar', 17 | :root => '/var/www/bar' 18 | } 19 | ] 20 | servers [ 21 | { 22 | :server_name => 'foo.site.x', 23 | } 24 | ] 25 | end 26 | """ 27 | When I run chef recipe on my node 28 | Then a file named '/tmp/foo.site.conf' should exist 29 | And a file named '/tmp/foo.site.conf' should contain 'root \/var\/www\/foo;' 30 | And a file named '/tmp/foo.site.conf' should contain 'root \/var\/www\/bar;' 31 | And a file named '/tmp/foo.site.conf' should contain 'root' only '2' times 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /catalyst-fastcgi/recipes/default.rb: -------------------------------------------------------------------------------- 1 | catalyst_application node.catalyst_fastcgi.service_name do 2 | application_user node.catalyst_fastcgi.application.user 3 | application_group node.catalyst_fastcgi.application.group 4 | application_home node.catalyst_fastcgi.application.home 5 | application_script node.catalyst_fastcgi.application.script 6 | catalyst_config node.catalyst_fastcgi.catalyst_config 7 | socket node.catalyst_fastcgi.socket 8 | envvars node.catalyst_fastcgi.envvars 9 | perl5lib node.catalyst_fastcgi.application.perl5lib 10 | nproc node.catalyst_fastcgi.nproc 11 | proc_manager node.catalyst_fastcgi.proc_manager 12 | start_service node.catalyst_fastcgi.start_service 13 | action 'install' 14 | end 15 | 16 | apache_fastcgi node.catalyst_fastcgi.service_name do 17 | server_name node.catalyst_fastcgi.server_name 18 | server_alias node.catalyst_fastcgi.server_alias 19 | socket node.catalyst_fastcgi.socket 20 | access_log node.catalyst_fastcgi.apache.access_log 21 | error_log node.catalyst_fastcgi.apache.error_log 22 | ssl node.catalyst_fastcgi.ssl 23 | ssl_cipher_suite node.catalyst_fastcgi.ssl_cipher_suite 24 | ssl_certificate_file node.catalyst_fastcgi.ssl_certificate_file 25 | ssl_certificate_key_file node.catalyst_fastcgi.ssl_certificate_key_file 26 | action 'install' 27 | end 28 | 29 | -------------------------------------------------------------------------------- /cpan/chefignore: -------------------------------------------------------------------------------- 1 | # Put files/directories that should be ignored in this file when uploading 2 | # or sharing to the community site. 3 | # Lines that start with '# ' are comments. 4 | 5 | # OS generated files # 6 | ###################### 7 | .DS_Store 8 | Icon? 9 | nohup.out 10 | ehthumbs.db 11 | Thumbs.db 12 | 13 | # SASS # 14 | ######## 15 | .sass-cache 16 | 17 | # EDITORS # 18 | ########### 19 | \#* 20 | .#* 21 | *~ 22 | *.sw[a-z] 23 | *.bak 24 | REVISION 25 | TAGS* 26 | tmtags 27 | *_flymake.* 28 | *_flymake 29 | *.tmproj 30 | .project 31 | .settings 32 | mkmf.log 33 | 34 | ## COMPILED ## 35 | ############## 36 | a.out 37 | *.o 38 | *.pyc 39 | *.so 40 | *.com 41 | *.class 42 | *.dll 43 | *.exe 44 | */rdoc/ 45 | 46 | # Testing # 47 | ########### 48 | .watchr 49 | .rspec 50 | spec/* 51 | spec/fixtures/* 52 | test/* 53 | features/* 54 | Guardfile 55 | Procfile 56 | 57 | # SCM # 58 | ####### 59 | .git 60 | */.git 61 | .gitignore 62 | .gitmodules 63 | .gitconfig 64 | .gitattributes 65 | .svn 66 | */.bzr/* 67 | */.hg/* 68 | */.svn/* 69 | 70 | # Berkshelf # 71 | ############# 72 | Berksfile 73 | Berksfile.lock 74 | cookbooks/* 75 | tmp 76 | 77 | # Cookbooks # 78 | ############# 79 | CONTRIBUTING 80 | CHANGELOG* 81 | 82 | # Strainer # 83 | ############ 84 | Colanderfile 85 | Strainerfile 86 | .colander 87 | .strainer 88 | 89 | # Vagrant # 90 | ########### 91 | .vagrant 92 | Vagrantfile 93 | 94 | # Travis # 95 | ########## 96 | .travis.yml 97 | -------------------------------------------------------------------------------- /pinto/chefignore: -------------------------------------------------------------------------------- 1 | # Put files/directories that should be ignored in this file when uploading 2 | # or sharing to the community site. 3 | # Lines that start with '# ' are comments. 4 | 5 | # OS generated files # 6 | ###################### 7 | .DS_Store 8 | Icon? 9 | nohup.out 10 | ehthumbs.db 11 | Thumbs.db 12 | 13 | # SASS # 14 | ######## 15 | .sass-cache 16 | 17 | # EDITORS # 18 | ########### 19 | \#* 20 | .#* 21 | *~ 22 | *.sw[a-z] 23 | *.bak 24 | REVISION 25 | TAGS* 26 | tmtags 27 | *_flymake.* 28 | *_flymake 29 | *.tmproj 30 | .project 31 | .settings 32 | mkmf.log 33 | 34 | ## COMPILED ## 35 | ############## 36 | a.out 37 | *.o 38 | *.pyc 39 | *.so 40 | *.com 41 | *.class 42 | *.dll 43 | *.exe 44 | */rdoc/ 45 | 46 | # Testing # 47 | ########### 48 | .watchr 49 | .rspec 50 | spec/* 51 | spec/fixtures/* 52 | test/* 53 | features/* 54 | Guardfile 55 | Procfile 56 | 57 | # SCM # 58 | ####### 59 | .git 60 | */.git 61 | .gitignore 62 | .gitmodules 63 | .gitconfig 64 | .gitattributes 65 | .svn 66 | */.bzr/* 67 | */.hg/* 68 | */.svn/* 69 | 70 | # Berkshelf # 71 | ############# 72 | Berksfile 73 | Berksfile.lock 74 | cookbooks/* 75 | tmp 76 | 77 | # Cookbooks # 78 | ############# 79 | CONTRIBUTING 80 | CHANGELOG* 81 | 82 | # Strainer # 83 | ############ 84 | Colanderfile 85 | Strainerfile 86 | .colander 87 | .strainer 88 | 89 | # Vagrant # 90 | ########### 91 | .vagrant 92 | Vagrantfile 93 | 94 | # Travis # 95 | ########## 96 | .travis.yml 97 | -------------------------------------------------------------------------------- /psgi/chefignore: -------------------------------------------------------------------------------- 1 | # Put files/directories that should be ignored in this file when uploading 2 | # or sharing to the community site. 3 | # Lines that start with '# ' are comments. 4 | 5 | # OS generated files # 6 | ###################### 7 | .DS_Store 8 | Icon? 9 | nohup.out 10 | ehthumbs.db 11 | Thumbs.db 12 | 13 | # SASS # 14 | ######## 15 | .sass-cache 16 | 17 | # EDITORS # 18 | ########### 19 | \#* 20 | .#* 21 | *~ 22 | *.sw[a-z] 23 | *.bak 24 | REVISION 25 | TAGS* 26 | tmtags 27 | *_flymake.* 28 | *_flymake 29 | *.tmproj 30 | .project 31 | .settings 32 | mkmf.log 33 | 34 | ## COMPILED ## 35 | ############## 36 | a.out 37 | *.o 38 | *.pyc 39 | *.so 40 | *.com 41 | *.class 42 | *.dll 43 | *.exe 44 | */rdoc/ 45 | 46 | # Testing # 47 | ########### 48 | .watchr 49 | .rspec 50 | spec/* 51 | spec/fixtures/* 52 | test/* 53 | features/* 54 | Guardfile 55 | Procfile 56 | 57 | # SCM # 58 | ####### 59 | .git 60 | */.git 61 | .gitignore 62 | .gitmodules 63 | .gitconfig 64 | .gitattributes 65 | .svn 66 | */.bzr/* 67 | */.hg/* 68 | */.svn/* 69 | 70 | # Berkshelf # 71 | ############# 72 | Berksfile 73 | Berksfile.lock 74 | cookbooks/* 75 | tmp 76 | 77 | # Cookbooks # 78 | ############# 79 | CONTRIBUTING 80 | CHANGELOG* 81 | 82 | # Strainer # 83 | ############ 84 | Colanderfile 85 | Strainerfile 86 | .colander 87 | .strainer 88 | 89 | # Vagrant # 90 | ########### 91 | .vagrant 92 | Vagrantfile 93 | 94 | # Travis # 95 | ########## 96 | .travis.yml 97 | -------------------------------------------------------------------------------- /cpanminus/chefignore: -------------------------------------------------------------------------------- 1 | # Put files/directories that should be ignored in this file when uploading 2 | # or sharing to the community site. 3 | # Lines that start with '# ' are comments. 4 | 5 | # OS generated files # 6 | ###################### 7 | .DS_Store 8 | Icon? 9 | nohup.out 10 | ehthumbs.db 11 | Thumbs.db 12 | 13 | # SASS # 14 | ######## 15 | .sass-cache 16 | 17 | # EDITORS # 18 | ########### 19 | \#* 20 | .#* 21 | *~ 22 | *.sw[a-z] 23 | *.bak 24 | REVISION 25 | TAGS* 26 | tmtags 27 | *_flymake.* 28 | *_flymake 29 | *.tmproj 30 | .project 31 | .settings 32 | mkmf.log 33 | 34 | ## COMPILED ## 35 | ############## 36 | a.out 37 | *.o 38 | *.pyc 39 | *.so 40 | *.com 41 | *.class 42 | *.dll 43 | *.exe 44 | */rdoc/ 45 | 46 | # Testing # 47 | ########### 48 | .watchr 49 | .rspec 50 | spec/* 51 | spec/fixtures/* 52 | test/* 53 | features/* 54 | Guardfile 55 | Procfile 56 | 57 | # SCM # 58 | ####### 59 | .git 60 | */.git 61 | .gitignore 62 | .gitmodules 63 | .gitconfig 64 | .gitattributes 65 | .svn 66 | */.bzr/* 67 | */.hg/* 68 | */.svn/* 69 | 70 | # Berkshelf # 71 | ############# 72 | Berksfile 73 | Berksfile.lock 74 | cookbooks/* 75 | tmp 76 | 77 | # Cookbooks # 78 | ############# 79 | CONTRIBUTING 80 | CHANGELOG* 81 | 82 | # Strainer # 83 | ############ 84 | Colanderfile 85 | Strainerfile 86 | .colander 87 | .strainer 88 | 89 | # Vagrant # 90 | ########### 91 | .vagrant 92 | Vagrantfile 93 | 94 | # Travis # 95 | ########## 96 | .travis.yml 97 | -------------------------------------------------------------------------------- /pinto/libraries/pinto_library.rb: -------------------------------------------------------------------------------- 1 | module PintoLibrary 2 | def pinto_home 3 | if node.pinto.user == 'root' 4 | pinto_home = '/opt/local/pinto' 5 | else 6 | pinto_home = "/home/#{node.pinto.user}/opt/local/pinto" 7 | end 8 | pinto_home 9 | end 10 | 11 | def pinto_sub_dirs 12 | if node.pinto.user == 'root' 13 | %w{ /opt /opt/local /opt/local/pinto /opt/local/pinto/bin /opt/local/pinto/misc /opt/local/pinto/misc/bin } 14 | else node.pinto.user == 'root' 15 | %w{ opt opt/local opt/local/pinto opt/local/pinto/bin opt/local/pinto/misc opt/local/pinto/misc/bin }.map do |d| 16 | "/home/#{node.pinto.user}/#{d}" 17 | end 18 | end 19 | end 20 | 21 | def create_pinto_sub_dirs 22 | log "create pinto_home sub directories" 23 | pinto_sub_dirs.each do |d| 24 | directory d do 25 | owner node.pinto.user 26 | group node.pinto.group 27 | end 28 | end 29 | end 30 | 31 | def repo_root 32 | 33 | if node.pinto.user == 'root' 34 | repo_root = '/opt/local/pinto/var/' 35 | else 36 | repo_root = "/home/#{node.pinto.user}/opt/local/pinto/var" 37 | end 38 | end 39 | 40 | def pinto_user_home 41 | node.pinto.user == 'root' ? nil : "/home/#{node.pinto.user}" 42 | end 43 | end 44 | 45 | -------------------------------------------------------------------------------- /nginx-fastcgi/features/install_site/without_ip_adress.feature: -------------------------------------------------------------------------------- 1 | Feature: nginx-fastcgi should be able to install nginx site config without ip adress 2 | 3 | Backgound: delete old configs 4 | Given I run 'rm -rf /tmp/foo.site.conf' 5 | Then a file named '/tmp/foo.site.conf' should not exist 6 | 7 | Scenario: install nginx site config, without ip adress 8 | And I have chef recipe: 9 | """ 10 | nginx_fastcgi '/tmp/foo.site.conf' do 11 | servers [ 12 | { 13 | :server_name => 'foo.site.x' 14 | } 15 | ] 16 | socket '/tmp/application.socket' 17 | end 18 | """ 19 | When I run chef recipe on my node 20 | Then a file named '/tmp/foo.site.conf' should exist 21 | And a file named '/tmp/foo.site.conf' should contain 'listen 80;' 22 | 23 | Scenario: install nginx https site config, without ip adress 24 | And I have chef recipe: 25 | """ 26 | nginx_fastcgi '/tmp/foo.site.conf' do 27 | servers [ 28 | { 29 | :server_name => 'foo.site.x', 30 | :ssl => true, 31 | :ssl_include_path => 'nginx_ssl_settings.conf' 32 | } 33 | ] 34 | socket '/tmp/application.socket' 35 | end 36 | """ 37 | When I run chef recipe on my node 38 | Then a file named '/tmp/foo.site.conf' should exist 39 | And a file named '/tmp/foo.site.conf' should contain 'listen 443 ssl;' 40 | 41 | -------------------------------------------------------------------------------- /nginx-fastcgi/features/install_site/pass_socket.feature: -------------------------------------------------------------------------------- 1 | Feature: nginx-fastcgi should be able to set unix/inet socket parameter 2 | 3 | Scenario: install nginx site config with inix socket 4 | Given I run 'rm -rf /tmp/foo.site.conf' 5 | Then a file named '/tmp/foo.site.conf' should not exist 6 | And I have chef recipe: 7 | """ 8 | nginx_fastcgi '/tmp/foo.site.conf' do 9 | servers [ 10 | { 11 | :ip => '127.0.0.1', 12 | :server_name => 'foo.site.x' 13 | } 14 | ] 15 | socket '/tmp/application.socket' 16 | end 17 | """ 18 | When I run chef recipe on my node 19 | Then a file named '/tmp/foo.site.conf' should exist 20 | And a file named '/tmp/foo.site.conf' should contain 'unix:/tmp/application.socket;' 21 | 22 | Scenario: install nginx site config with inet socket 23 | Given I run 'rm -rf /tmp/foo.site.conf' 24 | Then a file named '/tmp/foo.site.conf' should not exist 25 | And I have chef recipe: 26 | """ 27 | nginx_fastcgi '/tmp/foo.site.conf' do 28 | servers [ 29 | { 30 | :ip => '127.0.0.1', 31 | :server_name => 'foo.site.x' 32 | } 33 | ] 34 | inet_socket 'localhost:9000' 35 | end 36 | """ 37 | When I run chef recipe on my node 38 | Then a file named '/tmp/foo.site.conf' should exist 39 | And a file named '/tmp/foo.site.conf' should contain 'localhost:9000;' 40 | 41 | -------------------------------------------------------------------------------- /nginx-fastcgi/features/install_site/apply_default_settings.feature: -------------------------------------------------------------------------------- 1 | Feature: nginx-fastcgi should be able to apply default settings 2 | 3 | Backgound: delete old configs 4 | Given I run 'rm -rf /tmp/foo.site.conf' 5 | Then a file named '/tmp/foo.site.conf' should not exist 6 | 7 | Scenario: install nginx site config, default port is 80 8 | And I have chef recipe: 9 | """ 10 | nginx_fastcgi '/tmp/foo.site.conf' do 11 | servers [ 12 | { 13 | :ip => '127.0.0.1', 14 | :server_name => 'foo.site.x' 15 | } 16 | ] 17 | socket '/tmp/application.socket' 18 | end 19 | """ 20 | When I run chef recipe on my node 21 | Then a file named '/tmp/foo.site.conf' should exist 22 | And a file named '/tmp/foo.site.conf' should contain 'listen 127.0.0.1:80;' 23 | 24 | Scenario: install nginx ssl site config, default port is 443 25 | And I have chef recipe: 26 | """ 27 | nginx_fastcgi '/tmp/foo.site.conf' do 28 | servers [ 29 | { 30 | :ip => '127.0.0.1', 31 | :server_name => 'foo.site.x', 32 | :ssl => true, 33 | :ssl_include_path => 'nginx_ssl_settings.conf' 34 | } 35 | ] 36 | socket '/tmp/application.socket' 37 | end 38 | """ 39 | When I run chef recipe on my node 40 | Then a file named '/tmp/foo.site.conf' should exist 41 | Then a file named '/tmp/foo.site.conf' should contain 'listen 127.0.0.1:443 ssl;' 42 | 43 | -------------------------------------------------------------------------------- /nginx-fastcgi/features/install_site/ssl_enabled.feature: -------------------------------------------------------------------------------- 1 | Feature: nginx-fastcgi should be able to install ssl enabled nginx site config 2 | 3 | Backgound: delete old configs 4 | Given I run 'rm -rf /tmp/foo.site.conf' 5 | Then a file named '/tmp/foo.site.conf' should not exist 6 | 7 | Scenario: install nginx ssl site config 8 | And I have chef recipe: 9 | """ 10 | nginx_fastcgi '/tmp/foo.site.conf' do 11 | servers [ 12 | { 13 | :ip => '127.0.0.1', 14 | :server_name => 'foo.site.x', 15 | :ssl => true, 16 | :ssl_include_path => 'nginx_ssl_settings.conf' 17 | } 18 | ] 19 | socket '/tmp/application.socket' 20 | end 21 | """ 22 | When I run chef recipe on my node 23 | Then a file named '/tmp/foo.site.conf' should exist 24 | 25 | Scenario: install nginx ssl site config, non standart https port 26 | And I have chef recipe: 27 | """ 28 | nginx_fastcgi '/tmp/foo.site.conf' do 29 | servers [ 30 | { 31 | :ip => '127.0.0.1', 32 | :server_name => 'foo.site.x', 33 | :ssl => true, 34 | :port => 444, 35 | :ssl_include_path => 'nginx_ssl_settings.conf' 36 | } 37 | ] 38 | socket '/tmp/application.socket' 39 | end 40 | """ 41 | When I run chef recipe on my node 42 | Then a file named '/tmp/foo.site.conf' should exist 43 | Then a file named '/tmp/foo.site.conf' should contain 'listen 127.0.0.1:444 ssl;' 44 | -------------------------------------------------------------------------------- /pinto/files/default/tests/minitest/server_test.rb: -------------------------------------------------------------------------------- 1 | class PintoSpec < MiniTest::Chef::Spec 2 | 3 | include PintoLibrary 4 | 5 | describe 'installs pintod server' do 6 | 7 | it 'creates pinto repo directory' do 8 | directory(repo_root).must_exist.with(:owner, "#{node[:pinto][:user]}") 9 | directory(repo_root).must_exist.with(:group, "#{node[:pinto][:group]}") 10 | end 11 | 12 | it 'creates pintod init script' do 13 | file('/etc/init.d/pintod').must_exist.with(:owner, 'root') 14 | file('/etc/init.d/pintod').must_exist.with(:group, 'root') 15 | file('/etc/init.d/pintod').must_have(:mode, "755") 16 | end 17 | 18 | it 'runs pintod server' do 19 | 20 | sleep 5 21 | result = assert_sh('/etc/init.d/pintod status') 22 | assert_includes result, 'is running' 23 | 24 | pid = `cat /var/run/pintod.pid`.chomp! 25 | result = assert_sh("ps --ppid #{pid} | wc -l") 26 | assert_includes result, (node[:pinto][:server][:workers].to_i + 1).to_s 27 | 28 | result = assert_sh("curl -If http://#{node[:pinto][:server][:host]}:#{node[:pinto][:server][:port]}/modules/03modlist.data.gz") 29 | assert_includes result, ' 200 OK' 30 | end 31 | 32 | it 'multiple start should not increase number of child processes'do 33 | (1..3).each do |i| 34 | assert('/etc/init.d/pintod start') 35 | end 36 | result = assert_sh('ps aux | grep pinto | grep starman | grep worker | grep -v grep | wc -l') 37 | assert_includes result, node[:pinto][:server][:workers] 38 | end 39 | end 40 | end 41 | 42 | -------------------------------------------------------------------------------- /cpan/test/README.md: -------------------------------------------------------------------------------- 1 | test Cookbook 2 | ============= 3 | TODO: Enter the cookbook description here. 4 | 5 | e.g. 6 | This cookbook makes your favorite breakfast sandwhich. 7 | 8 | Requirements 9 | ------------ 10 | TODO: List your cookbook requirements. Be sure to include any requirements this cookbook has on platforms, libraries, other cookbooks, packages, operating systems, etc. 11 | 12 | e.g. 13 | #### packages 14 | - `toaster` - test needs toaster to brown your bagel. 15 | 16 | Attributes 17 | ---------- 18 | TODO: List you cookbook attributes here. 19 | 20 | e.g. 21 | #### test::default 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 |
KeyTypeDescriptionDefault
['test']['bacon']Booleanwhether to include bacontrue
36 | 37 | Usage 38 | ----- 39 | #### test::default 40 | TODO: Write usage instructions for each cookbook. 41 | 42 | e.g. 43 | Just include `test` in your node's `run_list`: 44 | 45 | ```json 46 | { 47 | "name":"my_node", 48 | "run_list": [ 49 | "recipe[test]" 50 | ] 51 | } 52 | ``` 53 | 54 | Contributing 55 | ------------ 56 | TODO: (optional) If this is a public cookbook, detail the process for contributing. If this is a private cookbook, remove this section. 57 | 58 | e.g. 59 | 1. Fork the repository on Github 60 | 2. Create a named feature branch (like `add_component_x`) 61 | 3. Write you change 62 | 4. Write tests for your change (if applicable) 63 | 5. Run the tests, ensuring they all pass 64 | 6. Submit a Pull Request using Github 65 | 66 | License and Authors 67 | ------------------- 68 | Authors: TODO: List authors 69 | -------------------------------------------------------------------------------- /psgi/test/README.md: -------------------------------------------------------------------------------- 1 | test Cookbook 2 | ============= 3 | TODO: Enter the cookbook description here. 4 | 5 | e.g. 6 | This cookbook makes your favorite breakfast sandwhich. 7 | 8 | Requirements 9 | ------------ 10 | TODO: List your cookbook requirements. Be sure to include any requirements this cookbook has on platforms, libraries, other cookbooks, packages, operating systems, etc. 11 | 12 | e.g. 13 | #### packages 14 | - `toaster` - test needs toaster to brown your bagel. 15 | 16 | Attributes 17 | ---------- 18 | TODO: List you cookbook attributes here. 19 | 20 | e.g. 21 | #### test::default 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 |
KeyTypeDescriptionDefault
['test']['bacon']Booleanwhether to include bacontrue
36 | 37 | Usage 38 | ----- 39 | #### test::default 40 | TODO: Write usage instructions for each cookbook. 41 | 42 | e.g. 43 | Just include `test` in your node's `run_list`: 44 | 45 | ```json 46 | { 47 | "name":"my_node", 48 | "run_list": [ 49 | "recipe[test]" 50 | ] 51 | } 52 | ``` 53 | 54 | Contributing 55 | ------------ 56 | TODO: (optional) If this is a public cookbook, detail the process for contributing. If this is a private cookbook, remove this section. 57 | 58 | e.g. 59 | 1. Fork the repository on Github 60 | 2. Create a named feature branch (like `add_component_x`) 61 | 3. Write you change 62 | 4. Write tests for your change (if applicable) 63 | 5. Run the tests, ensuring they all pass 64 | 6. Submit a Pull Request using Github 65 | 66 | License and Authors 67 | ------------------- 68 | Authors: TODO: List authors 69 | -------------------------------------------------------------------------------- /pinto/recipes/application.rb: -------------------------------------------------------------------------------- 1 | # installs Pinto application in standalone mode - see https://metacpan.org/module/THALJEF/Pinto-0.082/lib/Pinto/Manual/Installing.pod#___pod 2 | 3 | 4 | class Chef::Recipe 5 | include PintoLibrary 6 | end 7 | 8 | pinto_home = pinto_home() 9 | pinto_user_home = pinto_user_home() 10 | 11 | log "pinto_user_home: #{pinto_user_home}" 12 | log "pinto_home: #{pinto_home}" 13 | 14 | node.pinto.packages.each do |p| 15 | package p 16 | end 17 | 18 | unless node.pinto.user == 'root' 19 | group node.pinto.group 20 | user node.pinto.user do 21 | gid node.pinto.group 22 | supports :manage_home => true 23 | home pinto_user_home 24 | shell node.pinto.user_shell 25 | end 26 | end 27 | 28 | create_pinto_sub_dirs() 29 | 30 | case node.platform 31 | 32 | when 'centos' 33 | # on centos we need install some missed modules explicitelly 34 | # see https://github.com/thaljef/Pinto/issues/67 35 | 36 | log "Downloading the standalone executable cpanminus client from #{node.pinto.cpanminus_url}" 37 | 38 | remote_file "#{pinto_home}/misc/bin/cpanm" do 39 | source node.pinto.cpanminus_url 40 | user node.pinto.user 41 | group node.pinto.group 42 | mode '755' 43 | end 44 | 45 | execute "#{pinto_home}/misc/bin/cpanm --skip-satisfied --quiet Module::CoreList" 46 | 47 | end 48 | 49 | 50 | remote_file "#{pinto_home}/misc/bin/installer.sh" do 51 | source node.pinto.installer_url 52 | user node.pinto.user 53 | group node.pinto.group 54 | mode '755' 55 | end 56 | 57 | 58 | execute "cat #{pinto_home}/misc/bin/installer.sh | bash" do 59 | user node.pinto.user 60 | group node.pinto.group 61 | environment( { 'HOME' => pinto_user_home } ) 62 | end 63 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /psgi/test/recipes/bootstrap.rb: -------------------------------------------------------------------------------- 1 | include_recipe 'nginx' 2 | 3 | include_recipe 'cpan::bootstrap' 4 | 5 | package 'mc' 6 | 7 | cpan_client 'Plack' do 8 | install_type 'cpan_module' 9 | user 'root' 10 | group 'root' 11 | version node[:psgi][:plack][:version] 12 | action :install 13 | end 14 | 15 | cpan_client 'FCGI' do 16 | install_type 'cpan_module' 17 | user 'root' 18 | group 'root' 19 | action :install 20 | end 21 | 22 | cpan_client 'FCGI::ProcManager' do 23 | install_type 'cpan_module' 24 | user 'root' 25 | group 'root' 26 | action :install 27 | end 28 | 29 | cpan_client 'Starman' do 30 | install_type 'cpan_module' 31 | user 'root' 32 | group 'root' 33 | action :install 34 | force true 35 | end 36 | 37 | cpan_client 'Twiggy' do 38 | install_type 'cpan_module' 39 | user 'root' 40 | group 'root' 41 | force true 42 | action :install 43 | end 44 | 45 | directory '/tmp/psgi' do 46 | recursive true 47 | action :delete 48 | end 49 | 50 | %w{ app catalyst dancer default starman twiggy fcgi }.each do |id| 51 | 52 | user "psgi-#{id}-user" 53 | 54 | directory "/tmp/psgi/#{id}" do 55 | action :create 56 | owner "psgi-#{id}-user" 57 | recursive true 58 | end 59 | end 60 | 61 | %w{ starman twiggy fcgi }.each do |id| 62 | cookbook_file "/tmp/psgi/#{id}/app.psgi" do 63 | source 'test.psgi' 64 | user "psgi-#{id}-user" 65 | end 66 | cookbook_file "/tmp/psgi/#{id}/app.conf" do 67 | source 'test.conf' 68 | user "psgi-#{id}-user" 69 | end 70 | end 71 | 72 | 73 | service 'nginx' do 74 | action :start 75 | end 76 | 77 | cookbook_file '/etc/nginx/sites-available/app.conf' do 78 | source 'app_nginx.conf' 79 | owner 'root' 80 | group 'root' 81 | mode '644' 82 | end 83 | 84 | 85 | link '/etc/nginx/sites-enabled/app.conf' do 86 | to '/etc/nginx/sites-available/app.conf' 87 | end 88 | 89 | service 'nginx' do 90 | action :reload 91 | end 92 | 93 | 94 | -------------------------------------------------------------------------------- /nginx-fastcgi/definitions/nginx_fastcgi.rb: -------------------------------------------------------------------------------- 1 | define :nginx_fastcgi, :servers => [], :root => nil, :static => [], :fastcgi_param => [], :error_page => [], :fastcgi_intercept_errors => false do 2 | 3 | if (params[:socket].nil? || params[:socket].empty?) and (params[:inet_socket].nil? || params[:inet_socket].empty?) 4 | message = 'you should setup either socket or inet_socket param. ' 5 | raise message 6 | end 7 | 8 | params[:servers].each do |s| 9 | s[:server_alias] ||= [] 10 | s[:ssl] ||= false 11 | s[:port] ||= (s[:ssl] == true ? 443 : 80) 12 | s[:location] ||= '/' 13 | 14 | if s[:server_name].nil? || s[:server_name].empty? 15 | message = 'you should setup server_name for your virtual host. ' 16 | message << "virtual host string passed : #{s.inspect}" 17 | raise message 18 | end 19 | if s[:ssl] == true and ( s[:ssl_include_path].nil? || s[:ssl_include_path].empty? ) 20 | message = 'you should setup ssl_include_path for your virtual host. ' 21 | message << "virtual host string passed : #{s.inspect}" 22 | raise message 23 | end 24 | s[:static] ||= [] 25 | end 26 | 27 | template params[:name] do 28 | source 'nginx-site.erb' 29 | cookbook params[:cookbook] || 'nginx-fastcgi' 30 | mode 0664 31 | variables({ 32 | :static => ( (params[:static].is_a? Hash) ? [params[:static]] : params[:static] ), 33 | :root => params[:root], 34 | :socket => params[:socket], 35 | :inet_socket => params[:inet_socket], 36 | :servers => params[:servers], 37 | :fastcgi_param => params[:fastcgi_param], 38 | :site_name => File.basename(params[:name]).chomp(File.extname(params[:name])), 39 | :error_page => params[:error_page], 40 | :fastcgi_intercept_errors => params[:fastcgi_intercept_errors], 41 | :fastcgi_read_timeout => params[:fastcgi_read_timeout] 42 | }) 43 | 44 | end 45 | end 46 | -------------------------------------------------------------------------------- /psgi/templates/centos/init-script: -------------------------------------------------------------------------------- 1 | author "Alexey Melezhik" 2 | description "runs <%= @daemon_name %>" 3 | start on runlevel [2345] 4 | stop on runlevel [^2345] 5 | <% app_env = Array.new -%> 6 | <% app_opt = Array.new -%> 7 | <% app_opt << "-s #{@server}" -%> 8 | <% app_opt << "--listen #{@socket}" -%> 9 | <% app_opt << "-E #{@plackup_environment}" -%> 10 | <% app_opt << "-a " << ( Pathname.new(@application_script).relative? ? (Pathname.new(@application_home + "/") + Pathname.new(@application_script)).to_s : @application_script ) -%> 11 | <% if ! @proc_manager.nil? && ! @proc_manager.empty? && @server == 'FCGI' -%> 12 | <% app_opt << "--manager #{@proc_manager}" -%> 13 | <% end -%> 14 | <% if ! @loader.nil? && ! @loader.empty? -%> 15 | <% app_opt << "--loader #{@loader}" -%> 16 | <% end -%> 17 | <% if ! @proc_title.nil? && ! @proc_title.empty? -%> 18 | <% app_opt << "--proc_title #{@proc_title}" -%> 19 | <% end -%> 20 | <% if ! @mount.nil? && ! @mount.empty? -%> 21 | <% app_opt << "--path #{@mount}" -%> 22 | <% else -%> 23 | <% app_opt << "--path /" -%> 24 | <% end -%> 25 | <% if ! @nproc.nil? && @server == 'FCGI' -%> 26 | <% app_opt << "--nproc #{@nproc}" -%> 27 | <% elsif ! @nproc.nil? && @server == 'Starman' -%> 28 | <% app_opt << "--workers #{@nproc}" -%> 29 | <% end -%> 30 | <% if ! @backlog.nil? && @server == 'FCGI' -%> 31 | <% app_opt << "--backlog #{@backlog}" -%> 32 | <% end -%> 33 | <% if @server == 'Twiggy' %> 34 | <% app_env << "TWIGGY_DEBUG=#{@debug}" -%> 35 | <% end -%> 36 | <% if @operator == 'Catalyst' %> 37 | <% app_env << "CATALYST_CONFIG=#{@config}" -%> 38 | <% app_env << "CATALYST_DEBUG=#{@debug}" -%> 39 | <% elsif @operator == 'Dancer' -%> 40 | <% app_env << "DANCER_CONFDIR=#{@application_home}" -%> 41 | <% elsif @operator == 'Jifty' -%> 42 | <%- app_env << "JIFTY_CONFIG=#{@config}" -%> 43 | <% end -%> 44 | <% @envvars.each do |k,v| -%> 45 | <% app_env << "#{k}='#{v}'" -%> 46 | <% end -%> 47 | <% unless @perl5lib.empty? -%> 48 | <% app_env << "PERL5LIB=$PERL5LIB:#{@perl5lib.join(':')}" -%> 49 | <% end -%> 50 | exec sudo -u <%= @application_user %> /usr/bin/env <%= app_env.join ' ' %> <%= @daemon_path %> <%= app_opt.join ' ' %> 51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /psgi/templates/ubuntu/init-script: -------------------------------------------------------------------------------- 1 | author "Alexey Melezhik" 2 | description "runs <%= @daemon_name %>" 3 | start on runlevel [2345] 4 | stop on runlevel [^2345] 5 | <% app_env = Array.new -%> 6 | <% app_opt = Array.new -%> 7 | <% app_opt << "-s #{@server}" -%> 8 | <% app_opt << "--listen #{@socket}" -%> 9 | <% app_opt << "-E #{@plackup_environment}" -%> 10 | <% app_opt << "-a " << ( Pathname.new(@application_script).relative? ? (Pathname.new(@application_home + "/") + Pathname.new(@application_script)).to_s : @application_script ) -%> 11 | <% if ! @proc_manager.nil? && ! @proc_manager.empty? && @server == 'FCGI' -%> 12 | <% app_opt << "--manager #{@proc_manager}" -%> 13 | <% end -%> 14 | <% if ! @loader.nil? && ! @loader.empty? -%> 15 | <% app_opt << "--loader #{@loader}" -%> 16 | <% end -%> 17 | <% if ! @proc_title.nil? && ! @proc_title.empty? -%> 18 | <% app_opt << "--proc_title #{@proc_title}" -%> 19 | <% end -%> 20 | <% if ! @mount.nil? && ! @mount.empty? -%> 21 | <% app_opt << "--path #{@mount}" -%> 22 | <% else -%> 23 | <% app_opt << "--path /" -%> 24 | <% end -%> 25 | <% if ! @nproc.nil? && @server == 'FCGI' -%> 26 | <% app_opt << "--nproc #{@nproc}" -%> 27 | <% elsif ! @nproc.nil? && @server == 'Starman' -%> 28 | <% app_opt << "--workers #{@nproc}" -%> 29 | <% end -%> 30 | <% if ! @backlog.nil? && @server == 'FCGI' -%> 31 | <% app_opt << "--backlog #{@backlog}" -%> 32 | <% end -%> 33 | <% if @server == 'Twiggy' %> 34 | <% app_env << "TWIGGY_DEBUG=#{@debug}" -%> 35 | <% end -%> 36 | <% if @operator == 'Catalyst' %> 37 | <% app_env << "CATALYST_CONFIG=#{@config}" -%> 38 | <% app_env << "CATALYST_DEBUG=#{@debug}" -%> 39 | <% elsif @operator == 'Dancer' -%> 40 | <% app_env << "DANCER_CONFDIR=#{@application_home}" -%> 41 | <% elsif @operator == 'Jifty' -%> 42 | <%- app_env << "JIFTY_CONFIG=#{@config}" -%> 43 | <% end -%> 44 | <% @envvars.each do |k,v| -%> 45 | <% app_env << "#{k}='#{v}'" -%> 46 | <% end -%> 47 | <% unless @perl5lib.empty? -%> 48 | <% app_env << "PERL5LIB=$PERL5LIB:#{@perl5lib.join(':')}" -%> 49 | <% end -%> 50 | exec sudo -u <%= @application_user %> /usr/bin/env <%= app_env.join ' ' %> <%= @daemon_path %> <%= app_opt.join ' ' %> 51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /nginx-fastcgi/features/resource/validate_input_params.feature: -------------------------------------------------------------------------------- 1 | Feature: nginx-fastcgi should be able to validate it's input parameters 2 | 3 | Scenario: try to install without server_name 4 | Given I run 'rm -rf /tmp/foo.site.conf' 5 | Then a file named '/tmp/foo.site.conf' should not exist 6 | And I have chef recipe: 7 | """ 8 | nginx_fastcgi '/tmp/foo.site.conf' do 9 | servers [ 10 | { 11 | :ip => '127.0.0.1' 12 | } 13 | ] 14 | socket '/tmp/application.socket' 15 | end 16 | """ 17 | When I run chef recipe on my node 18 | Then 'stdout' should have 'RuntimeError: you should setup server_name for your virtual host' 19 | Then a file named '/tmp/foo.site.conf' should not exist 20 | 21 | Scenario: try to install without ssl_inlcude_path 22 | Given I run 'rm -rf /tmp/foo.site.conf' 23 | Then a file named '/tmp/foo.site.conf' should not exist 24 | And I have chef recipe: 25 | """ 26 | nginx_fastcgi '/tmp/foo.site.conf' do 27 | site_name 'foo.site.x' 28 | servers [ 29 | { 30 | :server_name => 'foo.x', 31 | :ssl => true 32 | } 33 | ] 34 | socket '/tmp/application.socket' 35 | end 36 | """ 37 | When I run chef recipe on my node 38 | Then 'stdout' should have 'RuntimeError: you should setup ssl_include_path for your virtual host' 39 | Then a file named '/tmp/foo.site.conf' should not exist 40 | 41 | Scenario: try to install without server_name 42 | Given I run 'rm -rf /tmp/foo.site.conf' 43 | Then a file named '/tmp/foo.site.conf' should not exist 44 | And I have chef recipe: 45 | """ 46 | nginx_fastcgi '/tmp/foo.site.conf' do 47 | servers [ 48 | { 49 | :server_name => 'foo.x', 50 | :ip => '127.0.0.1' 51 | } 52 | ] 53 | end 54 | """ 55 | When I run chef recipe on my node 56 | Then 'stdout' should have 'RuntimeError: you should setup either socket or inet_socket' 57 | Then a file named '/tmp/foo.site.conf' should not exist 58 | 59 | -------------------------------------------------------------------------------- /pinto/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # CHANGELOG for pinto 2 | 3 | This file is used to list changes made in each version of pinto. 4 | 5 | 6 | ## 0.1.11: 7 | - improved mini tests 8 | 9 | ## 0.1.10: 10 | - small bug fix in mini test for application recipe, to take into account http proxy issues 11 | - pinto.user_shell attribute added, now pinto application owner is created with this shell 12 | - fix version check in minitest 13 | 14 | ## 0.1.9: 15 | * default port for pinto server is now 3111 16 | * removed outdated code 17 | 18 | ## 0.1.8: 19 | 20 | * big refactoring 21 | * default.pinto.bootstrap namespace has been abolished to default.pinto namespace 22 | * default.pinto.bootstrap.home is depricated ( effectively evaluated to ~/local/opt/pinto ) 23 | * default.pinto.server.repo_root is depricated ( effectively evaluated to ~/local/opt/pinto/var/ ) 24 | * doing *system-wide install* when default.pinto.user == root 25 | * doing *local user install* when default.pinto.root != root 26 | * *local user install* is default one 27 | * removed Time::HiRes and CGI from missed dependencies list ( for centOS ) - https://github.com/thaljef/Pinto/issues/67 28 | 29 | 30 | ## 0.1.7: 31 | * init scripts for debian / ubuntu get refactored 32 | * warning message about installation for 'root' user 33 | 34 | ## 0.1.6: 35 | * README - add contribution section 36 | 37 | ## 0.1.5: 38 | * documentation bug fixes 39 | 40 | ## 0.1.4: 41 | * now installs and runs as the "pinto" user by default - [issues/8](https://github.com/melezhik/cookbooks/issues/8) 42 | * now does standalone installation from http://getpinto.stratopan.com - [issues/9](https://github.com/melezhik/cookbooks/issues/9) 43 | * pinto::server - init script for debian platform 44 | 45 | ## 0.1.3: 46 | 47 | * installs pintod server 48 | 49 | ## 0.1.2: 50 | * pinto bashrc fixed 51 | * mini::test chef tests imporved 52 | 53 | ## 0.1.1: 54 | * pinto::application - code from https://raw.github.com/thaljef/Pinto/master/etc/install.sh used as prototype 55 | 56 | ## 0.1.0: 57 | 58 | * Initial release of pinto 59 | 60 | - - - 61 | Check the [Markdown Syntax Guide](http://daringfireball.net/projects/markdown/syntax) for help with Markdown. 62 | 63 | The [Github Flavored Markdown page](http://github.github.com/github-flavored-markdown/) describes the differences between markdown on github and standard markdown. 64 | -------------------------------------------------------------------------------- /psgi/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # CHANGELOG for psgi 2 | 3 | This file is used to list changes made in each version of psgi. 4 | 5 | ## 0.1.2: 6 | * `test action` - log info for environment variables now is correct 7 | 8 | ## 0.1.1: 9 | * use Chef::Provider::Service::Debian provider for debian 10 | 11 | ## 0.1.0: 12 | * environment variables now have highest priority 13 | 14 | ## 0.0.15: 15 | * added notions about loader and backlog parameters 16 | * backlog parameter added for FCGI server 17 | 18 | ## 0.0.14: 19 | * support for Corona web server 20 | 21 | ## 0.0.13: 22 | * `loader` parameter now can be passed to `psgi` resource - see [plackup documenation](http://search.cpan.org/~miyagawa/Plack-1.0030/script/plackup) for details 23 | 24 | ## 0.0.12: 25 | * debian init scripts are refactored 26 | * now support for centOS 27 | * using upstart init system in ubuntu and centOS 28 | * README - notes about upstart, ubutnu, centOS, debian, etc. 29 | 30 | ## 0.0.11: 31 | * added 'Twiggy' server 32 | * default value for `operator` is not **Catalyst**, but **nill** 33 | * lower-case for postfix in socket file name, in case unix socket 34 | 35 | ## 0.0.10: 36 | * do not check Plack version 37 | * big fix for environment variable polluted (action :test) 38 | * re-factoring of debian / ubuntu init script 39 | * action `:test`, `ignore_failures` default value is **false** 40 | * support for Starman server 41 | 42 | 43 | ## 0.0.8: 44 | * take into account perl5lib when check Plack version 45 | 46 | ## 0.0.7: 47 | * checks version of Plack ( old versions do not work correctly with FCGI ) 48 | * berkshelf / minitest chef infrastructure has been added 49 | * default value for `proc_manager` is FCGI::ProcManager 50 | * `-fcgi` postfix in `proc-title` has been removed 51 | 52 | ## 0.0.6: 53 | * delete old files 54 | 55 | ## 0.0.5: 56 | * documentation gets more clear 57 | * `enabled_service` is `on` by default 58 | 59 | ## 0.0.4: 60 | * `supports` info fixed 61 | * doc updated 62 | 63 | ## 0.0.3: 64 | * added `daemon_path` parameter to `test` action 65 | 66 | ## 0.0.2: 67 | * new parameter - `daemon_path`, default is `system path to plackup` 68 | 69 | ## 0.0.1: 70 | 71 | * Initial release of psgi 72 | 73 | - - - 74 | Check the [Markdown Syntax Guide](http://daringfireball.net/projects/markdown/syntax) for help with Markdown. 75 | 76 | The [Github Flavored Markdown page](http://github.github.com/github-flavored-markdown/) describes the differences between markdown on github and standard markdown. 77 | -------------------------------------------------------------------------------- /dry-run/definitions/dry-run-template.rb: -------------------------------------------------------------------------------- 1 | define :dry_run_template do 2 | 3 | dry_run_conf = "#{node.dryrun.dir}/#{File.basename(params[:name])}" 4 | 5 | template dry_run_conf do 6 | source params[:source] 7 | variables params[:variables] unless params[:variables].nil? 8 | mode params[:mode] unless params[:source].nil? 9 | owner params[:owner] unless params[:owner].nil? 10 | group params[:group] unless params[:group].nil? 11 | end 12 | 13 | 14 | dry_run_stat = "#{dry_run_conf}.stat" 15 | dry_run_diff = "#{dry_run_conf}.diff" 16 | 17 | ruby_block 'create dry-run-stat file' do 18 | block do 19 | File.open(dry_run_stat,"w") do |log| 20 | log.puts("WOULD install config into #{params[:name]}") 21 | end 22 | end 23 | end 24 | 25 | 26 | ruby_block "dry-run install" do 27 | block do 28 | if ! File.directory?(File.dirname(params[:name])) 29 | File.open(dry_run_stat,"a") do |log| 30 | log.puts("WOULD create directory #{params[:name]}") 31 | end 32 | end 33 | if File.exist?(params[:name]) 34 | stat1 = `stat --format '%A|%U|%G' #{params[:name]}`.chomp! 35 | stat2 = `stat --format '%A|%U|%G' #{dry_run_conf}`.chomp! 36 | if stat1 != stat2 37 | File.open(dry_run_stat,"a") do |log| 38 | log.puts("WOULD change access rights from #{stat1} to #{stat2}") 39 | end 40 | end 41 | else 42 | File.open(dry_run_stat,"a") do |log| 43 | log.puts("WOULD create NEW config (current one does not exist)") 44 | end 45 | end 46 | end 47 | action :create 48 | end 49 | 50 | 51 | 52 | ruby_block "dry-run-diff" do 53 | block do 54 | if File.exist?("#{params[:name]}") 55 | system("diff -u -B -w #{dry_run_conf} #{params[:name]} > #{dry_run_diff}") 56 | if File.size?(dry_run_diff) 57 | File.open(dry_run_stat,"a") do |log| 58 | log.puts("WOULD change current config --- see #{dry_run_diff}") 59 | end 60 | else 61 | File.open(dry_run_stat,"a") do |log| 62 | log.puts("WOULD*NOT change current config") 63 | end 64 | end 65 | end 66 | end 67 | action :create 68 | end 69 | 70 | ruby_block 'dry-run-info' do 71 | block do 72 | puts '*******' 73 | IO.foreach(dry_run_stat) {|line| puts " +++ #{line}" } 74 | puts '*******' 75 | end 76 | end 77 | 78 | end 79 | -------------------------------------------------------------------------------- /nginx-fastcgi/templates/default/nginx-site.erb: -------------------------------------------------------------------------------- 1 | <%- @servers.each do |s| %> 2 | server { 3 | 4 | <%- if s[:ip].nil? || s[:ip].empty? %> 5 | <%- if s[:ssl] == true %> 6 | listen <%= s[:port] %> ssl; 7 | <%- else %> 8 | listen <%= s[:port] %>; 9 | <%- end %> 10 | <%- else %> 11 | <%- if s[:ssl] == true %> 12 | listen <%= "#{s[:ip]}:#{s[:port]}" %> ssl; 13 | <%- else %> 14 | listen <%= "#{s[:ip]}:#{s[:port]}" %>; 15 | <%- end %> 16 | <%- end %> 17 | 18 | server_name <%= s[:server_name] %> <%= s[:server_alias].join(' ') %>; 19 | 20 | <%- unless @root.nil? || @root.empty? %> 21 | root <%= @root %>; 22 | <%- end %> 23 | 24 | <%- @error_page.each do |page| %> 25 | error_page <%= page[:code] %> <%= page[:handler] %>; 26 | <%- end %> 27 | 28 | <%- unless @static.nil? || @static.empty? %> 29 | <%- @static.each do |item| %> 30 | location <%= item[:location] %> { 31 | root <%= item[:root] %>; 32 | } 33 | <%- end %> 34 | <%- end %> 35 | 36 | <%- if s[:ssl] == true %> 37 | include <%= s[:ssl_include_path] %>; 38 | <%- end %> 39 | 40 | <%- if s[:redirect].nil? || s[:redirect].empty? %> 41 | location <%= s[:location] %> { 42 | include fastcgi_params; 43 | <%- if ! @socket.nil? && ! @socket.empty? %> 44 | fastcgi_pass unix:<%= @socket %>; 45 | <%- end %> 46 | <%- if ! @inet_socket.nil? && ! @inet_socket.empty? %> 47 | fastcgi_pass <%= @inet_socket %>; 48 | <%- end %> 49 | <%- if s[:ssl] == true %> 50 | fastcgi_param HTTPS on; 51 | <%- end %> 52 | <%- @fastcgi_param.each do |f| %> 53 | fastcgi_param <%= f[:name] %> <%= f[:value] %>; 54 | <%- end %> 55 | <%- if @fastcgi_intercept_errors == true %> 56 | fastcgi_intercept_errors on; 57 | <%- end %> 58 | <%- unless @fastcgi_read_timeout.nil? || @fastcgi_read_timeout.empty? %> 59 | fastcgi_read_timeout <%= @fastcgi_read_timeout %>; 60 | <%- end %> 61 | 62 | } 63 | <%- else %> 64 | rewrite ^ <%= s[:redirect] %>://$server_name$request_uri? permanent; 65 | <%- end %> 66 | access_log /var/log/nginx/<%= @site_name %>.access.log; 67 | error_log /var/log/nginx/<%= @site_name %>.error.log; 68 | 69 | } 70 | <%- end %> 71 | 72 | -------------------------------------------------------------------------------- /pinto/README.md: -------------------------------------------------------------------------------- 1 | # Synopsis 2 | Installs, configures [Pinto](http://search.cpan.org/perldoc?Pinto) application 3 | 4 | # Recipes 5 | * pinto::application - installs Pinto application in standalone mode 6 | * pinto::server - installs Pinto server ( should be run after pinto::application recipe ) 7 | 8 | # Attributes 9 | May be overridden to alter recipes behaviour 10 | 11 | * `node[:pinto][:user]`, `node[:pinto][:group]` - The owner and group of pinto application. The application will be installed into `~/opt/local/pinto` directory 12 | * `node[:pinto][:user_shell]`, shell for pinto application owner, default is '/bin/bash' 13 | * `node[:pinto][:host]` - pinto server bind host, default value is **0.0.0.0** 14 | * `node[:pinto][:port]` - pinto server bind port, default value is **3111** 15 | * `node[:pinto][:workers]` - number of pinto server workers, default value is **3** 16 | 17 | 18 | # Tested on 19 | * CentOS-6.4-x86_64, , Chef 10.14.0 20 | * CentOS-6.3-x86_64-minimal, Chef 10.14.2 21 | * Debian-6.0.4-64-bit, Chef 11.4.4 22 | * Ubuntu 10.04.1 LTS, Chef 11.4.4 23 | 24 | # Current release 25 | http://community.opscode.com/cookbooks/pinto 26 | 27 | # Contributing 28 | I use berkshelf for developing / testing pinto cookbook. [Berkshelf](http://berkshelf.com/) is a framework for testing / managing chef cookbooks. 29 | So if you are interested in contributing, hacking - berkshelf is the best way to go ahead. Next commands will explain how to start. 30 | 31 | ## Install berkshelf 32 | 33 | $ gem install berkshelf 34 | 35 | ## Install vagrant 36 | [Vagrant](http://www.vagrantup.com/) is the tools for running / provisioning VirtualBox machines. 37 | Berkshelf and Vagrant are tightly integrated. Berskhelf requires latest version of vagrant. 38 | Visit the Vagrant downloads page - http://downloads.vagrantup.com/ and download the latest installer for your operating system. 39 | 40 | ## Install vagrant-berkshelf plugin 41 | Second thing we need is berkshelf vagrant plugin. Following command will install the plugin 42 | 43 | $ vagrant plugin install vagrant-berkshelf 44 | 45 | ## Fork cookbooks 46 | 47 | $ git clone https://github.com/melezhik/cookbooks.git 48 | 49 | ## Run vagrant box 50 | Following command will boot vagrant virtual machine, deploy pinto on it and run tests. 51 | 52 | $ cd cookbooks/pinto 53 | $ vagrant up 54 | 55 | ## Make changes 56 | Change code and revision your changes running tests again. For standard vagrant work-flow checkout - http://docs.vagrantup.com/v2/ 57 | 58 | $ mcedit recipes/application.rb 59 | $ vagrant provision 60 | 61 | -------------------------------------------------------------------------------- /catalyst-fastcgi/README.md: -------------------------------------------------------------------------------- 1 | # Description 2 | - Configures catalyst as fastcgi server 3 | - Configures apache virtual host for running catalyst fastcgi server 4 | 5 | # Platforms 6 | - ubuntu 7 | - gentoo 8 | 9 | # Requirements 10 | - [apache cookbook](https://github.com/melezhik/cookbooks/tree/master/catalyst) 11 | - [catalyst cookbook](https://github.com/melezhik/cookbooks/tree/master/catalyst) 12 | 13 | # Attributes 14 | * obligatory 15 | * `catalyst_fastcgi.service_name` - name of your catalyst application, default is 'foo' 16 | * `catalyst_fastcgi.server_name` - name of virtual host server, default is 'foo.x' 17 | * `catalyst_fastcgi.application.user` - a user name that we should change to before starting application, default is 'foo' 18 | * `catalyst_fastcgi.application.group` - a group name that we should change to before starting application, default is 'foo' 19 | * `catalyst_fastcgi.application.home` - a dir where catalyst application resides, default is '/tmp/foo' 20 | * `catalyst_fastcgi.application.script` - a name of script to start applicationm, an absolute path to your application will be constructed with application_home/script/application_script, default is 'foo_fastcgi.pl' 21 | * `catalyst_fastcgi.catalyst_config` - a path to catalyst config file, default is '/tmp/foo/foo.conf' 22 | * `catalyst_fastcgi.socket` - a socket, application will be binded to, default is '/tmp/foo.socket' 23 | * optional 24 | * `catalyst_fastcgi.server_alias` - Array, a list of server aliases, default value is `[]` 25 | * `catalyst_fastcgi.start_service` - true|false, whether to try to start application when configuring is done, default value `false` 26 | * `catalyst_fastcgi.application.perl5lib` - an array of perl5lib pathes, default is [] 27 | * `catalyst_fastcgi.nproc` - Integer, a number of processes will be launched when application start in fastcgi mode, default is 2 28 | * `catalyst_fastcgi.envvars` - a hash of environment vars, passed to application environment, default is { :CATALYST_DEBUG => 1 } 29 | * `catalyst_fastcgi.proc_manager` - a perl class, implimenting Fast CGI Process ProcManager 30 | * `catalyst_fastcgi.apache.access_log` - a path to apache access log 31 | * `catalyst_fastcgi.apache.error_log` - a path to apache error log 32 | 33 | * optional for ssl mode, see explanation in [apache cookbook](https://github.com/melezhik/cookbooks/tree/master/apache) 34 | * `ssl`, default value false 35 | * `ssl_cipher_suite`, default value nil 36 | * `ssl_certificate_file`, default value nil 37 | * `ssl_certificate_key_file`, default value nil 38 | 39 | 40 | -------------------------------------------------------------------------------- /catalyst/README.md: -------------------------------------------------------------------------------- 1 | Description 2 | =========== 3 | 4 | catalyst application resource provider (LWRP) 5 | 6 | * start your catalyst application as fastcgi server 7 | * configuration of apache is beyond the scope, but you may consider [my apache cookbook](https://github.com/melezhik/cookbooks/tree/master/apache) 8 | 9 | Platforms 10 | ========= 11 | 12 | * gentoo (tested with Calculate Linux Desktop 9.6) 13 | * ubuntu (tested with 11.10 server amd64) 14 | 15 | Requirements 16 | ============ 17 | 18 | * This cookbook doesn't have direct dependencies on other cookbooks. But you have to be sure 19 | that the catalyst application you are going to run at least installed and tested. 20 | 21 | Resources 22 | ========= 23 | catalyst_application 24 | 25 | Resources Actions 26 | ================= 27 | 28 | * `install` - install catalyst application as fastcgi server 29 | 30 | Resource Attributes 31 | =================== 32 | 33 | * obligatory attrubutes 34 | * `application_user` - a user name that we should change to before starting application 35 | * `application_group` - a group name that we should change to before starting application 36 | * `application_home` - a dir where catalyst application resides 37 | * `application_script` - a name of script to start application, an absolute path to your application will be constructed with application_home/script/application_script 38 | * `catalyst_config` - a path to catalyst config file 39 | * optional attributes 40 | * `start_service` - true|false, whether to try to start application when configuring is done, default value `true` 41 | * `perl5lib` - an array of perl5lib pathes 42 | * `nproc` - Integer, a number of processes will be launched when application start in fastcgi mode, default value 1 43 | * `envvars` - a hash of environment vars, passed to application environment 44 | * `proc_manager` - a perl class, implimenting Fast CGI Process ProcManager, default FCGI::ProcManager 45 | * `socket` - a socket, application will be binded to 46 | 47 | 48 | Usage 49 | ===== 50 | 51 | ## 1. Create your catalyst application from the scratch ## 52 | 53 | $ cd /tmp/ 54 | $ catalyst.pl Foo 55 | $ cd Foo 56 | $ perl Makefile.PL 57 | $ make 58 | $ make test 59 | $ make install 60 | 61 | ## 2. Deploy it as fast cgi server via catalyst cookbook ## 62 | 63 | catalyst_application 'foo' do 64 | application_home '/tmp/Foo' 65 | application_script 'foo_fastcgi.pl' 66 | catalyst_config '/tmp/Foo/foo.conf' 67 | action 'install' 68 | end 69 | 70 | ## 3. Now you have catalyst application running as fastcgi server ## 71 | 72 | /etc/init.d/foo start 73 | /etc/init.d/foo stop 74 | /etc/init.d/foo restart 75 | 76 | Links 77 | ===== 78 | 79 | * http://search.cpan.org/perldoc?Catalyst::Engine::FastCGI - running catalyst app as fastcgi server 80 | 81 | ToDo 82 | ==== 83 | 84 | * add support for more platforms 85 | * add more tests 86 | * add wikis and howtos 87 | 88 | -------------------------------------------------------------------------------- /catalyst/providers/application.rb: -------------------------------------------------------------------------------- 1 | def load_current_resource 2 | 3 | @resource = Chef::Resource::CatalystApplication.new(new_resource.name) 4 | @resource.application_home(new_resource.application_home) 5 | @resource.application_script(new_resource.application_script) 6 | @resource.application_user(new_resource.application_user) 7 | @resource.application_group(new_resource.application_group) 8 | @resource.catalyst_config(new_resource.catalyst_config) 9 | @resource.perl5lib(new_resource.perl5lib) 10 | @resource.envvars(new_resource.envvars) 11 | @resource.socket(new_resource.socket) 12 | @resource.nproc(new_resource.nproc) 13 | @resource.proc_manager(new_resource.proc_manager) 14 | @resource.start_service(new_resource.start_service) 15 | 16 | check_input_params 17 | 18 | end 19 | 20 | 21 | action :install do 22 | 23 | if node.platform == 'gentoo' # special case for gentoo 24 | template '/etc/init.d/catalyst_application' do 25 | source 'catalyst_application' 26 | mode '0775' 27 | cookbook 'catalyst' 28 | action :create_if_missing 29 | end 30 | link "/etc/init.d/#{service_name}" do 31 | to '/etc/init.d/catalyst_application' 32 | end 33 | end 34 | install_confd_template 35 | new_resource.updated_by_last_action(true) 36 | end 37 | 38 | 39 | def install_confd_template 40 | 41 | application_home = @resource.application_home 42 | application_script = @resource.application_script 43 | application_user = @resource.application_user 44 | application_group = @resource.application_group 45 | catalyst_config = @resource.catalyst_config 46 | perl5lib = @resource.perl5lib 47 | envvars = @resource.envvars 48 | socket = @resource.socket 49 | nproc = @resource.nproc 50 | proc_manager = @resource.proc_manager 51 | start_service = @resource.start_service 52 | 53 | service service_name do 54 | action :nothing 55 | end 56 | 57 | template "#{node.catalyst.initscript.template.dir}/#{service_name}" do 58 | source 'catalyst_application.erb' 59 | cookbook 'catalyst' 60 | variables( 61 | :service_name => service_name, 62 | :application_home => application_home, 63 | :application_user => application_user, 64 | :application_script => application_script, 65 | :catalyst_config => catalyst_config, 66 | :perl5lib => perl5lib, 67 | :envvars => envvars, 68 | :socket => socket, 69 | :nproc => nproc, 70 | :proc_manager => proc_manager 71 | ) 72 | mode node.catalyst.initscript.template.mode 73 | notifies [:enable, :restart], resources( :service => service_name ) unless start_service == false 74 | end 75 | 76 | service service_name do 77 | action :enable 78 | end 79 | 80 | # start for first time 81 | if start_service == true 82 | service service_name do 83 | action 'start' 84 | end 85 | end 86 | 87 | end 88 | 89 | 90 | def service_name 91 | @resource.name 92 | end 93 | 94 | def check_input_params 95 | [ 96 | 'application_home', 'application_user', 'application_group', 97 | 'application_script', 'catalyst_config' 98 | ].each do |p| 99 | raise "#{p} - obligatory parameter" if @resource.send(p).nil? 100 | end 101 | end 102 | -------------------------------------------------------------------------------- /cpan/Vagrantfile: -------------------------------------------------------------------------------- 1 | # -*- mode: ruby -*- 2 | # vi: set ft=ruby : 3 | 4 | Vagrant.configure("2") do |config| 5 | # All Vagrant configuration is done here. The most common configuration 6 | # options are documented and commented below. For a complete reference, 7 | # please see the online documentation at vagrantup.com. 8 | 9 | config.vm.hostname = "cpan-berkshelf" 10 | 11 | # Every Vagrant virtual environment requires a box to build off of. 12 | config.vm.box = "Berkshelf-Debian" 13 | 14 | # The url from where the 'config.vm.box' box will be fetched if it 15 | # doesn't already exist on the user's system. 16 | # config.vm.box_url = "https://dl.dropbox.com/u/31081437/Berkshelf-CentOS-6.3-x86_64-minimal.box" 17 | config.vm.box_url = "http://ergonlogic.com/files/boxes/debian-current.box" 18 | 19 | # Assign this VM to a host-only network IP, allowing you to access it 20 | # via the IP. Host-only networks can talk to the host machine as well as 21 | # any other machines on the same network, but cannot be accessed (through this 22 | # network interface) by any external networks. 23 | config.vm.network :private_network, ip: "33.33.33.10" 24 | 25 | # Create a public network, which generally matched to bridged network. 26 | # Bridged networks make the machine appear as another physical device on 27 | # your network. 28 | 29 | config.vm.network :public_network 30 | 31 | # Create a forwarded port mapping which allows access to a specific port 32 | # within the machine from a port on the host machine. In the example below, 33 | # accessing "localhost:8080" will access port 80 on the guest machine. 34 | 35 | # Share an additional folder to the guest VM. The first argument is 36 | # the path on the host to the actual folder. The second argument is 37 | # the path on the guest to mount the folder. And the optional third 38 | # argument is a set of non-required options. 39 | # config.vm.synced_folder "../data", "/vagrant_data" 40 | 41 | # Provider-specific configuration so you can fine-tune various 42 | # backing providers for Vagrant. These expose provider-specific options. 43 | # Example for VirtualBox: 44 | # 45 | # config.vm.provider :virtualbox do |vb| 46 | # # Don't boot with headless mode 47 | # vb.gui = true 48 | # 49 | # # Use VBoxManage to customize the VM. For example to change memory: 50 | # vb.customize ["modifyvm", :id, "--memory", "1024"] 51 | # end 52 | # 53 | # View the documentation for the provider you're using for more 54 | # information on available options. 55 | 56 | config.ssh.max_tries = 40 57 | config.ssh.timeout = 120 58 | 59 | # The path to the Berksfile to use with Vagrant Berkshelf 60 | # config.berkshelf.berksfile_path = "./Berksfile" 61 | 62 | # Enabling the Berkshelf plugin. To enable this globally, add this configuration 63 | # option to your ~/.vagrant.d/Vagrantfile file 64 | config.berkshelf.enabled = true 65 | 66 | # An array of symbols representing groups of cookbook described in the Vagrantfile 67 | # to exclusively install and copy to Vagrant's shelf. 68 | # config.berkshelf.only = [] 69 | 70 | # An array of symbols representing groups of cookbook described in the Vagrantfile 71 | # to skip installing and copying to Vagrant's shelf. 72 | # config.berkshelf.except = [] 73 | 74 | config.vm.provision :chef_solo do |chef| 75 | chef.run_list = [ 76 | "recipe[test]", 77 | "recipe[minitest-handler]" 78 | ] 79 | end 80 | end 81 | -------------------------------------------------------------------------------- /psgi/Vagrantfile: -------------------------------------------------------------------------------- 1 | # -*- mode: ruby -*- 2 | # vi: set ft=ruby : 3 | 4 | Vagrant.configure("2") do |config| 5 | # All Vagrant configuration is done here. The most common configuration 6 | # options are documented and commented below. For a complete reference, 7 | # please see the online documentation at vagrantup.com. 8 | 9 | config.vm.hostname = "psgi-berkshelf" 10 | 11 | # Every Vagrant virtual environment requires a box to build off of. 12 | config.vm.box = "CentOS-6.4-x86_64" 13 | 14 | # The url from where the 'config.vm.box' box will be fetched if it 15 | # doesn't already exist on the user's system. 16 | # config.vm.box_url = "https://s3.amazonaws.com/gsc-vagrant-boxes/ubuntu-12.04.2-i386-chef-11-omnibus.box" 17 | 18 | # Assign this VM to a host-only network IP, allowing you to access it 19 | # via the IP. Host-only networks can talk to the host machine as well as 20 | # any other machines on the same network, but cannot be accessed (through this 21 | # network interface) by any external networks. 22 | # config.vm.network :private_network, ip: "33.33.33.10" 23 | 24 | # Create a public network, which generally matched to bridged network. 25 | # Bridged networks make the machine appear as another physical device on 26 | # your network. 27 | 28 | config.vm.network :public_network 29 | 30 | # Create a forwarded port mapping which allows access to a specific port 31 | # within the machine from a port on the host machine. In the example below, 32 | # accessing "localhost:8080" will access port 80 on the guest machine. 33 | 34 | # Share an additional folder to the guest VM. The first argument is 35 | # the path on the host to the actual folder. The second argument is 36 | # the path on the guest to mount the folder. And the optional third 37 | # argument is a set of non-required options. 38 | # config.vm.synced_folder "../data", "/vagrant_data" 39 | 40 | # Provider-specific configuration so you can fine-tune various 41 | # backing providers for Vagrant. These expose provider-specific options. 42 | # Example for VirtualBox: 43 | # 44 | # config.vm.provider :virtualbox do |vb| 45 | # # Don't boot with headless mode 46 | # vb.gui = true 47 | # 48 | # # Use VBoxManage to customize the VM. For example to change memory: 49 | # vb.customize ["modifyvm", :id, "--memory", "1024"] 50 | # end 51 | # 52 | # View the documentation for the provider you're using for more 53 | # information on available options. 54 | 55 | config.ssh.max_tries = 40 56 | config.ssh.timeout = 120 57 | 58 | # The path to the Berksfile to use with Vagrant Berkshelf 59 | # config.berkshelf.berksfile_path = "./Berksfile" 60 | 61 | # Enabling the Berkshelf plugin. To enable this globally, add this configuration 62 | # option to your ~/.vagrant.d/Vagrantfile file 63 | config.berkshelf.enabled = true 64 | 65 | # An array of symbols representing groups of cookbook described in the Vagrantfile 66 | # to exclusively install and copy to Vagrant's shelf. 67 | # config.berkshelf.only = [] 68 | 69 | # An array of symbols representing groups of cookbook described in the Vagrantfile 70 | # to skip installing and copying to Vagrant's shelf. 71 | # config.berkshelf.except = [] 72 | 73 | config.vm.provision :chef_solo do |chef| 74 | chef.json = { 75 | :mysql => { 76 | :server_root_password => 'rootpass', 77 | :server_debian_password => 'debpass', 78 | :server_repl_password => 'replpass' 79 | } 80 | } 81 | 82 | chef.run_list = [ 83 | "recipe[test]", 84 | "recipe[minitest-handler]" 85 | ] 86 | end 87 | end 88 | -------------------------------------------------------------------------------- /pinto/Vagrantfile: -------------------------------------------------------------------------------- 1 | # -*- mode: ruby -*- 2 | # vi: set ft=ruby : 3 | 4 | Vagrant.configure("2") do |config| 5 | # All Vagrant configuration is done here. The most common configuration 6 | # options are documented and commented below. For a complete reference, 7 | # please see the online documentation at vagrantup.com. 8 | 9 | config.vm.hostname = "pinto-berkshelf" 10 | 11 | # Every Vagrant virtual environment requires a box to build off of. 12 | #config.vm.box = "Debian-Stable-64-bit" 13 | # config.vm.box = "CentOS-6.4-x86_64" 14 | config.vm.box = "Berkshelf-CentOS-6.3-x86_64-minimal" 15 | #config.vm.box = "Opscode-ubuntu-10.04" 16 | 17 | # The url from where the 'config.vm.box' box will be fetched if it 18 | # doesn't already exist on the user's system. 19 | config.vm.box_url = "https://dl.dropbox.com/u/31081437/Berkshelf-CentOS-6.3-x86_64-minimal.box" 20 | 21 | # Assign this VM to a host-only network IP, allowing you to access it 22 | # via the IP. Host-only networks can talk to the host machine as well as 23 | # any other machines on the same network, but cannot be accessed (through this 24 | # network interface) by any external networks. 25 | # config.vm.network :private_network, ip: "33.33.33.10" 26 | 27 | # Create a public network, which generally matched to bridged network. 28 | # Bridged networks make the machine appear as another physical device on 29 | # your network. 30 | 31 | config.vm.network :public_network 32 | 33 | # Create a forwarded port mapping which allows access to a specific port 34 | # within the machine from a port on the host machine. In the example below, 35 | # accessing "localhost:8080" will access port 80 on the guest machine. 36 | 37 | # Share an additional folder to the guest VM. The first argument is 38 | # the path on the host to the actual folder. The second argument is 39 | # the path on the guest to mount the folder. And the optional third 40 | # argument is a set of non-required options. 41 | # config.vm.synced_folder "../data", "/vagrant_data" 42 | 43 | # Provider-specific configuration so you can fine-tune various 44 | # backing providers for Vagrant. These expose provider-specific options. 45 | # Example for VirtualBox: 46 | # 47 | # config.vm.provider :virtualbox do |vb| 48 | # # Don't boot with headless mode 49 | # vb.gui = true 50 | # 51 | # # Use VBoxManage to customize the VM. For example to change memory: 52 | # vb.customize ["modifyvm", :id, "--memory", "1024"] 53 | # end 54 | # 55 | # View the documentation for the provider you're using for more 56 | # information on available options. 57 | 58 | config.ssh.max_tries = 40 59 | config.ssh.timeout = 120 60 | 61 | # The path to the Berksfile to use with Vagrant Berkshelf 62 | # config.berkshelf.berksfile_path = "./Berksfile" 63 | 64 | # Enabling the Berkshelf plugin. To enable this globally, add this configuration 65 | # option to your ~/.vagrant.d/Vagrantfile file 66 | config.berkshelf.enabled = true 67 | 68 | # An array of symbols representing groups of cookbook described in the Vagrantfile 69 | # to exclusively install and copy to Vagrant's shelf. 70 | # config.berkshelf.only = [] 71 | 72 | # An array of symbols representing groups of cookbook described in the Vagrantfile 73 | # to skip installing and copying to Vagrant's shelf. 74 | # config.berkshelf.except = [] 75 | 76 | config.vm.provision :chef_solo do |chef| 77 | chef.json = { 78 | :pinto => { 79 | :slow_tests => '1' 80 | } 81 | } 82 | 83 | chef.run_list = [ 84 | "recipe[pinto]", 85 | "recipe[minitest-handler]" 86 | ] 87 | end 88 | end 89 | -------------------------------------------------------------------------------- /cpanminus/Vagrantfile: -------------------------------------------------------------------------------- 1 | # -*- mode: ruby -*- 2 | # vi: set ft=ruby : 3 | 4 | Vagrant.configure("2") do |config| 5 | # All Vagrant configuration is done here. The most common configuration 6 | # options are documented and commented below. For a complete reference, 7 | # please see the online documentation at vagrantup.com. 8 | 9 | config.vm.hostname = "cpanminus-berkshelf" 10 | # Every Vagrant virtual environment requires a box to build off of. 11 | # config.vm.box = "Berkshelf-CentOS-6.3-x86_64-minimal" 12 | config.vm.box = "Berkshelf-Debian" 13 | 14 | # The url from where the 'config.vm.box' box will be fetched if it 15 | # doesn't already exist on the user's system. 16 | #config.vm.box_url = "https://dl.dropbox.com/u/31081437/Berkshelf-CentOS-6.3-x86_64-minimal.box" 17 | 18 | # Assign this VM to a host-only network IP, allowing you to access it 19 | # via the IP. Host-only networks can talk to the host machine as well as 20 | # any other machines on the same network, but cannot be accessed (through this 21 | # network interface) by any external networks. 22 | #config.vm.network :private_network, ip: "33.33.33.10" 23 | 24 | # Create a public network, which generally matched to bridged network. 25 | # Bridged networks make the machine appear as another physical device on 26 | # your network. 27 | 28 | config.vm.network :public_network 29 | 30 | # Create a forwarded port mapping which allows access to a specific port 31 | # within the machine from a port on the host machine. In the example below, 32 | # accessing "localhost:8080" will access port 80 on the guest machine. 33 | 34 | # Share an additional folder to the guest VM. The first argument is 35 | # the path on the host to the actual folder. The second argument is 36 | # the path on the guest to mount the folder. And the optional third 37 | # argument is a set of non-required options. 38 | # config.vm.synced_folder "../data", "/vagrant_data" 39 | 40 | # Provider-specific configuration so you can fine-tune various 41 | # backing providers for Vagrant. These expose provider-specific options. 42 | # Example for VirtualBox: 43 | # 44 | # config.vm.provider :virtualbox do |vb| 45 | # # Don't boot with headless mode 46 | # vb.gui = true 47 | # 48 | # # Use VBoxManage to customize the VM. For example to change memory: 49 | # vb.customize ["modifyvm", :id, "--memory", "1024"] 50 | # end 51 | # 52 | # View the documentation for the provider you're using for more 53 | # information on available options. 54 | 55 | config.ssh.max_tries = 40 56 | config.ssh.timeout = 120 57 | 58 | # The path to the Berksfile to use with Vagrant Berkshelf 59 | # config.berkshelf.berksfile_path = "./Berksfile" 60 | 61 | # Enabling the Berkshelf plugin. To enable this globally, add this configuration 62 | # option to your ~/.vagrant.d/Vagrantfile file 63 | config.berkshelf.enabled = true 64 | 65 | # An array of symbols representing groups of cookbook described in the Vagrantfile 66 | # to exclusively install and copy to Vagrant's shelf. 67 | # config.berkshelf.only = [] 68 | 69 | # An array of symbols representing groups of cookbook described in the Vagrantfile 70 | # to skip installing and copying to Vagrant's shelf. 71 | # config.berkshelf.except = [] 72 | 73 | config.vm.provision :chef_solo do |chef| 74 | chef.json = { 75 | :mysql => { 76 | :server_root_password => 'rootpass', 77 | :server_debian_password => 'debpass', 78 | :server_repl_password => 'replpass' 79 | } 80 | } 81 | 82 | chef.run_list = [ 83 | "recipe[cpanminus::default]", 84 | "recipe[minitest-handler]" 85 | ] 86 | end 87 | end 88 | -------------------------------------------------------------------------------- /pinto/files/default/tests/minitest/application_test.rb: -------------------------------------------------------------------------------- 1 | class PintoSpec < MiniTest::Chef::Spec 2 | 3 | include PintoLibrary 4 | 5 | describe 'installs pinto' do 6 | 7 | it 'creates pinto user/group' do 8 | group("#{node[:pinto][:group]}").must_exist 9 | user("#{node[:pinto][:user]}").must_exist.with(:group, "#{node[:pinto][:user]}") 10 | end 11 | 12 | it 'creates pinto_home directory' do 13 | directory(pinto_home).must_exist.with(:owner, "#{node[:pinto][:user]}") 14 | directory(pinto_home).must_exist.with(:group, "#{node[:pinto][:group]}") 15 | end 16 | 17 | it 'creates pinto_home sub directories' do 18 | pinto_sub_dirs.each do |d| 19 | directory(d).must_exist.with(:owner, "#{node[:pinto][:user]}") 20 | directory(d).must_exist.with(:group, "#{node[:pinto][:group]}") 21 | end 22 | end 23 | 24 | %w( pinto pintod ).each do |file| 25 | it "installs #{file} into pinto_home directory" do 26 | file("#{pinto_home}/bin/#{file}").must_exist.with(:owner, "#{node[:pinto][:user]}") 27 | file("#{pinto_home}/bin/#{file}").must_exist.with(:group, "#{node[:pinto][:group]}") 28 | file("#{pinto_home}/bin/#{file}").must_have(:mode, "555") 29 | end 30 | end 31 | 32 | it "installs pinto bashrc file" do 33 | file("#{pinto_home}/etc/bashrc").must_exist.with(:owner, "#{node[:pinto][:user]}") 34 | file("#{pinto_home}/etc/bashrc").must_exist.with(:group, "#{node[:pinto][:group]}") 35 | file("#{pinto_home}/etc/bashrc").must_have(:mode, "644") 36 | file("#{pinto_home}/etc/bashrc").must_include(pinto_home) 37 | end 38 | 39 | it "installs valid pinto bashrc file" do 40 | 41 | assert_sh "echo 'source #{pinto_home}/etc/bashrc' | sudo su -s /bin/bash --login #{node[:pinto][:user]}" 42 | 43 | %w( pinto pintod ).each do |file| 44 | result = assert_sh "echo 'source #{pinto_home}/etc/bashrc && which #{file}' | sudo su -s /bin/bash --login #{node[:pinto][:user]}" 45 | assert_includes result, "#{pinto_home}/bin/#{file}" 46 | end 47 | assert_sh "echo 'source #{pinto_home}/etc/bashrc && pinto --version' | sudo su -s /bin/bash --login #{node[:pinto][:user]}" 48 | end 49 | 50 | it "installs correct version of Printo Application" do 51 | result = assert_sh("sudo -u #{node[:pinto][:user]} bash -c 'source #{pinto_home}/etc/bashrc && pinto --version'") 52 | assert_includes result, "#{pinto_home}/bin/pinto" 53 | assert_includes result, node[:pinto][:version] 54 | end 55 | 56 | it "smoke tests on installed pinto client" do 57 | assert_sh "rm -rf #{pinto_home}/tmp/" 58 | assert_sh "sudo -u #{node[:pinto][:user]} bash -c 'mkdir #{pinto_home}/tmp/'" 59 | assert_sh "sudo -u #{node[:pinto][:user]} bash -c 'source #{pinto_home}/etc/bashrc && pinto -r #{pinto_home}/tmp/ init'" 60 | assert_sh "echo 'source #{pinto_home}/etc/bashrc && pinto -r #{pinto_home}/tmp/ pull Bundler' | sudo su -s /bin/bash --login #{node[:pinto][:user]}" 61 | 62 | if node[:pinto][:slow_tests] == '1' 63 | puts "running slow tests, please be patient, will take some time ..." 64 | result = assert_sh "sudo -u #{node[:pinto][:user]} bash -c 'source #{pinto_home}/etc/bashrc && pinto -r #{pinto_home}/tmp/ list'" 65 | assert_includes result, '[rf-] Bundler' 66 | else 67 | puts "skip slow tests" 68 | end 69 | 70 | end 71 | 72 | end 73 | end 74 | 75 | -------------------------------------------------------------------------------- /catalyst/templates/gentoo/catalyst_application: -------------------------------------------------------------------------------- 1 | #!<%= `which runscript`.chomp! %> 2 | # Copyright 1999-2004 Gentoo Foundation 3 | # Distributed under the terms of the GNU General Public License v2 4 | 5 | PIDFILE="/var/run/${SVCNAME}.pid" 6 | 7 | 8 | # default socket 9 | if [ ! $SOCKET ]; then 10 | SOCKET="/tmp/${SVCNAME}.socket" 11 | fi 12 | 13 | #default NPROC 14 | if [ ! $NPROC ]; then 15 | NPROC=1 16 | fi 17 | 18 | 19 | #default proc manager 20 | #if [ ! $PROC_MANAGER ]; then 21 | # PROC_MANAGER="Adriver::FCGI::ProcManager" 22 | #fi 23 | 24 | #default PERL5LIB 25 | #if [ ! ${PERL5LIB} ]; then 26 | # PERL5LIB='/usr/local/rle/lib/perl:${PERL5LIB}' 27 | #fi 28 | 29 | ENVVARSOPTS=`perl -e 'if($ARGV[0]) {chomp $ARGV[0]; print join " ", map {" --env $_"} split /\s+/, $ARGV[0]} ' "${ENVVARS}"` 30 | 31 | opts="${opts} getconfig" 32 | 33 | checkconfig() { 34 | 35 | if [ ! "${APPLICATION_HOME}" ]; then 36 | eerror "APPLICATION_HOME is not set!" 37 | return 1 38 | fi 39 | 40 | if [ ! -d "${APPLICATION_HOME}" ]; then 41 | eerror "application home dir is set to ${APPLICATION_HOME}, but this directory not found!" 42 | return 1 43 | fi 44 | 45 | if [ ! -f "${APPLICATION_HOME}/script/${SCRIPT}" ]; then 46 | eerror "application script ${APPLICATION_HOME}/script/${SCRIPT} not found!" 47 | return 1 48 | fi 49 | 50 | if [ ! -x "${APPLICATION_HOME}/script/${SCRIPT}" ]; then 51 | eerror "application script ${APPLICATION_HOME}/script/${SCRIPT} is found but it's not executable!" 52 | return 1 53 | fi 54 | 55 | if [ ! "${CATALYST_CONFIG}" ]; then 56 | eerror "CATALYST_CONFIG parameter has to be set!" 57 | return 1 58 | fi 59 | 60 | if [ ! "${APPLICATION_USER}" ]; then 61 | eerror "APPLICATION_USER parameter has to be set!" 62 | return 1 63 | fi 64 | 65 | return 0 66 | } 67 | 68 | start() { 69 | 70 | checkconfig || return 1 71 | 72 | ebegin "Starting catalyst application" 73 | cd $APPLICATION_HOME && 74 | eval "$ENVVARS" \ 75 | CATALYST_CONFIG="${CATALYST_CONFIG}" \ 76 | PERL5LIB="${PERL5LIB}" start-stop-daemon --verbose --start \ 77 | --chuid $APPLICATION_USER \ 78 | --pidfile $PIDFILE \ 79 | --background \ 80 | --make-pidfile \ 81 | --exec ${APPLICATION_HOME}/script/$SCRIPT \ 82 | --env "PERL5LIB=${PERL5LIB}" \ 83 | --env "CATALYST_CONFIG=${CATALYST_CONFIG}" \ 84 | -d $APPLICATION_HOME \ 85 | -- -M "${PROC_MANAGER}" -n "${NPROC}" -l "${SOCKET}" \ 86 | >> /tmp/log.txt 2>&1 87 | eend $? 88 | } 89 | # --background \ 90 | 91 | stop() { 92 | 93 | # checkconfig || return 1 94 | ebegin "Stopping catalyst application" 95 | 96 | if [ -f "${PIDFILE}" ]; then 97 | ebegin "stop pid ${PIDFILE}" 98 | start-stop-daemon --stop --pidfile "${PIDFILE}" 99 | else 100 | ewarn "pid file [${PIDFILE}] does not exist - cannot stop the process" 101 | ewarn "you may found pid by process name [${SCRIPT}]" 102 | fi 103 | 104 | eend $? 105 | } 106 | 107 | getconfig() { 108 | 109 | # checkconfig || return 1 110 | 111 | ebegin "APPLICATION_HOME : ${APPLICATION_HOME} " 112 | ebegin "SCRIPT : ${SCRIPT} " 113 | ebegin "APPLICATION_USER : ${APPLICATION_USER} " 114 | ebegin "CATALYST_CONFIG : ${CATALYST_CONFIG} " 115 | ebegin "ENVVARS : ${ENVVARS} " 116 | ebegin "ENVVARSOPTS : ${ENVVARSOPTS} " 117 | ebegin "SVCNAME : ${SVCNAME} " 118 | 119 | if [ -f "${PIDFILE}" ]; then 120 | ebegin "PIDFILE : ${PIDFILE} " 121 | ebegin "PID : `cat ${PIDFILE}` " 122 | else 123 | ewarn "PIDFILE : [${PIDFILE}] does not exist" 124 | fi 125 | 126 | ebegin "SOCKET : ${SOCKET} " 127 | ebegin "NPROC : ${NPROC} " 128 | ebegin "PROC_MANAGER : ${PROC_MANAGER} " 129 | ebegin "PERL5LIB : ${PERL5LIB} " 130 | 131 | } 132 | -------------------------------------------------------------------------------- /psgi/definitions/psgi_application.rb: -------------------------------------------------------------------------------- 1 | define :psgi_application, :cookbook => 'psgi', :server => 'FCGI', :environment => {}, :plackup_environment => 'development', :proc_manager => 'FCGI::ProcManager', :perl5lib => [], :nproc => '1', :debug => '1', :enable_service => 'on', :ignore_failure => true do 2 | base_name = ::File.basename(params[:script].chomp ::File.extname(params[:script])) 3 | daemon_name = params[:daemon_name] ? params[:daemon_name] : base_name 4 | proc_title = params[:proc_title] ? params[:proc_title] : base_name 5 | 6 | socket = params[:socket] ? params[:socket] : "/tmp/#{base_name}_#{params[:server].downcase}.socket" 7 | 8 | 9 | if params[:action] == 'install' 10 | 11 | install_dir = params[:install_dir] || node[:psgi][:install][:dir] 12 | template "#{install_dir}/#{daemon_name}#{node[:psgi][:install][:extention]}" do 13 | source 'init-script' 14 | cookbook params[:cookbook] 15 | variables({ 16 | :application_user => params[:application_user], 17 | :application_home => params[:application_home], 18 | :application_script => params[:script], 19 | :application_desc => params[:name], 20 | :daemon_name => daemon_name, 21 | :daemon_path => params[:daemon_path] || `which plackup`.chomp, 22 | :socket => socket, 23 | :envvars => params[:environment], 24 | :perl5lib => params[:perl5lib], 25 | :nproc => params[:nproc], 26 | :proc_manager => params[:proc_manager] || ( params[:server] == 'FCGI' ? 'FCGI::ProcManager' : nil ), 27 | :proc_title => params[:proc_title] || ( params[:server] == 'FCGI' ? base_name : nil ) , 28 | :mount => params[:mount], 29 | :config => params[:config], 30 | :debug => params[:debug], 31 | :plackup_environment => params[:plackup_environment], 32 | :install_dir => params[:install_dir], 33 | :operator => params[:operator] || 'default', 34 | :server => params[:server], 35 | :loader => params[:loader], 36 | :backlog => params[:backlog] 37 | }) 38 | owner 'root' 39 | group 'root' 40 | mode '0755' 41 | end 42 | if params[:enable_service] == 'on' 43 | service daemon_name do 44 | action :enable 45 | provider node[:psgi][:service][:provider] 46 | end 47 | end 48 | elsif params[:action] == 'test' 49 | 50 | my_test_env = Hash.new 51 | my_test_env['PERL5LIB'] = params[:perl5lib].join ':' unless params[:perl5lib].empty? 52 | 53 | if params[:server] == 'Twiggy' 54 | my_test_env['TWIGGY_DEBUG'] = '1' 55 | end 56 | 57 | unless params[:operator].nil? 58 | if params[:operator] == 'Catalyst' 59 | my_test_env['CATALYST_CONFIG'] = params[:config] 60 | my_test_env['CATALYST_DEBUG'] = '1' 61 | elsif params[:operator] == 'Dancer' 62 | my_test_env['DANCER_CONFDIR'] = params[:application_home] 63 | elsif params[:operator] == 'Jifty' 64 | my_test_env['JIFTY_CONFIG'] = params[:config] 65 | end 66 | end 67 | 68 | 69 | my_test_env['SERVER_PORT'] = '80' 70 | my_test_env['SCRIPT_NAME'] = '/' 71 | my_test_env['REQUEST_METHOD'] = 'GET' 72 | 73 | my_env = params[:environment].clone 74 | 75 | log "execute in pwd: #{params[:application_home]}" 76 | log "execute with env: #{my_test_env.merge my_env}" 77 | daemon_path = params[:daemon_path] || `which plackup`.chomp 78 | log "daemon_path: #{daemon_path}" 79 | execute "#{daemon_path} -s CGI #{params[:script]}" do 80 | environment my_test_env.merge my_env 81 | cwd params[:application_home] 82 | user params[:application_user] 83 | group params[:application_group] 84 | ignore_failure params[:ignore_failure] 85 | end 86 | end 87 | end 88 | 89 | -------------------------------------------------------------------------------- /cpan/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # 0.1.0 2 | 3 | - Update license #33 4 | 5 | 6 | # 0.0.37 7 | 8 | - Fixing my change log 9 | 10 | # 0.0.36 11 | - occasional syntax error fixed, thanks to @redterror 12 | 13 | # 0.0.35 14 | - merged PR by @abadelt to fix `undefined method `cpan_client' after update to Chef 13 ` error - #3 15 | 16 | # version 0.0.31 17 | - Fix the order of parameters to Iconv#initialize - by [ippeif](https://github.com/ippeif), MR - [pull/17](https://github.com/melezhik/cookbooks/pull/19) 18 | 19 | # version 0.0.30 20 | - bootstrap recipe now can be run in skip_uptodate mode, thanks to [phoolish](https://github.com/phoolish), merged [pull/17](https://github.com/melezhik/cookbooks/pull/17) 21 | 22 | # version 0.0.29 23 | - bootstrap recipe: added centos relate package [pull/16](https://github.com/melezhik/cookbooks/pull/16), thanks to [phoolish](https://github.com/phoolish) 24 | 25 | # version 0.0.28 26 | - berkshelf / minitest chef infrastructure has been added 27 | - messages 'won't install without force' in log file should turn into exception 28 | 29 | 30 | # version 0.0.27 31 | - cpan::bootstrap have been made multiplatforms - todo 32 | - centos platform now is supported - todo 33 | 34 | # version 0.0.26 35 | - have made bootstrap recipe more concise and clear 36 | - cucumber tests have been moved to distinct github project - https://github.com/melezhik/cpan-test/ 37 | - few logger/output changes 38 | 39 | # version 0.0.25 40 | - cpan index force reload 41 | - explicit cookbook name in metadata (https://github.com/melezhik/cookbooks/pull/5) 42 | 43 | # version 0.0.24 44 | - workaround for invalid byte sequence in UTF-8 45 | 46 | # version 0.0.23 47 | - fix for unstrusted string hanlding commented (does not work for ruby 1.8.*) 48 | - reload index action implemented now by `reload index` cpan client command 49 | - bootstrap list minimized 50 | 51 | # version 0.0.22 52 | - replace Iconv by encode 53 | - do not turn 'ERRORS/WARNINGS FOUND IN PREREQUISITES' into exception 54 | 55 | # version 0.0.21 56 | - turning 'ERRORS/WARNINGS FOUND IN PREREQUISITES' into exception 57 | - cpan::bootstrap - AUTOMATED_TESTING enabled (https://github.com/melezhik/cookbooks/issues/1) 58 | 59 | # version 0.0.20 60 | - cpan::bootstrap - added some vital Modules 61 | - cpan_client - handling untrusted strings with Iconv when grep cpan logs 62 | 63 | # version 0.0.19 64 | - default value for cwd is '/tmp/' 65 | 66 | # version 0.0.18 67 | - installs exact version now available 68 | 69 | # version 0.0.17 70 | - a big refactoring 71 | - `module_name` parameter added 72 | - version check when doing install from cookbook/url 73 | - documentation cleaned up 74 | 75 | 76 | # version 0.0.16 77 | - небольшой рефакторинг кода 78 | 79 | # version 0.0.15 80 | - install from remote tarball by http/ftp url 81 | 82 | # version 0.0.14 83 | - raise exception if found "Stopping: 'install' failed" in install_log - workaround for https://github.com/andk/cpanpm/issues/32 84 | - does `rm -rf "/tmp/local-lib/install/#{installed_module}"` in install from tarball to delete already unpacked distro 85 | - bugfix : user, group added to :action `test` 86 | 87 | # version 0.0.13 88 | - install summary: 89 | - improved, fixed and simplified 90 | 91 | # version 0.0.12 92 | - cpan-client: redirect stderr to stdout 93 | - made logs more clear 94 | 95 | # version 0.0.11 96 | - add cucumber features 97 | - bugfix for install_path cases 98 | 99 | # version 0.0.10 100 | - bugfix : before install create /tmp/local-lib/install directory 101 | 102 | # version 0.0.9 103 | - add documentation 104 | 105 | # version 0.0.8 106 | - .modulebuildrc create in :install action instead of cpan::default recipe 107 | - add cpan_home optional attribute 108 | - create '/tmp/local_lib/' before doing install 109 | 110 | # version 0.0.7 111 | - bugfix for install from tarball (forgot about cwd while refactoring) 112 | 113 | # version 0.0.6 114 | - replace execute resource by bash resources for less verbosity in logs 115 | - improve after-install summary 116 | 117 | # version 0.0.5 118 | - compact log messages 119 | 120 | # version 0.0.4 121 | - log messages are neat and at different levels 122 | - big fix for access to log files 123 | 124 | -------------------------------------------------------------------------------- /pinto/templates/debian/init.erb: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | ### BEGIN INIT INFO 3 | # Provides: Pinto Server Daemon 4 | # Required-Start: $remote_fs $syslog 5 | # Required-Stop: $remote_fs $syslog 6 | # Default-Start: 2 3 4 5 7 | # Default-Stop: 0 1 6 8 | # Short-Description: Example initscript 9 | # Description: This file should be used to construct scripts to be 10 | # placed in /etc/init.d. 11 | ### END INIT INFO 12 | 13 | # Author: Alexey Melezhik 14 | # 15 | 16 | # Do NOT "set -e" 17 | 18 | # PATH should only include /usr/* if it runs after the mountnfs.sh script 19 | PATH=/sbin:/usr/sbin:/bin:/usr/bin:<%= @home %>/bin/ 20 | DESC="Pinto Server Daemon" 21 | NAME=pintod 22 | DAEMON=<%= @home %>/bin/$NAME 23 | PIDFILE=/var/run/$NAME.pid 24 | SCRIPTNAME=/etc/init.d/$NAME 25 | DAEMON_ARGS="--root <%= @repo_root %> --server Starman --workers <%= @workers %> --host <%= @host %> --port <%= @port %> --user <%= @user %> --group <%= @group %> --access-log /var/log/pintod.log" 26 | 27 | # Exit if the package is not installed 28 | [ -x "$DAEMON" ] || exit 0 29 | 30 | # Read configuration variable file if it is present 31 | [ -r /etc/default/$NAME ] && . /etc/default/$NAME 32 | 33 | # Load the VERBOSE setting and other rcS variables 34 | . /lib/init/vars.sh 35 | 36 | # Define LSB log_* functions. 37 | # Depend on lsb-base (>= 3.2-14) to ensure that this file is present 38 | # and status_of_proc is working. 39 | . /lib/lsb/init-functions 40 | 41 | # 42 | # Function that starts the daemon/service 43 | # 44 | do_start() 45 | { 46 | # Return 47 | # 0 if daemon has been started 48 | # 1 if daemon was already running 49 | # 2 if daemon could not be started 50 | export PERL5LIB=PERL5LIB:<%= @home %>/lib/perl5 51 | start-stop-daemon --start --test -b --startas $DAEMON -m --pidfile $PIDFILE -- $DAEMON_ARGS > /dev/null || return 1 52 | start-stop-daemon --start --startas $DAEMON -b -m --pidfile $PIDFILE -- $DAEMON_ARGS || return 2 53 | # Add code here, if necessary, that waits for the process to be ready 54 | # to handle requests from services started subsequently which depend 55 | # on this one. As a last resort, sleep for some time. 56 | } 57 | 58 | # 59 | # Function that stops the daemon/service 60 | # 61 | do_stop() 62 | { 63 | # Return 64 | # 0 if daemon has been stopped 65 | # 1 if daemon was already stopped 66 | # 2 if daemon could not be stopped 67 | # other if a failure occurred 68 | start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE 69 | RETVAL="$?" 70 | [ "$RETVAL" = 2 ] && return 2 71 | # Wait for children to finish too if this is a daemon that forks 72 | # and if the daemon is only ever run from this initscript. 73 | # If the above conditions are not satisfied then add some other code 74 | # that waits for the process to drop all resources that could be 75 | # needed by services started subsequently. A last resort is to 76 | # sleep for some time. 77 | start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --pidfile $PIDFILE 78 | [ "$?" = 2 ] && return 2 79 | # Many daemons don't delete their pidfiles when they exit. 80 | # rm -f $PIDFILE 81 | return "$RETVAL" 82 | } 83 | 84 | # 85 | # Function that sends a SIGHUP to the daemon/service 86 | # 87 | do_reload() { 88 | # 89 | # If the daemon can reload its configuration without 90 | # restarting (for example, when it is sent a SIGHUP), 91 | # then implement that here. 92 | # 93 | start-stop-daemon --stop --signal 1 --quiet --pidfile $PIDFILE 94 | return 0 95 | } 96 | 97 | case "$1" in 98 | start) 99 | [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME" 100 | do_start 101 | case "$?" in 102 | 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; 103 | 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; 104 | esac 105 | ;; 106 | stop) 107 | [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME" 108 | do_stop 109 | case "$?" in 110 | 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; 111 | 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; 112 | esac 113 | ;; 114 | status) 115 | status_of_proc -p $PIDFILE "$DAEMON" "$NAME" && exit 0 || exit $? 116 | ;; 117 | #reload|force-reload) 118 | # 119 | # If do_reload() is not implemented then leave this commented out 120 | # and leave 'force-reload' as an alias for 'restart'. 121 | # 122 | #log_daemon_msg "Reloading $DESC" "$NAME" 123 | #do_reload 124 | #log_end_msg $? 125 | #;; 126 | restart|force-reload) 127 | # 128 | # If the "reload" option is implemented then remove the 129 | # 'force-reload' alias 130 | # 131 | log_daemon_msg "Restarting $DESC" "$NAME" 132 | do_stop 133 | case "$?" in 134 | 0|1) 135 | do_start 136 | case "$?" in 137 | 0) log_end_msg 0 ;; 138 | 1) log_end_msg 1 ;; # Old process is still running 139 | *) log_end_msg 1 ;; # Failed to start 140 | esac 141 | ;; 142 | *) 143 | # Failed to stop 144 | log_end_msg 1 145 | ;; 146 | esac 147 | ;; 148 | *) 149 | #echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2 150 | echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2 151 | exit 3 152 | ;; 153 | esac 154 | 155 | : 156 | -------------------------------------------------------------------------------- /pinto/templates/ubuntu/init.erb: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | ### BEGIN INIT INFO 3 | # Provides: Pinto Server Daemon 4 | # Required-Start: $remote_fs $syslog 5 | # Required-Stop: $remote_fs $syslog 6 | # Default-Start: 2 3 4 5 7 | # Default-Stop: 0 1 6 8 | # Short-Description: Example initscript 9 | # Description: This file should be used to construct scripts to be 10 | # placed in /etc/init.d. 11 | ### END INIT INFO 12 | 13 | # Author: Alexey Melezhik 14 | # 15 | 16 | # Do NOT "set -e" 17 | 18 | # PATH should only include /usr/* if it runs after the mountnfs.sh script 19 | PATH=/sbin:/usr/sbin:/bin:/usr/bin:<%= @home %>bin/ 20 | DESC="Pinto Server Daemon" 21 | NAME=pintod 22 | DAEMON=<%= @home %>/bin/$NAME 23 | PIDFILE=/var/run/$NAME.pid 24 | SCRIPTNAME=/etc/init.d/$NAME 25 | DAEMON_ARGS="--root <%= @repo_root %> --server Starman --workers <%= @workers %> --host <%= @host %> --port <%= @port %> --user <%= @user %> --group <%= @group %> --access-log /var/log/pintod.log" 26 | 27 | # Exit if the package is not installed 28 | [ -x "$DAEMON" ] || exit 0 29 | 30 | # Read configuration variable file if it is present 31 | [ -r /etc/default/$NAME ] && . /etc/default/$NAME 32 | 33 | # Load the VERBOSE setting and other rcS variables 34 | . /lib/init/vars.sh 35 | 36 | # Define LSB log_* functions. 37 | # Depend on lsb-base (>= 3.2-14) to ensure that this file is present 38 | # and status_of_proc is working. 39 | . /lib/lsb/init-functions 40 | 41 | # 42 | # Function that starts the daemon/service 43 | # 44 | do_start() 45 | { 46 | # Return 47 | # 0 if daemon has been started 48 | # 1 if daemon was already running 49 | # 2 if daemon could not be started 50 | export PERL5LIB=PERL5LIB:<%= @home %>/lib/perl5 51 | start-stop-daemon --start --test -b --startas $DAEMON -m --pidfile $PIDFILE -- $DAEMON_ARGS > /dev/null || return 1 52 | start-stop-daemon --start --startas $DAEMON -b -m --pidfile $PIDFILE -- $DAEMON_ARGS || return 2 53 | # Add code here, if necessary, that waits for the process to be ready 54 | # to handle requests from services started subsequently which depend 55 | # on this one. As a last resort, sleep for some time. 56 | } 57 | 58 | # 59 | # Function that stops the daemon/service 60 | # 61 | do_stop() 62 | { 63 | # Return 64 | # 0 if daemon has been stopped 65 | # 1 if daemon was already stopped 66 | # 2 if daemon could not be stopped 67 | # other if a failure occurred 68 | start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE 69 | RETVAL="$?" 70 | [ "$RETVAL" = 2 ] && return 2 71 | # Wait for children to finish too if this is a daemon that forks 72 | # and if the daemon is only ever run from this initscript. 73 | # If the above conditions are not satisfied then add some other code 74 | # that waits for the process to drop all resources that could be 75 | # needed by services started subsequently. A last resort is to 76 | # sleep for some time. 77 | start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --pidfile $PIDFILE 78 | [ "$?" = 2 ] && return 2 79 | # Many daemons don't delete their pidfiles when they exit. 80 | # rm -f $PIDFILE 81 | return "$RETVAL" 82 | } 83 | 84 | # 85 | # Function that sends a SIGHUP to the daemon/service 86 | # 87 | do_reload() { 88 | # 89 | # If the daemon can reload its configuration without 90 | # restarting (for example, when it is sent a SIGHUP), 91 | # then implement that here. 92 | # 93 | start-stop-daemon --stop --signal 1 --quiet --pidfile $PIDFILE 94 | return 0 95 | } 96 | 97 | case "$1" in 98 | start) 99 | [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME" 100 | do_start 101 | case "$?" in 102 | 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; 103 | 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; 104 | esac 105 | ;; 106 | stop) 107 | [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME" 108 | do_stop 109 | case "$?" in 110 | 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; 111 | 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; 112 | esac 113 | ;; 114 | status) 115 | status_of_proc -p $PIDFILE "$DAEMON" "$NAME" && exit 0 || exit $? 116 | ;; 117 | #reload|force-reload) 118 | # 119 | # If do_reload() is not implemented then leave this commented out 120 | # and leave 'force-reload' as an alias for 'restart'. 121 | # 122 | #log_daemon_msg "Reloading $DESC" "$NAME" 123 | #do_reload 124 | #log_end_msg $? 125 | #;; 126 | restart|force-reload) 127 | # 128 | # If the "reload" option is implemented then remove the 129 | # 'force-reload' alias 130 | # 131 | log_daemon_msg "Restarting $DESC" "$NAME" 132 | do_stop 133 | case "$?" in 134 | 0|1) 135 | do_start 136 | case "$?" in 137 | 0) log_end_msg 0 ;; 138 | 1) log_end_msg 1 ;; # Old process is still running 139 | *) log_end_msg 1 ;; # Failed to start 140 | esac 141 | ;; 142 | *) 143 | # Failed to stop 144 | log_end_msg 1 145 | ;; 146 | esac 147 | ;; 148 | *) 149 | #echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2 150 | echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2 151 | exit 3 152 | ;; 153 | esac 154 | 155 | : 156 | -------------------------------------------------------------------------------- /catalyst/templates/debian/catalyst_application.erb: -------------------------------------------------------------------------------- 1 | #! <%= `which sh`.chomp! %> 2 | ### BEGIN INIT INFO 3 | # Provides: <%= @service_name %> 4 | # Required-Start: $remote_fs $syslog 5 | # Required-Stop: $remote_fs $syslog 6 | # Default-Start: 2 3 4 5 7 | # Default-Stop: 0 1 6 8 | # Short-Description: Example initscript 9 | # Description: This file should be used to construct scripts to be 10 | # placed in /etc/init.d. 11 | ### END INIT INFO 12 | 13 | # Author: Foo Bar 14 | # 15 | # Please remove the "Author" lines above and replace them 16 | # with your own name if you copy and modify this script. 17 | 18 | # Do NOT "set -e" 19 | 20 | # PATH should only include /usr/* if it runs after the mountnfs.sh script 21 | 22 | APPLICATION_USER=<%= @application_user %> 23 | APPLICATION_HOME=<%= @application_home %> 24 | CATALYST_CONFIG=<%= @catalyst_config %> 25 | 26 | <%- unless @perl5lib.empty? %> 27 | PERL5LIB="<%= @perl5lib.join(':') %>" 28 | <%- end %> 29 | 30 | NAME="<%= @service_name %>" 31 | PATH=/sbin:/usr/sbin:/bin:/usr/bin 32 | DESC="fastcgi catalyst application" 33 | DAEMON=<%= @application_home %>/script/<%= @application_script %> 34 | DAEMON_ARGS="-M <%= @proc_manager %> -n <%= @nproc %> -l <%= @socket %> --proc_title <%= @application_script %>-fcgi" 35 | PIDFILE=/var/run/$NAME.pid 36 | SCRIPTNAME=/etc/init.d/$NAME 37 | 38 | <%- vars = [] %> 39 | <%- @envvars.each do |k,v| %> 40 | <%- vars << "#{k}=#{v}" %> 41 | <%- end %> 42 | ENVVARS='<%= vars.join(" ") %>' 43 | 44 | 45 | # Exit if the package is not installed 46 | [ -x "$DAEMON" ] || exit 0 47 | 48 | # Read configuration variable file if it is present 49 | [ -r /etc/default/$NAME ] && . /etc/default/$NAME 50 | 51 | # Load the VERBOSE setting and other rcS variables 52 | . /lib/init/vars.sh 53 | 54 | # Define LSB log_* functions. 55 | # Depend on lsb-base (>= 3.0-6) to ensure that this file is present. 56 | . /lib/lsb/init-functions 57 | 58 | # 59 | # Function that starts the daemon/service 60 | # 61 | do_start() 62 | { 63 | # Return 64 | # 0 if daemon has been started 65 | # 1 if daemon was already running 66 | # 2 if daemon could not be started 67 | start-stop-daemon --start --quiet --pidfile $PIDFILE --startas "<%= @application_script %>-fcgi" --test --verbose \ 68 | || return 1 69 | eval "$ENVVARS" \ 70 | CATALYST_CONFIG="${CATALYST_CONFIG}" \ 71 | PERL5LIB="${PERL5LIB}" \ 72 | start-stop-daemon -d $APPLICATION_HOME \ 73 | --chuid $APPLICATION_USER \ 74 | --background --make-pidfile \ 75 | --start --verbose --pidfile $PIDFILE \ 76 | --exec $DAEMON -- \ 77 | $DAEMON_ARGS \ 78 | || return 2 79 | # Add code here, if necessary, that waits for the process to be ready 80 | # to handle requests from services started subsequently which depend 81 | # on this one. As a last resort, sleep for some time. 82 | } 83 | 84 | # 85 | # Function that stops the daemon/service 86 | # 87 | do_stop() 88 | { 89 | # Return 90 | # 0 if daemon has been stopped 91 | # 1 if daemon was already stopped 92 | # 2 if daemon could not be stopped 93 | # other if a failure occurred 94 | start-stop-daemon --stop --signal 15 --retry 5 --quiet --pidfile $PIDFILE 95 | RETVAL="$?" 96 | [ "$RETVAL" = 2 ] && return 2 97 | # Many daemons don't delete their pidfiles when they exit. 98 | rm -f $PIDFILE 99 | return "$RETVAL" 100 | } 101 | 102 | # 103 | # Function that sends a SIGHUP to the daemon/service 104 | # 105 | do_reload() { 106 | # 107 | # If the daemon can reload its configuration without 108 | # restarting (for example, when it is sent a SIGHUP), 109 | # then implement that here. 110 | # 111 | start-stop-daemon --stop --signal 1 --quiet --pidfile $PIDFILE --name $NAME 112 | return 0 113 | } 114 | 115 | case "$1" in 116 | start) 117 | [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME" 118 | do_start 119 | case "$?" in 120 | 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; 121 | 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; 122 | esac 123 | ;; 124 | stop) 125 | [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME" 126 | do_stop 127 | case "$?" in 128 | 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; 129 | 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; 130 | esac 131 | ;; 132 | status) 133 | status_of_proc "<%= @application_script %>-fcgi" "$NAME" && exit 0 || exit $? 134 | ;; 135 | #reload|force-reload) 136 | # 137 | # If do_reload() is not implemented then leave this commented out 138 | # and leave 'force-reload' as an alias for 'restart'. 139 | # 140 | #log_daemon_msg "Reloading $DESC" "$NAME" 141 | #do_reload 142 | #log_end_msg $? 143 | #;; 144 | restart|force-reload) 145 | # 146 | # If the "reload" option is implemented then remove the 147 | # 'force-reload' alias 148 | # 149 | log_daemon_msg "Restarting $DESC" "$NAME" 150 | do_stop 151 | case "$?" in 152 | 0|1) 153 | do_start 154 | case "$?" in 155 | 0) log_end_msg 0 ;; 156 | 1) log_end_msg 1 ;; # Old process is still running 157 | *) log_end_msg 1 ;; # Failed to start 158 | esac 159 | ;; 160 | *) 161 | # Failed to stop 162 | log_end_msg 1 163 | ;; 164 | esac 165 | ;; 166 | *) 167 | #echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2 168 | echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2 169 | exit 3 170 | ;; 171 | esac 172 | 173 | : 174 | -------------------------------------------------------------------------------- /nginx-fastcgi/README.md: -------------------------------------------------------------------------------- 1 | # Description 2 | Creates nginx site to run your fastcgi application with nginx front-end 3 | 4 | # Requirements 5 | Should work on any platform where nginx is installed. Tested on Ubuntu/Debian. 6 | 7 | # Limitations 8 | fastcgi standalone server mode is only supported 9 | 10 | # DEFINITIONS 11 | ``nginx_fastcgi`` 12 | 13 | This definition can be used to create nginx site to run your fastcgi application with nginx front-end. 14 | 15 | The definition takes the following parameters: 16 | 17 | * `name`: specifies a path for nginx site configuration file. No default, this must be specified. 18 | * `socket`: specifies unix socket of FastCGI server. 19 | * `inet_socket`: specifies inet socket of FastCGI server. No default. Choose either unix or inet socket. 20 | 21 | Check out http://wiki.nginx.org/HttpFastcgiModule#fastcgi_pass for details. 22 | 23 | * `static`: specifies location of static files (to be handled by nginx). Array of Hashes or hash with following keys: 24 | * `location` 25 | * `root` 26 | * `servers`: specifies virtual hosts to be included into ngix site configuration. Array of Hashes with following keys: 27 | * `ip` 28 | * `server_name` 29 | * `ssl` 30 | * `ssl_include_path` 31 | * `error_page` 32 | * `redirect` 33 | * `cookbook`: specifies the cookbook with nginx site configuration template. Optional 34 | * `fastcgi_param`: specifies additional fastcgi params 35 | * `error_page` - specifies custom error pages. Array of Hashes with following keys: 36 | * code 37 | * handler 38 | 39 | Check out http://wiki.nginx.org/HttpCoreModule#error_page for details 40 | 41 | * `fastcgi_intercept_errors` - specify value for fastcgi_intercept_errors. Check out http://wiki.nginx.org/HttpFastcgiModule#fastcgi_intercept_errors for details. Default value is false 42 | * `fastcgi_read_timeout` - specify value for fastcgi read timeout. Check out http://nginx.org/en/docs/http/ngx_http_fastcgi_module.html#fastcgi_read_timeout for details. Default value is nil. 43 | 44 | # Usage cases 45 | 46 | ## named virtual host, port 80 47 | 48 | nginx_fastcgi '/etc/nginx/sites-available/foo.site.conf' do 49 | socket '/tmp/application.socket' 50 | servers [ 51 | { 52 | :ip => '127.0.0.1', 53 | :server_name => 'foo.site.x' 54 | } 55 | ] 56 | end 57 | 58 | ## fastcgi running on inet socket 59 | 60 | nginx_fastcgi '/etc/nginx/sites-available/foo.site.conf' do 61 | inet_socket 'localhost:9000' 62 | servers [ 63 | { 64 | :ip => '127.0.0.1', 65 | :server_name => 'foo.site.x' 66 | } 67 | ] 68 | end 69 | 70 | ## ssl enabled virtual host 71 | 72 | nginx_fastcgi '/etc/nginx/sites-available/foo.site.conf' do 73 | socket '/tmp/application.socket' 74 | servers [ 75 | { 76 | :server_name => 'bar.site.x', 77 | :ssl => true, 78 | :ssl_include_path => 'nginx_ssl_settings.conf' 79 | 80 | } 81 | ] 82 | end 83 | 84 | ## set document root 85 | 86 | nginx_fastcgi '/etc/nginx/sites-available/foo.site.conf' do 87 | root '/var/www/MyApp/root' 88 | socket '/tmp/application.socket' 89 | servers [ 90 | { 91 | :server_name => 'foo.site.x', 92 | } 93 | ] 94 | end 95 | 96 | ## enabling http -> https redirect 97 | 98 | # all http traffic get redirected to https host: 99 | 100 | nginx_fastcgi '/etc/nginx/sites-available/foo.site.conf' do 101 | socket '/tmp/application.socket' 102 | servers [ 103 | { 104 | :ip => '127.0.0.1', 105 | :server_name => 'bar.site.x', 106 | :redirect => 'https' 107 | }, 108 | { 109 | :ip => '127.0.0.1', 110 | :server_name => 'bar.site.x', 111 | :ssl => true, 112 | :ssl_include_path => 'nginx_ssl_settings.conf' 113 | } 114 | ] 115 | end 116 | 117 | ## handling static files by nginx 118 | 119 | nginx_fastcgi '/etc/nginx/sites-available/foo.site.conf' do 120 | socket '/tmp/application.socket' 121 | static( 122 | :location => 'static/', 123 | :root => '/var/www/MyApp/root' 124 | ) 125 | servers [ 126 | { 127 | :server_name => 'foo.site.x', 128 | } 129 | ] 130 | end 131 | 132 | ## set specific fastcgi params: 133 | 134 | nginx_fastcgi '/etc/nginx/sites-available/foo.site.conf' do 135 | socket '/tmp/application.socket' 136 | fastcgi_param [ 137 | { :name => 'SCRIPT_NAME', :value => "\"\"" }, 138 | { :name => 'PATH_INFO' , :value => '$uri' } 139 | ] 140 | servers [ 141 | { 142 | :server_name => 'foo.site.x', 143 | } 144 | ] 145 | end 146 | 147 | ## set error page, code 500 148 | 149 | nginx_fastcgi '/etc/nginx/sites-available/foo.site.conf' do 150 | socket '/tmp/application.socket' 151 | servers [ 152 | { 153 | :server_name => 'foo.site.x' 154 | } 155 | ] 156 | error_page [ 157 | { 158 | :code => 500, 159 | :handler => '/500.html' 160 | } 161 | ] 162 | end 163 | 164 | ------ 165 | 166 | For complete examples of usage see https://github.com/melezhik/cookbooks/tree/master/nginx-fastcgi/features 167 | 168 | 169 | -------------------------------------------------------------------------------- /catalyst/templates/ubuntu/catalyst_application.erb: -------------------------------------------------------------------------------- 1 | #! <%= `which sh`.chomp! %> 2 | ### BEGIN INIT INFO 3 | # Provides: <%= @service_name %> 4 | # Required-Start: $remote_fs $syslog 5 | # Required-Stop: $remote_fs $syslog 6 | # Default-Start: 2 3 4 5 7 | # Default-Stop: 0 1 6 8 | # Short-Description: Example initscript 9 | # Description: This file should be used to construct scripts to be 10 | # placed in /etc/init.d. 11 | ### END INIT INFO 12 | 13 | # Author: Foo Bar 14 | # 15 | # Please remove the "Author" lines above and replace them 16 | # with your own name if you copy and modify this script. 17 | 18 | # Do NOT "set -e" 19 | 20 | # PATH should only include /usr/* if it runs after the mountnfs.sh script 21 | 22 | APPLICATION_USER=<%= @application_user %> 23 | APPLICATION_HOME=<%= @application_home %> 24 | CATALYST_CONFIG=<%= @catalyst_config %> 25 | 26 | <%- unless @perl5lib.empty? %> 27 | PERL5LIB="<%= @perl5lib.join(':') %>" 28 | <%- end %> 29 | 30 | NAME="<%= @service_name %>" 31 | PATH=/sbin:/usr/sbin:/bin:/usr/bin 32 | DESC="fastcgi catalyst application" 33 | DAEMON=<%= @application_home %>/script/<%= @application_script %> 34 | DAEMON_ARGS="-M <%= @proc_manager %> -n <%= @nproc %> -l <%= @socket %>" 35 | PIDFILE=/var/run/$NAME.pid 36 | SCRIPTNAME=/etc/init.d/$NAME 37 | 38 | <%- vars = [] %> 39 | <%- @envvars.each do |k,v| %> 40 | <%- vars << "#{k}=#{v}" %> 41 | <%- end %> 42 | ENVVARS='<%= vars.join(" ") %>' 43 | 44 | 45 | # Exit if the package is not installed 46 | [ -x "$DAEMON" ] || exit 0 47 | 48 | # Read configuration variable file if it is present 49 | [ -r /etc/default/$NAME ] && . /etc/default/$NAME 50 | 51 | # Load the VERBOSE setting and other rcS variables 52 | . /lib/init/vars.sh 53 | 54 | # Define LSB log_* functions. 55 | # Depend on lsb-base (>= 3.0-6) to ensure that this file is present. 56 | . /lib/lsb/init-functions 57 | 58 | # 59 | # Function that starts the daemon/service 60 | # 61 | do_start() 62 | { 63 | # Return 64 | # 0 if daemon has been started 65 | # 1 if daemon was already running 66 | # 2 if daemon could not be started 67 | start-stop-daemon --start --quiet --pidfile $PIDFILE --startas "<%= @application_script %>-fcgi" --test --verbose \ 68 | || return 1 69 | eval "$ENVVARS" \ 70 | CATALYST_CONFIG="${CATALYST_CONFIG}" \ 71 | PERL5LIB="${PERL5LIB}" \ 72 | start-stop-daemon -d $APPLICATION_HOME \ 73 | --chuid $APPLICATION_USER \ 74 | --background --make-pidfile \ 75 | --start --verbose --pidfile $PIDFILE \ 76 | --env "PERL5LIB=${PERL5LIB}" \ 77 | --env "CATALYST_CONFIG=${CATALYST_CONFIG}" \ 78 | --exec $DAEMON -- \ 79 | $DAEMON_ARGS \ 80 | || return 2 81 | # Add code here, if necessary, that waits for the process to be ready 82 | # to handle requests from services started subsequently which depend 83 | # on this one. As a last resort, sleep for some time. 84 | } 85 | 86 | # 87 | # Function that stops the daemon/service 88 | # 89 | do_stop() 90 | { 91 | # Return 92 | # 0 if daemon has been stopped 93 | # 1 if daemon was already stopped 94 | # 2 if daemon could not be stopped 95 | # other if a failure occurred 96 | start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE --name $NAME 97 | RETVAL="$?" 98 | [ "$RETVAL" = 2 ] && return 2 99 | # Wait for children to finish too if this is a daemon that forks 100 | # and if the daemon is only ever run from this initscript. 101 | # If the above conditions are not satisfied then add some other code 102 | # that waits for the process to drop all resources that could be 103 | # needed by services started subsequently. A last resort is to 104 | # sleep for some time. 105 | start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --pidfile $PIDFILE 106 | [ "$?" = 2 ] && return 2 107 | # Many daemons don't delete their pidfiles when they exit. 108 | rm -f $PIDFILE 109 | return "$RETVAL" 110 | } 111 | 112 | # 113 | # Function that sends a SIGHUP to the daemon/service 114 | # 115 | do_reload() { 116 | # 117 | # If the daemon can reload its configuration without 118 | # restarting (for example, when it is sent a SIGHUP), 119 | # then implement that here. 120 | # 121 | start-stop-daemon --stop --signal 1 --quiet --pidfile $PIDFILE --name $NAME 122 | return 0 123 | } 124 | 125 | case "$1" in 126 | start) 127 | [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME" 128 | do_start 129 | case "$?" in 130 | 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; 131 | 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; 132 | esac 133 | ;; 134 | stop) 135 | [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME" 136 | do_stop 137 | case "$?" in 138 | 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; 139 | 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; 140 | esac 141 | ;; 142 | status) 143 | status_of_proc "<%= @application_script %>-fcgi" "$NAME" && exit 0 || exit $? 144 | ;; 145 | #reload|force-reload) 146 | # 147 | # If do_reload() is not implemented then leave this commented out 148 | # and leave 'force-reload' as an alias for 'restart'. 149 | # 150 | #log_daemon_msg "Reloading $DESC" "$NAME" 151 | #do_reload 152 | #log_end_msg $? 153 | #;; 154 | restart|force-reload) 155 | # 156 | # If the "reload" option is implemented then remove the 157 | # 'force-reload' alias 158 | # 159 | log_daemon_msg "Restarting $DESC" "$NAME" 160 | do_stop 161 | case "$?" in 162 | 0|1) 163 | do_start 164 | case "$?" in 165 | 0) log_end_msg 0 ;; 166 | 1) log_end_msg 1 ;; # Old process is still running 167 | *) log_end_msg 1 ;; # Failed to start 168 | esac 169 | ;; 170 | *) 171 | # Failed to stop 172 | log_end_msg 1 173 | ;; 174 | esac 175 | ;; 176 | *) 177 | #echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2 178 | echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2 179 | exit 3 180 | ;; 181 | esac 182 | 183 | : 184 | -------------------------------------------------------------------------------- /psgi/README.md: -------------------------------------------------------------------------------- 1 | # Synopsis 2 | 3 | Configures and runs psgi application 4 | 5 | # Prerequisites 6 | * [Plack](http://search.cpan.org/perldoc?Plack) 7 | * a chosen web server cpan module should be installed ( see list in the `web servers supported` section ) 8 | 9 | # Last release 10 | 11 | http://community.opscode.com/cookbooks/psgi 12 | 13 | # Features 14 | 15 | ## web servers supported 16 | - [FCGI](http://search.cpan.org/perldoc?FCGI) 17 | - [Starman](http://search.cpan.org/perldoc?Starman) 18 | - [Twiggy](http://search.cpan.org/perldoc?Twiggy) 19 | 20 | ## web frameworks supported 21 | - [Catalyst](http://search.cpan.org/perldoc?Catalyst) 22 | - [Jifty](http://search.cpan.org/perldoc?Jifty) 23 | - [Dancer](http://search.cpan.org/perldoc?Dancer) 24 | 25 | 26 | # Resources 27 | psgi_application 28 | 29 | # Resource parameters 30 | - `operator` (Catalyst|Dancer|Jifty), specify web framework to use, optional 31 | - `server` (FCGI|Starman), specify web server to use, default value is **FCGI** 32 | - `application_user`, change to this user name before starting the process 33 | - `application_home`, absolute path to directory holding application home 34 | - `enable_service`, whether to add service to run levels, default value is **on**. To not enable service set this parameter to 'off' 35 | - `script` - the relative or absolute path to psgi script 36 | - `daemon_name`, optional, if not set - evaluated as basename from `script` 37 | - `daemon_path` - absolute path to daemon, default value is path to system installed [plackup](http://search.cpan.org/perldoc?plackup) 38 | - `socket`, optional, specify unix or inet socket 39 | - `environment`, hash containing environmental variables, default value **{}** 40 | - `perl5lib`, array containing perl5lib paths, default value **[]** 41 | - `nproc`, default value `1`, number of child processes to launch 42 | - `loader`, specifies the server loading subclass that implements how to run the server - see [plackup doc](http://search.cpan.org/perldoc?plackup) 43 | - `backlog`, maximum length of the queue of pending connections, only valid for `FCGI` server - [Plack::Handler::FCGI](http://search.cpan.org/perldoc?Plack%3A%3AHandler%3A%3AFCGI) 44 | - `proc_manager`, optional, default value is **FCGI::ProcManager** 45 | - `proc_title`, optional, how the processes are seen in process list 46 | - `mount`, optional, mount path, see [Plack::App::URLMap](http://search.cpan.org/perldoc?Plack%3A%3AApp%3A%3AURLMap) for details 47 | - `config`, absolute path to application configuration file (optional for 'Dancer' operator) 48 | - `debug`, default value **1** 49 | - `plackup_environment`, default value **development** 50 | - `cookbook`, default value `psgi`, the name of cookbook where init script template coming from 51 | - `ignore_failure` - used in action 'test', whether to ignore test failures, if enabled, than test fail will cause chef runtime exception. Default value is **false** 52 | 53 | 54 | # Web server specific options 55 | 56 | ## FCGI 57 | - `proc_manager` 58 | - `proc_title` 59 | 60 | # Init scripts notes 61 | 62 | ## Ubuntu, CentOS 63 | 64 | [upstart](http://upstart.ubuntu.com/) system used 65 | 66 | ## Debian 67 | [start-stop-daemon](http://www.unix.com/man-page/Linux/8/start-stop-daemon/) with [System V](http://en.wikipedia.org/wiki/UNIX_System_V) system used 68 | 69 | # Usage examples 70 | 71 | ## run Catalyst application as FCGI standalone server 72 | 73 | psgi_application 'Catalyst FCGI application' do 74 | operator 'Catalyst' 75 | server 'FCGI' 76 | application_user 'user' 77 | application_home '/home/user/app/MyApplication' 78 | script '/home/user/app/MyApplication/scripts/foo.psgi' 79 | config '/home/user/app/MyApplication/app.conf' 80 | action 'install' 81 | end 82 | 83 | ## run Dancer application as FCGI standalone server 84 | 85 | psgi_application 'Dancer FCGI application' do 86 | operator 'Dancer' 87 | server 'FCGI' 88 | application_user 'user' 89 | application_home '/home/user/app/MyApplication' 90 | script '/home/user/app/MyApplication/scripts/foo.psgi' 91 | action 'install' 92 | end 93 | 94 | ## run Jifty application as FCGI standalone server 95 | 96 | psgi_application 'Jifty FCGI application' do 97 | operator 'Jifty' 98 | server 'FCGI' 99 | application_user 'user' 100 | application_home '/home/user/app/MyApplication' 101 | script '/home/user/app/MyApplication/scripts/foo.psgi' 102 | config '/home/user/app/MyApplication/app.conf' 103 | action 'install' 104 | end 105 | 106 | ## run psgi application with Starman server, port 5001 107 | 108 | psgi_application 'psgi Starman application' do 109 | server 'Starman' 110 | application_user 'user' 111 | application_home '/home/user/app/MyApplication' 112 | script 'app.psgi' 113 | socket ':5000' 114 | nproc '2' 115 | action 'install' 116 | end 117 | 118 | ## using with non system plackup 119 | 120 | psgi_application 'my application' do 121 | server 'Starman' 122 | application_user 'user' 123 | application_home '/home/user/app/MyApplication' 124 | script '/home/user/app/MyApplication/scripts/foo.psgi' 125 | config '/home/user/app/MyApplication/app.conf' 126 | action 'install' 127 | daemon_path '/home/user/app/MyApplication/cpanlib/bin/plackup' 128 | end 129 | 130 | ## run smoke test on installed psgi application 131 | 132 | psgi_application 'my application' do 133 | application_user 'user' 134 | application_group 'user' 135 | application_home '/home/user/app/MyApplication' 136 | script '/home/user/app/MyApplication/scripts/foo.psgi' 137 | action 'test' 138 | end 139 | 140 | 141 | 142 | # Tested on 143 | * Debian-Stable-64-bit, chef 11.4.4 144 | * Ubuntu 10.04.1 LTS, chef 11.4.4 145 | * CentOS-6.4-x86_64, , Chef 10.14.0 146 | 147 | -------------------------------------------------------------------------------- /psgi/templates/debian/init-script: -------------------------------------------------------------------------------- 1 | #! <%= `which sh`.chomp! %> 2 | ### BEGIN INIT INFO 3 | # Provides: <%= @daemon_name %> 4 | # Required-Start: $remote_fs $syslog 5 | # Required-Stop: $remote_fs $syslog 6 | # Default-Start: 2 3 4 5 7 | # Default-Stop: 0 1 6 8 | # Short-Description: <%= @daemon_name %> 9 | # Description: init script for <%= @daemon_name %> 10 | # 11 | ### END INIT INFO 12 | 13 | # Author: Alexey Melezhik 14 | # 15 | 16 | # Do NOT "set -e" 17 | 18 | # PATH should only include /usr/* if it runs after the mountnfs.sh script 19 | 20 | APPLICATION_USER=<%= @application_user %> 21 | APPLICATION_HOME=<%= @application_home %> 22 | 23 | NAME="<%= @daemon_name %>" 24 | PATH=/sbin:/usr/sbin:/bin:/usr/bin 25 | DESC="<%= @application_desc %>" 26 | DAEMON="<%= @daemon_path %>" 27 | PIDFILE=/var/run/$NAME.pid 28 | SCRIPTNAME=<%= @install_dir %>/$NAME 29 | 30 | <% app_env = Array.new -%> 31 | <% app_opt = Array.new -%> 32 | <% app_opt << "-s #{@server}" -%> 33 | <% app_opt << "--listen #{@socket}" -%> 34 | <% app_opt << "-E #{@plackup_environment}" -%> 35 | <% app_opt << "-a " << ( Pathname.new(@application_script).relative? ? (Pathname.new(@application_home + "/") + Pathname.new(@application_script)).to_s : @application_script ) -%> 36 | <% if ! @proc_manager.nil? && ! @proc_manager.empty? && @server == 'FCGI' -%> 37 | <% app_opt << "--manager #{@proc_manager}" -%> 38 | <% end -%> 39 | <% if ! @loader.nil? && ! @loader.empty? -%> 40 | <% app_opt << "--loader #{@loader}" -%> 41 | <% end -%> 42 | <% if ! @proc_title.nil? && ! @proc_title.empty? -%> 43 | <% app_opt << "--proc_title #{@proc_title}" -%> 44 | <% end -%> 45 | <% if ! @mount.nil? && ! @mount.empty? -%> 46 | <% app_opt << "--path #{@mount}" -%> 47 | <% else -%> 48 | <% app_opt << "--path /" -%> 49 | <% end -%> 50 | <% if ! @nproc.nil? && @server == 'FCGI' -%> 51 | <% app_opt << "--nproc #{@nproc}" -%> 52 | <% elsif ! @nproc.nil? && @server == 'Starman' -%> 53 | <% app_opt << "--workers #{@nproc}" -%> 54 | <% end -%> 55 | <% if ! @backlog.nil? && @server == 'FCGI' -%> 56 | <% app_opt << "--backlog #{@backlog}" -%> 57 | <% end -%> 58 | <% if @server == 'Twiggy' %> 59 | <% app_env << "TWIGGY_DEBUG=#{@debug}" -%> 60 | <% end -%> 61 | <% if @operator == 'Catalyst' %> 62 | <% app_env << "CATALYST_CONFIG=#{@config}" -%> 63 | <% app_env << "CATALYST_DEBUG=#{@debug}" -%> 64 | <% elsif @operator == 'Dancer' -%> 65 | <% app_env << "DANCER_CONFDIR=#{@application_home}" -%> 66 | <% elsif @operator == 'Jifty' -%> 67 | <%- app_env << "JIFTY_CONFIG=#{@config}" -%> 68 | <% end -%> 69 | <% @envvars.each do |k,v| -%> 70 | <% app_env << "#{k}='#{v}'" -%> 71 | <% end -%> 72 | <% unless @perl5lib.empty? -%> 73 | <% app_env << "PERL5LIB=$PERL5LIB:#{@perl5lib.join(':')}" -%> 74 | <% end -%> 75 | 76 | 77 | # Exit if the package is not installed 78 | [ -x "$DAEMON" ] || exit 0 79 | 80 | # Read configuration variable file if it is present 81 | [ -r /etc/default/$NAME ] && . /etc/default/$NAME 82 | 83 | # Load the VERBOSE setting and other rcS variables 84 | . /lib/init/vars.sh 85 | 86 | # Define LSB log_* functions. 87 | # Depend on lsb-base (>= 3.0-6) to ensure that this file is present. 88 | . /lib/lsb/init-functions 89 | 90 | # 91 | # Function that starts the daemon/service 92 | # 93 | do_start() 94 | { 95 | # Return 96 | # 0 if daemon has been started 97 | # 1 if daemon was already running 98 | # 2 if daemon could not be started 99 | <%= app_env.join ' ' %> start-stop-daemon -m --pidfile $PIDFILE --chuid $APPLICATION_USER -b -d $APPLICATION_HOME --start --test --startas $DAEMON -- <%= app_opt.join ' ' %> || return 1 100 | <%= app_env.join ' ' %> start-stop-daemon -m --pidfile $PIDFILE --chuid $APPLICATION_USER -b -d $APPLICATION_HOME --start --startas $DAEMON -- <%= app_opt.join ' ' %> || return 2 101 | # Add code here, if necessary, that waits for the process to be ready 102 | # to handle requests from services started subsequently which depend 103 | # on this one. As a last resort, sleep for some time. 104 | } 105 | 106 | # 107 | # Function that stops the daemon/service 108 | # 109 | do_stop() 110 | { 111 | # Return 112 | # 0 if daemon has been stopped 113 | # 1 if daemon was already stopped 114 | # 2 if daemon could not be stopped 115 | # other if a failure occurred 116 | start-stop-daemon --stop --signal 15 --retry 5 --quiet --pidfile $PIDFILE 117 | RETVAL="$?" 118 | [ "$RETVAL" = 2 ] && return 2 119 | # Many daemons don't delete their pidfiles when they exit. 120 | rm -f $PIDFILE 121 | return "$RETVAL" 122 | } 123 | 124 | # 125 | # Function that sends a SIGHUP to the daemon/service 126 | # 127 | do_reload() { 128 | # 129 | # If the daemon can reload its configuration without 130 | # restarting (for example, when it is sent a SIGHUP), 131 | # then implement that here. 132 | # 133 | start-stop-daemon --stop --signal 1 --quiet --pidfile $PIDFILE --name $NAME 134 | return 0 135 | } 136 | 137 | case "$1" in 138 | start) 139 | [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME" 140 | do_start 141 | case "$?" in 142 | 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; 143 | 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; 144 | esac 145 | ;; 146 | stop) 147 | [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME" 148 | do_stop 149 | case "$?" in 150 | 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; 151 | 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; 152 | esac 153 | ;; 154 | status) 155 | status_of_proc -p $PIDFILE "$DAEMON" "$NAME" && exit 0 || exit $? 156 | ;; 157 | #reload|force-reload) 158 | # 159 | # If do_reload() is not implemented then leave this commented out 160 | # and leave 'force-reload' as an alias for 'restart'. 161 | # 162 | #log_daemon_msg "Reloading $DESC" "$NAME" 163 | #do_reload 164 | #log_end_msg $? 165 | #;; 166 | restart|force-reload) 167 | # 168 | # If the "reload" option is implemented then remove the 169 | # 'force-reload' alias 170 | # 171 | log_daemon_msg "Restarting $DESC" "$NAME" 172 | do_stop 173 | case "$?" in 174 | 0|1) 175 | do_start 176 | case "$?" in 177 | 0) log_end_msg 0 ;; 178 | 1) log_end_msg 1 ;; # Old process is still running 179 | *) log_end_msg 1 ;; # Failed to start 180 | esac 181 | ;; 182 | *) 183 | # Failed to stop 184 | log_end_msg 1 185 | ;; 186 | esac 187 | ;; 188 | *) 189 | echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2 190 | exit 3 191 | ;; 192 | esac 193 | 194 | : 195 | -------------------------------------------------------------------------------- /cpan/README.md: -------------------------------------------------------------------------------- 1 | [![Build Status](https://travis-ci.org/melezhik/cookbooks-test.png?branch=master)](https://travis-ci.org/melezhik/cpan-test) 2 | 3 | DESCRIPTION 4 | === 5 | 6 | [cpan](http://search.cpan.org/perldoc?CPAN) modules resource provider 7 | 8 | WARNING 9 | === 10 | 11 | The cpan cookbook seems does not work under recent versipon of chef ( since 12.5 ) and is no longer mainatained. 12 | Feel free to fork the code and take up further development. 13 | 14 | PREREQUISITES 15 | === 16 | A little prerequisites are required. Run `cpan::bootstrap` recipe to satisfy 17 | - [curl](http://curl.haxx.se/) 18 | - [App::cpanminus](http://search.cpan.org/perldoc?App::cpanminus) 19 | - [CPAN](http://search.cpan.org/perldoc?CPAN) 20 | - [local::lib](http://search.cpan.org/perldoc?local::lib) 21 | 22 | If you only want to run bootstrap once, set the `bootstrap['keep_uptodate']` attribute to false. 23 | 24 | 25 | BASIC USAGE 26 | === 27 | cpan_client 'CGI' do 28 | action 'install' 29 | install_type 'cpan_module' 30 | user 'root' 31 | group 'root' 32 | end 33 | 34 | RESOURCE ACTIONS 35 | === 36 | 37 | * `install` - install module or application 38 | * `test` - test module, don't install it 39 | * `reload_cpan_index` - reload cpan client indexes 40 | 41 | RESOURCE ATTRIBUTES 42 | === 43 | 44 | * `cwd` - specifies current working directory where installation process runs, default value is `/tmp/` 45 | * `dry_run` - specifies whether to run installation process in dry-run mode or not, default value is `false` 46 | * `environment` - specifies Hash with environment variables exported to installation process 47 | * `force` - specifies whether to run installation process in force mode, default - false 48 | * `from_cookbook` - specifies cookbook, where distributive stored at. Check out [chef cookbook_file resource documentation](http://docs.opscode.com/chef/resources.html#cookbook-file) 49 | * `user`/`group` - specifies a user/group for installation process 50 | * `inc` - specifies perl @INC array 51 | * `install_base` - specifies installation base 52 | * `install_path` - specifies installation paths 53 | * `install_type` - specifies installation type : cpan_module, bundle, application; default - application 54 | * `module_name` - specifies the name of cpan module to check version against when install, useful when installing from http url or cookbook 55 | * `version` - specifies version of module to install, see also `module_name` parameter 56 | * if version defined as `version '0'` - installs only if module is not installed yet 57 | * if version defined as `version 'version-number'` - installs by version and higher 58 | * if version defined as `version '=version-number'` - installs exact version 59 | 60 | EXAMPLES OF USAGE 61 | === 62 | 63 | ## fake install 64 | 65 | cpan_client 'CGI' do 66 | user 'root' 67 | group 'root' 68 | dry_run true 69 | install_type 'cpan_module' 70 | action 'install' 71 | end 72 | 73 | ## does not install, only run tests 74 | 75 | cpan_client 'CGI' do 76 | user 'root' 77 | group 'root' 78 | install_type 'cpan_module' 79 | action 'test' 80 | end 81 | 82 | ## Bundle install 83 | 84 | cpan_client 'Bundle::LWP' do 85 | user 'root' 86 | group 'root' 87 | install_type 'bundle' 88 | action 'install' 89 | end 90 | 91 | ## force install 92 | 93 | cpan_client 'CGI' do 94 | user 'root' 95 | group 'root' 96 | force true 97 | install_type 'cpan_module' 98 | action 'install' 99 | end 100 | 101 | 102 | 103 | ## installs version or higher 104 | 105 | cpan_client 'CGI' do 106 | user 'root' 107 | group 'root' 108 | version '3.55' 109 | install_type 'cpan_module' 110 | action 'install' 111 | end 112 | 113 | 114 | ## installs only if module is not installed yet 115 | 116 | cpan_client 'CGI' do 117 | user 'root' 118 | group 'root' 119 | version '0' 120 | install_type 'cpan_module' 121 | action 'install' 122 | end 123 | 124 | ## installs exact version of module 125 | 126 | # exact version installation is available only for install from cookbook or from http url 127 | 128 | cpan_client 'http://search.cpan.org/CPAN/authors/id/M/MA/MARKSTOS/CGI.pm-3.59.tar.gz' do 129 | user 'root' 130 | group 'root' 131 | module_name 'CGI' 132 | version '=3.59' 133 | action 'install' 134 | end 135 | 136 | cpan_client 'Moose-1.24.tar.gz' do 137 | user 'root' 138 | group 'root' 139 | from_cookbook 'moose' 140 | module_name 'Moose' 141 | version '=1.24' 142 | action 'install' 143 | end 144 | 145 | 146 | ## installs distributive stored in cookbook 147 | 148 | cpan_client 'Moose-1.24.tar.gz' do 149 | user 'root' 150 | group 'root' 151 | from_cookbook 'moose' 152 | install_type 'cpan_module' 153 | action 'install' 154 | end 155 | 156 | ## installs distributive stored in cookbook with version check 157 | 158 | cpan_client 'Moose-1.24.tar.gz' do 159 | user 'root' 160 | group 'root' 161 | from_cookbook 'moose' 162 | module_name 'Moose' 163 | version '1.24' 164 | action 'install' 165 | end 166 | 167 | ## installs distributive strored remotely 168 | 169 | # only http protocol now is supported: 170 | cpan_client 'http://search.cpan.org/CPAN/authors/id/M/MA/MARKSTOS/CGI.pm-3.59.tar.gz' do 171 | user 'root' 172 | group 'root' 173 | action 'install' 174 | end 175 | 176 | ## installs distributive strored remotely with version check 177 | 178 | cpan_client 'http://search.cpan.org/CPAN/authors/id/M/MA/MARKSTOS/CGI.pm-3.58.tar.gz' do 179 | user 'root' 180 | group 'root' 181 | module_name 'CGI' 182 | version '3.59' 183 | action 'install' 184 | end 185 | 186 | ## installs into given installation base 187 | 188 | cpan_client 'CGI' do 189 | user 'root' 190 | group 'root' 191 | install_base '/some/where/else' 192 | install_type 'cpan_module' 193 | action 'install' 194 | end 195 | 196 | 197 | ## installs into given installation base, relative to given cwd 198 | 199 | # will install into '/home/alex/mydir' 200 | cpan_client 'CGI' do 201 | user 'root' 202 | group 'root' 203 | install_base 'mydir' 204 | cwd '/home/alex/' 205 | install_type 'cpan_module' 206 | action 'install' 207 | end 208 | 209 | 210 | 211 | ## installs with given install paths 212 | 213 | # will override settings for `htdocs` and `config` elements 214 | cpan_client 'Module' do 215 | user 'root' 216 | group 'root' 217 | install_path ["htdocs=#{ENV['PWD']}/htdocs/", "config=#{ENV['PWD']}/etc/"] 218 | install_type 'cpan_module' 219 | action 'install' 220 | end 221 | 222 | ## installs distributive unpacked in current working directory 223 | 224 | cpan_client 'my application' do 225 | user 'root' 226 | group 'root' 227 | install_type 'application' 228 | action 'install' 229 | end 230 | 231 | ## installs under not privileged user 232 | 233 | # will install into $PWD/cpanlib directory 234 | cpan_client 'my application' do 235 | install_type 'application' 236 | user 'user' 237 | group 'users' 238 | install_base 'cpanlib' 239 | action 'install' 240 | end 241 | 242 | ## reloads cpan indexes 243 | 244 | cpan_client 'reload cpan index' do 245 | user 'user' 246 | group 'users' 247 | action 'reload_cpan_index' 248 | end 249 | 250 | 251 | ## Features 252 | 253 | Other examples (cucumber features) may be found at [cpan-test project](https://github.com/melezhik/cpan-test/) 254 | 255 | 256 | -------------------------------------------------------------------------------- /cpan/providers/client.rb: -------------------------------------------------------------------------------- 1 | 2 | def load_current_resource 3 | 4 | @installer = Chef::Resource::CpanClient.new(new_resource.name) 5 | @installer.name(new_resource.name) 6 | @installer.module_name(new_resource.module_name) 7 | @installer.install_base(new_resource.install_base) 8 | @installer.dry_run(new_resource.dry_run) 9 | @installer.reload_cpan_index(new_resource.reload_cpan_index) 10 | @installer.inc(new_resource.inc) 11 | @installer.install_type(new_resource.install_type) 12 | @installer.cwd(new_resource.cwd) 13 | @installer.from_cookbook(new_resource.from_cookbook) 14 | @installer.force(new_resource.force) 15 | @installer.install_path(new_resource.install_path) 16 | @installer.user(new_resource.user) 17 | @installer.group(new_resource.group) 18 | @installer.version(new_resource.version) 19 | @installer.environment(new_resource.environment) 20 | @installer.cpan_home(new_resource.cpan_home) 21 | 22 | nil 23 | end 24 | 25 | def header 26 | 27 | user = @installer.user 28 | group = @installer.group 29 | dry_run = @installer.dry_run 30 | install_type = @installer.install_type 31 | version = @installer.version 32 | force_mode = @installer.force 33 | cwd = @installer.cwd 34 | 35 | Chef::Log.info("#{dry_run == true ? 'DRYRUN' : 'REAL' } install #{install_type} #{installed_module}. install_version: #{version_print}") 36 | Chef::Log.debug("cpan_client has started with rights: user=#{user} group=#{group}") 37 | Chef::Log.debug("cpan_home: #{get_home}") 38 | Chef::Log.debug("cwd: #{cwd}") 39 | Chef::Log.debug("install-base: #{install_base_print}") 40 | Chef::Log.debug("local::lib expresion: #{local_lib_stack}") 41 | Chef::Log.debug("perl5lib variable: #{perl5lib_stack}") 42 | Chef::Log.debug("install command: #{install_perl_code}") 43 | Chef::Log.debug("environment: #{cpan_env_print}") 44 | Chef::Log.info("install log file: #{install_log_file}") 45 | Chef::Log.info("force_mode: #{force_mode}") 46 | 47 | end 48 | 49 | 50 | def cpan_env 51 | c_env = @installer.environment 52 | c_env['HOME'] = get_home 53 | c_env['MODULEBUILDRC'] = '/tmp/local-lib/.modulebuildrc' 54 | c_env['PERL5LIB'] = perl5lib_stack unless (perl5lib_stack.nil? || perl5lib_stack.empty?) 55 | c_env 56 | end 57 | 58 | def cpan_env_print 59 | st = '' 60 | cpan_env.each {|key, value| st << " #{key}=#{value}; " } 61 | st 62 | end 63 | 64 | def version_print 65 | retval = nil 66 | if @installer.version.nil? # not install if uptodate 67 | retval = 'highest' 68 | elsif @installer.version == "0" # not install if any version already installed 69 | retval = 'any' 70 | elsif @installer.version != "0" # not install if have higher or equal version 71 | v = @installer.version 72 | retval = "#{v}" 73 | else 74 | raise "bad version : #{@installer.version}" 75 | end 76 | retval 77 | end 78 | 79 | def install_log_file 80 | "/tmp/local-lib/#{installed_module}-install.log" 81 | end 82 | 83 | 84 | def sanity_string file_contents 85 | 86 | require 'iconv' unless String.method_defined?(:encode) 87 | if String.method_defined?(:encode) 88 | file_contents.encode!('UTF-8', 'UTF-8', :invalid => :replace) 89 | else 90 | ic = Iconv.new('UTF-8//IGNORE', 'UTF-8') 91 | file_contents = ic.iconv(file_contents) 92 | end 93 | end 94 | 95 | def install_log 96 | 97 | my_installed_module = installed_module 98 | force_mode = @installer.force 99 | ruby_block 'validate cpan client logs' do 100 | block do 101 | print ">>> #{my_installed_module} install summary <<<\n" 102 | prev_line = '' 103 | IO.foreach(install_log_file) do |l| 104 | ll = sanity_string l 105 | print " #{l} [#{prev_line}]\n" if /\s--\s(OK|NOT OK)/.match(ll) 106 | if /(Stopping: 'install' failed|won't install without force)/.match(ll) 107 | if force_mode == true 108 | Chef::Log.warn("error occured : #{ll}[#{prev_line}]") 109 | Chef::Log.info("will continue because we are in force_mode = true mode") 110 | else 111 | raise "#{ll}[#{prev_line}]\n" 112 | end 113 | end 114 | prev_line = ll.chomp.gsub(/^\s+/,"").gsub(/\s+$/,"") 115 | end 116 | end 117 | end 118 | end 119 | 120 | 121 | 122 | def install_perl_code install_thing = '$ARGV[0]' 123 | cmd = Array.new 124 | if @test_mode.nil? 125 | if @installer.force == true 126 | cmd << "CPAN::Shell->force(\"install\",#{install_thing})" 127 | else 128 | cmd << "CPAN::Shell->install(#{install_thing})" 129 | end 130 | else 131 | cmd << "CPAN::Shell->test(#{install_thing})" 132 | end 133 | cmd.join('; ') 134 | end 135 | 136 | def get_home 137 | user = @installer.user 138 | group = @installer.group 139 | cpan_home = @installer.cpan_home 140 | home = user == 'root' ? "/root/" : ( cpan_home.nil? ? "/home/#{user}/" : cpan_home ) 141 | return home 142 | end 143 | 144 | def perl5lib_stack 145 | 146 | perl5lib = Array.new 147 | perl5lib += node.cpan_client.default_inc 148 | perl5lib += @installer.inc 149 | perl5lib.join(':') 150 | 151 | end 152 | 153 | def evaluate_mb_opt 154 | string = '' 155 | install_paths = [] 156 | @installer.install_path.each do |i| 157 | install_paths << "--install_path #{i}" 158 | end 159 | string << "PERL_MB_OPT=\"${PERL_MB_OPT} #{install_paths.join(' ')}\"; " unless install_paths.empty? 160 | string 161 | end 162 | 163 | 164 | def local_lib_stack 165 | 166 | stack = ''; 167 | #stack << "#{perl5lib_stack}; " unless ( perl5lib_stack.nil? || perl5lib_stack.empty? ) 168 | 169 | unless @installer.install_base.nil? 170 | stack << "eval $(perl -Mlocal::lib=#{real_install_base}); #{evaluate_mb_opt} " 171 | else 172 | stack << "#{evaluate_mb_opt} " 173 | end 174 | return stack 175 | end 176 | 177 | def real_install_base 178 | install_base = @installer.install_base 179 | unless install_base.nil? 180 | install_base.gsub!('\s','') 181 | install_base.chomp! 182 | unless /^\//.match(install_base) 183 | install_base = "#{@installer.cwd}/#{install_base}" 184 | end 185 | end 186 | return install_base 187 | end 188 | 189 | def install_base_print 190 | @installer.install_base.nil? ? 'default::install::base' : real_install_base 191 | end 192 | 193 | 194 | action :reload_cpan_index do 195 | 196 | user = @installer.user 197 | group = @installer.group 198 | cwd = @installer.cwd 199 | home = get_home 200 | 201 | log 'reload cpan index' 202 | execute "reload cpan index" do 203 | command 'perl -MCPAN -e "CPAN::Index->force_reload"' 204 | action :run 205 | user user 206 | group group 207 | cwd cwd 208 | environment ({'HOME' => home , 'MODULEBUILDRC' => '/tmp/local-lib/.modulebuildrc' }) 209 | end 210 | 211 | end 212 | 213 | action :install do 214 | 215 | @test_mode = nil 216 | user = @installer.user 217 | group = @installer.group 218 | cwd = @installer.cwd 219 | 220 | directory '/tmp/local-lib/' do 221 | owner user 222 | group group 223 | end 224 | 225 | directory '/tmp/local-lib/install' do 226 | owner user 227 | group group 228 | end 229 | 230 | file install_log_file do 231 | action :create 232 | owner user 233 | group group 234 | end 235 | 236 | cookbook_file '/tmp/local-lib/.modulebuildrc' do 237 | cookbook 'cpan' 238 | action :create 239 | source '.modulebuildrc' 240 | mode '0644' 241 | owner user 242 | group group 243 | end 244 | 245 | header 246 | @installer.dry_run == true ? install_dry_run : install_real 247 | new_resource.updated_by_last_action(true) 248 | 249 | end 250 | 251 | action :test do 252 | 253 | @test_mode = 1 254 | 255 | header 256 | log 'don*t install, run tests only' 257 | 258 | user = @installer.user 259 | group = @installer.group 260 | 261 | directory '/tmp/local-lib/' do 262 | owner user 263 | group group 264 | end 265 | 266 | file install_log_file do 267 | action :create 268 | owner user 269 | group group 270 | end 271 | 272 | install_real 273 | 274 | end 275 | 276 | 277 | def install_dry_run 278 | return install_dry_run_tarball if @installer.from_cookbook 279 | return install_dry_run_cpan_module if @installer.install_type == 'cpan_module' 280 | return install_dry_run_cpan_module if @installer.install_type == 'bundle' 281 | return install_dry_run_application if @installer.install_type == 'application' 282 | raise 'should set install_type as (cpan_module|bundle|application) or from_cookbook parameter' 283 | end 284 | 285 | def install_real 286 | if @installer.from_cookbook or /([a-z\d\.-]+)\.tar\.gz$/i.match(@installer.name) or /^(http:\/\/)/i.match(@installer.name) 287 | return install_tarball 288 | end 289 | 290 | return install_cpan_module if @installer.install_type == 'cpan_module' 291 | return install_cpan_module if @installer.install_type == 'bundle' 292 | return install_application if @installer.install_type == 'application' 293 | raise 'should set install_type as (cpan_module|bundle|application) or from_cookbook parameter' 294 | end 295 | 296 | def installed_module 297 | if /([a-z\d\.-]+)\.tar\.gz$/i.match(@installer.name) or ! @installer.from_cookbook.nil? 298 | installed_module = @installer.name.split('/').last 299 | installed_module.gsub!(' ','-') 300 | mat = /([a-z\d\.-]+)\.tar\.gz$/i.match(installed_module) 301 | if mat.nil? 302 | raise "distributive name #{@installer.name} does not match ([a-z\d\.-]+)\.tar\.gz$ pattern" 303 | end 304 | installed_module = mat[1] 305 | else 306 | installed_module = @installer.name 307 | installed_module.gsub!(' ','-') 308 | end 309 | return installed_module 310 | end 311 | 312 | def install_dry_run_cpan_module 313 | text = Array.new 314 | text << "WOULD install cpan module #{@installer.name}" 315 | ruby_block 'info' do 316 | block do 317 | print text.join("\n") 318 | end 319 | end 320 | end 321 | 322 | def install_dry_run_tarball 323 | 324 | text = Array.new 325 | text << "WOULD copy cookbook file #{@installer.from_cookbook}::#{@installer.name} to /tmp/local-lib/install/" 326 | text << "WOULD cd to /tmp/local-lib/install/" 327 | text << "WOULD tar -zxf #{@installer.name}" 328 | text << "WOULD cd to #{installed_module}" 329 | text << "WOULD install via #{install_perl_code} ." 330 | 331 | ruby_block 'info' do 332 | block do 333 | print text.join("\n") 334 | end 335 | end 336 | end 337 | 338 | 339 | def install_dry_run_application 340 | 341 | cwd = @installer.cwd 342 | user = @installer.user 343 | group = @installer.group 344 | 345 | text = Array.new 346 | text << "WOULD install application" 347 | ruby_block 'info' do 348 | block do 349 | print text.join("\n") 350 | end 351 | end 352 | 353 | cmd = Array.new 354 | cmd << local_lib_stack 355 | cmd << 'if test -f Build.PL; then' 356 | cmd << 'perl Build.PL && ./Build' 357 | cmd << " echo './Build fakeinstall' 1>#{install_log_file} 2>&1" 358 | cmd << " ./Build fakeinstall 1>>#{install_log_file} 2>&1" 359 | cmd << " echo './Build prereq_report' 1>>#{install_log_file} 2>&1" 360 | cmd << " ./Build prereq_report 1>>#{install_log_file} 2>&1" 361 | cmd << 'else' 362 | cmd << 'perl Makefile.PL && make' 363 | cmd << "echo ' -- OK dry-run mode only enabled for Module::Build based distributions' 1>#{install_log_file} 2>&1" 364 | cmd << 'fi' 365 | 366 | bash "install application dry-run" do 367 | user user 368 | group group 369 | cwd cwd 370 | code cmd.join("\n") 371 | environment cpan_env 372 | end 373 | 374 | ruby_block 'prereq_report' do 375 | block do 376 | IO.foreach(install_log_file) do |l| 377 | print l unless /^Skipping /.match(l) 378 | end 379 | end 380 | end 381 | 382 | end 383 | 384 | 385 | def install_cpan_module args = { } 386 | 387 | user = @installer.user 388 | group = @installer.group 389 | 390 | cwd = args[:cwd] || @installer.cwd 391 | module_name = args[:module_name] || @installer.name 392 | module_version = args[:module_version] || @installer.version 393 | install_object = args[:install_object] || @installer.name 394 | 395 | if @installer.install_type == 'bundle' 396 | cpan_type = 'Bundle' 397 | else 398 | cpan_type = 'Module' 399 | end 400 | 401 | execute "rm #{install_log_file}" 402 | 403 | if module_name != '.' 404 | 405 | bash "checking if module exists at CPAN" do 406 | code <<-CODE 407 | #{local_lib_stack} 408 | perl -MCPAN -e ' 409 | my $m = CPAN::Shell->expand("#{cpan_type}","#{module_name}"); 410 | exit(2) unless defined $m'; 411 | CODE 412 | user user 413 | group group 414 | cwd cwd 415 | environment cpan_env 416 | end 417 | end 418 | 419 | if @installer.version.nil? && module_name != '.' && @test_mode.nil? # not install if uptodate 420 | bash "installing cpan module" do 421 | code <<-CODE 422 | #{local_lib_stack} 423 | perl -MCPAN -e ' 424 | my $m = CPAN::Shell->expand("#{cpan_type}","#{module_name}"); 425 | if ($m->uptodate){ 426 | print "#{module_name} -- OK have higher or equal version [",$m->inst_version,"] [",$m->inst_file,"]\n"; 427 | }else{ 428 | #{install_perl_code} 429 | }' #{install_object} 1>>#{install_log_file} 2>&1 430 | CODE 431 | user user 432 | group group 433 | cwd cwd 434 | environment cpan_env 435 | end 436 | elsif @installer.version == "0" && module_name != '.' && @test_mode.nil? # not install if any version already installed 437 | bash "installing cpan module" do 438 | code <<-CODE 439 | #{local_lib_stack} 440 | perl -MCPAN -e ' 441 | my $m = CPAN::Shell->expand("#{cpan_type}","#{module_name}"); 442 | if ($m->inst_version){ 443 | print "#{module_name} -- OK already installed at version [",$m->inst_version,"] [",$m->inst_file,"]\n"; 444 | }else{ 445 | #{install_perl_code} 446 | }' #{install_object} 1>>#{install_log_file} 2>&1 447 | CODE 448 | user user 449 | group group 450 | cwd cwd 451 | environment cpan_env 452 | end 453 | elsif @installer.version != "0" && module_name != '.' && @test_mode.nil? # not install if have higher or equal version 454 | v = @installer.version 455 | bash "installing cpan module" do 456 | code <<-CODE 457 | #{local_lib_stack} 458 | perl -MCPAN -MCPAN::Version -e ' 459 | my $m = CPAN::Shell->expand("#{cpan_type}","#{module_name}"); 460 | my $inst_v = CPAN::Shell->expand("#{cpan_type}","#{module_name}")->inst_version; 461 | my $version_required = "#{module_version}"; 462 | s/\s//g for $version_required; 463 | my $exact_version_check = 0; 464 | if ($version_required=~/=/){ 465 | $exact_version_check = 1; 466 | s/=//g for $version_required; 467 | } 468 | 469 | if ($exact_version_check == 0 && CPAN::Version->vcmp($inst_v, $version_required) >= 0){ 470 | print "#{module_name} -- OK : have higher or equal version [$inst_v] [",$m->inst_file,"]\n"; 471 | }elsif($exact_version_check == 1 && CPAN::Version->vcmp($inst_v, $version_required) == 0){ 472 | print "#{module_name} -- OK : have equal version [$inst_v] [",$m->inst_file,"]\n"; 473 | }else{ 474 | #{install_perl_code} 475 | }' #{install_object} 1>>#{install_log_file} 2>&1 476 | CODE 477 | user user 478 | group group 479 | cwd cwd 480 | environment cpan_env 481 | end 482 | elsif ! @test_mode.nil? && @test_mode == 1 483 | bash 'running tests on cpan module' do 484 | code <<-CODE 485 | #{local_lib_stack} 486 | perl -MCPAN -e ' 487 | #{install_perl_code}' #{install_object} 1>>#{install_log_file} 2>&1 488 | CODE 489 | user user 490 | group group 491 | cwd cwd 492 | environment cpan_env 493 | end 494 | elsif module_name == '.' 495 | bash 'installing cpan module as cpan_client .' do 496 | code <<-CODE 497 | #{local_lib_stack} 498 | perl -MCPAN -e ' 499 | #{install_perl_code}' #{install_object} 1>>#{install_log_file} 2>&1 500 | CODE 501 | user user 502 | group group 503 | cwd cwd 504 | environment cpan_env 505 | end 506 | else 507 | raise "bad version : #{@installer.version}" 508 | end 509 | 510 | install_log 511 | 512 | end 513 | 514 | def install_tarball 515 | 516 | cwd = @installer.cwd 517 | user = @installer.user 518 | group = @installer.group 519 | 520 | Chef::Log.debug "installed_module: #{installed_module}" 521 | 522 | execute "rm -rf /tmp/local-lib/install/#{installed_module}/" 523 | 524 | if @installer.name.match('^http:\/\/') 525 | tarball_name = @installer.name.split('/').last 526 | execute "rm -rf /tmp/local-lib/install/#{tarball_name}" 527 | source_name = @installer.name 528 | Chef::Log.debug "tarball_name: #{tarball_name}" 529 | remote_file "/tmp/local-lib/install/#{tarball_name}" do 530 | source source_name 531 | mode "0644" 532 | owner user 533 | group group 534 | end 535 | else 536 | tarball_name = @installer.name 537 | from_cookbook = @installer.from_cookbook 538 | execute "rm -rf /tmp/local-lib/install/#{tarball_name}" 539 | cookbook_file "/tmp/local-lib/install/#{tarball_name}" do 540 | action 'create_if_missing' 541 | mode "0644" 542 | cookbook from_cookbook 543 | owner user 544 | group group 545 | end 546 | end 547 | 548 | execute "tar -zxf #{tarball_name}" do 549 | user user 550 | group group 551 | cwd "/tmp/local-lib/install/" 552 | end 553 | 554 | install_cpan_module({ 555 | :cwd => "/tmp/local-lib/install/#{installed_module}", 556 | :install_object => '.', 557 | :module_name => @installer.module_name || '.' 558 | }) 559 | 560 | end 561 | 562 | def install_application 563 | 564 | install_cpan_module({ 565 | :cwd => @installer.cwd, 566 | :install_object => '.', 567 | :module_name => '.' 568 | }) 569 | 570 | 571 | end 572 | 573 | --------------------------------------------------------------------------------