├── .gitignore ├── .travis.yml ├── README.md ├── bootstrap.sh ├── cluster └── Vagrantfile ├── cookbooks ├── apt │ ├── .gitignore │ ├── CHANGELOG.md │ ├── CONTRIBUTING │ ├── Gemfile │ ├── LICENSE │ ├── README.md │ ├── files │ │ └── default │ │ │ └── apt-proxy-v2.conf │ ├── metadata.json │ ├── metadata.rb │ ├── providers │ │ ├── preference.rb │ │ └── repository.rb │ ├── recipes │ │ ├── cacher-client.rb │ │ ├── cacher-ng.rb │ │ └── default.rb │ └── resources │ │ ├── preference.rb │ │ └── repository.rb ├── build-essential │ ├── .gitignore │ ├── CHANGELOG.md │ ├── CONTRIBUTING │ ├── Gemfile │ ├── LICENSE │ ├── README.md │ ├── attributes │ │ └── default.rb │ ├── metadata.json │ ├── metadata.rb │ └── recipes │ │ └── default.rb ├── fakes3 │ ├── recipes │ │ └── default.rb │ └── templates │ │ └── default │ │ └── upstart-fakes3.conf.erb ├── git │ ├── CHANGELOG.md │ ├── CONTRIBUTING │ ├── LICENSE │ ├── README.md │ ├── attributes │ │ └── default.rb │ ├── metadata.json │ ├── metadata.rb │ ├── recipes │ │ ├── default.rb │ │ ├── server.rb │ │ └── source.rb │ └── templates │ │ └── default │ │ ├── sv-git-daemon-log-run.erb │ │ └── sv-git-daemon-run.erb ├── heroku-toolbelt │ └── recipes │ │ └── default.rb ├── nodejs │ ├── .gitignore │ ├── .kitchen.yml │ ├── .travis.yml │ ├── Berksfile │ ├── CHANGELOG.md │ ├── Gemfile │ ├── README.md │ ├── Rakefile │ ├── Vagrantfile │ ├── attributes │ │ └── default.rb │ ├── metadata.rb │ ├── recipes │ │ ├── default.rb │ │ ├── install_from_binary.rb │ │ ├── install_from_package.rb │ │ ├── install_from_source.rb │ │ └── npm.rb │ └── test │ │ ├── integration │ │ ├── package │ │ │ └── bats │ │ │ │ └── package.bats │ │ └── source │ │ │ └── bats │ │ │ └── source.bats │ │ └── support │ │ └── Gemfile ├── openruko │ ├── attributes │ │ └── default.rb │ ├── recipes │ │ ├── apiserver.rb │ │ ├── client.rb │ │ ├── default.rb │ │ ├── dynohost.rb │ │ ├── gitmouth.rb │ │ ├── httprouting.rb │ │ ├── integration-tests.rb │ │ └── logplex.rb │ └── templates │ │ └── default │ │ ├── profile-openruko-apiserver.erb │ │ ├── profile-openruko-dynohost.erb │ │ ├── ssh-config.erb │ │ ├── upstart-openruko-apiserver.conf.erb │ │ ├── upstart-openruko-dynohost.conf.erb │ │ ├── upstart-openruko-gitmouth.conf.erb │ │ ├── upstart-openruko-httprouting.conf.erb │ │ └── upstart-openruko-logplex.conf.erb ├── openssl │ ├── README.md │ ├── libraries │ │ └── secure_password.rb │ ├── metadata.json │ ├── metadata.rb │ └── recipes │ │ └── default.rb ├── postgresql │ ├── .gitignore │ ├── .ruby-version │ ├── LICENSE.txt │ ├── README.md │ ├── Rakefile │ ├── attributes │ │ └── default.rb │ ├── definitions │ │ ├── pg_database.rb │ │ ├── pg_database_extensions.rb │ │ └── pg_user.rb │ ├── files │ │ └── default │ │ │ └── pgdg.pref │ ├── metadata.rb │ ├── recipes │ │ ├── client.rb │ │ ├── contrib.rb │ │ ├── dbg.rb │ │ ├── default.rb │ │ ├── doc.rb │ │ ├── libpq.rb │ │ ├── postgis.rb │ │ └── server.rb │ ├── templates │ │ └── default │ │ │ ├── environment.erb │ │ │ ├── pg_ctl.conf.erb │ │ │ ├── pg_hba.conf.erb │ │ │ ├── pg_ident.conf.erb │ │ │ ├── postgresql.conf.custom.erb │ │ │ ├── postgresql.conf.standard.erb │ │ │ └── start.conf.erb │ └── test │ │ ├── .chef │ │ └── knife.rb │ │ └── support │ │ └── Gemfile ├── proxy │ ├── recipes │ │ └── default.rb │ └── templates │ │ └── default │ │ ├── aptproxy.erb │ │ ├── gitproxy.erb │ │ └── systemproxy.erb └── python │ ├── CHANGELOG.md │ ├── CONTRIBUTING │ ├── LICENSE │ ├── README.md │ ├── attributes │ └── default.rb │ ├── metadata.rb │ ├── providers │ ├── pip.rb │ └── virtualenv.rb │ ├── recipes │ ├── default.rb │ ├── package.rb │ ├── pip.rb │ ├── source.rb │ └── virtualenv.rb │ └── resources │ ├── pip.rb │ └── virtualenv.rb ├── deploy.sh ├── solo.json ├── solo.rb ├── standalone └── Vagrantfile ├── unlock_versions.rb └── vagrant_common.rb /.gitignore: -------------------------------------------------------------------------------- 1 | .vagrant.d 2 | .vagrant 3 | chef-stacktrace.out 4 | Vagrantfile.local 5 | solo.local.json 6 | distribute-* 7 | distribute_setup.py 8 | npm-debug.log 9 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: bash 2 | before_script: source bootstrap.sh 3 | script: sudo su - rukosan -c "cd /home/rukosan/openruko/integration-tests && ./run.sh" 4 | 5 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Bootstrapping OpenRuko 2 | [![Build Status](https://travis-ci.org/openruko/vagrant-openruko.png)](https://travis-ci.org/openruko/vagrant-openruko) 3 | 4 | Chef recipes for bootstrapping [OpenRuko](https://github.com/openruko). 5 | 6 | Both a Vagrantfile for running local development environments and, using Vagrant 1.1, for deploying to VPSs. 7 | 8 | ## Standalone Install 9 | 10 | Useful for local dev environments or just single-server setups. 11 | 12 | To generate a new VirtualBox VM with OpenRuko and all its dependencies already installed. 13 | 14 | ``` 15 | $ sudo apt-get install vagrant 16 | $ git clone https://github.com/openruko/vagrant-openruko.git 17 | $ cd vagrant-openruko/standalone 18 | $ vagrant up 19 | # wait ... 20 | ``` 21 | 22 | ## Cluster Install 23 | 24 | Openruko is designed to be scalable, so that you can have a central API server with mulitple dyno servers. 25 | 26 | To generate a new VirtualBox VM with OpenRuko and all its dependencies already installed. 27 | 28 | ``` 29 | $ cd vagrant-openruko/cluster 30 | $ vagrant up 31 | # wait for both VMs to boot 32 | 33 | ``` 34 | 35 | You can ssh into each individual VM with `vagrant ssh api` and `vagrant ssh dynohost` 36 | 37 | ## Launch tests 38 | 39 | Login to the server `vagrant ssh`, or `vagrant ssh api` if you're bootstrapping a cluster and run 40 | 41 | ``` 42 | $ cd ~/openruko/integration-tests 43 | $ ./run.sh 44 | ``` 45 | 46 | See also [integration-tests](https://github.com/openruko/integration-tests) 47 | 48 | ## If you're behind a proxy 49 | 50 | Export the following environment variable in the host machine: 51 | 52 | ``` 53 | export HTTP_PROXY=http://proxy.xxx:3128 54 | export HTTPS_PROXY=http://proxy.xxx:3128 55 | export NO_PROXY=localhost 56 | ``` 57 | 58 | Connect to the server with SSH, and create a new project (we will use node.js) 59 | 60 | ``` 61 | $ mkdir myapp 62 | $ cd myapp 63 | $ git init 64 | $ npm init 65 | $ cat > index.js << EOF 66 | var http = require('http'); 67 | http.createServer(function (req, res) { 68 | res.writeHead(200, {'Content-Type': 'text/plain'}); 69 | res.end('Hello World\n'); 70 | }).listen(process.env.PORT); 71 | console.log('Server running'); 72 | EOF 73 | 74 | $ cat > Procfile << EOF 75 | web: node index.js 76 | EOF 77 | 78 | $ git add -A 79 | $ git commit -m 'fisrt commit' 80 | 81 | $ ~/openruko/client/openruko keys:add 82 | 83 | $ ~/openruko/client/openruko create myapp 84 | # email: openruko@openruko.com 85 | # Password: rukosan 86 | 87 | $ git push heroku master 88 | $ curl http://myapp.mymachine.me:8080/ 89 | ``` 90 | 91 | -------------------------------------------------------------------------------- /bootstrap.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # This is used by non-vagrant environments. 4 | 5 | PATH=$PATH:/var/lib/gems/1.9.1/bin 6 | 7 | chef_version="10.20" 8 | 9 | function add_rukosan_user { 10 | sudo useradd -d /home/rukosan -m rukosan -s /bin/bash -c Rukosan && 11 | sudo su - -c "echo \"rukosan ALL=(ALL) NOPASSWD: ALL\" >> /etc/sudoers" 12 | } 13 | 14 | if [ "$TRAVIS" != "true" ]; then 15 | 16 | # Are we on a vanilla system? 17 | if (! command -v chef-solo >/dev/null 2>&1) || (! chef-solo --version | grep $chef_version); then 18 | 19 | # After an apt-get update the kernel and Vbox modules can get out of sync, so use apt pinning to 20 | # prevent updates to the kernel. 21 | if [[ "$(whoami)" = "vagrant" ]]; then 22 | 23 | sudo cat > /etc/apt/preferences <<-EOF 24 | Package: linux-generic linux-headers-generic linux-image-generic linux-restricted-modules-generic 25 | Pin: version 3.2.0-23 26 | Pin-Priority: 1001 27 | EOF 28 | 29 | fi 30 | 31 | export DEBIAN_FRONTEND=noninteractive 32 | # Upgrade headlessly (this is only safe-ish on vanilla systems) 33 | sudo aptitude update && 34 | sudo apt-cache policy && 35 | 36 | # Everything works fine without upgrading. Besides it upgrades the kernel, which means that 37 | # the existing Vbox modules get out of sync. Not to mention that updating everytime introduces 38 | # time-dependent variables that don't make this box future-proof and idempotent. 39 | #sudo apt-get -o Dpkg::Options::="--force-confnew" \ 40 | # --force-yes -fuy dist-upgrade && 41 | 42 | # Install Ruby and Chef 43 | sudo aptitude install -y ruby1.9.1 ruby1.9.1-dev make && 44 | sudo gem1.9.1 install --no-rdoc --no-ri chef --version $chef_version && 45 | add_rukosan_user 46 | export GEM_HOME=/home/rukosan/.gem/ruby/1.9.1 47 | export PATH=$PATH:~/.gem/ruby/1.9.1/bin/ 48 | 49 | # If the Vagrant shared folder mounts create /home/rukosan before the user has been created 50 | # then root will own /home/rukosan and chef will complain about permission issues. 51 | sudo chown rukosan:rukosan /home/rukosan 52 | 53 | fi && 54 | 55 | sudo_command=sudo 56 | 57 | else 58 | 59 | echo "Travis CI environment detected." 60 | sudo apt-get update 61 | 62 | # Remove exsiting Postgres installation 63 | sudo /etc/init.d/postgresql stop 64 | sudo apt-get --force-yes -fuy remove --purge postgresql postgresql-9.1 postgresql-client lxc 65 | 66 | sudo mkdir -p /var/log/postgresql 67 | 68 | gem install --no-rdoc --no-ri chef --version $chef_version 69 | add_rukosan_user 70 | 71 | # rvmsudo is the only way to give chef the needed permissions 72 | sudo_command=rvmsudo 73 | fi 74 | 75 | $sudo_command chef-solo -c solo.rb -j solo.json 76 | -------------------------------------------------------------------------------- /cluster/Vagrantfile: -------------------------------------------------------------------------------- 1 | require File.join(File.dirname(__FILE__), "..", "vagrant_common") 2 | 3 | Vagrant::Config.run do |config| 4 | config.vm.box = "precise64" 5 | config.vm.box_url = "http://files.vagrantup.com/precise64.box" 6 | 7 | # Or use the Travis CI environment to fix Travis-specific buidl failures 8 | # See http://ruby-journal.com/debug-your-failed-test-in-travis-ci/ for more info 9 | #config.vm.box = "travis-ruby" 10 | 11 | config.vm.share_folder "chef", "~/chef", "." 12 | 13 | ###################### 14 | # Api node definition 15 | ###################### 16 | config.vm.define :api do |api_config| 17 | 18 | api_config.vm.forward_port 80, 8888 19 | api_config.vm.network :hostonly, "10.10.10.100" 20 | 21 | api_config.vm.provision :chef_solo do |chef| 22 | chef.cookbooks_path = '../cookbooks' 23 | 24 | # First apply proxy recipe 25 | proxy_set(chef) 26 | json_load(chef) 27 | 28 | chef.json["run_list"].reject! { |r| r == 'recipe[openruko::dynohost]' } 29 | chef.json["run_list"].each do |recipe_name| 30 | chef.add_recipe recipe_name 31 | end 32 | end 33 | 34 | end 35 | 36 | 37 | ########################### 38 | # Dynohost node definition 39 | ########################### 40 | config.vm.define :dynohost do |dynohost_config| 41 | 42 | dynohost_config.vm.network :hostonly, "10.10.10.101" 43 | 44 | dynohost_config.vm.provision :chef_solo do |chef| 45 | chef.cookbooks_path = '../cookbooks' 46 | 47 | # First apply proxy recipe 48 | proxy_set(chef) 49 | json_load(chef) 50 | chef.json["openruko"]["apiserver_ip"] = "10.10.10.100" 51 | chef.json['run_list'] = [ 52 | 'recipe[openruko::default]', 53 | 'recipe[openruko::dynohost]' 54 | ] 55 | chef.json["run_list"].each do |recipe_name| 56 | chef.add_recipe recipe_name 57 | end 58 | end 59 | end 60 | 61 | end 62 | 63 | # If you want to do some funky custom stuff to your box, but don't want those things tracked by git, 64 | # add a Vagrantfile.local and it will be included. For example you could mount your dev version of 65 | # openruko with; 66 | # config.vm.share_folder "openruko", "/home/rukosan/openruko_mount", "~/Software/openruko" 67 | # Then symlink the various repos you're hacking on to see changes straight away on the live box. 68 | load "../Vagrantfile.local" if File.exists? "../Vagrantfile.local" 69 | -------------------------------------------------------------------------------- /cookbooks/apt/.gitignore: -------------------------------------------------------------------------------- 1 | .bundle 2 | .cache 3 | .kitchen 4 | bin 5 | -------------------------------------------------------------------------------- /cookbooks/apt/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## v1.5.0: 2 | 3 | * [COOK-1500] - Avoid triggering apt-get update 4 | * [COOK-1548] - Add execute commands for autoclean and autoremove 5 | * [COOK-1591] - Setting up the apt proxy should leave https 6 | connections direct 7 | * [COOK-1596] - execute[apt-get-update-periodic] never runs 8 | * [COOK-1762] - create /etc/apt/preferences.d directory 9 | * [COOK-1776] - apt key check isn't idempotent 10 | 11 | ## v1.4.8: 12 | 13 | * Adds test-kitchen support 14 | * [COOK-1435] - repository lwrp is not idempotent with http key 15 | 16 | ## v1.4.6: 17 | 18 | * [COOK-1530] - apt_repository isn't aware of update-success-stamp 19 | file (also reverts COOK-1382 patch). 20 | 21 | ## v1.4.4: 22 | 23 | * [COOK-1229] - Allow cacher IP to be set manually in non-Chef Solo 24 | environments 25 | * [COOK-1530] - Immediately update apt-cache when sources.list file is dropped off 26 | 27 | ## v1.4.2: 28 | 29 | * [COOK-1155] - LWRP for apt pinning 30 | 31 | ## v1.4.0: 32 | 33 | * [COOK-889] - overwrite existing repo source files 34 | * [COOK-921] - optionally use cookbook\_file or remote\_file for key 35 | * [COOK-1032] - fixes problem with apt repository key installation 36 | -------------------------------------------------------------------------------- /cookbooks/apt/CONTRIBUTING: -------------------------------------------------------------------------------- 1 | If you would like to contribute, please open a ticket in JIRA: 2 | 3 | * http://tickets.opscode.com 4 | 5 | Create the ticket in the COOK project and use the cookbook name as the 6 | component. 7 | 8 | For all code contributions, we ask that contributors sign a 9 | contributor license agreement (CLA). Instructions may be found here: 10 | 11 | * http://wiki.opscode.com/display/chef/How+to+Contribute 12 | 13 | When contributing changes to individual cookbooks, please do not 14 | modify the version number in the metadata.rb. Also please do not 15 | update the CHANGELOG.md for a new version. Not all changes to a 16 | cookbook may be merged and released in the same versions. Opscode will 17 | handle the version updates during the release process. You are welcome 18 | to correct typos or otherwise make updates to documentation in the 19 | README. 20 | 21 | If a contribution adds new platforms or platform versions, indicate 22 | such in the body of the commit message(s), and update the relevant 23 | COOK ticket. When writing commit messages, it is helpful for others if 24 | you indicate the COOK ticket. For example: 25 | 26 | git commit -m '[COOK-1041] Updated pool resource to correctly delete.' 27 | 28 | In the ticket itself, it is also helpful if you include log output of 29 | a successful Chef run, but this is not absolutely required. 30 | -------------------------------------------------------------------------------- /cookbooks/apt/Gemfile: -------------------------------------------------------------------------------- 1 | source :rubygems 2 | 3 | gem 'test-kitchen', :git => 'git@github.com:opscode/test-kitchen.git' 4 | -------------------------------------------------------------------------------- /cookbooks/apt/LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /cookbooks/apt/README.md: -------------------------------------------------------------------------------- 1 | Description 2 | =========== 3 | 4 | This cookbook includes recipes to execute apt-get update to ensure the 5 | local APT package cache is up to date. There are recipes for managing 6 | the apt-cacher-ng caching proxy and proxy clients. It also includes a 7 | LWRP for managing APT repositories in /etc/apt/sources.list.d as well as 8 | an LWRP for pinning packages via /etc/apt/preferences.d. 9 | 10 | Recipes 11 | ======= 12 | 13 | default 14 | ------- 15 | 16 | This recipe installs the `update-notifier-common` package to provide 17 | the timestamp file used to only run `apt-get update` if the cache is 18 | more than one day old. 19 | 20 | This recipe should appear first in the run list of Debian or Ubuntu 21 | nodes to ensure that the package cache is up to date before managing 22 | any `package` resources with Chef. 23 | 24 | This recipe also sets up a local cache directory for preseeding packages. 25 | 26 | cacher-ng 27 | --------- 28 | 29 | Installs the `apt-cacher-ng` package and service so the system can 30 | provide APT caching. You can check the usage report at 31 | http://{hostname}:3142/acng-report.html. The `cacher-ng` recipe 32 | includes the `cacher-client` recipe, so it helps seed itself. 33 | 34 | cacher-client 35 | ------------- 36 | Configures the node to use the `apt-cacher-ng` server as a client. 37 | 38 | Resources/Providers 39 | =================== 40 | 41 | Managing repositories 42 | --------------------- 43 | 44 | This LWRP provides an easy way to manage additional APT repositories. 45 | Adding a new repository will notify running the `execute[apt-get-update]` 46 | resource immediately. 47 | 48 | # Actions 49 | 50 | - :add: creates a repository file and builds the repository listing 51 | - :remove: removes the repository file 52 | 53 | # Attribute Parameters 54 | 55 | - repo_name: name attribute. The name of the channel to discover 56 | - uri: the base of the Debian distribution 57 | - distribution: this is usually your release's codename...ie something 58 | like `karmic`, `lucid` or `maverick` 59 | - components: package groupings..when it doubt use `main` 60 | - deb_src: whether or not to add the repository as a source repo as 61 | well - value can be `true` or `false`, default `false`. 62 | - key_server: the GPG keyserver where the key for the repo should be retrieved 63 | - key: if a `key_server` is provided, this is assumed to be the 64 | fingerprint, otherwise it can be either the URI to the GPG key for 65 | the repo, or a cookbook_file. 66 | - cookbook: if key should be a cookbook_file, specify a cookbook where 67 | the key is located for files/default. Defaults to nil, so it will 68 | use the cookbook where the resource is used. 69 | 70 | # Examples 71 | 72 | # add the Zenoss repo 73 | apt_repository "zenoss" do 74 | uri "http://dev.zenoss.org/deb" 75 | components ["main","stable"] 76 | end 77 | 78 | # add the Nginx PPA; grab key from keyserver 79 | apt_repository "nginx-php" do 80 | uri "http://ppa.launchpad.net/nginx/php5/ubuntu" 81 | distribution node['lsb']['codename'] 82 | components ["main"] 83 | keyserver "keyserver.ubuntu.com" 84 | key "C300EE8C" 85 | end 86 | 87 | # add the Nginx PPA; grab key from keyserver, also add source repo 88 | apt_repository "nginx-php" do 89 | uri "http://ppa.launchpad.net/nginx/php5/ubuntu" 90 | distribution node['lsb']['codename'] 91 | components ["main"] 92 | keyserver "keyserver.ubuntu.com" 93 | key "C300EE8C" 94 | deb_src true 95 | end 96 | 97 | # add the Cloudkick Repo 98 | apt_repository "cloudkick" do 99 | uri "http://packages.cloudkick.com/ubuntu" 100 | distribution node['lsb']['codename'] 101 | components ["main"] 102 | key "http://packages.cloudkick.com/cloudkick.packages.key" 103 | end 104 | 105 | # add the Cloudkick Repo with the key downloaded in the cookbook 106 | apt_repository "cloudkick" do 107 | uri "http://packages.cloudkick.com/ubuntu" 108 | distribution node['lsb']['codename'] 109 | components ["main"] 110 | key "cloudkick.packages.key" 111 | end 112 | 113 | # remove Zenoss repo 114 | apt_repository "zenoss" do 115 | action :remove 116 | end 117 | 118 | Pinning packages 119 | ---------------- 120 | 121 | This LWRP provides an easy way to pin packages in /etc/apt/preferences.d. 122 | Although apt-pinning is quite helpful from time to time please note that Debian 123 | does not encourage its use without thorough consideration. 124 | 125 | Further information regarding apt-pinning is available via 126 | http://wiki.debian.org/AptPreferences. 127 | 128 | # Actions 129 | 130 | - :add: creates a preferences file under /etc/apt/preferences.d 131 | - :remove: Removes the file, therefore unpin the package 132 | 133 | # Attribute Parameters 134 | 135 | - package_name: name attribute. The name of the package 136 | - pin: The package version/repository to pin 137 | - pin_priority: The pinning priority aka "the highest package version wins" 138 | 139 | # Examples 140 | 141 | # Pin libmysqlclient16 to version 5.1.49-3 142 | apt_preference "libmysqlclient16" do 143 | pin "version 5.1.49-3" 144 | pin_priority "700" 145 | end 146 | 147 | # Unpin libmysqlclient16 148 | apt_preference "libmysqlclient16" do 149 | action :remove 150 | end 151 | 152 | Usage 153 | ===== 154 | 155 | Put `recipe[apt]` first in the run list. If you have other recipes 156 | that you want to use to configure how apt behaves, like new sources, 157 | notify the execute resource to run, e.g.: 158 | 159 | template "/etc/apt/sources.list.d/my_apt_sources.list" do 160 | notifies :run, resources(:execute => "apt-get update"), :immediately 161 | end 162 | 163 | The above will run during execution phase since it is a normal 164 | template resource, and should appear before other package resources 165 | that need the sources in the template. 166 | 167 | Put `recipe[apt::cacher-ng]` in the run_list for a server to provide 168 | APT caching and add `recipe[apt::cacher-client]` on the rest of the 169 | Debian-based nodes to take advantage of the caching server. 170 | 171 | If you want to cleanup unused packages, there is also the `apt-get autoclean` 172 | and `apt-get autoremove` resources provided for automated cleanup. 173 | 174 | License and Author 175 | ================== 176 | 177 | Author:: Joshua Timberman () 178 | Author:: Matt Ray () 179 | Author:: Seth Chisamore () 180 | 181 | Copyright 2009-2012 Opscode, Inc. 182 | 183 | Licensed under the Apache License, Version 2.0 (the "License"); 184 | you may not use this file except in compliance with the License. 185 | You may obtain a copy of the License at 186 | 187 | http://www.apache.org/licenses/LICENSE-2.0 188 | 189 | Unless required by applicable law or agreed to in writing, software 190 | distributed under the License is distributed on an "AS IS" BASIS, 191 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 192 | See the License for the specific language governing permissions and 193 | limitations under the License. 194 | -------------------------------------------------------------------------------- /cookbooks/apt/files/default/apt-proxy-v2.conf: -------------------------------------------------------------------------------- 1 | [DEFAULT] 2 | ;; All times are in seconds, but you can add a suffix 3 | ;; for minutes(m), hours(h) or days(d) 4 | 5 | ;; commented out address so apt-proxy will listen on all IPs 6 | ;; address = 127.0.0.1 7 | port = 9999 8 | cache_dir = /var/cache/apt-proxy 9 | 10 | ;; Control files (Packages/Sources/Contents) refresh rate 11 | min_refresh_delay = 1s 12 | complete_clientless_downloads = 1 13 | 14 | ;; Debugging settings. 15 | debug = all:4 db:0 16 | 17 | time = 30 18 | passive_ftp = on 19 | 20 | ;;-------------------------------------------------------------- 21 | ;; Cache housekeeping 22 | 23 | cleanup_freq = 1d 24 | max_age = 120d 25 | max_versions = 3 26 | 27 | ;;--------------------------------------------------------------- 28 | ;; Backend servers 29 | ;; 30 | ;; Place each server in its own [section] 31 | 32 | [ubuntu] 33 | ; Ubuntu archive 34 | backends = 35 | http://us.archive.ubuntu.com/ubuntu 36 | 37 | [ubuntu-security] 38 | ; Ubuntu security updates 39 | backends = http://security.ubuntu.com/ubuntu 40 | 41 | [debian] 42 | ;; Backend servers, in order of preference 43 | backends = 44 | http://debian.osuosl.org/debian/ 45 | 46 | [security] 47 | ;; Debian security archive 48 | backends = 49 | http://security.debian.org/debian-security 50 | http://ftp2.de.debian.org/debian-security 51 | -------------------------------------------------------------------------------- /cookbooks/apt/metadata.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "apt", 3 | "description": "Configures apt and apt services and LWRPs for managing apt repositories and preferences", 4 | "long_description": "Description\n===========\n\nThis cookbook includes recipes to execute apt-get update to ensure the\nlocal APT package cache is up to date. There are recipes for managing\nthe apt-cacher-ng caching proxy and proxy clients. It also includes a\nLWRP for managing APT repositories in /etc/apt/sources.list.d as well as\nan LWRP for pinning packages via /etc/apt/preferences.d.\n\nRecipes\n=======\n\ndefault\n-------\n\nThis recipe installs the `update-notifier-common` package to provide\nthe timestamp file used to only run `apt-get update` if the cache is\nmore than one day old.\n\nThis recipe should appear first in the run list of Debian or Ubuntu\nnodes to ensure that the package cache is up to date before managing\nany `package` resources with Chef.\n\nThis recipe also sets up a local cache directory for preseeding packages.\n\ncacher-ng\n---------\n\nInstalls the `apt-cacher-ng` package and service so the system can\nprovide APT caching. You can check the usage report at\nhttp://{hostname}:3142/acng-report.html. The `cacher-ng` recipe\nincludes the `cacher-client` recipe, so it helps seed itself.\n\ncacher-client\n-------------\nConfigures the node to use the `apt-cacher-ng` server as a client.\n\nResources/Providers\n===================\n\nManaging repositories\n---------------------\n\nThis LWRP provides an easy way to manage additional APT repositories.\nAdding a new repository will notify running the `execute[apt-get-update]`\nresource immediately.\n\n# Actions\n\n- :add: creates a repository file and builds the repository listing\n- :remove: removes the repository file\n\n# Attribute Parameters\n\n- repo_name: name attribute. The name of the channel to discover\n- uri: the base of the Debian distribution\n- distribution: this is usually your release's codename...ie something\n like `karmic`, `lucid` or `maverick`\n- components: package groupings..when it doubt use `main`\n- deb_src: whether or not to add the repository as a source repo as\n well - value can be `true` or `false`, default `false`.\n- key_server: the GPG keyserver where the key for the repo should be retrieved\n- key: if a `key_server` is provided, this is assumed to be the\n fingerprint, otherwise it can be either the URI to the GPG key for\n the repo, or a cookbook_file.\n- cookbook: if key should be a cookbook_file, specify a cookbook where\n the key is located for files/default. Defaults to nil, so it will\n use the cookbook where the resource is used.\n\n# Examples\n\n # add the Zenoss repo\n apt_repository \"zenoss\" do\n uri \"http://dev.zenoss.org/deb\"\n components [\"main\",\"stable\"]\n end\n\n # add the Nginx PPA; grab key from keyserver\n apt_repository \"nginx-php\" do\n uri \"http://ppa.launchpad.net/nginx/php5/ubuntu\"\n distribution node['lsb']['codename']\n components [\"main\"]\n keyserver \"keyserver.ubuntu.com\"\n key \"C300EE8C\"\n end\n\n # add the Nginx PPA; grab key from keyserver, also add source repo\n apt_repository \"nginx-php\" do\n uri \"http://ppa.launchpad.net/nginx/php5/ubuntu\"\n distribution node['lsb']['codename']\n components [\"main\"]\n keyserver \"keyserver.ubuntu.com\"\n key \"C300EE8C\"\n deb_src true\n end\n\n # add the Cloudkick Repo\n apt_repository \"cloudkick\" do\n uri \"http://packages.cloudkick.com/ubuntu\"\n distribution node['lsb']['codename']\n components [\"main\"]\n key \"http://packages.cloudkick.com/cloudkick.packages.key\"\n end\n\n # add the Cloudkick Repo with the key downloaded in the cookbook\n apt_repository \"cloudkick\" do\n uri \"http://packages.cloudkick.com/ubuntu\"\n distribution node['lsb']['codename']\n components [\"main\"]\n key \"cloudkick.packages.key\"\n end\n\n # remove Zenoss repo\n apt_repository \"zenoss\" do\n action :remove\n end\n\nPinning packages\n----------------\n\nThis LWRP provides an easy way to pin packages in /etc/apt/preferences.d.\nAlthough apt-pinning is quite helpful from time to time please note that Debian\ndoes not encourage its use without thorough consideration.\n\nFurther information regarding apt-pinning is available via\nhttp://wiki.debian.org/AptPreferences.\n\n# Actions\n\n- :add: creates a preferences file under /etc/apt/preferences.d\n- :remove: Removes the file, therefore unpin the package\n\n# Attribute Parameters\n\n- package_name: name attribute. The name of the package\n- pin: The package version/repository to pin\n- pin_priority: The pinning priority aka \"the highest package version wins\"\n\n# Examples\n\n # Pin libmysqlclient16 to version 5.1.49-3\n apt_preference \"libmysqlclient16\" do\n pin \"version 5.1.49-3\"\n pin_priority \"700\"\n end\n\n # Unpin libmysqlclient16\n apt_preference \"libmysqlclient16\" do\n action :remove\n end\n\nUsage\n=====\n\nPut `recipe[apt]` first in the run list. If you have other recipes\nthat you want to use to configure how apt behaves, like new sources,\nnotify the execute resource to run, e.g.:\n\n template \"/etc/apt/sources.list.d/my_apt_sources.list\" do\n notifies :run, resources(:execute => \"apt-get update\"), :immediately\n end\n\nThe above will run during execution phase since it is a normal\ntemplate resource, and should appear before other package resources\nthat need the sources in the template.\n\nPut `recipe[apt::cacher-ng]` in the run_list for a server to provide\nAPT caching and add `recipe[apt::cacher-client]` on the rest of the\nDebian-based nodes to take advantage of the caching server.\n\nIf you want to cleanup unused packages, there is also the `apt-get autoclean`\nand `apt-get autoremove` resources provided for automated cleanup.\n\nLicense and Author\n==================\n\nAuthor:: Joshua Timberman ()\nAuthor:: Matt Ray ()\nAuthor:: Seth Chisamore ()\n\nCopyright 2009-2012 Opscode, Inc.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n", 5 | "maintainer": "Opscode, Inc.", 6 | "maintainer_email": "cookbooks@opscode.com", 7 | "license": "Apache 2.0", 8 | "platforms": { 9 | "ubuntu": ">= 0.0.0", 10 | "debian": ">= 0.0.0" 11 | }, 12 | "dependencies": { 13 | }, 14 | "recommendations": { 15 | }, 16 | "suggestions": { 17 | }, 18 | "conflicting": { 19 | }, 20 | "providing": { 21 | }, 22 | "replacing": { 23 | }, 24 | "attributes": { 25 | }, 26 | "groupings": { 27 | }, 28 | "recipes": { 29 | "apt": "Runs apt-get update during compile phase and sets up preseed directories", 30 | "apt::cacher-ng": "Set up an apt-cacher-ng caching proxy", 31 | "apt::cacher-client": "Client for the apt::cacher-ng caching proxy" 32 | }, 33 | "version": "1.5.0" 34 | } -------------------------------------------------------------------------------- /cookbooks/apt/metadata.rb: -------------------------------------------------------------------------------- 1 | maintainer "Opscode, Inc." 2 | maintainer_email "cookbooks@opscode.com" 3 | license "Apache 2.0" 4 | description "Configures apt and apt services and LWRPs for managing apt repositories and preferences" 5 | long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) 6 | version "1.5.0" 7 | recipe "apt", "Runs apt-get update during compile phase and sets up preseed directories" 8 | recipe "apt::cacher-ng", "Set up an apt-cacher-ng caching proxy" 9 | recipe "apt::cacher-client", "Client for the apt::cacher-ng caching proxy" 10 | 11 | %w{ ubuntu debian }.each do |os| 12 | supports os 13 | end 14 | -------------------------------------------------------------------------------- /cookbooks/apt/providers/preference.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: apt 3 | # Provider:: preference 4 | # 5 | # Copyright 2010-2011, Opscode, Inc. 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # 19 | 20 | # Build preferences.d file contents 21 | def build_pref(package_name, pin, pin_priority) 22 | preference_content = "Package: #{package_name}\nPin: #{pin}\nPin-Priority: #{pin_priority}\n" 23 | end 24 | 25 | action :add do 26 | new_resource.updated_by_last_action(false) 27 | 28 | preference = build_pref(new_resource.package_name, 29 | new_resource.pin, 30 | new_resource.pin_priority) 31 | 32 | preference_dir = directory "/etc/apt/preferences.d" do 33 | owner "root" 34 | group "root" 35 | mode "0644" 36 | recursive true 37 | action :nothing 38 | end 39 | 40 | preference_file = file "/etc/apt/preferences.d/#{new_resource.package_name}" do 41 | owner "root" 42 | group "root" 43 | mode 0644 44 | content preference 45 | action :nothing 46 | end 47 | 48 | preference_dir.run_action(:create) 49 | # write out the preference file, replace it if it already exists 50 | preference_file.run_action(:create) 51 | end 52 | 53 | action :remove do 54 | if ::File.exists?("/etc/apt/preferences.d/#{new_resource.package_name}") 55 | Chef::Log.info "Un-pinning #{new_resource.package_name} from /etc/apt/preferences.d/" 56 | file "/etc/apt/preferences.d/#{new_resource.package_name}" do 57 | action :delete 58 | end 59 | new_resource.updated_by_last_action(true) 60 | end 61 | end 62 | -------------------------------------------------------------------------------- /cookbooks/apt/providers/repository.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: apt 3 | # Provider:: repository 4 | # 5 | # Copyright 2010-2011, Opscode, Inc. 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # 19 | 20 | def whyrun_supported? 21 | true 22 | end 23 | 24 | # install apt key from keyserver 25 | def install_key_from_keyserver(key, keyserver) 26 | unless system("apt-key list | grep #{key}") 27 | execute "install-key #{key}" do 28 | command "apt-key adv --keyserver #{keyserver} --recv #{key}" 29 | action :nothing 30 | end.run_action(:run) 31 | end 32 | end 33 | 34 | # run command and extract gpg ids 35 | def extract_gpg_ids_from_cmd(cmd) 36 | so = Mixlib::ShellOut.new(cmd) 37 | so.run_command 38 | so.stdout.split(/\n/).collect do |t| 39 | if z = t.match(/^pub\s+\d+\w\/([0-9A-F]{8})/) 40 | z[1] 41 | end 42 | end.compact 43 | end 44 | 45 | # install apt key from URI 46 | def install_key_from_uri(uri) 47 | key_name = uri.split(/\//).last 48 | cached_keyfile = "#{Chef::Config[:file_cache_path]}/#{key_name}" 49 | if new_resource.key =~ /http/ 50 | r = remote_file cached_keyfile do 51 | source new_resource.key 52 | mode "0644" 53 | action :nothing 54 | end 55 | else 56 | r = cookbook_file cached_keyfile do 57 | source new_resource.key 58 | cookbook new_resource.cookbook 59 | mode "0644" 60 | action :nothing 61 | end 62 | end 63 | 64 | r.run_action(:create) 65 | 66 | installed_ids = extract_gpg_ids_from_cmd("apt-key finger") 67 | key_ids = extract_gpg_ids_from_cmd("gpg --with-fingerprint #{cached_keyfile}") 68 | unless (installed_ids & key_ids).sort == key_ids.sort 69 | execute "install-key #{key_name}" do 70 | command "apt-key add #{cached_keyfile}" 71 | action :nothing 72 | end.run_action(:run) 73 | end 74 | end 75 | 76 | # build repo file contents 77 | def build_repo(uri, distribution, components, add_deb_src) 78 | components = components.join(' ') if components.respond_to?(:join) 79 | repo_info = "#{uri} #{distribution} #{components}\n" 80 | repo = "deb #{repo_info}" 81 | repo << "deb-src #{repo_info}" if add_deb_src 82 | repo 83 | end 84 | 85 | action :add do 86 | new_resource.updated_by_last_action(false) 87 | 88 | # add key 89 | if new_resource.keyserver && new_resource.key 90 | install_key_from_keyserver(new_resource.key, new_resource.keyserver) 91 | elsif new_resource.key 92 | install_key_from_uri(new_resource.key) 93 | end 94 | 95 | execute "apt-get update" do 96 | ignore_failure true 97 | action :nothing 98 | end 99 | 100 | file "/var/lib/apt/periodic/update-success-stamp" do 101 | action :nothing 102 | end 103 | 104 | # build repo file 105 | repository = build_repo(new_resource.uri, 106 | new_resource.distribution, 107 | new_resource.components, 108 | new_resource.deb_src) 109 | 110 | f = file "/etc/apt/sources.list.d/#{new_resource.repo_name}-source.list" do 111 | owner "root" 112 | group "root" 113 | mode 0644 114 | content repository 115 | action :create 116 | notifies :delete, resources(:file => "/var/lib/apt/periodic/update-success-stamp"), :immediately 117 | notifies :run, resources(:execute => "apt-get update"), :immediately if new_resource.cache_rebuild 118 | end 119 | new_resource.updated_by_last_action(f.updated?) 120 | end 121 | 122 | action :remove do 123 | if ::File.exists?("/etc/apt/sources.list.d/#{new_resource.repo_name}-source.list") 124 | Chef::Log.info "Removing #{new_resource.repo_name} repository from /etc/apt/sources.list.d/" 125 | file "/etc/apt/sources.list.d/#{new_resource.repo_name}-source.list" do 126 | action :delete 127 | end 128 | end 129 | end 130 | -------------------------------------------------------------------------------- /cookbooks/apt/recipes/cacher-client.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: apt 3 | # Recipe:: cacher-client 4 | # 5 | # Copyright 2011, 2012 Opscode, Inc. 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # 19 | 20 | #remove Acquire::http::Proxy lines from /etc/apt/apt.conf since we use 01proxy 21 | #these are leftover from preseed installs 22 | execute "Remove proxy from /etc/apt/apt.conf" do 23 | command "sed --in-place '/^Acquire::http::Proxy/d' /etc/apt/apt.conf" 24 | only_if "grep Acquire::http::Proxy /etc/apt/apt.conf" 25 | end 26 | 27 | servers = [] 28 | if node['apt'] && node['apt']['cacher_ipaddress'] 29 | cacher = Chef::Node.new 30 | cacher.name(node['apt']['cacher_ipaddress']) 31 | cacher.ipaddress(node['apt']['cacher_ipaddress']) 32 | servers << cacher 33 | end 34 | 35 | servers += search(:node, 'recipes:apt\:\:cacher-ng') unless Chef::Config[:solo] 36 | 37 | if servers.length > 0 38 | Chef::Log.info("apt-cacher-ng server found on #{servers[0]}.") 39 | proxy = "Acquire::http::Proxy \"http://#{servers[0].ipaddress}:3142\";\n" 40 | proxy += "Acquire::https::Proxy \"DIRECT\";\n" 41 | file "/etc/apt/apt.conf.d/01proxy" do 42 | owner "root" 43 | group "root" 44 | mode "0644" 45 | content proxy 46 | action :create 47 | end 48 | else 49 | Chef::Log.info("No apt-cacher-ng server found.") 50 | file "/etc/apt/apt.conf.d/01proxy" do 51 | action :delete 52 | only_if {::File.exists?("/etc/apt/apt.conf.d/01proxy")} 53 | end 54 | end 55 | -------------------------------------------------------------------------------- /cookbooks/apt/recipes/cacher-ng.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: apt 3 | # Recipe:: cacher-ng 4 | # 5 | # Copyright 2008-2012, Opscode, Inc. 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # 19 | 20 | package "apt-cacher-ng" do 21 | action :install 22 | end 23 | 24 | service "apt-cacher-ng" do 25 | supports :restart => true, :status => false 26 | action [ :enable, :start ] 27 | end 28 | 29 | #this will help seed the proxy 30 | include_recipe "apt::cacher-client" 31 | -------------------------------------------------------------------------------- /cookbooks/apt/recipes/default.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: apt 3 | # Recipe:: default 4 | # 5 | # Copyright 2008-2011, Opscode, Inc. 6 | # Copyright 2009, Bryan McLellan 7 | # 8 | # Licensed under the Apache License, Version 2.0 (the "License"); 9 | # you may not use this file except in compliance with the License. 10 | # You may obtain a copy of the License at 11 | # 12 | # http://www.apache.org/licenses/LICENSE-2.0 13 | # 14 | # Unless required by applicable law or agreed to in writing, software 15 | # distributed under the License is distributed on an "AS IS" BASIS, 16 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | # See the License for the specific language governing permissions and 18 | # limitations under the License. 19 | # 20 | 21 | # Run apt-get update to create the stamp file 22 | execute "apt-get-update" do 23 | command "apt-get update" 24 | ignore_failure true 25 | not_if do ::File.exists?('/var/lib/apt/periodic/update-success-stamp') end 26 | end 27 | 28 | # For other recipes to call to force an update 29 | execute "apt-get update" do 30 | command "apt-get update" 31 | ignore_failure true 32 | action :nothing 33 | end 34 | 35 | # Automatically remove packages that are no longer needed for depdencies 36 | execute "apt-get autoremove" do 37 | command "apt-get -y autoremove" 38 | action :nothing 39 | end 40 | 41 | # Automatically remove .deb files for packages no longer on your system 42 | execute "apt-get autoclean" do 43 | command "apt-get -y autoclean" 44 | action :nothing 45 | end 46 | 47 | # provides /var/lib/apt/periodic/update-success-stamp on apt-get update 48 | package "update-notifier-common" do 49 | notifies :run, resources(:execute => "apt-get-update"), :immediately 50 | end 51 | 52 | execute "apt-get-update-periodic" do 53 | command "apt-get update" 54 | ignore_failure true 55 | only_if do 56 | ::File.exists?('/var/lib/apt/periodic/update-success-stamp') && 57 | ::File.mtime('/var/lib/apt/periodic/update-success-stamp') < Time.now - 86400 58 | end 59 | end 60 | 61 | %w{/var/cache/local /var/cache/local/preseeding}.each do |dirname| 62 | directory dirname do 63 | owner "root" 64 | group "root" 65 | mode 0644 66 | action :create 67 | end 68 | end 69 | -------------------------------------------------------------------------------- /cookbooks/apt/resources/preference.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: apt 3 | # Resource:: preference 4 | # 5 | # Copyright 2010-2011, Opscode, Inc. 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # 19 | 20 | actions :add, :remove 21 | 22 | def initialize(*args) 23 | super 24 | @action = :add 25 | end 26 | 27 | attribute :package_name, :kind_of => String, :name_attribute => true 28 | attribute :pin, :kind_of => String 29 | attribute :pin_priority, :kind_of => String 30 | -------------------------------------------------------------------------------- /cookbooks/apt/resources/repository.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: apt 3 | # Resource:: repository 4 | # 5 | # Copyright 2010-2011, Opscode, Inc. 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # 19 | 20 | actions :add, :remove 21 | 22 | def initialize(*args) 23 | super 24 | @action = :add 25 | end 26 | 27 | #name of the repo, used for source.list filename 28 | attribute :repo_name, :kind_of => String, :name_attribute => true 29 | attribute :uri, :kind_of => String 30 | attribute :distribution, :kind_of => String 31 | attribute :components, :kind_of => Array, :default => [] 32 | #whether or not to add the repository as a source repo as well 33 | attribute :deb_src, :default => false 34 | attribute :keyserver, :kind_of => String, :default => nil 35 | attribute :key, :kind_of => String, :default => nil 36 | attribute :cookbook, :kind_of => String, :default => nil 37 | #trigger cache rebuild 38 | #If not you can trigger in the recipe itself after checking the status of resource.updated{_by_last_action}? 39 | attribute :cache_rebuild, :kind_of => [TrueClass, FalseClass], :default => true -------------------------------------------------------------------------------- /cookbooks/build-essential/.gitignore: -------------------------------------------------------------------------------- 1 | .bundle 2 | .cache 3 | .kitchen 4 | bin 5 | -------------------------------------------------------------------------------- /cookbooks/build-essential/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## v1.2.0: 2 | 3 | * Add test-kitchen support (source repo only) 4 | * [COOK-1677] - build-essential cookbook support for OpenSuse and SLES 5 | * [COOK-1718] - build-essential cookbook metadata should include scientific 6 | * [COOK-1768] - The apt-get update in build-essentials needs to be renamed 7 | 8 | ## v1.1.2: 9 | 10 | * [COOK-1620] - support OS X 10.8 11 | 12 | ## v1.1.0: 13 | 14 | * [COOK-1098] - support amazon linux 15 | * [COOK-1149] - support Mac OS X 16 | * [COOK-1296] - allow for compile-time installation of packages 17 | through an attribute (see README) 18 | 19 | ## v1.0.2: 20 | 21 | * [COOK-1098] - Add Amazon Linux platform support 22 | * [COOK-1149] - Add OS X platform support 23 | -------------------------------------------------------------------------------- /cookbooks/build-essential/CONTRIBUTING: -------------------------------------------------------------------------------- 1 | If you would like to contribute, please open a ticket in JIRA: 2 | 3 | * http://tickets.opscode.com 4 | 5 | Create the ticket in the COOK project and use the cookbook name as the 6 | component. 7 | 8 | For all code contributions, we ask that contributors sign a 9 | contributor license agreement (CLA). Instructions may be found here: 10 | 11 | * http://wiki.opscode.com/display/chef/How+to+Contribute 12 | 13 | When contributing changes to individual cookbooks, please do not 14 | modify the version number in the metadata.rb. Also please do not 15 | update the CHANGELOG.md for a new version. Not all changes to a 16 | cookbook may be merged and released in the same versions. Opscode will 17 | handle the version updates during the release process. You are welcome 18 | to correct typos or otherwise make updates to documentation in the 19 | README. 20 | 21 | If a contribution adds new platforms or platform versions, indicate 22 | such in the body of the commit message(s), and update the relevant 23 | COOK ticket. When writing commit messages, it is helpful for others if 24 | you indicate the COOK ticket. For example: 25 | 26 | git commit -m '[COOK-1041] Updated pool resource to correctly delete.' 27 | 28 | In the ticket itself, it is also helpful if you include log output of 29 | a successful Chef run, but this is not absolutely required. 30 | -------------------------------------------------------------------------------- /cookbooks/build-essential/Gemfile: -------------------------------------------------------------------------------- 1 | source :rubygems 2 | 3 | gem 'test-kitchen' 4 | -------------------------------------------------------------------------------- /cookbooks/build-essential/README.md: -------------------------------------------------------------------------------- 1 | Description 2 | =========== 3 | 4 | Installs packages required for compiling C software from source. Use 5 | this cookbook if you wish to compile C programs, or install RubyGems 6 | with native extensions. 7 | 8 | Requirements 9 | ============ 10 | 11 | ## Platform 12 | 13 | Supported platforms by platform family: 14 | 15 | * Linux (fedora redhat centos ubuntu debian amazon scientific) 16 | * Darwin (`mac_os_x` 10.6+) 17 | 18 | Attributes 19 | ========== 20 | 21 | * `node['build_essential']['compiletime']` - Whether the resources in 22 | the default recipe should be configured at the "Compile" phase of the 23 | Chef run. Defaults to false, see __Usage__ for more information. 24 | * `node['build_essential']['osx']['gcc_installer_url']` - The URL of 25 | the OS X GCC package installer (.pkg). 26 | * `node['build_essential']['osx']['gcc_installer_checksum']` - The 27 | SHA256 checksum of the OS X GCC installer. 28 | 29 | Recipes 30 | ======= 31 | 32 | This cookbook has one recipe, default. 33 | 34 | On Linux platforms (see __Platform__ above for a supported list of 35 | families), packages required to build C source projects are installed. 36 | This includes GCC, make, autconf and others. On Debian-family 37 | distributions, the apt-cache may need to be updated, especially during 38 | compile time installation. See __Usage__ for further information. 39 | 40 | On Mac OS X, the GCC standalone installer by Kenneth Reitz is 41 | installed. Note that this is *not* the Xcode CLI package, as that does 42 | not include all programs and headers required to build some common 43 | GNU-style C projects, such as those that are available from projects 44 | such as MacPorts or Homebrew. Changing the attributes for the GCC 45 | installer URL and checksum to the Xcode values may work, but this is 46 | untested. 47 | 48 | Usage 49 | ===== 50 | 51 | Simply include the `build-essential` and the required tools will be 52 | installed to the system, and later recipes will be able to compile 53 | software from C source code. 54 | 55 | For RubyGems that include native C extensions you wish to use with 56 | Chef, you should do two things. 57 | 58 | 0. Ensure that the C libraries, include files and other assorted "dev" 59 | type packages are installed. You should do this in the compile phase 60 | after the build-essential recipe. 61 | 1. Use the `chef_gem` resource in your recipes. This requires Chef version 0.10.10+. 62 | 2. Set the `compiletime` attribute in roles where such recipes are 63 | required. This will ensure that the build tools are available to 64 | compile the RubyGems' extensions, as `chef_gem` happens during the 65 | compile phase, too. 66 | 67 | Example installation of a devel package at compile-time in a recipe: 68 | 69 | package "mypackage-dev" do 70 | action :nothing 71 | end.run_action(:install) 72 | 73 | Example use of `chef_gem`: 74 | 75 | chef_gem "mygem" 76 | 77 | Example role: 78 | 79 | name "myapp" 80 | run_list( 81 | "recipe[build-essential]", 82 | "recipe[myapp]" 83 | ) 84 | default_attributes( 85 | "build_essential" => { 86 | "compiletime" => true 87 | } 88 | ) 89 | 90 | The compile time option (via the attribute) is to ensure that the 91 | proper packages are available at the right time in the Chef run. It is 92 | recommended that the build-essential recipe appear early in the run 93 | list. 94 | 95 | The Chef wiki has documentation on 96 | [the anatomy of a chef run](http://wiki.opscode.com/display/chef/Anatomy+of+a+Chef+Run). 97 | 98 | Limitations 99 | =========== 100 | 101 | It is not in the scope of this cookbook to handle installing the 102 | required headers for individual software projects in order to compile 103 | them, or to compile RubyGems with native C extensions. You should 104 | create a cookbook for handling that. 105 | 106 | License and Author 107 | ================== 108 | 109 | Author:: Joshua Timberman () 110 | Author:: Seth Chisamore () 111 | 112 | Copyright 2009-2011, Opscode, Inc. () 113 | 114 | Licensed under the Apache License, Version 2.0 (the "License"); 115 | you may not use this file except in compliance with the License. 116 | You may obtain a copy of the License at 117 | 118 | http://www.apache.org/licenses/LICENSE-2.0 119 | 120 | Unless required by applicable law or agreed to in writing, software 121 | distributed under the License is distributed on an "AS IS" BASIS, 122 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 123 | See the License for the specific language governing permissions and 124 | limitations under the License. 125 | -------------------------------------------------------------------------------- /cookbooks/build-essential/attributes/default.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: build-essential 3 | # Attributes:: default 4 | # 5 | # Copyright 2008-2012, Opscode, Inc. 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # 19 | 20 | default['build_essential']['compiletime'] = false 21 | 22 | case node['platform'] 23 | when "mac_os_x" 24 | case 25 | when Chef::VersionConstraint.new("~> 10.7.0").include?(node['platform_version']), 26 | Chef::VersionConstraint.new("~> 10.8.0").include?(node['platform_version']) 27 | default['build_essential']['osx']['gcc_installer_url'] = "https://github.com/downloads/kennethreitz/osx-gcc-installer/GCC-10.7-v2.pkg" 28 | default['build_essential']['osx']['gcc_installer_checksum'] = "df36aa87606feb99d0db9ac9a492819e" 29 | when Chef::VersionConstraint.new("~> 10.6.0").include?(node['platform_version']) 30 | default['build_essential']['osx']['gcc_installer_url'] = "https://github.com/downloads/kennethreitz/osx-gcc-installer/GCC-10.6.pkg" 31 | default['build_essential']['osx']['gcc_installer_checksum'] = "d1db5bab6a3f6b9f3b5577a130baeefa" 32 | end 33 | end 34 | -------------------------------------------------------------------------------- /cookbooks/build-essential/metadata.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "build-essential", 3 | "description": "Installs C compiler / build tools", 4 | "long_description": "", 5 | "maintainer": "Opscode, Inc.", 6 | "maintainer_email": "cookbooks@opscode.com", 7 | "license": "Apache 2.0", 8 | "platforms": { 9 | "fedora": ">= 0.0.0", 10 | "redhat": ">= 0.0.0", 11 | "centos": ">= 0.0.0", 12 | "ubuntu": ">= 0.0.0", 13 | "debian": ">= 0.0.0", 14 | "amazon": ">= 0.0.0", 15 | "suse": ">= 0.0.0", 16 | "scientific": ">= 0.0.0", 17 | "mac_os_x": ">= 10.6.0" 18 | }, 19 | "dependencies": { 20 | }, 21 | "recommendations": { 22 | }, 23 | "suggestions": { 24 | }, 25 | "conflicting": { 26 | }, 27 | "providing": { 28 | }, 29 | "replacing": { 30 | }, 31 | "attributes": { 32 | }, 33 | "groupings": { 34 | }, 35 | "recipes": { 36 | "build-essential": "Installs packages required for compiling C software from source." 37 | }, 38 | "version": "1.2.0" 39 | } -------------------------------------------------------------------------------- /cookbooks/build-essential/metadata.rb: -------------------------------------------------------------------------------- 1 | maintainer "Opscode, Inc." 2 | maintainer_email "cookbooks@opscode.com" 3 | license "Apache 2.0" 4 | description "Installs C compiler / build tools" 5 | version "1.2.0" 6 | recipe "build-essential", "Installs packages required for compiling C software from source." 7 | 8 | %w{ fedora redhat centos ubuntu debian amazon suse scientific}.each do |os| 9 | supports os 10 | end 11 | 12 | supports "mac_os_x", ">= 10.6.0" 13 | -------------------------------------------------------------------------------- /cookbooks/build-essential/recipes/default.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: build-essential 3 | # Recipe:: default 4 | # 5 | # Copyright 2008-2009, Opscode, Inc. 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # 19 | 20 | require 'chef/shell_out' 21 | 22 | compiletime = node['build_essential']['compiletime'] 23 | 24 | case node['os'] 25 | when "linux" 26 | 27 | # on apt-based platforms when first provisioning we need to force 28 | # apt-get update at compiletime if we are going to try to install at compiletime 29 | if node['platform_family'] == "debian" 30 | execute "apt-get-update-build-essentials" do 31 | command "apt-get update" 32 | action :nothing 33 | # tip: to suppress this running every time, just use the apt cookbook 34 | not_if do 35 | ::File.exists?('/var/lib/apt/periodic/update-success-stamp') && 36 | ::File.mtime('/var/lib/apt/periodic/update-success-stamp') > Time.now - 86400*2 37 | end 38 | end.run_action(:run) if compiletime 39 | end 40 | 41 | packages = case node['platform_family'] 42 | when "debian" 43 | %w{build-essential binutils-doc} 44 | when "rhel", "fedora" 45 | %w{gcc gcc-c++ kernel-devel make} 46 | when "suse" 47 | %w{gcc gcc-c++ kernel-default-devel make m4} # in SLES there is no kernel-devel 48 | end 49 | 50 | packages.each do |pkg| 51 | r = package pkg do 52 | action ( compiletime ? :nothing : :install ) 53 | end 54 | r.run_action(:install) if compiletime 55 | end 56 | 57 | %w{autoconf flex bison}.each do |pkg| 58 | r = package pkg do 59 | action ( compiletime ? :nothing : :install ) 60 | end 61 | r.run_action(:install) if compiletime 62 | end 63 | when "darwin" 64 | result = Chef::ShellOut.new("pkgutil --pkgs").run_command 65 | installed = result.stdout.split("\n").include?("com.apple.pkg.gcc4.2Leo") 66 | pkg_filename = File.basename(node['build_essential']['osx']['gcc_installer_url']) 67 | pkg_path = "#{Chef::Config[:file_cache_path]}/#{pkg_filename}" 68 | 69 | r = remote_file pkg_path do 70 | source node['build_essential']['osx']['gcc_installer_url'] 71 | checksum node['build_essential']['osx']['gcc_installer_checksum'] 72 | action ( compiletime ? :nothing : :create ) 73 | not_if { installed } 74 | end 75 | r.run_action(:create) if compiletime 76 | 77 | r = execute "sudo installer -pkg \"#{pkg_path}\" -target /" do 78 | action ( compiletime ? :nothing : :run ) 79 | not_if { installed } 80 | end 81 | r.run_action(:run) if compiletime 82 | end 83 | -------------------------------------------------------------------------------- /cookbooks/fakes3/recipes/default.rb: -------------------------------------------------------------------------------- 1 | package "rubygems" 2 | 3 | script "install-fakes3" do 4 | interpreter "bash" 5 | 6 | code <<-EOF 7 | sudo su - #{node['fakes3']['user']} -c 'gem install fakes3 --no-rdoc --no-ri' 8 | EOF 9 | 10 | not_if "sudo su - #{node['fakes3']['user']} -c 'gem which fakes3'" 11 | end 12 | 13 | template "/etc/init/fakes3.conf" do 14 | source "upstart-fakes3.conf.erb" 15 | owner "root" 16 | group "root" 17 | mode 0644 18 | end 19 | 20 | service "fakes3" do 21 | provider Chef::Provider::Service::Upstart 22 | supports :restart => true, :start => true, :stop => true 23 | action [:enable, :start] 24 | end 25 | -------------------------------------------------------------------------------- /cookbooks/fakes3/templates/default/upstart-fakes3.conf.erb: -------------------------------------------------------------------------------- 1 | pre-start script 2 | touch /var/log/fakes3.log 3 | chown <%= node['fakes3']['user'] %> /var/log/fakes3.log 4 | end script 5 | 6 | start on (started network-interface 7 | or started network-manager 8 | or started networking) 9 | 10 | stop on (stopping network-interface 11 | or stopping network-manager 12 | or stopping networking) 13 | 14 | respawn 15 | 16 | script 17 | su - <%= node['fakes3']['user'] %> -c 'fakes3 -r /tmp/fakes3_root -p 4567 >> /var/log/fakes3.log 2>&1' 18 | end script 19 | -------------------------------------------------------------------------------- /cookbooks/git/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## v2.0.0: 2 | 3 | This version uses platform_family attribute, making the cookbook incompatible 4 | with older versions of Chef/Ohai, hence the major version bump. 5 | 6 | * [COOK-1668] - git cookbook fails to run due to bad platform_family 7 | call 8 | * [COOK-1759] - git::source needs additional package for rhel 9 | platform_family 10 | 11 | ## v1.0.2: 12 | 13 | * [COOK-1537] - add recipe for source installation 14 | 15 | ## v1.0.0: 16 | 17 | * [COOK-1152] - Add support for Mac OS X 18 | * [COOK-1112] - Add support for Windows 19 | 20 | ## v0.10.0: 21 | 22 | * [COOK-853] - Git client installation on CentOS 23 | 24 | ## v0.9.0: 25 | 26 | * Current public release. 27 | -------------------------------------------------------------------------------- /cookbooks/git/CONTRIBUTING: -------------------------------------------------------------------------------- 1 | If you would like to contribute, please open a ticket in JIRA: 2 | 3 | * http://tickets.opscode.com 4 | 5 | Create the ticket in the COOK project and use the cookbook name as the 6 | component. 7 | 8 | For all code contributions, we ask that contributors sign a 9 | contributor license agreement (CLA). Instructions may be found here: 10 | 11 | * http://wiki.opscode.com/display/chef/How+to+Contribute 12 | 13 | When contributing changes to individual cookbooks, please do not 14 | modify the version number in the metadata.rb. Also please do not 15 | update the CHANGELOG.md for a new version. Not all changes to a 16 | cookbook may be merged and released in the same versions. Opscode will 17 | handle the version updates during the release process. You are welcome 18 | to correct typos or otherwise make updates to documentation in the 19 | README. 20 | 21 | If a contribution adds new platforms or platform versions, indicate 22 | such in the body of the commit message(s), and update the relevant 23 | COOK ticket. When writing commit messages, it is helpful for others if 24 | you indicate the COOK ticket. For example: 25 | 26 | git commit -m '[COOK-1041] Updated pool resource to correctly delete.' 27 | 28 | In the ticket itself, it is also helpful if you include log output of 29 | a successful Chef run, but this is not absolutely required. 30 | -------------------------------------------------------------------------------- /cookbooks/git/LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /cookbooks/git/README.md: -------------------------------------------------------------------------------- 1 | Description 2 | =========== 3 | 4 | Installs git and optionally sets up a git server as a daemon under runit. 5 | 6 | Requirements 7 | ============ 8 | 9 | ## Platform: 10 | 11 | The following platform families are supported: 12 | 13 | * Debian 14 | * Arch 15 | * RHEL 16 | * Fedora 17 | * Mac OS X (10.6.0+) 18 | * Windows 19 | 20 | ## Cookbooks: 21 | 22 | * runit (for `git::server`) 23 | * build-essential (for `git::source`) 24 | * dmg (for OS X installation) 25 | * yum (for RHEL 5 installation) 26 | 27 | Recipes 28 | ======= 29 | 30 | ## default 31 | 32 | Installs base git packages based on platform. 33 | 34 | ## server 35 | 36 | Sets up a git daemon to provide a server. 37 | 38 | ## source 39 | 40 | Installs git from source. 41 | 42 | Usage 43 | ===== 44 | 45 | This cookbook primarily installs git core packages. It can also be 46 | used to serve git repositories. 47 | 48 | include_recipe "git::server" 49 | 50 | This creates the directory /srv/git and starts a git daemon, exporting 51 | all repositories found. Repositories need to be added manually, but 52 | will be available once they are created. 53 | 54 | License and Author 55 | ================== 56 | 57 | - Author:: Joshua Timberman () 58 | - Copyright:: 2009-2012, Opscode, Inc. 59 | 60 | Licensed under the Apache License, Version 2.0 (the "License"); 61 | you may not use this file except in compliance with the License. 62 | You may obtain a copy of the License at 63 | 64 | http://www.apache.org/licenses/LICENSE-2.0 65 | 66 | Unless required by applicable law or agreed to in writing, software 67 | distributed under the License is distributed on an "AS IS" BASIS, 68 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 69 | See the License for the specific language governing permissions and 70 | limitations under the License. 71 | -------------------------------------------------------------------------------- /cookbooks/git/attributes/default.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Author:: Jamie Winsor () 3 | # Cookbook Name:: git 4 | # Attributes:: default 5 | # 6 | # Copyright 2008-2012, Opscode, Inc. 7 | # 8 | # Licensed under the Apache License, Version 2.0 (the "License"); 9 | # you may not use this file except in compliance with the License. 10 | # You may obtain a copy of the License at 11 | # 12 | # http://www.apache.org/licenses/LICENSE-2.0 13 | # 14 | # Unless required by applicable law or agreed to in writing, software 15 | # distributed under the License is distributed on an "AS IS" BASIS, 16 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | # See the License for the specific language governing permissions and 18 | # limitations under the License. 19 | 20 | case node['platform_family'] 21 | when 'windows' 22 | default['git']['version'] = "1.7.9-preview20120201" 23 | default['git']['url'] = "http://msysgit.googlecode.com/files/Git-#{node['git']['version']}.exe" 24 | default['git']['checksum'] = "0627394709375140d1e54e923983d259a60f9d8e" 25 | when "mac_os_x" 26 | default['git']['osx_dmg']['app_name'] = "git-1.7.9.4-intel-universal-snow-leopard" 27 | default['git']['osx_dmg']['volumes_dir'] = "Git 1.7.9.4 Snow Leopard Intel Universal" 28 | default['git']['osx_dmg']['package_id'] = "GitOSX.Installer.git1794.git.pkg" 29 | default['git']['osx_dmg']['url'] = "http://git-osx-installer.googlecode.com/files/git-1.7.9.4-intel-universal-snow-leopard.dmg" 30 | default['git']['osx_dmg']['checksum'] = "661c3fcf765572d3978df17c7636d59e" 31 | else 32 | default['git']['prefix'] = "/usr/local" 33 | default['git']['version'] = "1.7.11.4" 34 | default['git']['url'] = "https://github.com/git/git/tarball/v#{node['git']['version']}" 35 | default['git']['checksum'] = "7a26d9bd0fd3384374bdc1afaae829f406bc123126817d994a460c49a3260ecc" 36 | end -------------------------------------------------------------------------------- /cookbooks/git/metadata.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "git", 3 | "description": "Installs git and/or sets up a Git server daemon", 4 | "long_description": "Description\n===========\n\nInstalls git and optionally sets up a git server as a daemon under runit.\n\nRequirements\n============\n\n## Platform:\n\nThe following platform families are supported:\n\n* Debian\n* Arch\n* RHEL\n* Fedora\n* Mac OS X (10.6.0+)\n* Windows\n\n## Cookbooks:\n\n* runit (for `git::server`)\n* build-essential (for `git::source`)\n* dmg (for OS X installation)\n* yum (for RHEL 5 installation)\n\nRecipes\n=======\n\n## default\n\nInstalls base git packages based on platform.\n\n## server\n\nSets up a git daemon to provide a server.\n\n## source\n\nInstalls git from source.\n\nUsage\n=====\n\nThis cookbook primarily installs git core packages. It can also be\nused to serve git repositories.\n\n include_recipe \"git::server\"\n\nThis creates the directory /srv/git and starts a git daemon, exporting\nall repositories found. Repositories need to be added manually, but\nwill be available once they are created.\n\nLicense and Author\n==================\n\n- Author:: Joshua Timberman ()\n- Copyright:: 2009-2012, Opscode, Inc.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n", 5 | "maintainer": "Opscode, Inc.", 6 | "maintainer_email": "cookbooks@opscode.com", 7 | "license": "Apache 2.0", 8 | "platforms": { 9 | "amazon": ">= 0.0.0", 10 | "arch": ">= 0.0.0", 11 | "centos": ">= 0.0.0", 12 | "debian": ">= 0.0.0", 13 | "fedora": ">= 0.0.0", 14 | "redhat": ">= 0.0.0", 15 | "scientific": ">= 0.0.0", 16 | "oracle": ">= 0.0.0", 17 | "ubuntu": ">= 0.0.0", 18 | "windows": ">= 0.0.0", 19 | "mac_os_x": ">= 10.6.0" 20 | }, 21 | "dependencies": { 22 | "build-essential": ">= 0.0.0", 23 | "dmg": ">= 0.0.0", 24 | "runit": ">= 0.0.0", 25 | "yum": ">= 0.0.0" 26 | }, 27 | "recommendations": { 28 | }, 29 | "suggestions": { 30 | }, 31 | "conflicting": { 32 | }, 33 | "providing": { 34 | }, 35 | "replacing": { 36 | }, 37 | "attributes": { 38 | }, 39 | "groupings": { 40 | }, 41 | "recipes": { 42 | "git": "Installs git", 43 | "git::server": "Sets up a runit_service for git daemon", 44 | "git::source": "Installs git from source" 45 | }, 46 | "version": "2.0.0" 47 | } -------------------------------------------------------------------------------- /cookbooks/git/metadata.rb: -------------------------------------------------------------------------------- 1 | name "git" 2 | maintainer "Opscode, Inc." 3 | maintainer_email "cookbooks@opscode.com" 4 | license "Apache 2.0" 5 | description "Installs git and/or sets up a Git server daemon" 6 | long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) 7 | version "2.0.0" 8 | recipe "git", "Installs git" 9 | recipe "git::server", "Sets up a runit_service for git daemon" 10 | recipe "git::source", "Installs git from source" 11 | 12 | %w{ amazon arch centos debian fedora redhat scientific oracle amazon ubuntu windows }.each do |os| 13 | supports os 14 | end 15 | 16 | supports "mac_os_x", ">= 10.6.0" 17 | 18 | %w{ build-essential dmg runit yum }.each do |cb| 19 | depends cb 20 | end 21 | -------------------------------------------------------------------------------- /cookbooks/git/recipes/default.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: git 3 | # Recipe:: default 4 | # 5 | # Copyright 2008-2009, Opscode, Inc. 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | 19 | case node['platform_family'] 20 | when "debian" 21 | package "git-core" 22 | when "rhel","fedora" 23 | case node['platform_version'].to_i 24 | when 5 25 | include_recipe "yum::epel" 26 | end 27 | package "git" 28 | when "windows" 29 | windows_package "git" do 30 | source node['git']['url'] 31 | checksum node['git']['checksum'] 32 | action :install 33 | not_if { File.exists? 'C:\Program Files (x86)\Git\bin\git.exe' } 34 | end 35 | when "mac_os_x" 36 | dmg_package "GitOSX-Installer" do 37 | app node['git']['osx_dmg']['app_name'] 38 | package_id node['git']['osx_dmg']['package_id'] 39 | volumes_dir node['git']['osx_dmg']['volumes_dir'] 40 | source node['git']['osx_dmg']['url'] 41 | checksum node['git']['osx_dmg']['checksum'] 42 | type "pkg" 43 | action :install 44 | end 45 | else 46 | package "git" 47 | end 48 | -------------------------------------------------------------------------------- /cookbooks/git/recipes/server.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: git 3 | # Recipe:: server 4 | # 5 | # Copyright 2009, Opscode, Inc. 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | 19 | include_recipe "git" 20 | 21 | directory "/srv/git" do 22 | owner "root" 23 | group "root" 24 | mode 00755 25 | end 26 | 27 | case node['platform_family'] 28 | when "debian" 29 | include_recipe "runit" 30 | runit_service "git-daemon" 31 | else 32 | log "Platform requires setting up a git daemon service script." 33 | log "Hint: /usr/bin/git daemon --export-all --user=nobody --group=daemon --base-path=/srv/git" 34 | end 35 | -------------------------------------------------------------------------------- /cookbooks/git/recipes/source.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: git 3 | # Recipe:: source 4 | # 5 | # Copyright 2012, Brian Flad, Fletcher Nichol 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | 19 | include_recipe "build-essential" 20 | 21 | pkgs = value_for_platform_family( 22 | ["rhel"] => %w{ expat-devel gettext-devel libcurl-devel openssl-devel perl-ExtUtils-MakeMaker zlib-devel } 23 | ) 24 | 25 | pkgs.each do |pkg| 26 | package pkg 27 | end 28 | 29 | remote_file "#{Chef::Config['file_cache_path']}/git-#{node['git']['version']}.tar.gz" do 30 | source node['git']['url'] 31 | checksum node['git']['checksum'] 32 | mode 00644 33 | not_if "test -f #{Chef::Config['file_cache_path']}/git-#{node['git']['version']}.tar.gz" 34 | end 35 | 36 | execute "Extracting and Building Git #{node['git']['version']} from Source" do 37 | cwd Chef::Config['file_cache_path'] 38 | command <<-COMMAND 39 | (mkdir git-#{node['git']['version']} && tar -zxf git-#{node['git']['version']}.tar.gz -C git-#{node['git']['version']} --strip-components 1) 40 | (cd git-#{node['git']['version']} && make prefix=#{node['git']['prefix']} install) 41 | COMMAND 42 | creates "node['git']['prefix']}/bin/git" 43 | not_if "git --version | grep #{node['git']['version']}" 44 | end 45 | -------------------------------------------------------------------------------- /cookbooks/git/templates/default/sv-git-daemon-log-run.erb: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | exec svlogd -tt ./main 3 | -------------------------------------------------------------------------------- /cookbooks/git/templates/default/sv-git-daemon-run.erb: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | exec 2>&1 3 | exec /usr/bin/git daemon --export-all --user=nobody --group=daemon --base-path=/srv/git /srv/git 4 | -------------------------------------------------------------------------------- /cookbooks/heroku-toolbelt/recipes/default.rb: -------------------------------------------------------------------------------- 1 | apt_repository "heroku-toolbelt" do 2 | uri "http://toolbelt.heroku.com/ubuntu" 3 | components ["./"] 4 | end 5 | 6 | script "setup-heroku-toolbelt" do 7 | interpreter "bash" 8 | user "root" 9 | code <<-EOF 10 | wget -O- https://toolbelt.heroku.com/apt/release.key | apt-key add - 11 | apt-get update 12 | EOF 13 | 14 | not_if "which heroku" 15 | end 16 | 17 | package "heroku-toolbelt" 18 | -------------------------------------------------------------------------------- /cookbooks/nodejs/.gitignore: -------------------------------------------------------------------------------- 1 | Gemfile.lock 2 | Berksfile.lock 3 | tmp/ 4 | .kitchen 5 | .kitchen.local.yml 6 | -------------------------------------------------------------------------------- /cookbooks/nodejs/.kitchen.yml: -------------------------------------------------------------------------------- 1 | --- 2 | driver_plugin: vagrant 3 | driver_config: 4 | customize: 5 | memory: 512 6 | cpus: 4 7 | platforms: 8 | - name: ubuntu-12.04 9 | driver_config: 10 | box: opscode-ubuntu-12.04 11 | box_url: https://opscode-vm.s3.amazonaws.com/vagrant/boxes/opscode-ubuntu-12.04.box 12 | run_list: 13 | - recipe[apt] 14 | - name: ubuntu-10.04 15 | driver_config: 16 | box: opscode-ubuntu-10.04 17 | box_url: https://opscode-vm.s3.amazonaws.com/vagrant/boxes/opscode-ubuntu-10.04.box 18 | run_list: 19 | - recipe[apt] 20 | - name: centos-6.3 21 | driver_config: 22 | box: opscode-centos-6.3 23 | box_url: https://opscode-vm.s3.amazonaws.com/vagrant/boxes/opscode-centos-6.3.box 24 | - name: centos-5.8 25 | driver_config: 26 | box: opscode-centos-5.8 27 | box_url: https://opscode-vm.s3.amazonaws.com/vagrant/boxes/opscode-centos-5.8.box 28 | suites: 29 | - name: package 30 | run_list: 31 | - recipe[nodejs] 32 | attributes: 33 | nodejs: 34 | install_method: package 35 | - name: source 36 | run_list: 37 | - recipe[nodejs] 38 | - recipe[nodejs::npm] 39 | attributes: 40 | nodejs: 41 | install_method: source 42 | -------------------------------------------------------------------------------- /cookbooks/nodejs/.travis.yml: -------------------------------------------------------------------------------- 1 | language: ruby 2 | gemfile: 3 | - test/support/Gemfile 4 | rvm: 5 | - 1.9.3 6 | script: bundle exec rake foodcritic 7 | -------------------------------------------------------------------------------- /cookbooks/nodejs/Berksfile: -------------------------------------------------------------------------------- 1 | cookbook 'apt', '~> 1.7.0' 2 | cookbook 'build-essential' 3 | cookbook 'nodejs', :path => '.' 4 | -------------------------------------------------------------------------------- /cookbooks/nodejs/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## v1.1.1: 2 | * update default versions to the latest: node - v0.10.0 and npm - v1.2.14 3 | * `make_thread` is now a real attribute - ([@ChrisLundquist][]) 4 | 5 | 6 | ## v1.1.0: 7 | * rewrite the package install; remove rpm support since there are no longer any packages available anywhere 8 | * add support to install `legacy_packages` from ubuntu repo as well as the latest 0.10.x branch (this is default). 9 | 10 | ## v1.0.4: 11 | * add support for binary installation method ([@JulesAU][]) 12 | 13 | ## v1.0.3: 14 | - unreleased 15 | 16 | ## v1.0.2: 17 | * add smartos support for package install ([@sax][]) 18 | * support to compile with all processors available (default 2 if unknown) - ([@ChrisLundquist][]) 19 | * moved to `platform_family` syntax 20 | * ensure npm recipe honours the 'source' or 'package' setting - ([@markbirbeck][]) 21 | * updated the default versions to the latest stable node/npm 22 | 23 | ## v1.0.1: 24 | 25 | * fixed bug that prevented overwritting the node/npm versions (moved the `src_url`s as local variables instead of attributes) - ([@johannesbecker][]) 26 | * updated the default versions to the latest node/npm 27 | 28 | ## v1.0.0: 29 | 30 | * added packages installation support ([@smith][]) 31 | 32 | [@JulesAU]: https://github.com/JulesAU 33 | [@sax]: https://github.com/sax 34 | [@ChrisLundquist]: https://github.com/ChrisLundquist 35 | [@markbirbeck]: https://github.com/markbirbeck 36 | [@johannesbecker]: https://github.com/johannesbecker 37 | [@smith]: https://github.com/smith 38 | -------------------------------------------------------------------------------- /cookbooks/nodejs/Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | 3 | gem 'foodcritic' 4 | gem 'berkshelf' 5 | gem 'thor-foodcritic' 6 | gem 'vagrant', '~> 1.0.6' 7 | 8 | group :integration do 9 | gem 'test-kitchen', :git => "git://github.com/opscode/test-kitchen.git", :branch => '1.0' 10 | gem 'kitchen-vagrant', :git => "git://github.com/opscode/kitchen-vagrant.git" 11 | 12 | # Change .kitchen.yml's driver_plugin to ec2 and populate 13 | # .kitchen.local.yml's driver_config with aws auth data 14 | gem 'kitchen-ec2', :git => "git://github.com/opscode/kitchen-ec2.git" 15 | end 16 | -------------------------------------------------------------------------------- /cookbooks/nodejs/README.md: -------------------------------------------------------------------------------- 1 | # nodejs-cookbook [![Build Status](https://secure.travis-ci.org/mdxp/nodejs-cookbook.png)](http://travis-ci.org/mdxp/nodejs-cookbook) 2 | 3 | DESCRIPTION 4 | =========== 5 | 6 | Installs Node.JS 7 | 8 | REQUIREMENTS 9 | ============ 10 | 11 | 12 | ## Platform 13 | 14 | * Tested on Debian 6 and Ubuntu 10.04 15 | * Should work fine on Centos, RHEL, etc. 16 | 17 | ## Cookbooks: 18 | 19 | * build-essential 20 | * apt 21 | 22 | Opscode cookbooks (http://github.com/opscode/cookbooks/tree/master) 23 | 24 | ATTRIBUTES 25 | ========== 26 | 27 | * nodejs['install_method'] = source or package 28 | * nodejs['version'] - release version of node to install 29 | * nodejs['src_url'] - download location for node source tarball 30 | * nodejs['dir'] - location where node will be installed, default /usr/local 31 | * nodejs['npm'] - version of npm to install 32 | * nodejs['npm_src_url'] - download location for npm source tarball 33 | 34 | USAGE 35 | ===== 36 | 37 | Include the nodejs recipe to install node on your system based on the default installation method: 38 | 39 | * include_recipe "nodejs" 40 | 41 | Include the install_from_source recipe to install node from sources: 42 | 43 | * include_recipe "nodejs::install_from_source" 44 | 45 | Include the install_from_package recipe to install node from packages: 46 | Note that only apt (Ubuntu, Debian) appears to have up to date packages available. 47 | Centos, RHEL, etc are non-functional. (Try install_from_binary for those) 48 | 49 | * include_recipe "nodejs::install_from_package" 50 | 51 | Include the install_from_binary recipe to install node from official prebuilt binaries: 52 | (Currently Linux x86, x86_64 only) 53 | 54 | * include_recipe "nodejs::install_from_binary" 55 | 56 | Include the npm recipe to install npm: 57 | 58 | * include_recipe "nodejs::npm" 59 | 60 | LICENSE and AUTHOR 61 | ================== 62 | 63 | Author:: Marius Ducea (marius@promethost.com) 64 | Author:: Nathan L Smith (nlloyds@gmail.com) 65 | 66 | Copyright:: 2010-2012, Promet Solutions 67 | Copyright:: 2012, Cramer Development, Inc. 68 | 69 | Licensed under the Apache License, Version 2.0 (the "License"); 70 | you may not use this file except in compliance with the License. 71 | You may obtain a copy of the License at 72 | 73 | http://www.apache.org/licenses/LICENSE-2.0 74 | 75 | Unless required by applicable law or agreed to in writing, software 76 | distributed under the License is distributed on an "AS IS" BASIS, 77 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 78 | See the License for the specific language governing permissions and 79 | limitations under the License. 80 | -------------------------------------------------------------------------------- /cookbooks/nodejs/Rakefile: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env rake 2 | 3 | @cookbook = "nodejs" 4 | 5 | desc "Runs foodcritic linter" 6 | task :foodcritic do 7 | if Gem::Version.new("1.9.2") <= Gem::Version.new(RUBY_VERSION.dup) 8 | sandbox = File.join(File.dirname(__FILE__), %w{tmp foodcritic}, @cookbook) 9 | prepare_foodcritic_sandbox(sandbox) 10 | 11 | sh "foodcritic --epic-fail any #{File.dirname(sandbox)}" 12 | else 13 | puts "WARN: foodcritic run is skipped as Ruby #{RUBY_VERSION} is < 1.9.2." 14 | end 15 | end 16 | 17 | task :default => 'foodcritic' 18 | 19 | private 20 | 21 | def prepare_foodcritic_sandbox(sandbox) 22 | files = %w{*.md *.rb attributes definitions files providers 23 | recipes resources templates} 24 | 25 | rm_rf sandbox 26 | mkdir_p sandbox 27 | cp_r Dir.glob("{#{files.join(',')}}"), sandbox 28 | puts "\n\n" 29 | end 30 | 31 | begin 32 | require 'jamie/rake_tasks' 33 | Jamie::RakeTasks.new 34 | rescue LoadError 35 | puts ">>>>> Jamie gem not loaded, omitting tasks" unless ENV['CI'] 36 | end 37 | -------------------------------------------------------------------------------- /cookbooks/nodejs/Vagrantfile: -------------------------------------------------------------------------------- 1 | # Automatically install and mount cookbooks from Berksfile 2 | 3 | require 'kitchen/vagrant' 4 | require 'berkshelf/vagrant' 5 | 6 | Vagrant::Config.run do |config| 7 | Kitchen::Vagrant.define_vms(config) 8 | end 9 | -------------------------------------------------------------------------------- /cookbooks/nodejs/attributes/default.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: nodejs 3 | # Attributes:: nodejs 4 | # 5 | # Copyright 2010-2012, Promet Solutions 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # 19 | 20 | default['nodejs']['install_method'] = 'source' 21 | default['nodejs']['version'] = '0.10.0' 22 | default['nodejs']['checksum'] = '1624dc37866ebfb5431e3393e6b049cf238cac8ad4d20c6d567263b1259177ab' 23 | default['nodejs']['checksum_linux_x64'] = 'eaedcf7e3e443cf2fa35f834ed62b334885dc20fcbc7a32ea34e8e85f81b2533' 24 | default['nodejs']['checksum_linux_x86'] = 'ea4508e4df3c74d964a02d5740374b54f8192af19db518163c77ee7ff318daa7' 25 | default['nodejs']['dir'] = '/usr/local' 26 | default['nodejs']['npm'] = '1.2.14' 27 | default['nodejs']['src_url'] = "http://nodejs.org/dist" 28 | default['nodejs']['make_threads'] = node['cpu'] ? node['cpu']['total'].to_i : 2 29 | 30 | # Set this to true to install the legacy packages (0.8.x) from ubuntu/debian repositories; default is false (using the latest stable 0.10.x) 31 | default['nodejs']['legacy_packages'] = false 32 | -------------------------------------------------------------------------------- /cookbooks/nodejs/metadata.rb: -------------------------------------------------------------------------------- 1 | maintainer "Promet Solutions" 2 | maintainer_email "marius@promethost.com" 3 | license "Apache 2.0" 4 | description "Installs/Configures nodejs" 5 | long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) 6 | version "1.1.1" 7 | name "nodejs" 8 | provides "nodejs" 9 | 10 | recipe "nodejs", "Installs Node.JS based on the default installation method" 11 | recipe "nodejs::install_from_source", "Installs Node.JS from source" 12 | recipe "nodejs::install_from_binary", "Installs Node.JS from official binaries" 13 | recipe "nodejs::install_from_package", "Installs Node.JS from packages" 14 | recipe "nodejs::npm", "Installs npm from source - a package manager for node" 15 | 16 | depends "build-essential" 17 | depends "apt" 18 | 19 | %w{ debian ubuntu centos redhat smartos }.each do |os| 20 | supports os 21 | end 22 | -------------------------------------------------------------------------------- /cookbooks/nodejs/recipes/default.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Author:: Marius Ducea (marius@promethost.com) 3 | # Cookbook Name:: nodejs 4 | # Recipe:: default 5 | # 6 | # Copyright 2010-2012, Promet Solutions 7 | # 8 | # Licensed under the Apache License, Version 2.0 (the "License"); 9 | # you may not use this file except in compliance with the License. 10 | # You may obtain a copy of the License at 11 | # 12 | # http://www.apache.org/licenses/LICENSE-2.0 13 | # 14 | # Unless required by applicable law or agreed to in writing, software 15 | # distributed under the License is distributed on an "AS IS" BASIS, 16 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | # See the License for the specific language governing permissions and 18 | # limitations under the License. 19 | # 20 | case node['platform_family'] 21 | when "debian" 22 | include_recipe "apt" 23 | end 24 | 25 | include_recipe "nodejs::install_from_#{node['nodejs']['install_method']}" 26 | -------------------------------------------------------------------------------- /cookbooks/nodejs/recipes/install_from_binary.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Author:: Julian Wilde (jules@jules.com.au) 3 | # Cookbook Name:: nodejs 4 | # Recipe:: install_from_binary 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | 19 | 20 | # Shamelessly borrowed from http://docs.opscode.com/dsl_recipe_method_platform.html 21 | # Surely there's a more canonical way to get arch? 22 | arch = node['kernel']['machine'] =~ /x86_64/ ? "x64" : "x86" 23 | distro_suffix = "-linux-#{arch}" 24 | 25 | # package_stub is for example: "node-v0.8.20-linux-x64" 26 | package_stub = "node-v#{node['nodejs']['version']}#{distro_suffix}" 27 | nodejs_tar = "#{package_stub}.tar.gz" 28 | expected_checksum = node['nodejs']["checksum_linux_#{arch}"] 29 | 30 | nodejs_tar_path = nodejs_tar 31 | if node['nodejs']['version'].split('.')[1].to_i >= 5 32 | nodejs_tar_path = "v#{node['nodejs']['version']}/#{nodejs_tar_path}" 33 | end 34 | 35 | # Let the user override the source url in the attributes 36 | nodejs_bin_url = "#{node['nodejs']['src_url']}/#{nodejs_tar_path}" 37 | 38 | # Download it: 39 | remote_file "/usr/local/src/#{nodejs_tar}" do 40 | source nodejs_bin_url 41 | checksum expected_checksum 42 | mode 0644 43 | action :create_if_missing 44 | end 45 | 46 | # Where we will install the binaries and libs to (normally /usr/local): 47 | destination_dir = node['nodejs']['dir'] 48 | 49 | install_not_needed = File.exists?("#{node['nodejs']['dir']}/bin/node") && `#{node['nodejs']['dir']}/bin/node --version`.chomp == "v#{node['nodejs']['version']}" 50 | 51 | # Verify the SHA sum of the downloaded file: 52 | ruby_block "verify_sha_sum" do 53 | block do 54 | require 'digest/sha1' 55 | calculated_sha256_hash = Digest::SHA256.file("/usr/local/src/#{nodejs_tar}") 56 | if calculated_sha256_hash != expected_checksum 57 | raise "SHA256 Hash of #{nodejs_tar} did not match! Expected #{expected_checksum} found #{calculated_sha256_hash}" 58 | end 59 | end 60 | not_if { install_not_needed } 61 | end 62 | 63 | # One hopes that we can trust the contents of the node tarball not to overwrite anything it shouldn't! 64 | execute "install package to system" do 65 | command <<-EOF 66 | tar xf /usr/local/src/#{nodejs_tar} \ 67 | --strip-components=1 --no-same-owner \ 68 | -C #{destination_dir} \ 69 | #{package_stub}/bin \ 70 | #{package_stub}/include \ 71 | #{package_stub}/lib \ 72 | #{package_stub}/share 73 | EOF 74 | 75 | not_if { install_not_needed } 76 | end 77 | -------------------------------------------------------------------------------- /cookbooks/nodejs/recipes/install_from_package.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Author:: Nathan L Smith (nlloyds@gmail.com) 3 | # Author:: Marius Ducea (marius@promethost.com) 4 | # Cookbook Name:: nodejs 5 | # Recipe:: package 6 | # 7 | # Copyright 2012, Cramer Development, Inc. 8 | # Copyright 2013, Opscale 9 | # 10 | # Licensed under the Apache License, Version 2.0 (the "License"); 11 | # you may not use this file except in compliance with the License. 12 | # You may obtain a copy of the License at 13 | # 14 | # http://www.apache.org/licenses/LICENSE-2.0 15 | # 16 | # Unless required by applicable law or agreed to in writing, software 17 | # distributed under the License is distributed on an "AS IS" BASIS, 18 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | # See the License for the specific language governing permissions and 20 | # limitations under the License. 21 | # 22 | 23 | case node['platform_family'] 24 | when 'debian' 25 | if node['nodejs']['legacy_packages'] == true 26 | repo = 'http://ppa.launchpad.net/chris-lea/node.js-legacy/ubuntu' 27 | packages = %w{ nodejs npm } 28 | else 29 | repo = 'http://ppa.launchpad.net/chris-lea/node.js/ubuntu' 30 | packages = %w{ nodejs } 31 | end 32 | apt_repository 'node.js' do 33 | uri repo 34 | distribution node['lsb']['codename'] 35 | components ['main'] 36 | keyserver "keyserver.ubuntu.com" 37 | key "C7917B12" 38 | action :add 39 | end 40 | when 'smartos' 41 | packages = %w{ nodejs } 42 | else 43 | Chef::Log.error "There are no nodejs packages for this platform; please use the source or binary method to install node" 44 | return 45 | end 46 | 47 | packages.each do |node_pkg| 48 | package node_pkg 49 | end 50 | -------------------------------------------------------------------------------- /cookbooks/nodejs/recipes/install_from_source.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Author:: Marius Ducea (marius@promethost.com) 3 | # Cookbook Name:: nodejs 4 | # Recipe:: source 5 | # 6 | # Copyright 2010-2012, Promet Solutions 7 | # 8 | # Licensed under the Apache License, Version 2.0 (the "License"); 9 | # you may not use this file except in compliance with the License. 10 | # You may obtain a copy of the License at 11 | # 12 | # http://www.apache.org/licenses/LICENSE-2.0 13 | # 14 | # Unless required by applicable law or agreed to in writing, software 15 | # distributed under the License is distributed on an "AS IS" BASIS, 16 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | # See the License for the specific language governing permissions and 18 | # limitations under the License. 19 | # 20 | 21 | include_recipe "build-essential" 22 | 23 | case node['platform_family'] 24 | when 'rhel','fedora' 25 | package "openssl-devel" 26 | when 'debian' 27 | package "libssl-dev" 28 | end 29 | 30 | nodejs_tar = "node-v#{node['nodejs']['version']}.tar.gz" 31 | nodejs_tar_path = nodejs_tar 32 | if node['nodejs']['version'].split('.')[1].to_i >= 5 33 | nodejs_tar_path = "v#{node['nodejs']['version']}/#{nodejs_tar_path}" 34 | end 35 | # Let the user override the source url in the attributes 36 | nodejs_src_url = "#{node['nodejs']['src_url']}/#{nodejs_tar_path}" 37 | 38 | remote_file "/usr/local/src/#{nodejs_tar}" do 39 | source nodejs_src_url 40 | checksum node['nodejs']['checksum'] 41 | mode 0644 42 | action :create_if_missing 43 | end 44 | 45 | # --no-same-owner required overcome "Cannot change ownership" bug 46 | # on NFS-mounted filesystem 47 | execute "tar --no-same-owner -zxf #{nodejs_tar}" do 48 | cwd "/usr/local/src" 49 | creates "/usr/local/src/node-v#{node['nodejs']['version']}" 50 | end 51 | 52 | bash "compile node.js (on #{node['nodejs']['make_threads']} cpu)" do 53 | # OSX doesn't have the attribute so arbitrarily default 2 54 | cwd "/usr/local/src/node-v#{node['nodejs']['version']}" 55 | code <<-EOH 56 | PATH="/usr/local/bin:$PATH" 57 | ./configure --prefix=#{node['nodejs']['dir']} && \ 58 | make -j #{node['nodejs']['make_threads']} 59 | EOH 60 | creates "/usr/local/src/node-v#{node['nodejs']['version']}/node" 61 | end 62 | 63 | execute "nodejs make install" do 64 | environment({"PATH" => "/usr/local/bin:/usr/bin:/bin:$PATH"}) 65 | command "make install" 66 | cwd "/usr/local/src/node-v#{node['nodejs']['version']}" 67 | not_if {File.exists?("#{node['nodejs']['dir']}/bin/node") && `#{node['nodejs']['dir']}/bin/node --version`.chomp == "v#{node['nodejs']['version']}" } 68 | end 69 | -------------------------------------------------------------------------------- /cookbooks/nodejs/recipes/npm.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Author:: Marius Ducea (marius@promethost.com) 3 | # Cookbook Name:: nodejs 4 | # Recipe:: npm 5 | # 6 | # Copyright 2010-2012, Promet Solutions 7 | # 8 | # Licensed under the Apache License, Version 2.0 (the "License"); 9 | # you may not use this file except in compliance with the License. 10 | # You may obtain a copy of the License at 11 | # 12 | # http://www.apache.org/licenses/LICENSE-2.0 13 | # 14 | # Unless required by applicable law or agreed to in writing, software 15 | # distributed under the License is distributed on an "AS IS" BASIS, 16 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | # See the License for the specific language governing permissions and 18 | # limitations under the License. 19 | # 20 | 21 | include_recipe "nodejs" 22 | 23 | package "curl" 24 | 25 | npm_src_url = "http://registry.npmjs.org/npm/-/npm-#{node['nodejs']['npm']}.tgz" 26 | 27 | bash "install npm - package manager for node" do 28 | cwd "/usr/local/src" 29 | user "root" 30 | code <<-EOH 31 | mkdir -p npm-v#{node['nodejs']['npm']} && \ 32 | cd npm-v#{node['nodejs']['npm']} 33 | curl -L #{npm_src_url} | tar xzf - --strip-components=1 && \ 34 | make uninstall dev 35 | EOH 36 | not_if "#{node['nodejs']['dir']}/bin/npm -v 2>&1 | grep '#{node['nodejs']['npm']}'" 37 | end 38 | 39 | -------------------------------------------------------------------------------- /cookbooks/nodejs/test/integration/package/bats/package.bats: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bats 2 | 3 | @test "node should be in the path" { 4 | [ "$(command -v node)" ] 5 | } 6 | -------------------------------------------------------------------------------- /cookbooks/nodejs/test/integration/source/bats/source.bats: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bats 2 | 3 | @test "node should be in the path" { 4 | [ "$(command -v node)" ] 5 | } 6 | -------------------------------------------------------------------------------- /cookbooks/nodejs/test/support/Gemfile: -------------------------------------------------------------------------------- 1 | source "https://rubygems.org" 2 | 3 | gem 'rake' 4 | gem 'foodcritic' 5 | 6 | -------------------------------------------------------------------------------- /cookbooks/openruko/attributes/default.rb: -------------------------------------------------------------------------------- 1 | # Default repos to clone openruko parts 2 | 3 | default['openruko']['repositories']['apiserver'] = "https://github.com/openruko/apiserver.git" 4 | default['openruko']['repositories']['client'] = "https://github.com/openruko/client.git" 5 | default['openruko']['repositories']['codonhooks'] = "https://github.com/openruko/codonhooks.git" 6 | default['openruko']['repositories']['dynohost'] = "https://github.com/openruko/dynohost.git" 7 | default['openruko']['repositories']['gitmouth'] = "https://github.com/openruko/gitmouth.git" 8 | default['openruko']['repositories']['httprouting'] = "https://github.com/openruko/httprouting.git" 9 | default['openruko']['repositories']['logplex'] = "https://github.com/openruko/logplex.git" 10 | default['openruko']['repositories']['rukorun'] = "https://github.com/openruko/rukorun.git" 11 | default['openruko']['repositories']['integration-tests'] = "https://github.com/openruko/integration-tests.git" -------------------------------------------------------------------------------- /cookbooks/openruko/recipes/apiserver.rb: -------------------------------------------------------------------------------- 1 | package "expect" 2 | package "socat" 3 | package "postgresql-server-dev-9.1" 4 | package "postgresql-contrib-9.1" 5 | 6 | bash "setup-ruby" do 7 | code <<-EOF 8 | sudo update-alternatives --set ruby /usr/bin/ruby1.9.1 9 | sudo update-alternatives --set gem /usr/bin/gem1.9.1 10 | EOF 11 | end 12 | 13 | git "#{node['openruko']['home']}/apiserver" do 14 | user node['user'] 15 | group node['group'] 16 | repository node['openruko']['repositories']['apiserver'] 17 | action :checkout 18 | revision node["versions"]["apiserver"] 19 | end 20 | 21 | bash "setup-apiserver" do 22 | user node['user'] 23 | group node['group'] 24 | cwd "#{node['openruko']['home']}/apiserver" 25 | environment Hash['HOME' => node['home']] 26 | 27 | code <<-EOF 28 | set -e 29 | make init 30 | echo -e '\n\n\n\n\n\n\n\n' | make certs 31 | echo -e '\ny' | ssh-keygen -t rsa -N '' 32 | EOF 33 | end 34 | 35 | bash "setup-postgres-user" do 36 | user "postgres" 37 | code <<-EOF 38 | psql <<< "CREATE ROLE #{node['user']} ENCRYPTED PASSWORD '#{node['postgresql']['password'][node['user']]}' SUPERUSER CREATEDB CREATEROLE INHERIT LOGIN;" 39 | EOF 40 | end 41 | 42 | bash "setup-postgres-database" do 43 | user node['user'] 44 | group node['group'] 45 | code <<-EOF 46 | psql postgres <<< "CREATE DATABASE openruko;" 47 | EOF 48 | end 49 | 50 | template "/etc/init/openruko-apiserver.conf" do 51 | source "upstart-openruko-apiserver.conf.erb" 52 | owner "root" 53 | group "root" 54 | mode 0644 55 | end 56 | 57 | template "/etc/profile.d/openruko-apiserver.sh" do 58 | source "profile-openruko-apiserver.erb" 59 | owner "root" 60 | group "root" 61 | mode 0755 62 | end 63 | 64 | service "openruko-apiserver" do 65 | provider Chef::Provider::Service::Upstart 66 | supports :restart => true, :start => true, :stop => true 67 | action [:enable, :start] 68 | end 69 | -------------------------------------------------------------------------------- /cookbooks/openruko/recipes/client.rb: -------------------------------------------------------------------------------- 1 | git "#{node['openruko']['home']}/client" do 2 | user node['user'] 3 | group node['group'] 4 | repository node['openruko']['repositories']['client'] 5 | action :checkout 6 | revision node["versions"]["client"] 7 | end 8 | 9 | 10 | template "#{node['home']}/.ssh/config" do 11 | source "ssh-config.erb" 12 | owner "root" 13 | group "root" 14 | mode 0644 15 | end 16 | -------------------------------------------------------------------------------- /cookbooks/openruko/recipes/default.rb: -------------------------------------------------------------------------------- 1 | include_recipe "apt" 2 | include_recipe "build-essential" 3 | include_recipe "git" 4 | include_recipe "nodejs::install_from_package" 5 | 6 | package "libssl0.9.8" 7 | package "uuid-dev" 8 | package "curl" 9 | package "wget" 10 | package "ruby1.9.1" 11 | 12 | 13 | bash "setup-local-domains" do 14 | user "root" 15 | code <<-EOF 16 | echo "#{node['openruko']['apiserver_ip']} #{node['openruko']['apiserver_host']}" >> /etc/hosts 17 | echo "#{node['openruko']['apiserver_ip']} openruko.#{node['openruko']['apiserver_host']} # fakes3 host" >> /etc/hosts 18 | EOF 19 | 20 | not_if "grep '#{node['openruko']['apiserver_host']}' /etc/hosts" 21 | end 22 | 23 | bash "setup-apiserver" do 24 | code <<-EOF 25 | sudo su - -c "echo \\"rukosan ALL=(ALL) NOPASSWD: ALL\\" >> /etc/sudoers" 26 | EOF 27 | end 28 | 29 | group node['group'] do 30 | end 31 | 32 | user node['user'] do 33 | gid node['group'] 34 | home "/home/" + node['user'] 35 | supports :manage_home => true 36 | shell "/bin/bash" 37 | comment "Rukosan" 38 | end 39 | 40 | directory node['openruko']['home'] do 41 | owner node['user'] 42 | group node['group'] 43 | mode 0755 44 | end 45 | 46 | directory "/var/log/openruko" do 47 | owner node['user'] 48 | group node['group'] 49 | mode 0755 50 | end 51 | -------------------------------------------------------------------------------- /cookbooks/openruko/recipes/dynohost.rb: -------------------------------------------------------------------------------- 1 | # Various repos are combined here so that we can define a Dynohost as a separate server 2 | package "lxc" 3 | 4 | # Packages to run php projects 5 | package "libpq5" 6 | package "libltdl7" 7 | package "libjpeg62" 8 | 9 | # Mysql packages 10 | package "libmysqlclient-dev" 11 | 12 | ############# 13 | # Codonhooks 14 | ############# 15 | git "#{node['openruko']['home']}/codonhooks" do 16 | user node['user'] 17 | group node['group'] 18 | repository node['openruko']['repositories']['codonhooks'] 19 | action :checkout 20 | revision node["versions"]["codonhooks"] 21 | end 22 | 23 | 24 | ########## 25 | # Rukorun 26 | ########## 27 | git "#{node['openruko']['home']}/rukorun" do 28 | user node['user'] 29 | group node['group'] 30 | repository node['openruko']['repositories']['rukorun'] 31 | action :checkout 32 | revision node["versions"]["rukorun"] 33 | end 34 | 35 | bash "setup-rukorun" do 36 | user node['user'] 37 | group node['group'] 38 | cwd "#{node['openruko']['home']}/rukorun" 39 | environment Hash['HOME' => node['home']] 40 | 41 | code <<-EOF 42 | make init 43 | EOF 44 | end 45 | 46 | 47 | ########### 48 | # Dynohost 49 | ########### 50 | git "#{node['openruko']['home']}/dynohost" do 51 | user node['user'] 52 | group node['group'] 53 | repository node['openruko']['repositories']['dynohost'] 54 | action :checkout 55 | revision node["versions"]["dynohost"] 56 | end 57 | 58 | bash "setup-dynohost" do 59 | user node['user'] 60 | group node['group'] 61 | cwd "#{node['openruko']['home']}/dynohost" 62 | environment Hash['HOME' => node['home']] 63 | 64 | code <<-EOF 65 | set -e 66 | make init 67 | echo -e '\n\n\n\n\n\n' | make certs 68 | EOF 69 | end 70 | 71 | template "/etc/init/openruko-dynohost.conf" do 72 | source "upstart-openruko-dynohost.conf.erb" 73 | owner "root" 74 | group "root" 75 | mode 0644 76 | end 77 | 78 | template "/etc/profile.d/openruko-dynohost.sh" do 79 | source "profile-openruko-dynohost.erb" 80 | owner "root" 81 | group "root" 82 | mode 0755 83 | end 84 | 85 | service "openruko-dynohost" do 86 | provider Chef::Provider::Service::Upstart 87 | supports :restart => true, :start => true, :stop => true 88 | action [:enable, :start] 89 | end 90 | -------------------------------------------------------------------------------- /cookbooks/openruko/recipes/gitmouth.rb: -------------------------------------------------------------------------------- 1 | git "#{node['openruko']['home']}/gitmouth" do 2 | user node['user'] 3 | group node['group'] 4 | repository node['openruko']['repositories']['gitmouth'] 5 | action :checkout 6 | revision node["versions"]["gitmouth"] 7 | end 8 | 9 | bash "setup-gitmouth" do 10 | user node['user'] 11 | group node['group'] 12 | cwd "#{node['openruko']['home']}/gitmouth" 13 | environment Hash['HOME' => node['home']] 14 | 15 | code <<-EOF 16 | set -e 17 | if [ ! -f ./bin/activate ]; then 18 | make init 19 | fi 20 | EOF 21 | end 22 | 23 | bash "setup-gitmouth-certs" do 24 | user node['user'] 25 | group node['group'] 26 | cwd "#{node['openruko']['home']}/gitmouth" 27 | 28 | code <<-EOF 29 | rm -fr certs 30 | expect <<- EOH\nspawn make certs \nexpect "*passphrase*"\nsend -- "\r"\nexpect "*passphrase*"\nsend -- "\r"\ninteract\nEOH 31 | EOF 32 | end 33 | 34 | template "/etc/init/openruko-gitmouth.conf" do 35 | source "upstart-openruko-gitmouth.conf.erb" 36 | owner "root" 37 | group "root" 38 | mode 0644 39 | end 40 | -------------------------------------------------------------------------------- /cookbooks/openruko/recipes/httprouting.rb: -------------------------------------------------------------------------------- 1 | git "#{node['openruko']['home']}/httprouting" do 2 | user node['user'] 3 | group node['group'] 4 | repository node['openruko']['repositories']['httprouting'] 5 | action :checkout 6 | revision node["versions"]["httprouting"] 7 | end 8 | 9 | bash "setup-httprouting" do 10 | user node['user'] 11 | group node['group'] 12 | cwd "#{node['openruko']['home']}/httprouting" 13 | environment Hash['HOME' => node['home']] 14 | 15 | code <<-EOF 16 | set -e 17 | make init 18 | echo -e '\n\n\n\n\n\n\n\n' | make certs 19 | EOF 20 | end 21 | 22 | template "/etc/init/openruko-httprouting.conf" do 23 | source "upstart-openruko-httprouting.conf.erb" 24 | owner "root" 25 | group "root" 26 | mode 0644 27 | end 28 | -------------------------------------------------------------------------------- /cookbooks/openruko/recipes/integration-tests.rb: -------------------------------------------------------------------------------- 1 | git "#{node['openruko']['home']}/integration-tests" do 2 | user node['user'] 3 | group node['group'] 4 | repository node['openruko']['repositories']['integration-tests'] 5 | action :checkout 6 | revision node["versions"]["integration-tests"] 7 | end 8 | -------------------------------------------------------------------------------- /cookbooks/openruko/recipes/logplex.rb: -------------------------------------------------------------------------------- 1 | ########## 2 | # Logplex 3 | ########## 4 | git "#{node['openruko']['home']}/logplex" do 5 | user node['user'] 6 | group node['group'] 7 | repository node['openruko']['repositories']['logplex'] 8 | action :checkout 9 | revision node["versions"]["logplex"] 10 | end 11 | 12 | bash "setup-logplex" do 13 | user node['user'] 14 | group node['group'] 15 | cwd "#{node['openruko']['home']}/logplex" 16 | environment Hash['HOME' => node['home']] 17 | 18 | code <<-EOF 19 | make init 20 | EOF 21 | end 22 | 23 | template "/etc/init/openruko-logplex.conf" do 24 | source "upstart-openruko-logplex.conf.erb" 25 | owner "root" 26 | group "root" 27 | mode 0644 28 | end 29 | -------------------------------------------------------------------------------- /cookbooks/openruko/templates/default/profile-openruko-apiserver.erb: -------------------------------------------------------------------------------- 1 | export APISERVER_KEY=<%= node['openruko']['apiserver_key'] %> 2 | export PG_USER=<%= node['user'] %> 3 | export PG_PASSWORD=<%= node['postgresql']['password'][node['user']] %> 4 | export S3_KEY=<%= node['s3']['s3_key'] %> 5 | export S3_SECRET=<%= node['s3']['s3_secret'] %> 6 | export S3_BUCKET=<%= node['s3']['s3_bucket'] %> 7 | export GEM_HOME=/home/<%= node['user'] %>/.gem/ruby/1.9.1 8 | export PATH=$PATH:/home/<%= node['user'] %>/.gem/ruby/1.9.1/bin/ 9 | -------------------------------------------------------------------------------- /cookbooks/openruko/templates/default/profile-openruko-dynohost.erb: -------------------------------------------------------------------------------- 1 | export RUKORUN_PATH=<%= node['openruko']['home'] %>/rukorun 2 | export CODONHOOKS_PATH=<%= node['openruko']['home'] %>/codonhooks 3 | 4 | -------------------------------------------------------------------------------- /cookbooks/openruko/templates/default/ssh-config.erb: -------------------------------------------------------------------------------- 1 | Host <%= node['openruko']['host'] %> 2 | Hostname localhost 3 | Port 2222 4 | StrictHostKeyChecking no 5 | -------------------------------------------------------------------------------- /cookbooks/openruko/templates/default/upstart-openruko-apiserver.conf.erb: -------------------------------------------------------------------------------- 1 | start on (started network-interface 2 | or started network-manager 3 | or started networking) 4 | 5 | stop on (stopping network-interface 6 | or stopping network-manager 7 | or stopping networking) 8 | 9 | respawn 10 | 11 | setuid <%= node['user'] %> 12 | setgid <%= node['group'] %> 13 | 14 | env PG_USER="<%= node['user'] %>" 15 | env PG_PASSWORD="<%= node['postgresql']['password'][node['user']] %>" 16 | <% if node['s3']['s3_hostname'] %> 17 | env S3_HOSTNAME="<%= node['s3']['s3_hostname'] %>" 18 | env S3_PORT="<%= node['s3']['s3_port'] %>" 19 | <% end %> 20 | env S3_KEY="<%= node['s3']['s3_key'] %>" 21 | env S3_SECRET="<%= node['s3']['s3_secret'] %>" 22 | env S3_BUCKET="<%= node['s3']['s3_bucket'] %>" 23 | env APISERVER_KEY="<%= node['openruko']['apiserver_key'] %>" 24 | env APISERVER_HOST="<%= node['openruko']['apiserver_host'] %>" 25 | env LOGPLEX_HOST="<%= node['openruko']['apiserver_host'] %>" 26 | 27 | chdir <%= node['openruko']['home'] %>/apiserver 28 | 29 | script 30 | ./apiserver/bin/apiserver >> /var/log/openruko/apiserver.log 2>&1 31 | end script 32 | -------------------------------------------------------------------------------- /cookbooks/openruko/templates/default/upstart-openruko-dynohost.conf.erb: -------------------------------------------------------------------------------- 1 | start on (started network-interface 2 | or started network-manager 3 | or started networking) 4 | 5 | stop on (stopping network-interface 6 | or stopping network-manager 7 | or stopping networking) 8 | respawn 9 | 10 | env RUKORUN_PATH="<%= node['openruko']['home'] %>/rukorun" 11 | env CODONHOOKS_PATH="<%= node['openruko']['home'] %>/codonhooks" 12 | env APISERVER_KEY="<%= node['openruko']['apiserver_key'] %>" 13 | env APISERVER_HOST="<%= node['openruko']['apiserver_host'] %>" 14 | env LOGPLEX_HOST="<%= node['openruko']['apiserver_host'] %>" 15 | 16 | chdir <%= node['openruko']['home'] %>/dynohost 17 | 18 | script 19 | ./dynohost/bin/dynohost >> /var/log/openruko/dynohost.log 2>&1 20 | end script 21 | -------------------------------------------------------------------------------- /cookbooks/openruko/templates/default/upstart-openruko-gitmouth.conf.erb: -------------------------------------------------------------------------------- 1 | start on starting openruko-apiserver 2 | stop on stopping openruko-apiserver 3 | respawn 4 | 5 | setuid <%= node['user'] %> 6 | setgid <%= node['group'] %> 7 | 8 | env APISERVER_KEY="<%= node['openruko']['apiserver_key'] %>" 9 | 10 | chdir <%= node['openruko']['home'] %>/gitmouth 11 | 12 | script 13 | ./bin/gitmouth >> /var/log/openruko/gitmouth.log 2>&1 14 | end script 15 | -------------------------------------------------------------------------------- /cookbooks/openruko/templates/default/upstart-openruko-httprouting.conf.erb: -------------------------------------------------------------------------------- 1 | start on starting openruko-apiserver 2 | stop on stopping openruko-apiserver 3 | respawn 4 | 5 | setuid <%= node['user'] %> 6 | setgid <%= node['group'] %> 7 | 8 | env PG_USER=<%= node['user'] %> 9 | env PG_PASSWORD=<%= node['postgresql']['password'][node['user']] %> 10 | env HTTPROUTING_PORT=8080 11 | env HTTPROUTING_TLS=true 12 | 13 | chdir <%= node['openruko']['home'] %>/httprouting 14 | 15 | script 16 | ./httprouting/bin/httprouting >> /var/log/openruko/httprouting.log 2>&1 17 | end script 18 | -------------------------------------------------------------------------------- /cookbooks/openruko/templates/default/upstart-openruko-logplex.conf.erb: -------------------------------------------------------------------------------- 1 | start on starting openruko-apiserver 2 | stop on stopping openruko-apiserver 3 | respawn 4 | 5 | setuid <%= node['user'] %> 6 | setgid <%= node['group'] %> 7 | 8 | chdir <%= node['openruko']['home'] %>/logplex 9 | 10 | script 11 | ./logplex/bin/logplex >> /var/log/openruko/logplex.log 2>&1 12 | end script 13 | -------------------------------------------------------------------------------- /cookbooks/openssl/README.md: -------------------------------------------------------------------------------- 1 | Description 2 | ==== 3 | 4 | Provide a library method to generate secure random passwords in recipes. 5 | 6 | Requirements 7 | ==== 8 | 9 | Works on any platform with OpenSSL Ruby bindings installed, which are a requirement for Chef anyway. 10 | 11 | Usage 12 | ==== 13 | 14 | Most often this will be used to generate a secure password for an attribute. 15 | 16 | include Opscode::OpenSSL::Password 17 | 18 | set_unless[:my_password] = secure_password 19 | 20 | License and Author 21 | ==== 22 | 23 | Author:: Joshua Timberman () 24 | 25 | Copyright:: 2009-2011, Opscode, Inc 26 | 27 | Licensed under the Apache License, Version 2.0 (the "License"); 28 | you may not use this file except in compliance with the License. 29 | You may obtain a copy of the License at 30 | 31 | http://www.apache.org/licenses/LICENSE-2.0 32 | 33 | Unless required by applicable law or agreed to in writing, software 34 | distributed under the License is distributed on an "AS IS" BASIS, 35 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 36 | See the License for the specific language governing permissions and 37 | limitations under the License. 38 | -------------------------------------------------------------------------------- /cookbooks/openssl/libraries/secure_password.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: openssl 3 | # Library:: secure_password 4 | # Author:: Joshua Timberman 5 | # 6 | # Copyright 2009, Opscode, Inc. 7 | # 8 | # Licensed under the Apache License, Version 2.0 (the "License"); 9 | # you may not use this file except in compliance with the License. 10 | # You may obtain a copy of the License at 11 | # 12 | # http://www.apache.org/licenses/LICENSE-2.0 13 | # 14 | # Unless required by applicable law or agreed to in writing, software 15 | # distributed under the License is distributed on an "AS IS" BASIS, 16 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | # See the License for the specific language governing permissions and 18 | # limitations under the License. 19 | # 20 | 21 | require 'openssl' 22 | 23 | module Opscode 24 | module OpenSSL 25 | module Password 26 | def secure_password 27 | pw = String.new 28 | 29 | while pw.length < 20 30 | pw << ::OpenSSL::Random.random_bytes(1).gsub(/\W/, '') 31 | end 32 | 33 | pw 34 | end 35 | end 36 | end 37 | end 38 | -------------------------------------------------------------------------------- /cookbooks/openssl/metadata.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "openssl", 3 | "description": "Provides a library with a method for generating secure random passwords.", 4 | "long_description": "Description\n====\n\nProvide a library method to generate secure random passwords in recipes.\n\nRequirements\n====\n\nWorks on any platform with OpenSSL Ruby bindings installed, which are a requirement for Chef anyway.\n\nUsage\n====\n\nMost often this will be used to generate a secure password for an attribute.\n\n include Opscode::OpenSSL::Password\n\n set_unless[:my_password] = secure_password\n\nLicense and Author\n====\n\nAuthor:: Joshua Timberman ()\n\nCopyright:: 2009-2011, Opscode, Inc\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n", 5 | "maintainer": "Opscode, Inc.", 6 | "maintainer_email": "cookbooks@opscode.com", 7 | "license": "Apache 2.0", 8 | "platforms": { 9 | }, 10 | "dependencies": { 11 | }, 12 | "recommendations": { 13 | }, 14 | "suggestions": { 15 | }, 16 | "conflicting": { 17 | }, 18 | "providing": { 19 | }, 20 | "replacing": { 21 | }, 22 | "attributes": { 23 | }, 24 | "groupings": { 25 | }, 26 | "recipes": { 27 | "openssl": "Empty, this cookbook provides a library, see README.md" 28 | }, 29 | "version": "1.0.0" 30 | } -------------------------------------------------------------------------------- /cookbooks/openssl/metadata.rb: -------------------------------------------------------------------------------- 1 | maintainer "Opscode, Inc." 2 | maintainer_email "cookbooks@opscode.com" 3 | license "Apache 2.0" 4 | description "Provides a library with a method for generating secure random passwords." 5 | long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) 6 | version "1.0.0" 7 | 8 | recipe "openssl", "Empty, this cookbook provides a library, see README.md" 9 | -------------------------------------------------------------------------------- /cookbooks/openssl/recipes/default.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: openssl 3 | # Recipe:: default 4 | # 5 | # Copyright 2009, Opscode, Inc. 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # 19 | 20 | -------------------------------------------------------------------------------- /cookbooks/postgresql/.gitignore: -------------------------------------------------------------------------------- 1 | *.tgz 2 | *.tar.gz 3 | vendor/bundle 4 | .bundle 5 | .DS_Store 6 | build/* 7 | tmp/ 8 | -------------------------------------------------------------------------------- /cookbooks/postgresql/.ruby-version: -------------------------------------------------------------------------------- 1 | 1.9.3@chef-postgresql 2 | -------------------------------------------------------------------------------- /cookbooks/postgresql/LICENSE.txt: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | Copyright © 2012-2013 Phil Cohen 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy 5 | of this software and associated documentation files (the “Software”), to deal 6 | in the Software without restriction, including without limitation the rights 7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | copies of the Software, and to permit persons to whom the Software is 9 | furnished to do so, subject to the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be included in 12 | all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /cookbooks/postgresql/Rakefile: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env rake 2 | 3 | task :default => "foodcritic" 4 | 5 | desc "Runs foodcritic linter" 6 | task :foodcritic do 7 | Rake::Task[:prepare_sandbox].execute 8 | 9 | if Gem::Version.new("1.9.2") <= Gem::Version.new(RUBY_VERSION.dup) 10 | sh "foodcritic -f any #{sandbox_path}" 11 | else 12 | puts "WARN: foodcritic run is skipped as Ruby #{RUBY_VERSION} is < 1.9.2." 13 | end 14 | end 15 | 16 | desc "Runs knife cookbook test" 17 | task :knife do 18 | Rake::Task[:prepare_sandbox].execute 19 | 20 | sh "bundle exec knife cookbook test cookbook -c test/.chef/knife.rb -o #{sandbox_path}/../" 21 | end 22 | 23 | task :prepare_sandbox do 24 | files = %w{*.md *.rb attributes definitions libraries files providers recipes resources templates} 25 | 26 | rm_rf sandbox_path 27 | mkdir_p sandbox_path 28 | cp_r Dir.glob("{#{files.join(",")}}"), sandbox_path 29 | end 30 | 31 | private 32 | 33 | def sandbox_path 34 | File.join(File.dirname(__FILE__), %w[tmp cookbooks cookbook]) 35 | end 36 | -------------------------------------------------------------------------------- /cookbooks/postgresql/definitions/pg_database.rb: -------------------------------------------------------------------------------- 1 | define :pg_database, :action => :create do 2 | 3 | defaults = { 4 | :user => "postgres", 5 | :username => nil, 6 | :host => nil, 7 | :port => nil, 8 | :encoding => "utf8", 9 | :locale => nil, 10 | :template => nil, 11 | :owner => nil, 12 | } 13 | 14 | defaults.merge! params 15 | 16 | exists = ["psql"] 17 | exists.push "-c \"SELECT datname from pg_database WHERE datname='#{params[:name]}'\"" 18 | exists.push "--host #{defaults[:host]}" if defaults[:host] 19 | exists.push "--port #{defaults[:port]}" if defaults[:port] 20 | exists.push "| grep #{params[:name]}" 21 | 22 | exists = exists.join ' ' 23 | 24 | case params[:action] 25 | when :create 26 | createdb = ["createdb"] 27 | createdb.push "-U #{defaults[:username]}" if defaults[:username] 28 | createdb.push "-E #{defaults[:encoding]}" if defaults[:encoding] 29 | createdb.push "--locale #{defaults[:locale]}" if defaults[:locale] 30 | createdb.push "-T #{defaults[:template]}" if defaults[:template] 31 | createdb.push "--host #{defaults[:host]}" if defaults[:host] 32 | createdb.push "--port #{defaults[:port]}" if defaults[:port] 33 | createdb.push "-O #{defaults[:owner]}" if defaults[:owner] 34 | 35 | createdb.push params[:name] 36 | 37 | createdb = createdb.join ' ' 38 | 39 | execute "creating pg database #{params[:name]}" do 40 | user defaults[:user] 41 | command createdb 42 | not_if exists, :user => defaults[:user] 43 | end 44 | 45 | when :drop 46 | dropdb = ["dropdb"] 47 | dropdb.push "-U #{defaults[:username]}" if defaults[:username] 48 | dropdb.push "--host #{defaults[:host]}" if defaults[:host] 49 | dropdb.push "--port #{defaults[:port]}" if defaults[:port] 50 | 51 | dropdb.push params[:name] 52 | 53 | dropdb = dropdb.join ' ' 54 | 55 | execute "dropping pg database #{params[:name]}" do 56 | user defaults[:user] 57 | command dropdb 58 | only_if exists, :user => defaults[:user] 59 | end 60 | end 61 | end 62 | -------------------------------------------------------------------------------- /cookbooks/postgresql/definitions/pg_database_extensions.rb: -------------------------------------------------------------------------------- 1 | define :pg_database_extensions, :action => :create do 2 | 3 | dbname = params[:name] 4 | languages = [params[:languages] || []].flatten # Allow single value or array of values 5 | extensions = [params[:extensions] || []].flatten 6 | postgis = params[:postgis] 7 | 8 | postgresql_version = node["postgresql"]["version"] 9 | postgis_version = node["postgis"]["version"] 10 | 11 | case params[:action] 12 | when :create 13 | 14 | languages.each do |language| 15 | execute "createlang #{language} #{dbname}" do 16 | user "postgres" 17 | not_if "psql -c 'SELECT lanname FROM pg_catalog.pg_language' #{dbname} | grep '^ #{language}$'", :user => "postgres" 18 | end 19 | end 20 | 21 | extensions.each do |extension| 22 | execute "psql -c 'CREATE EXTENSION IF NOT EXISTS #{extension}' #{dbname}" do 23 | user "postgres" 24 | end 25 | end 26 | 27 | if postgis 28 | include_recipe 'postgresql::postgis' 29 | 30 | execute "psql -d #{dbname} -f /usr/share/postgresql/#{postgresql_version}/contrib/postgis-#{postgis_version}/postgis.sql" do 31 | user "postgres" 32 | not_if "psql -c \"SELECT proname FROM pg_catalog.pg_proc WHERE proname = 'st_area'\" #{dbname} | grep 'st_area$'", :user => "postgres" 33 | end 34 | 35 | execute "psql -d #{dbname} -f /usr/share/postgresql/#{postgresql_version}/contrib/postgis-#{postgis_version}/spatial_ref_sys.sql" do 36 | user "postgres" 37 | only_if "psql -c 'SELECT count(1) FROM spatial_ref_sys' #{dbname} | grep '0$'", :user => "postgres" 38 | end 39 | 40 | [:geometry_columns, :geography_columns, :spatial_ref_sys].each do |table| 41 | execute "psql -c 'GRANT ALL ON #{table} TO PUBLIC' #{dbname}" do 42 | user "postgres" 43 | end 44 | end 45 | end 46 | 47 | when :drop 48 | 49 | languages.each do |language| 50 | execute "droplang #{language} #{dbname}" do 51 | user "postgres" 52 | only_if "psql -c 'SELECT lanname FROM pg_catalog.pg_language' #{dbname} | grep '^ #{language}$'", :user => "postgres" 53 | end 54 | end 55 | 56 | extensions.each do |extension| 57 | execute "psql -c 'DROP EXTENSION IF EXISTS #{extension}' #{dbname}" do 58 | user "postgres" 59 | end 60 | end 61 | 62 | if postgis 63 | Chef::Log.warn("Postgis support dropping isn't supported") 64 | end 65 | 66 | end 67 | end 68 | -------------------------------------------------------------------------------- /cookbooks/postgresql/definitions/pg_user.rb: -------------------------------------------------------------------------------- 1 | define :pg_user, :action => :create do 2 | case params[:action] 3 | when :create 4 | privileges = { 5 | :superuser => false, 6 | :createdb => false, 7 | :login => true 8 | } 9 | privileges.merge! params[:privileges] if params[:privileges] 10 | 11 | sql = [params[:name]] 12 | 13 | sql.push privileges.to_a.map! { |p,b| (b ? '' : 'NO') + p.to_s.upcase }.join ' ' 14 | 15 | if params[:encrypted_password] 16 | sql.push "ENCRYPTED PASSWORD '#{params[:encrypted_password]}'" 17 | elsif params[:password] 18 | sql.push "PASSWORD '#{params[:password]}'" 19 | end 20 | 21 | sql = sql.join ' ' 22 | 23 | exists = ["psql -c \"SELECT usename FROM pg_user WHERE usename='#{params[:name]}'\""] 24 | exists.push "| grep #{params[:name]}" 25 | exists = exists.join ' ' 26 | 27 | execute "altering pg user #{params[:name]}" do 28 | user "postgres" 29 | command "psql -c \"ALTER ROLE #{sql}\"" 30 | only_if exists, :user => "postgres" 31 | end 32 | 33 | execute "creating pg user #{params[:name]}" do 34 | user "postgres" 35 | command "psql -c \"CREATE ROLE #{sql}\"" 36 | not_if exists, :user => "postgres" 37 | end 38 | 39 | when :drop 40 | execute "dropping pg user #{params[:name]}" do 41 | user "postgres" 42 | command "psql -c \"DROP ROLE IF EXISTS #{params[:name]}\"" 43 | end 44 | end 45 | end -------------------------------------------------------------------------------- /cookbooks/postgresql/files/default/pgdg.pref: -------------------------------------------------------------------------------- 1 | Package: * 2 | Pin: release o=apt.postgresql.org 3 | Pin-Priority: 500 4 | -------------------------------------------------------------------------------- /cookbooks/postgresql/metadata.rb: -------------------------------------------------------------------------------- 1 | name "postgresql" 2 | maintainer "Phil Cohen" 3 | maintainer_email "github@phlippers.net" 4 | license "MIT" 5 | description "Installs PostgreSQL, The world's most advanced open source database." 6 | long_description IO.read(File.join(File.dirname(__FILE__), "README.md")) 7 | version "0.9.0" 8 | 9 | recipe "postgresql", "Set up the apt repository and install dependent packages" 10 | recipe "postgresql::client", "Front-end programs for PostgreSQL 9.x" 11 | recipe "postgresql::server", "Object-relational SQL database, version 9.x server" 12 | recipe "postgresql::contrib", "Additional facilities for PostgreSQL" 13 | recipe "postgresql::dbg", "Debug symbols for the server daemon" 14 | recipe "postgresql::doc", "Documentation for the PostgreSQL database management system" 15 | recipe "postgresql::libpq", "PostgreSQL C client library and header files for libpq5 (PostgreSQL library)" 16 | recipe "postgresql::postgis", "Geographic objects support for PostgreSQL 9.x" 17 | 18 | %w[ubuntu debian].each do |os| 19 | supports os 20 | end 21 | 22 | depends "apt" 23 | -------------------------------------------------------------------------------- /cookbooks/postgresql/recipes/client.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: postgresql 3 | # Recipe:: client 4 | # 5 | 6 | include_recipe "postgresql" 7 | 8 | package "postgresql-client-#{node["postgresql"]["version"]}" 9 | -------------------------------------------------------------------------------- /cookbooks/postgresql/recipes/contrib.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: postgresql 3 | # Recipe:: contrib 4 | # 5 | 6 | include_recipe "postgresql" 7 | 8 | package "postgresql-contrib-#{node["postgresql"]["version"]}" 9 | -------------------------------------------------------------------------------- /cookbooks/postgresql/recipes/dbg.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: postgresql 3 | # Recipe:: dbg 4 | # 5 | 6 | include_recipe "postgresql" 7 | 8 | package "postgresql-#{node["postgresql"]["version"]}-dbg" 9 | -------------------------------------------------------------------------------- /cookbooks/postgresql/recipes/default.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: postgresql 3 | # Recipe:: default 4 | # 5 | 6 | case node["platform"] 7 | when "ubuntu" 8 | 9 | apt_repository "pitti-postgresql" do 10 | uri "http://ppa.launchpad.net/pitti/postgresql/ubuntu" 11 | distribution node["lsb"]["codename"] 12 | components ["main"] 13 | keyserver "keyserver.ubuntu.com" 14 | key "8683D8A2" 15 | action :add 16 | end 17 | 18 | # install common files 19 | package "postgresql-common" 20 | 21 | when "debian" 22 | 23 | # backports for initial support 24 | apt_repository "debian-backports" do 25 | uri "http://backports.debian.org/debian-backports" 26 | distribution "#{node["lsb"]["codename"]}-backports" 27 | components ["main"] 28 | action :add 29 | end 30 | 31 | cookbook_file "/etc/apt/preferences.d/pgdg.pref" do 32 | source "pgdg.pref" 33 | end 34 | 35 | # backports support for debian 36 | %w[libpq5 postgresql-common].each do |pkg| 37 | package pkg do 38 | options "-t #{node["lsb"]["codename"]}-backports" 39 | end 40 | end 41 | 42 | # use `apt.postgresql.org` for primary package installation support 43 | apt_repository "apt.postgresql.org" do 44 | uri "http://apt.postgresql.org/pub/repos/apt" 45 | distribution "#{node["lsb"]["codename"]}-pgdg" 46 | components ["main"] 47 | key "http://apt.postgresql.org/pub/repos/apt/ACCC4CF8.asc" 48 | action :add 49 | end 50 | end 51 | -------------------------------------------------------------------------------- /cookbooks/postgresql/recipes/doc.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: postgresql 3 | # Recipe:: doc 4 | # 5 | 6 | include_recipe "postgresql" 7 | 8 | package "postgresql-doc-#{node["postgresql"]["version"]}" 9 | -------------------------------------------------------------------------------- /cookbooks/postgresql/recipes/libpq.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: postgresql 3 | # Recipe:: libpq 4 | # 5 | 6 | include_recipe "postgresql" 7 | 8 | package "libpq5" 9 | package "libpq-dev" 10 | -------------------------------------------------------------------------------- /cookbooks/postgresql/recipes/postgis.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: postgresql 3 | # Recipe:: postgis 4 | # 5 | 6 | include_recipe "postgresql" 7 | 8 | package "postgresql-#{node["postgresql"]["version"]}-postgis" 9 | -------------------------------------------------------------------------------- /cookbooks/postgresql/recipes/server.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: postgresql 3 | # Recipe:: server 4 | # 5 | 6 | include_recipe "postgresql" 7 | 8 | pg_version = node["postgresql"]["version"] 9 | 10 | # install the package 11 | package "postgresql-#{pg_version}" 12 | 13 | # Make sure /etc/postgresql/9.1/main exists. 14 | # For some reason Travis CI doesn't create it. 15 | bash "postgres-dir" do 16 | user "root" 17 | code <<-EOF 18 | mkdir -p /etc/postgresql/#{pg_version}/main 19 | EOF 20 | end 21 | 22 | # ensure data directory exists 23 | directory node["postgresql"]["data_directory"] do 24 | owner "postgres" 25 | group "postgres" 26 | mode "0700" 27 | not_if "test -f #{node["postgresql"]["data_directory"]}/PG_VERSION" 28 | end 29 | 30 | # initialize the data directory if necessary 31 | bash "postgresql initdb" do 32 | user "postgres" 33 | code <<-EOC 34 | /usr/lib/postgresql/#{pg_version}/bin/initdb \ 35 | #{node["postgresql"]["initdb_options"]} \ 36 | -U postgres \ 37 | -D #{node["postgresql"]["data_directory"]} 38 | EOC 39 | creates "#{node["postgresql"]["data_directory"]}/PG_VERSION" 40 | end 41 | 42 | # environment 43 | template "/etc/postgresql/#{pg_version}/main/environment" do 44 | source "environment.erb" 45 | owner "postgres" 46 | group "postgres" 47 | mode "0644" 48 | notifies :restart, "service[postgresql]" 49 | end 50 | 51 | # pg_ctl 52 | template "/etc/postgresql/#{pg_version}/main/pg_ctl.conf" do 53 | source "pg_ctl.conf.erb" 54 | owner "postgres" 55 | group "postgres" 56 | mode "0644" 57 | notifies :restart, "service[postgresql]" 58 | end 59 | 60 | # pg_hba 61 | template node["postgresql"]["hba_file"] do 62 | source "pg_hba.conf.erb" 63 | owner "postgres" 64 | group "postgres" 65 | mode "0640" 66 | notifies :restart, "service[postgresql]" 67 | end 68 | 69 | # pg_ident 70 | template node["postgresql"]["ident_file"] do 71 | source "pg_ident.conf.erb" 72 | owner "postgres" 73 | group "postgres" 74 | mode "0640" 75 | notifies :restart, "service[postgresql]" 76 | end 77 | 78 | # postgresql 79 | pg_template_source = node["postgresql"]["conf"].any? ? "custom" : "standard" 80 | template "/etc/postgresql/#{pg_version}/main/postgresql.conf" do 81 | source "postgresql.conf.#{pg_template_source}.erb" 82 | owner "postgres" 83 | group "postgres" 84 | mode "0644" 85 | variables(:configuration => node["postgresql"]["conf"]) 86 | notifies :restart, "service[postgresql]" 87 | end 88 | 89 | # start 90 | template "/etc/postgresql/#{pg_version}/main/start.conf" do 91 | source "start.conf.erb" 92 | owner "postgres" 93 | group "postgres" 94 | mode "0644" 95 | notifies :restart, "service[postgresql]", :immediately 96 | end 97 | 98 | # setup users 99 | node["postgresql"]["users"].each do |user| 100 | pg_user user["username"] do 101 | privileges :superuser => user["superuser"], :createdb => user["createdb"], :login => user["login"] 102 | password user["password"] 103 | end 104 | end 105 | 106 | # setup databases 107 | node["postgresql"]["databases"].each do |database| 108 | pg_database database["name"] do 109 | owner database["owner"] 110 | encoding database["encoding"] 111 | template database["template"] 112 | locale database["locale"] 113 | end 114 | 115 | pg_database_extensions database["name"] do 116 | extensions database["extensions"] 117 | languages database["languages"] 118 | postgis database["postgis"] 119 | end 120 | end 121 | 122 | # define the service 123 | service "postgresql" do 124 | supports :restart => true 125 | action [:enable, :start] 126 | end 127 | -------------------------------------------------------------------------------- /cookbooks/postgresql/templates/default/environment.erb: -------------------------------------------------------------------------------- 1 | # environment variables for postmaster process 2 | # This file has the same syntax as postgresql.conf: 3 | # VARIABLE = simple_value 4 | # VARIABLE2 = 'any value!' 5 | # I. e. you need to enclose any value which does not only consist of letters, 6 | # numbers, and '-', '_', '.' in single quotes. Shell commands are not 7 | # evaluated. 8 | 9 | <% node["postgresql"]["environment_variables"].each_pair do |k, v| %> 10 | <%= "#{k} = #{v}" %> 11 | <% end %> 12 | -------------------------------------------------------------------------------- /cookbooks/postgresql/templates/default/pg_ctl.conf.erb: -------------------------------------------------------------------------------- 1 | # Automatic pg_ctl configuration 2 | # This configuration file contains cluster specific options to be passed to 3 | # pg_ctl(1). 4 | 5 | pg_ctl_options = '<%= node["postgresql"]["pg_ctl_options"] %>' 6 | -------------------------------------------------------------------------------- /cookbooks/postgresql/templates/default/pg_hba.conf.erb: -------------------------------------------------------------------------------- 1 | # PostgreSQL Client Authentication Configuration File 2 | # =================================================== 3 | # 4 | # Refer to the "Client Authentication" section in the PostgreSQL 5 | # documentation for a complete description of this file. A short 6 | # synopsis follows. 7 | # 8 | # This file controls: which hosts are allowed to connect, how clients 9 | # are authenticated, which PostgreSQL user names they can use, which 10 | # databases they can access. Records take one of these forms: 11 | # 12 | # local DATABASE USER METHOD [OPTIONS] 13 | # host DATABASE USER ADDRESS METHOD [OPTIONS] 14 | # hostssl DATABASE USER ADDRESS METHOD [OPTIONS] 15 | # hostnossl DATABASE USER ADDRESS METHOD [OPTIONS] 16 | # 17 | # (The uppercase items must be replaced by actual values.) 18 | # 19 | # The first field is the connection type: "local" is a Unix-domain 20 | # socket, "host" is either a plain or SSL-encrypted TCP/IP socket, 21 | # "hostssl" is an SSL-encrypted TCP/IP socket, and "hostnossl" is a 22 | # plain TCP/IP socket. 23 | # 24 | # DATABASE can be "all", "sameuser", "samerole", "replication", a 25 | # database name, or a comma-separated list thereof. The "all" 26 | # keyword does not match "replication". Access to replication 27 | # must be enabled in a separate record (see example below). 28 | # 29 | # USER can be "all", a user name, a group name prefixed with "+", or a 30 | # comma-separated list thereof. In both the DATABASE and USER fields 31 | # you can also write a file name prefixed with "@" to include names 32 | # from a separate file. 33 | # 34 | # ADDRESS specifies the set of hosts the record matches. It can be a 35 | # host name, or it is made up of an IP address and a CIDR mask that is 36 | # an integer (between 0 and 32 (IPv4) or 128 (IPv6) inclusive) that 37 | # specifies the number of significant bits in the mask. A host name 38 | # that starts with a dot (.) matches a suffix of the actual host name. 39 | # Alternatively, you can write an IP address and netmask in separate 40 | # columns to specify the set of hosts. Instead of a CIDR-address, you 41 | # can write "samehost" to match any of the server's own IP addresses, 42 | # or "samenet" to match any address in any subnet that the server is 43 | # directly connected to. 44 | # 45 | # METHOD can be "trust", "reject", "md5", "password", "gss", "sspi", 46 | # "krb5", "ident", "peer", "pam", "ldap", "radius" or "cert". Note that 47 | # "password" sends passwords in clear text; "md5" is preferred since 48 | # it sends encrypted passwords. 49 | # 50 | # OPTIONS are a set of options for the authentication in the format 51 | # NAME=VALUE. The available options depend on the different 52 | # authentication methods -- refer to the "Client Authentication" 53 | # section in the documentation for a list of which options are 54 | # available for which authentication methods. 55 | # 56 | # Database and user names containing spaces, commas, quotes and other 57 | # special characters must be quoted. Quoting one of the keywords 58 | # "all", "sameuser", "samerole" or "replication" makes the name lose 59 | # its special character, and just match a database or username with 60 | # that name. 61 | # 62 | # This file is read on server startup and when the postmaster receives 63 | # a SIGHUP signal. If you edit the file on a running system, you have 64 | # to SIGHUP the postmaster for the changes to take effect. You can 65 | # use "pg_ctl reload" to do that. 66 | 67 | # Put your actual configuration here 68 | # ---------------------------------- 69 | # 70 | # If you want to allow non-local connections, you need to add more 71 | # "host" records. In that case you will also need to make PostgreSQL 72 | # listen on a non-local interface via the listen_addresses 73 | # configuration parameter, or via the -i or -h command line switches. 74 | 75 | <% node["postgresql"]["pg_hba"].each do |hba| %> 76 | <%= hba['type'] %> <%= hba['db'] %> <%= hba['user'] %> <%= hba['addr'] %> <%= hba['method'] %> 77 | <% end %> 78 | 79 | # DO NOT DISABLE! 80 | # If you change this first entry you will need to make sure that the 81 | # database superuser can access the database using some other method. 82 | # Noninteractive access to all databases is required during automatic 83 | # maintenance (custom daily cronjobs, replication, and similar tasks). 84 | # 85 | # TYPE DATABASE USER ADDRESS METHOD 86 | <% if node[:postgresql][:pg_hba_defaults] %> 87 | # Database administrative login by Unix domain socket 88 | local all postgres peer 89 | # "local" is for Unix domain socket connections only 90 | local all all peer 91 | # IPv4 local connections: 92 | host all all 127.0.0.1/32 md5 93 | # IPv6 local connections: 94 | host all all ::1/128 md5 95 | # Allow replication connections from localhost, by a user with the 96 | # replication privilege. 97 | #local replication postgres peer 98 | #host replication postgres 127.0.0.1/32 md5 99 | #host replication postgres ::1/128 md5 100 | <% end %> 101 | -------------------------------------------------------------------------------- /cookbooks/postgresql/templates/default/pg_ident.conf.erb: -------------------------------------------------------------------------------- 1 | # PostgreSQL User Name Maps 2 | # ========================= 3 | # 4 | # Refer to the PostgreSQL documentation, chapter "Client 5 | # Authentication" for a complete description. A short synopsis 6 | # follows. 7 | # 8 | # This file controls PostgreSQL user name mapping. It maps external 9 | # user names to their corresponding PostgreSQL user names. Records 10 | # are of the form: 11 | # 12 | # MAPNAME SYSTEM-USERNAME PG-USERNAME 13 | # 14 | # (The uppercase quantities must be replaced by actual values.) 15 | # 16 | # MAPNAME is the (otherwise freely chosen) map name that was used in 17 | # pg_hba.conf. SYSTEM-USERNAME is the detected user name of the 18 | # client. PG-USERNAME is the requested PostgreSQL user name. The 19 | # existence of a record specifies that SYSTEM-USERNAME may connect as 20 | # PG-USERNAME. 21 | # 22 | # If SYSTEM-USERNAME starts with a slash (/), it will be treated as a 23 | # regular expression. Optionally this can contain a capture (a 24 | # parenthesized subexpression). The substring matching the capture 25 | # will be substituted for \1 (backslash-one) if present in 26 | # PG-USERNAME. 27 | # 28 | # Multiple maps may be specified in this file and used by pg_hba.conf. 29 | # 30 | # No map names are defined in the default configuration. If all 31 | # system user names and PostgreSQL user names are the same, you don't 32 | # need anything in this file. 33 | # 34 | # This file is read on server startup and when the postmaster receives 35 | # a SIGHUP signal. If you edit the file on a running system, you have 36 | # to SIGHUP the postmaster for the changes to take effect. You can 37 | # use "pg_ctl reload" to do that. 38 | 39 | # Put your actual configuration here 40 | # ---------------------------------- 41 | 42 | # MAPNAME SYSTEM-USERNAME PG-USERNAME 43 | 44 | <% node["postgresql"]["pg_ident"].each do |ident| %> 45 | <%= ident %> 46 | <% end %> 47 | -------------------------------------------------------------------------------- /cookbooks/postgresql/templates/default/postgresql.conf.custom.erb: -------------------------------------------------------------------------------- 1 | # generated by Chef for node <%= node["fqdn"] %> 2 | # 3 | # ----------------------------- 4 | # PostgreSQL configuration file 5 | # ----------------------------- 6 | # 7 | 8 | <% @configuration.each_pair do |key, value| %> 9 | <%= "#{key} = '#{value}'" %> 10 | <% end %> 11 | -------------------------------------------------------------------------------- /cookbooks/postgresql/templates/default/start.conf.erb: -------------------------------------------------------------------------------- 1 | # Automatic startup configuration 2 | # auto: automatically start/stop the cluster in the init script 3 | # manual: do not start/stop in init scripts, but allow manual startup with 4 | # pg_ctlcluster 5 | # disabled: do not allow manual startup with pg_ctlcluster (this can be easily 6 | # circumvented and is only meant to be a small protection for 7 | # accidents). 8 | 9 | auto 10 | -------------------------------------------------------------------------------- /cookbooks/postgresql/test/.chef/knife.rb: -------------------------------------------------------------------------------- 1 | cache_type "BasicFile" 2 | cache_options(:path => "#{ENV["HOME"]}/.chef/checksums") 3 | -------------------------------------------------------------------------------- /cookbooks/postgresql/test/support/Gemfile: -------------------------------------------------------------------------------- 1 | source "https://rubygems.org" 2 | 3 | gem "rake" 4 | gem "foodcritic" 5 | gem "chef", "~> 10.12.0" 6 | -------------------------------------------------------------------------------- /cookbooks/proxy/recipes/default.rb: -------------------------------------------------------------------------------- 1 | if node['proxy']['http_proxy'] 2 | template "/etc/apt/apt.conf.d/proxy" do 3 | source "aptproxy.erb" 4 | owner "root" 5 | group "root" 6 | mode 0600 7 | end 8 | end 9 | 10 | template "/usr/local/bin/gitproxy" do 11 | source "gitproxy.erb" 12 | owner "root" 13 | group "root" 14 | mode 0755 15 | end 16 | 17 | template "/etc/profile.d/proxy.sh" do 18 | source "systemproxy.erb" 19 | owner "root" 20 | group "root" 21 | mode 0755 22 | end 23 | 24 | package "socat" 25 | -------------------------------------------------------------------------------- /cookbooks/proxy/templates/default/aptproxy.erb: -------------------------------------------------------------------------------- 1 | Acquire::http::Proxy "<%= node['proxy']['http_proxy'] %>"; 2 | -------------------------------------------------------------------------------- /cookbooks/proxy/templates/default/gitproxy.erb: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | if [ -n "$http_proxy" ]; then 3 | proxy_host=`echo "$http_proxy"| sed -e "s/[^/]*\/\/\([^@]*@\)\?\([^:/]*\)\(\(\:\)\([0-9]\+\)\)\?.*/\2/"` 4 | proxy_port=`echo "$http_proxy"| sed -e "s/[^/]*\/\/\([^@]*@\)\?\([^:/]*\)\(\(\:\)\([0-9]\+\)\)\?.*/\5/"` 5 | exec socat STDIO PROXY:"$proxy_host":$1:$2,proxyport="$proxy_port" 6 | else 7 | exec socat STDIO TCP:$1:$2 8 | fi -------------------------------------------------------------------------------- /cookbooks/proxy/templates/default/systemproxy.erb: -------------------------------------------------------------------------------- 1 | <% if node['proxy']['http_proxy'] %> 2 | export http_proxy="<%= node['proxy']['http_proxy'] %>" 3 | export ftp_proxy="<%= node['proxy']['http_proxy'] %>" 4 | <% end %> 5 | <% if node['proxy']['https_proxy'] %> 6 | export https_proxy="<%= node['proxy']['https_proxy'] %>" 7 | <% end %> 8 | <% if node['proxy']['no_proxy'] %> 9 | export no_proxy="<%= node['proxy']['no_proxy'] %>" 10 | <% end %> 11 | export GIT_PROXY_COMMAND=gitproxy -------------------------------------------------------------------------------- /cookbooks/python/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## v1.2.0: 2 | 3 | * [COOK-1866] - /usr/bin is not a pip binary location in source 4 | installs on RHEL 5 | * [COOK-1925] - add smartos support 6 | 7 | ## v1.1.0: 8 | 9 | * [COOK-1715] - Add user and group to python_pip 10 | * [COOK-1727] - Python cookbook cannot install `pip` on CentOS 11 | versions < 6 12 | 13 | ## v1.0.8: 14 | 15 | * [COOK-1016] - python package needs separate names for centos/rhel 5.x vs 6.x 16 | * [COOK-1048] - installation of pip does not honor selected python version 17 | * [COOK-1282] - catch Chef::Exceptions::ShellCommandFailed for chef 0.10.8 compatibility 18 | * [COOK-1311] - virtualenv should have options attribute 19 | * [COOK-1320] - pip provider doesn't catch correct exception 20 | * [COOK-1415] - use plain 'python' binary instead of versioned one for 21 | default interpreter 22 | 23 | ## v1.0.6: 24 | 25 | * [COOK-1036] - correctly grep for python-module version 26 | * [COOK-1046] - run pip inside the virtualenv 27 | 28 | ## v1.0.4: 29 | 30 | * [COOK-960] - add timeout to python_pip 31 | * [COOK-651] - 'install_path' not correctly resolved when using python::source 32 | * [COOK-650] - Add ability to specify version when installing distribute. 33 | * [COOK-553] - FreeBSD support in the python cookbook 34 | -------------------------------------------------------------------------------- /cookbooks/python/CONTRIBUTING: -------------------------------------------------------------------------------- 1 | If you would like to contribute, please open a ticket in JIRA: 2 | 3 | * http://tickets.opscode.com 4 | 5 | Create the ticket in the COOK project and use the cookbook name as the 6 | component. 7 | 8 | For all code contributions, we ask that contributors sign a 9 | contributor license agreement (CLA). Instructions may be found here: 10 | 11 | * http://wiki.opscode.com/display/chef/How+to+Contribute 12 | 13 | When contributing changes to individual cookbooks, please do not 14 | modify the version number in the metadata.rb. Also please do not 15 | update the CHANGELOG.md for a new version. Not all changes to a 16 | cookbook may be merged and released in the same versions. Opscode will 17 | handle the version updates during the release process. You are welcome 18 | to correct typos or otherwise make updates to documentation in the 19 | README. 20 | 21 | If a contribution adds new platforms or platform versions, indicate 22 | such in the body of the commit message(s), and update the relevant 23 | COOK ticket. When writing commit messages, it is helpful for others if 24 | you indicate the COOK ticket. For example: 25 | 26 | git commit -m '[COOK-1041] Updated pool resource to correctly delete.' 27 | 28 | In the ticket itself, it is also helpful if you include log output of 29 | a successful Chef run, but this is not absolutely required. 30 | -------------------------------------------------------------------------------- /cookbooks/python/LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /cookbooks/python/README.md: -------------------------------------------------------------------------------- 1 | Description 2 | =========== 3 | 4 | Installs and configures Python. Also includes LWRPs for managing python packages with `pip` and `virtualenv` isolated Python environments. 5 | 6 | Requirements 7 | ============ 8 | 9 | Platform 10 | -------- 11 | 12 | * Debian, Ubuntu 13 | * CentOS, Red Hat, Fedora 14 | 15 | Cookbooks 16 | --------- 17 | 18 | * build-essential 19 | * yum 20 | 21 | NOTE: The `yum` cookbook is a dependency of the cookbook, and will be used to install [EPEL](http://fedoraproject.org/wiki/EPEL) on RedHet/CentOS 5.x systems to provide the Python 2.6 packages. 22 | 23 | Attributes 24 | ========== 25 | 26 | See `attributes/default.rb` for default values. 27 | 28 | * `node["python"]["install_method"]` - method to install python with, default `package`. 29 | 30 | The file also contains the following attributes: 31 | 32 | * platform specific locations and settings. 33 | * source installation settings 34 | 35 | Resource/Provider 36 | ================= 37 | 38 | This cookbook includes LWRPs for managing: 39 | 40 | * pip packages 41 | * virtualenv isolated Python environments 42 | 43 | `python_pip` 44 | ------------ 45 | 46 | Install packages using the new hotness in Python package management...[`pip`](http://pypi.python.org/pypi/pip). Yo dawg...easy_install is so 2009, you better ask your local Pythonista if you don't know! The usage semantics are like that of any normal package provider. 47 | 48 | # Actions 49 | 50 | - :install: Install a pip package - if version is provided, install that specific version 51 | - :upgrade: Upgrade a pip package - if version is provided, upgrade to that specific version 52 | - :remove: Remove a pip package 53 | - :user: User to run pip as, for using with virtualenv 54 | - :group: Group to run pip as, for using with virtualenv 55 | - :purge: Purge a pip package (this usually entails removing configuration files as well as the package itself). With pip packages this behaves the same as `:remove` 56 | 57 | # Attribute Parameters 58 | 59 | - package_name: name attribute. The name of the pip package to install 60 | - version: the version of the package to install/upgrade. If no version is given latest is assumed. 61 | - virtualenv: virtualenv environment to install pip package into 62 | - options: Add additional options to the underlying pip package command 63 | - timeout: timeout in seconds for the command to execute. Useful for pip packages that may take a long time to install. Default 900 seconds. 64 | 65 | # Example 66 | 67 | # install latest gunicorn into system path 68 | python_pip "gunicorn" do 69 | action :install 70 | end 71 | 72 | # target a virtualenv 73 | python_pip "gunicorn" do 74 | virtualenv "/home/ubunut/my_ve" 75 | action :install 76 | end 77 | 78 | # install Django 1.1.4 79 | python_pip "django" do 80 | version "1.1.4" 81 | action :install 82 | end 83 | 84 | # use this provider with the core package resource 85 | package "django" do 86 | provider Chef::Provider::PythonPip 87 | action :install 88 | end 89 | 90 | `python_virtualenv` 91 | ------------------- 92 | 93 | [`virtualenv`](http://pypi.python.org/pypi/virtualenv) is a great tool that creates isolated python environments. Think of it as RVM without all those hipsters and tight jeans. 94 | 95 | # Actions 96 | 97 | - :create: creates a new virtualenv 98 | - :delete: deletes an existing virtualenv 99 | 100 | # Attribute Parameters 101 | 102 | - path: name attribute. The path where the virtualenv will be created 103 | - interpreter: The Python interpreter to use. default is `python2.6` 104 | - owner: The owner for the virtualenv 105 | - group: The group owner of the file (string or id) 106 | - options : Command line options (string) 107 | 108 | # Example 109 | 110 | # create a 2.6 virtualenv owned by ubuntu user 111 | python_virtualenv "/home/ubuntu/my_cool_ve" do 112 | owner "ubuntu" 113 | group "ubuntu" 114 | action :create 115 | end 116 | 117 | # create a Python 2.4 virtualenv 118 | python_virtualenv "/home/ubuntu/my_old_ve" do 119 | interpreter "python2.4" 120 | owner "ubuntu" 121 | group "ubuntu" 122 | action :create 123 | end 124 | 125 | # create a Python 2.6 virtualenv with access to the global packages owned by ubuntu user 126 | python_virtualenv "/home/ubuntu/my_old_ve" do 127 | owner "ubuntu" 128 | group "ubuntu" 129 | options "--system-site-packages" 130 | action :create 131 | end 132 | 133 | Usage 134 | ===== 135 | 136 | default 137 | ------- 138 | 139 | Include default recipe in a run list, to get `python`, `pip` and `virtualenv`. Installs python by package or source depending on the platform. 140 | 141 | package 142 | ------- 143 | 144 | Installs Python from packages. 145 | 146 | source 147 | ------ 148 | 149 | Installs Python from source. 150 | 151 | pip 152 | --- 153 | 154 | Installs `pip` from source. 155 | 156 | virtualenv 157 | ---------- 158 | 159 | Installs virtualenv using the `python_pip` resource. 160 | 161 | License and Author 162 | ================== 163 | 164 | Author:: Seth Chisamore () 165 | 166 | Copyright:: 2011, Opscode, Inc 167 | 168 | Licensed under the Apache License, Version 2.0 (the "License"); 169 | you may not use this file except in compliance with the License. 170 | You may obtain a copy of the License at 171 | 172 | http://www.apache.org/licenses/LICENSE-2.0 173 | 174 | Unless required by applicable law or agreed to in writing, software 175 | distributed under the License is distributed on an "AS IS" BASIS, 176 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 177 | See the License for the specific language governing permissions and 178 | limitations under the License. 179 | -------------------------------------------------------------------------------- /cookbooks/python/attributes/default.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Author:: Seth Chisamore () 3 | # Cookbook Name:: python 4 | # Attribute:: default 5 | # 6 | # Copyright 2011, Opscode, Inc. 7 | # 8 | # Licensed under the Apache License, Version 2.0 (the "License"); 9 | # you may not use this file except in compliance with the License. 10 | # You may obtain a copy of the License at 11 | # 12 | # http://www.apache.org/licenses/LICENSE-2.0 13 | # 14 | # Unless required by applicable law or agreed to in writing, software 15 | # distributed under the License is distributed on an "AS IS" BASIS, 16 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | # See the License for the specific language governing permissions and 18 | # limitations under the License. 19 | # 20 | 21 | default['python']['install_method'] = 'package' 22 | 23 | if python['install_method'] == 'package' 24 | case platform 25 | when "smartos" 26 | default['python']['prefix_dir'] = '/opt/local' 27 | else 28 | default['python']['prefix_dir'] = '/usr' 29 | end 30 | else 31 | default['python']['prefix_dir'] = '/usr/local' 32 | end 33 | 34 | default['python']['binary'] = "#{python['prefix_dir']}/bin/python" 35 | 36 | default['python']['url'] = 'http://www.python.org/ftp/python' 37 | default['python']['version'] = '2.7.1' 38 | default['python']['checksum'] = '80e387bcf57eae8ce26726753584fd63e060ec11682d1145af921e85fd612292' 39 | default['python']['configure_options'] = %W{--prefix=#{python['prefix_dir']}} 40 | -------------------------------------------------------------------------------- /cookbooks/python/metadata.rb: -------------------------------------------------------------------------------- 1 | name "python" 2 | maintainer "Opscode, Inc." 3 | maintainer_email "cookbooks@opscode.com" 4 | license "Apache 2.0" 5 | description "Installs Python, pip and virtualenv. Includes LWRPs for managing Python packages with `pip` and `virtualenv` isolated Python environments." 6 | version "1.2.0" 7 | 8 | depends "build-essential" 9 | depends "yum" 10 | 11 | recipe "python", "Installs python, pip, and virtualenv" 12 | recipe "python::package", "Installs python using packages." 13 | recipe "python::source", "Installs python from source." 14 | recipe "python::pip", "Installs pip from source." 15 | recipe "python::virtualenv", "Installs virtualenv using the python_pip resource." 16 | 17 | %w{ debian ubuntu centos redhat fedora freebsd smartos }.each do |os| 18 | supports os 19 | end 20 | -------------------------------------------------------------------------------- /cookbooks/python/providers/pip.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Author:: Seth Chisamore 3 | # Cookbook Name:: python 4 | # Provider:: pip 5 | # 6 | # Copyright:: 2011, Opscode, Inc 7 | # 8 | # Licensed under the Apache License, Version 2.0 (the "License"); 9 | # you may not use this file except in compliance with the License. 10 | # You may obtain a copy of the License at 11 | # 12 | # http://www.apache.org/licenses/LICENSE-2.0 13 | # 14 | # Unless required by applicable law or agreed to in writing, software 15 | # distributed under the License is distributed on an "AS IS" BASIS, 16 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | # See the License for the specific language governing permissions and 18 | # limitations under the License. 19 | # 20 | 21 | require 'chef/mixin/shell_out' 22 | require 'chef/mixin/language' 23 | include Chef::Mixin::ShellOut 24 | 25 | def whyrun_supported? 26 | true 27 | end 28 | 29 | # the logic in all action methods mirror that of 30 | # the Chef::Provider::Package which will make 31 | # refactoring into core chef easy 32 | 33 | action :install do 34 | # If we specified a version, and it's not the current version, move to the specified version 35 | if @new_resource.version != nil && @new_resource.version != @current_resource.version 36 | install_version = @new_resource.version 37 | # If it's not installed at all, install it 38 | elsif @current_resource.version == nil 39 | install_version = candidate_version 40 | end 41 | 42 | if install_version 43 | description = "install package #{@new_resource} version #{install_version}" 44 | converge_by(description) do 45 | Chef::Log.info("Installing #{@new_resource} version #{install_version}") 46 | status = install_package(install_version) 47 | if status 48 | @new_resource.updated_by_last_action(true) 49 | end 50 | end 51 | end 52 | end 53 | 54 | action :upgrade do 55 | if @current_resource.version != candidate_version 56 | orig_version = @current_resource.version || "uninstalled" 57 | description = "upgrade #{@current_resource} version from #{@current_resource.version} to #{candidate_version}" 58 | converge_by(description) do 59 | Chef::Log.info("Upgrading #{@new_resource} version from #{orig_version} to #{candidate_version}") 60 | status = upgrade_package(candidate_version) 61 | if status 62 | @new_resource.updated_by_last_action(true) 63 | end 64 | end 65 | end 66 | end 67 | 68 | action :remove do 69 | if removing_package? 70 | description = "remove package #{@new_resource}" 71 | converge_by(description) do 72 | Chef::Log.info("Removing #{@new_resource}") 73 | remove_package(@new_resource.version) 74 | @new_resource.updated_by_last_action(true) 75 | end 76 | end 77 | end 78 | 79 | def removing_package? 80 | if @current_resource.version.nil? 81 | false # nothing to remove 82 | elsif @new_resource.version.nil? 83 | true # remove any version of a package 84 | elsif @new_resource.version == @current_resource.version 85 | true # remove the version we have 86 | else 87 | false # we don't have the version we want to remove 88 | end 89 | end 90 | 91 | # these methods are the required overrides of 92 | # a provider that extends from Chef::Provider::Package 93 | # so refactoring into core Chef should be easy 94 | 95 | def load_current_resource 96 | @current_resource = Chef::Resource::PythonPip.new(@new_resource.name) 97 | @current_resource.package_name(@new_resource.package_name) 98 | @current_resource.version(nil) 99 | 100 | unless current_installed_version.nil? 101 | @current_resource.version(current_installed_version) 102 | end 103 | 104 | @current_resource 105 | end 106 | 107 | def current_installed_version 108 | @current_installed_version ||= begin 109 | delimeter = /==/ 110 | 111 | version_check_cmd = "#{which_pip(@new_resource)} freeze | grep -i '^#{@new_resource.package_name}=='" 112 | # incase you upgrade pip with pip! 113 | if @new_resource.package_name.eql?('pip') 114 | delimeter = /\s/ 115 | version_check_cmd = "pip --version" 116 | end 117 | p = shell_out!(version_check_cmd) 118 | p.stdout.split(delimeter)[1].strip 119 | rescue Chef::Exceptions::ShellCommandFailed 120 | rescue Mixlib::ShellOut::ShellCommandFailed 121 | end 122 | end 123 | 124 | def candidate_version 125 | @candidate_version ||= begin 126 | # `pip search` doesn't return versions yet 127 | # `pip list` may be coming soon: 128 | # https://bitbucket.org/ianb/pip/issue/197/option-to-show-what-version-would-be 129 | @new_resource.version||'latest' 130 | end 131 | end 132 | 133 | def install_package(version) 134 | pip_cmd('install', version == 'latest' ? '' : "==#{version}") 135 | end 136 | 137 | def upgrade_package(version) 138 | @new_resource.options "#{@new_resource.options} --upgrade" 139 | install_package(version) 140 | end 141 | 142 | def remove_package(version) 143 | @new_resource.options "#{@new_resource.options} --yes" 144 | pip_cmd('uninstall') 145 | end 146 | 147 | def pip_cmd(subcommand, version='') 148 | options = { :timeout => @new_resource.timeout, :user => @new_resource.user, :group => @new_resource.group } 149 | options[:environment] = { 'HOME' => ::File.expand_path("~#{@new_resource.user}") } if @new_resource.user 150 | shell_out!("#{which_pip(@new_resource)} #{subcommand} #{@new_resource.options} #{@new_resource.name}#{version}", options) 151 | end 152 | 153 | # TODO remove when provider is moved into Chef core 154 | # this allows PythonPip to work with Chef::Resource::Package 155 | def which_pip(nr) 156 | if (nr.respond_to?("virtualenv") && nr.virtualenv) 157 | ::File.join(nr.virtualenv,'/bin/pip') 158 | elsif "#{node['python']['install_method']}".eql?("source") 159 | ::File.join("#{node['python']['prefix_dir']}","/bin/pip") 160 | else 161 | 'pip' 162 | end 163 | end 164 | -------------------------------------------------------------------------------- /cookbooks/python/providers/virtualenv.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Author:: Seth Chisamore 3 | # Cookbook Name:: python 4 | # Provider:: virtualenv 5 | # 6 | # Copyright:: 2011, Opscode, Inc 7 | # 8 | # Licensed under the Apache License, Version 2.0 (the "License"); 9 | # you may not use this file except in compliance with the License. 10 | # You may obtain a copy of the License at 11 | # 12 | # http://www.apache.org/licenses/LICENSE-2.0 13 | # 14 | # Unless required by applicable law or agreed to in writing, software 15 | # distributed under the License is distributed on an "AS IS" BASIS, 16 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | # See the License for the specific language governing permissions and 18 | # limitations under the License. 19 | # 20 | 21 | require 'chef/mixin/shell_out' 22 | require 'chef/mixin/language' 23 | include Chef::Mixin::ShellOut 24 | 25 | def whyrun_supported? 26 | true 27 | end 28 | 29 | action :create do 30 | unless exists? 31 | Chef::Log.info("Creating virtualenv #{@new_resource} at #{@new_resource.path}") 32 | execute "#{virtualenv_cmd} --python=#{@new_resource.interpreter} #{@new_resource.options} #{@new_resource.path}" do 33 | user new_resource.owner if new_resource.owner 34 | group new_resource.group if new_resource.group 35 | end 36 | new_resource.updated_by_last_action(true) 37 | end 38 | end 39 | 40 | action :delete do 41 | if exists? 42 | description = "delete virtualenv #{@new_resource} at #{@new_resource.path}" 43 | converge_by(description) do 44 | Chef::Log.info("Deleting virtualenv #{@new_resource} at #{@new_resource.path}") 45 | FileUtils.rm_rf(@new_resource.path) 46 | end 47 | end 48 | end 49 | 50 | def load_current_resource 51 | @current_resource = Chef::Resource::PythonVirtualenv.new(@new_resource.name) 52 | @current_resource.path(@new_resource.path) 53 | 54 | if exists? 55 | cstats = ::File.stat(@current_resource.path) 56 | @current_resource.owner(cstats.uid) 57 | @current_resource.group(cstats.gid) 58 | end 59 | @current_resource 60 | end 61 | 62 | def virtualenv_cmd() 63 | if "#{node['python']['install_method']}".eql?("source") 64 | ::File.join("#{node['python']['prefix_dir']}","/bin/virtualenv") 65 | else 66 | "virtualenv" 67 | end 68 | end 69 | 70 | private 71 | def exists? 72 | ::File.exist?(@current_resource.path) && ::File.directory?(@current_resource.path) \ 73 | && ::File.exists?("#{@current_resource.path}/bin/activate") 74 | end 75 | -------------------------------------------------------------------------------- /cookbooks/python/recipes/default.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Author:: Seth Chisamore 3 | # Cookbook Name:: python 4 | # Recipe:: default 5 | # 6 | # Copyright 2011, Opscode, Inc. 7 | # 8 | # Licensed under the Apache License, Version 2.0 (the "License"); 9 | # you may not use this file except in compliance with the License. 10 | # You may obtain a copy of the License at 11 | # 12 | # http://www.apache.org/licenses/LICENSE-2.0 13 | # 14 | # Unless required by applicable law or agreed to in writing, software 15 | # distributed under the License is distributed on an "AS IS" BASIS, 16 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | # See the License for the specific language governing permissions and 18 | # limitations under the License. 19 | # 20 | 21 | include_recipe "python::#{node['python']['install_method']}" 22 | include_recipe "python::pip" 23 | include_recipe "python::virtualenv" -------------------------------------------------------------------------------- /cookbooks/python/recipes/package.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Author:: Seth Chisamore 3 | # Cookbook Name:: python 4 | # Recipe:: package 5 | # 6 | # Copyright 2011, Opscode, Inc. 7 | # 8 | # Licensed under the Apache License, Version 2.0 (the "License"); 9 | # you may not use this file except in compliance with the License. 10 | # You may obtain a copy of the License at 11 | # 12 | # http://www.apache.org/licenses/LICENSE-2.0 13 | # 14 | # Unless required by applicable law or agreed to in writing, software 15 | # distributed under the License is distributed on an "AS IS" BASIS, 16 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | # See the License for the specific language governing permissions and 18 | # limitations under the License. 19 | # 20 | 21 | major_version = node['platform_version'].split('.').first.to_i 22 | 23 | # COOK-1016 Handle RHEL/CentOS namings of python packages, by installing EPEL 24 | # repo & package 25 | if platform_family?('rhel') && major_version < 6 26 | include_recipe 'yum::epel' 27 | python_pkgs = ["python26", "python26-devel"] 28 | node['python']['binary'] = "/usr/bin/python26" 29 | else 30 | python_pkgs = value_for_platform_family( 31 | "debian" => ["python","python-dev"], 32 | "rhel" => ["python","python-devel"], 33 | "freebsd" => ["python"], 34 | "smartos" => ["python27"], 35 | "default" => ["python","python-dev"] 36 | ) 37 | end 38 | 39 | python_pkgs.each do |pkg| 40 | package pkg do 41 | action :install 42 | end 43 | end 44 | -------------------------------------------------------------------------------- /cookbooks/python/recipes/pip.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Author:: Seth Chisamore 3 | # Cookbook Name:: python 4 | # Recipe:: pip 5 | # 6 | # Copyright 2011, Opscode, Inc. 7 | # 8 | # Licensed under the Apache License, Version 2.0 (the "License"); 9 | # you may not use this file except in compliance with the License. 10 | # You may obtain a copy of the License at 11 | # 12 | # http://www.apache.org/licenses/LICENSE-2.0 13 | # 14 | # Unless required by applicable law or agreed to in writing, software 15 | # distributed under the License is distributed on an "AS IS" BASIS, 16 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | # See the License for the specific language governing permissions and 18 | # limitations under the License. 19 | # 20 | 21 | if platform_family?("rhel") and node['python']['install_method'] == 'package' 22 | pip_binary = "/usr/bin/pip" 23 | elsif platform_family?("smartos") 24 | pip_binary = "/opt/local/bin/pip" 25 | else 26 | pip_binary = "/usr/local/bin/pip" 27 | end 28 | 29 | # Ubuntu's python-setuptools, python-pip and python-virtualenv packages 30 | # are broken...this feels like Rubygems! 31 | # http://stackoverflow.com/questions/4324558/whats-the-proper-way-to-install-pip-virtualenv-and-distribute-for-python 32 | # https://bitbucket.org/ianb/pip/issue/104/pip-uninstall-on-ubuntu-linux 33 | remote_file "#{Chef::Config[:file_cache_path]}/distribute_setup.py" do 34 | source "http://python-distribute.org/distribute_setup.py" 35 | mode "0644" 36 | not_if { ::File.exists?(pip_binary) } 37 | end 38 | 39 | execute "install-pip" do 40 | cwd Chef::Config[:file_cache_path] 41 | command <<-EOF 42 | #{node['python']['binary']} distribute_setup.py 43 | #{::File.dirname(pip_binary)}/easy_install pip 44 | EOF 45 | not_if { ::File.exists?(pip_binary) } 46 | end 47 | -------------------------------------------------------------------------------- /cookbooks/python/recipes/source.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Author:: Seth Chisamore 3 | # Cookbook Name:: python 4 | # Recipe:: source 5 | # 6 | # Copyright 2011, Opscode, Inc. 7 | # 8 | # Licensed under the Apache License, Version 2.0 (the "License"); 9 | # you may not use this file except in compliance with the License. 10 | # You may obtain a copy of the License at 11 | # 12 | # http://www.apache.org/licenses/LICENSE-2.0 13 | # 14 | # Unless required by applicable law or agreed to in writing, software 15 | # distributed under the License is distributed on an "AS IS" BASIS, 16 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | # See the License for the specific language governing permissions and 18 | # limitations under the License. 19 | # 20 | 21 | configure_options = node['python']['configure_options'].join(" ") 22 | 23 | packages = value_for_platform_family( 24 | "rhel" => ["openssl-devel","bzip2-devel","zlib-devel","expat-devel","db4-devel","sqlite-devel","ncurses-devel","readline-devel"], 25 | "default" => ["libssl-dev","libbz2-dev","zlib1g-dev","libexpat1-dev","libdb4.8-dev","libsqlite3-dev","libncursesw5-dev","libncurses5-dev","libreadline-dev"] 26 | ) 27 | 28 | packages.each do |dev_pkg| 29 | package dev_pkg 30 | end 31 | 32 | version = node['python']['version'] 33 | install_path = "#{node['python']['prefix_dir']}/lib/python#{version.split(/(^\d+\.\d+)/)[1]}" 34 | 35 | remote_file "#{Chef::Config[:file_cache_path]}/Python-#{version}.tar.bz2" do 36 | source "#{node['python']['url']}/#{version}/Python-#{version}.tar.bz2" 37 | checksum node['python']['checksum'] 38 | mode "0644" 39 | not_if { ::File.exists?(install_path) } 40 | end 41 | 42 | bash "build-and-install-python" do 43 | cwd Chef::Config[:file_cache_path] 44 | code <<-EOF 45 | tar -jxvf Python-#{version}.tar.bz2 46 | (cd Python-#{version} && ./configure #{configure_options}) 47 | (cd Python-#{version} && make && make install) 48 | EOF 49 | not_if { ::File.exists?(install_path) } 50 | end 51 | -------------------------------------------------------------------------------- /cookbooks/python/recipes/virtualenv.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Author:: Seth Chisamore 3 | # Cookbook Name:: python 4 | # Recipe:: virtualenv 5 | # 6 | # Copyright 2011, Opscode, Inc. 7 | # 8 | # Licensed under the Apache License, Version 2.0 (the "License"); 9 | # you may not use this file except in compliance with the License. 10 | # You may obtain a copy of the License at 11 | # 12 | # http://www.apache.org/licenses/LICENSE-2.0 13 | # 14 | # Unless required by applicable law or agreed to in writing, software 15 | # distributed under the License is distributed on an "AS IS" BASIS, 16 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | # See the License for the specific language governing permissions and 18 | # limitations under the License. 19 | # 20 | 21 | include_recipe "python::pip" 22 | 23 | python_pip "virtualenv" do 24 | action :install 25 | end 26 | -------------------------------------------------------------------------------- /cookbooks/python/resources/pip.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Author:: Seth Chisamore 3 | # Cookbook Name:: python 4 | # Resource:: pip 5 | # 6 | # Copyright:: 2011, Opscode, Inc 7 | # 8 | # Licensed under the Apache License, Version 2.0 (the "License"); 9 | # you may not use this file except in compliance with the License. 10 | # You may obtain a copy of the License at 11 | # 12 | # http://www.apache.org/licenses/LICENSE-2.0 13 | # 14 | # Unless required by applicable law or agreed to in writing, software 15 | # distributed under the License is distributed on an "AS IS" BASIS, 16 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | # See the License for the specific language governing permissions and 18 | # limitations under the License. 19 | # 20 | 21 | actions :install, :upgrade, :remove, :purge 22 | 23 | attribute :package_name, :kind_of => String, :name_attribute => true 24 | attribute :version, :default => nil 25 | attribute :timeout, :default => 900 26 | attribute :virtualenv, :kind_of => String 27 | attribute :user, :regex => Chef::Config[:user_valid_regex] 28 | attribute :group, :regex => Chef::Config[:group_valid_regex] 29 | attribute :options, :kind_of => String, :default => '' 30 | -------------------------------------------------------------------------------- /cookbooks/python/resources/virtualenv.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Author:: Seth Chisamore 3 | # Cookbook Name:: python 4 | # Resource:: virtualenv 5 | # 6 | # Copyright:: 2011, Opscode, Inc 7 | # 8 | # Licensed under the Apache License, Version 2.0 (the "License"); 9 | # you may not use this file except in compliance with the License. 10 | # You may obtain a copy of the License at 11 | # 12 | # http://www.apache.org/licenses/LICENSE-2.0 13 | # 14 | # Unless required by applicable law or agreed to in writing, software 15 | # distributed under the License is distributed on an "AS IS" BASIS, 16 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | # See the License for the specific language governing permissions and 18 | # limitations under the License. 19 | # 20 | 21 | actions :create, :delete 22 | 23 | attribute :path, :kind_of => String, :name_attribute => true 24 | attribute :interpreter, :default => 'python' 25 | attribute :owner, :regex => Chef::Config[:user_valid_regex] 26 | attribute :group, :regex => Chef::Config[:group_valid_regex] 27 | attribute :options, :kind_of => String 28 | -------------------------------------------------------------------------------- /deploy.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Usage: ./deploy.sh [root@host] (Only root can deploy) 4 | 5 | host="${1}" 6 | 7 | # The host key might change when we instantiate a new VM, so 8 | # we remove (-R) the old host key from known_hosts 9 | ssh-keygen -R "${host#*@}" 2> /dev/null 10 | 11 | tar c . | ssh -o 'StrictHostKeyChecking no' "$host" ' 12 | echo "*******************" 13 | echo "DEPLOY OUTPUT START" 14 | echo "*******************" 15 | rm -rf ~/chef && 16 | mkdir ~/chef && 17 | cd ~/chef && 18 | tar x && 19 | bash bootstrap.sh' 20 | 21 | echo "*****************" 22 | echo "DEPLOY OUTPUT END" 23 | echo "*****************" 24 | -------------------------------------------------------------------------------- /solo.json: -------------------------------------------------------------------------------- 1 | { 2 | "run_list": [ 3 | "recipe[apt]", 4 | "recipe[build-essential]", 5 | "recipe[openssl]", 6 | "recipe[postgresql::client]", 7 | "recipe[postgresql::server]", 8 | "recipe[git]", 9 | "recipe[python]", 10 | "recipe[nodejs::install_from_package]", 11 | "recipe[openruko::default]", 12 | "recipe[openruko::apiserver]", 13 | "recipe[openruko::logplex]", 14 | "recipe[openruko::httprouting]", 15 | "recipe[openruko::gitmouth]", 16 | "recipe[openruko::client]", 17 | "recipe[openruko::integration-tests]", 18 | "recipe[openruko::dynohost]", 19 | "recipe[fakes3]", 20 | "recipe[heroku-toolbelt]" 21 | ], 22 | 23 | "versions" : { 24 | "apiserver": "v0.2.1", 25 | "client": "v0.1.1", 26 | "codonhooks": "v0.1.1", 27 | "dynohost": "v0.2.1", 28 | "httprouting": "v0.2.1", 29 | "integration-tests": "v0.1.4", 30 | "logplex": "v0.1.0", 31 | "gitmouth": "v0.1.2", 32 | "rukorun": "v0.1.2" 33 | }, 34 | 35 | "user": "rukosan", 36 | "group": "rukosan", 37 | "home": "/home/rukosan", 38 | 39 | "openruko": { 40 | "host": "mymachine.me", 41 | "home": "/home/rukosan/openruko", 42 | "passsword": "rukosan", 43 | "apiserver_key": "ec1a8eb9-18a6-42c2-81ec-c0f0f615280c", 44 | "apiserver_host": "openruko.local", 45 | "apiserver_ip": "127.0.0.1", 46 | "dev_domain": "openruko.local", 47 | "live_domain": "openruko.com" 48 | }, 49 | 50 | "s3": { 51 | "s3_key": "123", 52 | "s3_secret": "123", 53 | "s3_bucket": "openruko", 54 | "s3_hostname": "openruko.local", 55 | "s3_port": "4567" 56 | }, 57 | 58 | "fakes3": { 59 | "user": "rukosan", 60 | "group": "rukosan" 61 | }, 62 | 63 | "postgresql": { 64 | "version": "9.1", 65 | "listen_addresses": "*", 66 | "pg_hba": [ 67 | { "type": "host", "db": "all", "user": "all", "addr": "0.0.0.0/0", "method": "md5" }, 68 | { "type": "host", "db": "all", "user": "all", "addr": "::1/0", "method": "md5" } 69 | ], 70 | "password": { 71 | "postgres": "password", 72 | "rukosan": "rukosan" 73 | } 74 | }, 75 | 76 | "nodejs": { 77 | 78 | "version": "0.8.6", 79 | "npm": "1.1.48", 80 | "legacy_packages": true 81 | } 82 | 83 | } 84 | -------------------------------------------------------------------------------- /solo.rb: -------------------------------------------------------------------------------- 1 | root = File.absolute_path(File.dirname(__FILE__)) 2 | 3 | file_cache_path root 4 | cookbook_path root + '/cookbooks' -------------------------------------------------------------------------------- /standalone/Vagrantfile: -------------------------------------------------------------------------------- 1 | require File.join(File.dirname(__FILE__), "..", "vagrant_common") 2 | 3 | Vagrant::Config.run do |config| 4 | config.vm.box = "precise64" 5 | config.vm.box_url = "http://files.vagrantup.com/precise64.box" 6 | 7 | # Or use the Travis CI environment to fix Travis-specific buidl failures 8 | # See http://ruby-journal.com/debug-your-failed-test-in-travis-ci/ for more info 9 | #config.vm.box = "travis-ruby" 10 | 11 | # Allow access to the VM's IP from host 12 | config.vm.network :bridged 13 | 14 | config.vm.share_folder "chef", "/chef", "../" 15 | 16 | config.vm.provision :chef_solo do |chef| 17 | chef.cookbooks_path = '../cookbooks' 18 | 19 | # First apply proxy recipe 20 | proxy_set(chef) 21 | json_load(chef) 22 | 23 | # Override solo.json to use vagrant user 24 | chef.json["user"] = "vagrant" 25 | chef.json["group"] = "vagrant" 26 | chef.json["home"] = "/home/vagrant" 27 | chef.json["openruko"]["home"] = "/home/vagrant/openruko" 28 | chef.json["openruko"]["password"] = "vagrant" 29 | chef.json["s3"] = { 30 | s3_key: "123", 31 | s3_secret: "123", 32 | s3_bucket: "openruko", 33 | s3_hostname: "mymachine.me", 34 | s3_port: "4567" 35 | } 36 | chef.json["fakes3"]["user"] = "vagrant" 37 | chef.json["fakes3"]["group"] = "vagrant" 38 | chef.json["postgresql"]["password"]["vagrant"] = "vagrant" 39 | 40 | chef.json["run_list"].each do |recipe_name| 41 | chef.add_recipe recipe_name 42 | end 43 | end 44 | 45 | end 46 | 47 | # If you want to do some funky custom stuff to your box, but don't want those things tracked by git, 48 | # add a Vagrantfile.local and it will be included. For example you could mount your dev version of 49 | # openruko with; 50 | # config.vm.share_folder "openruko", "/home/rukosan/openruko_mount", "~/Software/openruko" 51 | # Then symlink the various repos you're hacking on to see changes straight away on the live box. 52 | load "../Vagrantfile.local" if File.exists? "../Vagrantfile.local" 53 | -------------------------------------------------------------------------------- /unlock_versions.rb: -------------------------------------------------------------------------------- 1 | # This script unlocks all the openruko dependencies in solo.json from their tagged versions. 2 | # This allows us to manually trigger Travis builds to test the bleeding edge versions of the dependencies. 3 | 4 | require 'json' 5 | 6 | file = File.dirname(__FILE__) + '/solo.json' 7 | 8 | data = JSON.parse(IO.read(file)) 9 | 10 | data['versions'].each do |repo, version| 11 | data['versions'][repo] = 'master' unless repo == 'client' 12 | end 13 | 14 | File.open(file,"w") do |f| 15 | f.write(data.to_json) 16 | end 17 | -------------------------------------------------------------------------------- /vagrant_common.rb: -------------------------------------------------------------------------------- 1 | root = File.expand_path(File.dirname(__FILE__)) 2 | 3 | ENV["CHEF_GLOBAL"] = ENV["CHEF_GLOBAL"] || File.join(root, "solo.json") 4 | ENV["CHEF_LOCAL"] = ENV["CHEF_LOCAL"] || File.join(root, "solo.local.json") 5 | 6 | def rmerge(hash, other_hash) 7 | r = {} 8 | hash.merge(other_hash) do |key, oldval, newval| 9 | r[key] = oldval.class == hash.class ? rmerge(oldval, newval) : newval 10 | end 11 | end 12 | 13 | def proxy_set(chef) 14 | if ENV["HTTP_PROXY"] 15 | chef.add_recipe 'proxy' 16 | chef.json = rmerge(chef.json || {}, { 17 | :proxy => { 18 | :http_proxy => ENV['HTTP_PROXY'], 19 | :https_proxy => ENV['HTTPS_PROXY'], 20 | :no_proxy => "mymachine.me," + (ENV['NO_PROXY'] || '') 21 | } 22 | }) 23 | end 24 | end 25 | 26 | def json_load(chef) 27 | chef.json = chef.json || {} 28 | files = [ENV["CHEF_GLOBAL"], ENV["CHEF_LOCAL"]] 29 | files.each do |file_json| 30 | if File.exists?(file_json) 31 | chef.json = rmerge(chef.json, JSON.parse(File.open(file_json, &:read))) 32 | end 33 | end 34 | 35 | (chef.json.delete("reject_run") || []).each do |recipe| 36 | chef.json["run_list"].delete(recipe) 37 | end 38 | end --------------------------------------------------------------------------------