├── .foodcritic ├── .gitignore ├── .kitchen.cloud.yml ├── .kitchen.yml ├── .rubocop.yml ├── .travis.yml ├── Berksfile ├── CHANGELOG.md ├── Gemfile ├── Guardfile ├── README.md ├── Rakefile ├── attributes ├── default.rb ├── package.rb └── source.rb ├── libraries └── cuttlefish.rb ├── metadata.rb ├── recipes ├── default.rb ├── java.rb ├── package.rb ├── source.rb └── sysctl.rb ├── templates └── freebsd │ └── rcd.erb ├── test └── integration │ ├── custom_package │ └── serverspec │ │ ├── custom_package_spec.rb │ │ └── spec_helper.rb │ ├── custom_repository │ └── serverspec │ │ ├── custom_repository_spec.rb │ │ └── spec_helper.rb │ ├── default │ └── serverspec │ │ ├── default_spec.rb │ │ └── spec_helper.rb │ ├── enterprise │ └── serverspec │ │ ├── enterprise_spec.rb │ │ └── spec_helper.rb │ ├── search │ └── serverspec │ │ ├── search_spec.rb │ │ └── spec_helper.rb │ ├── source │ └── rspec │ │ ├── Gemfile │ │ ├── source_spec.rb │ │ └── spec_helper.rb │ └── sysctl │ └── serverspec │ ├── spec_helper.rb │ └── sysctl_spec.rb └── vagrantfile_bsd.erb /.foodcritic: -------------------------------------------------------------------------------- 1 | ~FC024 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .vagrant 2 | Berksfile.lock 3 | Gemfile.lock 4 | *~ 5 | *# 6 | .#* 7 | \#*# 8 | .*.sw[a-z] 9 | *.un~ 10 | .bundle 11 | .cache 12 | .kitchen 13 | .rspec 14 | bin 15 | .kitchen.local.yml 16 | tmp 17 | -------------------------------------------------------------------------------- /.kitchen.cloud.yml: -------------------------------------------------------------------------------- 1 | <% 2 | version = '2.1.1' 3 | split = version.split('.') 4 | maj = split[0] 5 | min = split[1] 6 | inc = split[2] 7 | url = "http://s3.amazonaws.com/downloads.basho.com/riak/#{maj}.#{min}" 8 | %> 9 | --- 10 | 11 | provisioner: 12 | name: chef_zero 13 | require_chef_omnibus: 12.6.0 14 | 15 | platforms: 16 | - name: amazon-2014.09.01 17 | driver: 18 | name: ec2 19 | image_id: ami-5ba7ea6b 20 | transport: 21 | username: ec2-user 22 | ssh_key: <%= ENV["EC2_SSH_KEY_PATH"] %> 23 | run_list: 24 | - recipe[yum-epel] 25 | attributes: 26 | riak: 27 | package: 28 | local: 29 | url: "<%= url %>/<%= version %>/rhel/6" 30 | - name: ubuntu-14-04-x64 31 | driver: 32 | name: digitalocean 33 | run_list: 34 | - recipe[apt] 35 | attributes: 36 | riak: 37 | package: 38 | local: 39 | url: "<%= url %>/<%= version %>/ubuntu/trusty" 40 | - name: ubuntu-12-04-x64 41 | driver: 42 | name: digitalocean 43 | run_list: 44 | - recipe[apt] 45 | attributes: 46 | riak: 47 | package: 48 | local: 49 | url: "<%= url %>/<%= version %>/ubuntu/precise" 50 | - name: debian-7-0-x64 51 | driver: 52 | name: digitalocean 53 | run_list: 54 | - recipe[apt] 55 | attributes: 56 | riak: 57 | package: 58 | local: 59 | url: "<%= url %>/<%= version %>/debian/7" 60 | - name: centos-7-0-x64 61 | driver: 62 | name: digitalocean 63 | run_list: 64 | - recipe[yum-epel] 65 | attributes: 66 | riak: 67 | package: 68 | local: 69 | url: "<%= url %>/<%= version %>/rhel/7" 70 | - name: centos-6-5-x64 71 | driver: 72 | name: digitalocean 73 | run_list: 74 | - recipe[yum-epel] 75 | attributes: 76 | riak: 77 | package: 78 | local: 79 | url: "<%= url %>/<%= version %>/rhel/6" 80 | - name: centos-5-8-x64 81 | driver: 82 | name: digitalocean 83 | run_list: 84 | - recipe[yum-epel] 85 | attributes: 86 | riak: 87 | package: 88 | local: 89 | url: "<%= url %>/<%= version %>/rhel/5" 90 | 91 | suites: 92 | - name: default 93 | run_list: 94 | - recipe[riak::sysctl] 95 | - recipe[riak] 96 | attributes: 97 | riak: 98 | package: 99 | local: 100 | filename: "" 101 | version: 102 | major: <%= maj %> 103 | minor: <%= min %> 104 | incremental: <%= inc %> 105 | - name: search 106 | run_list: 107 | - recipe[riak::sysctl] 108 | - recipe[riak] 109 | attributes: 110 | riak: 111 | manage_java: true 112 | package: 113 | version: 114 | major: <%= maj %> 115 | minor: <%= min %> 116 | incremental: <%= inc %> 117 | config: 118 | search.top_level: "on" 119 | - name: enterprise 120 | run_list: 121 | - recipe[riak::sysctl] 122 | - recipe[riak] 123 | attributes: 124 | riak: 125 | package: 126 | version: 127 | major: <%= maj %> 128 | minor: <%= min %> 129 | incremental: <%= inc %> 130 | local: 131 | url: "" 132 | enterprise_key: <%= (ENV["RIAK_ENTERPRISE_KEY"].nil? ? "" : ENV["RIAK_ENTERPRISE_KEY"]) %> 133 | - name: custom_package 134 | run_list: 135 | - recipe[riak::sysctl] 136 | - recipe[riak] 137 | attributes: 138 | riak: 139 | install_method: "custom_package" 140 | - name: source 141 | run_list: 142 | - recipe[riak::sysctl] 143 | - recipe[riak] 144 | attributes: 145 | riak: 146 | install_method: "source" 147 | source: 148 | major: <%= maj %> 149 | minor: <%= min %> 150 | incremental: <%= inc %> 151 | - name: sysctl 152 | run_list: 153 | - recipe[riak::sysctl] 154 | -------------------------------------------------------------------------------- /.kitchen.yml: -------------------------------------------------------------------------------- 1 | <% 2 | version = '2.1.1' 3 | split = version.split('.') 4 | maj = split[0] 5 | min = split[1] 6 | inc = split[2] 7 | url = "http://s3.amazonaws.com/downloads.basho.com/riak/#{maj}.#{min}" 8 | %> 9 | --- 10 | driver: 11 | name: vagrant 12 | require_chef_omnibus: 12.6.0 13 | customize: 14 | memory: 512 15 | 16 | provisioner: 17 | name: chef_zero 18 | 19 | platforms: 20 | - name: ubuntu-14.04 21 | run_list: 22 | - recipe[apt] 23 | attributes: 24 | riak: 25 | package: 26 | local: 27 | url: "<%= url %>/<%= version %>/ubuntu/trusty" 28 | - name: ubuntu-12.04 29 | run_list: 30 | - recipe[apt] 31 | attributes: 32 | riak: 33 | package: 34 | local: 35 | url: "<%= url %>/<%= version %>/ubuntu/precise" 36 | - name: debian-7.8 37 | run_list: 38 | - recipe[apt] 39 | attributes: 40 | riak: 41 | package: 42 | local: 43 | url: "<%= url %>/<%= version %>/debian/7" 44 | - name: centos-7.3 45 | run_list: 46 | - recipe[yum-epel] 47 | attributes: 48 | riak: 49 | package: 50 | local: 51 | url: "<%= url %>/<%= version %>/rhel/7" 52 | - name: centos-6.8 53 | run_list: 54 | - recipe[yum-epel] 55 | attributes: 56 | riak: 57 | package: 58 | local: 59 | url: "<%= url %>/<%= version %>/rhel/6" 60 | - name: centos-5.11 61 | run_list: 62 | - recipe[yum-epel] 63 | attributes: 64 | riak: 65 | package: 66 | local: 67 | url: "<%= url %>/<%= version %>/rhel/5" 68 | - name: freebsd-10.3 69 | run_list: 70 | - recipe[freebsd::portsnap] 71 | attributes: 72 | riak: 73 | package: 74 | local: 75 | url: "<%= url %>/<%= version %>/freebsd/10" 76 | suites: 77 | - name: default 78 | run_list: 79 | - recipe[riak::sysctl] 80 | - recipe[riak] 81 | attributes: 82 | riak: 83 | package: 84 | version: 85 | major: <%= maj %> 86 | minor: <%= min %> 87 | incremental: <%= inc %> 88 | - name: search 89 | run_list: 90 | - recipe[riak::sysctl] 91 | - recipe[riak] 92 | attributes: 93 | riak: 94 | manage_java: true 95 | package: 96 | version: 97 | major: <%= maj %> 98 | minor: <%= min %> 99 | incremental: <%= inc %> 100 | config: 101 | search.top_level: "on" 102 | excludes: ["freebsd-10.3"] 103 | - name: enterprise 104 | run_list: 105 | - recipe[riak::sysctl] 106 | - recipe[riak] 107 | attributes: 108 | riak: 109 | package: 110 | version: 111 | major: <%= maj %> 112 | minor: <%= min %> 113 | incremental: <%= inc %> 114 | local: 115 | url: "" 116 | enterprise_key: <%= (ENV["RIAK_ENTERPRISE_KEY"].nil? ? "" : ENV["RIAK_ENTERPRISE_KEY"]) %> 117 | - name: custom_package 118 | run_list: 119 | - recipe[riak::sysctl] 120 | - recipe[riak] 121 | attributes: 122 | riak: 123 | install_method: "custom_package" 124 | - name: source 125 | run_list: 126 | - recipe[riak::sysctl] 127 | - recipe[riak] 128 | attributes: 129 | riak: 130 | install_method: "source" 131 | source: 132 | major: <%= maj %> 133 | minor: <%= min %> 134 | incremental: <%= inc %> 135 | excludes: ["freebsd-10.3"] 136 | - name: sysctl 137 | run_list: 138 | - recipe[riak::sysctl] 139 | excludes: ["freebsd-10.3"] 140 | -------------------------------------------------------------------------------- /.rubocop.yml: -------------------------------------------------------------------------------- 1 | AllCops: 2 | Exclude: 3 | - bin/**/* 4 | - script/**/* 5 | - vendor/**/* 6 | 7 | AlignParameters: 8 | Enabled: false 9 | ClassAndModuleChildren: 10 | Enabled: false 11 | Documentation: 12 | Enabled: false 13 | DoubleNegation: 14 | Enabled: false 15 | Encoding: 16 | Enabled: false 17 | GuardClause: 18 | Enabled: false 19 | LineLength: 20 | Max: 160 21 | MethodLength: 22 | Max: 20 23 | PercentLiteralDelimiters: 24 | Enabled: false 25 | SignalException: 26 | Enabled: false 27 | SingleSpaceBeforeFirstArg: 28 | Enabled: false 29 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | 2 | language: ruby 3 | 4 | rvm: 5 | - 2.3.1 6 | 7 | bundler_args: --jobs 7 --without kitchen_vagrant --without development 8 | 9 | before_install: 10 | - export USE_SYSTEM_GECODE=1 11 | - sudo apt-get -y install libgecode-dev 12 | 13 | script: bundle exec rake travis:ci 14 | -------------------------------------------------------------------------------- /Berksfile: -------------------------------------------------------------------------------- 1 | source 'https://supermarket.getchef.com' 2 | 3 | metadata 4 | 5 | group :integration do 6 | cookbook 'apt' 7 | cookbook 'yum' 8 | cookbook 'freebsd' 9 | cookbook 'pkg_add' 10 | end 11 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## v3.1.4 2 | 3 | * Fix URL location for new EE package locations 4 | 5 | ## v3.1.3 6 | 7 | * Fix config content to be lazily evaluated 8 | 9 | ## v3.1.2 10 | 11 | * Fix basho-patches directory 12 | 13 | ## v3.1.1 14 | 15 | * Riak `2.1.1` is now the default 16 | * Updated syctl tuning and made optional #169 17 | * Relaxed dependency constraints #168 18 | * Fixed building from source on Amazon #175 19 | 20 | ## v3.1.0 21 | 22 | * Riak `2.0.5` is now the default 23 | * Removal of `enterprise_package recipe` 24 | * Removal of `custom_package recipe` 25 | * All logic for the removed recipes moved to `package` 26 | * Make Java install truely optional instead of based on config 27 | * Remove extraneous attributes 28 | * Checksums moved to attributes 29 | * Cleaned up test-kitchen configs to refelct above changes 30 | * FreeBSD support (finally) 31 | 32 | ## v3.0.2 33 | 34 | * Riak `2.0.2` is now the default 35 | * Updated build-essentials dependency 36 | 37 | ## v3.0.1 38 | 39 | * Fixes enterprise package installs 40 | * Passing all RuboCop checks 41 | * Lots of small testing related fixes 42 | * Pinning JDK version 43 | 44 | ## v3.0.0 45 | 46 | * Riak `2.0.1` is now the default 47 | * Add CentOS 7 Support 48 | * Migrate to packagecloud.io repos 49 | 50 | ## v2.4.17 51 | 52 | * Fix and update tests 53 | * Add digitalocean to .kitchen.cloud.yml 54 | * Add source build suite to .kitchen.cloud.yml 55 | 56 | ## v2.4.16 57 | 58 | * If fqdn isn't valid, use ipaddress for vm.args -name 59 | * Drop 13.10 support (EOL) 60 | * Drop minitest for serverspec 61 | * Update yum dependency which fixes https://github.com/opscode-cookbooks/yum/issues/99 62 | 63 | 64 | ## v2.4.15: 65 | 66 | * Update Riak CS default version to 1.5.1 67 | 68 | ## v2.4.14: 69 | 70 | * Riak `1.4.10` is now the default. 71 | * Remove Ubuntu 13.04 support (EOL). 72 | * Add Ubuntu 13.10 support 73 | * Add Ubuntu 14.04 support 74 | 75 | ## v2.4.13: 76 | 77 | * Increase pessimistic version constraint on `build-essential`. 78 | * Restrict version constraint on `sysctl` due to breaking changes. 79 | 80 | ## v2.4.12: 81 | 82 | * Increase default `ulimit` from `4096` to `65536`. 83 | 84 | ## v2.4.11: 85 | 86 | * Ensure SNMP directory is created when customer `data_dir` is provided. 87 | 88 | ## v2.4.10: 89 | 90 | * Fix invalid default Multi backend definitions. 91 | 92 | ## v2.4.9: 93 | 94 | * Revert errant change of Riak node name from FQDN to IP address. 95 | 96 | ## v2.4.8: 97 | 98 | * Make default for `cs_version` be `1.4.5` 99 | * Add support for Ubuntu 13.04 (Raring). 100 | * Add support for Amazon Linux (2014.03). 101 | 102 | ## v2.4.7: 103 | 104 | * Ensure /etc/default/riak is regenerated when open file limits change. 105 | * Ensure Riak data directory exists and is owned by the Riak user. 106 | * Make all cookbook dependency versions explicit. 107 | 108 | ## v2.4.6: 109 | 110 | * Updated yum dependency constraint. 111 | 112 | ## v2.4.5: 113 | 114 | * Riak `1.4.8` is now the default. 115 | 116 | ## v2.4.4: 117 | 118 | * Riak `1.4.7` is now the default. 119 | 120 | ## v2.4.3: 121 | 122 | * Add a constraint to `yum` cookbook dependency so that breaking changes in 123 | v3.0 are mitigated. 124 | * Updated Gemfile to include integration test dependencies. 125 | 126 | ## v2.4.2: 127 | 128 | * Riak `1.4.6` is now the default. 129 | * Make use of `vagrantfile_erb` setting of kitchen-vagrant. 130 | * Added kernel and network tuning via sysctl. 131 | 132 | ## v2.4.1: 133 | 134 | * Removed Recipe Tester. 135 | * Bumped Chef to version `11.8.0` for Test Kitchen. 136 | * Make default for `cs_version` be `1.4.3` 137 | 138 | ## v2.4.0: 139 | 140 | * Added a recipe for installing Riak through a custom package repository. 141 | 142 | ## v2.3.4: 143 | 144 | * Made Test Kitchen run faster by enabling the `vagrant-cachier` plugin 145 | through the `kitchen-vagrant` driver. 146 | * Make default for `cs_version` be `1.4.1` 147 | 148 | ## v2.3.3: 149 | 150 | * Riak `1.4.2` is now the default. 151 | * Fixed the `remote_file` resource for Enterprise packages so that it utilizes 152 | a checksum. 153 | 154 | ## v2.3.2: 155 | 156 | * Add a default `cluster_mgr` attribute. 157 | * Add `allow_mult` override when the `riak_cs_kv_multi_backend` is chosen. 158 | 159 | ## v2.3.1: 160 | 161 | * Riak `1.4.1` is now the default. 162 | * Fixed Debian support. 163 | * Added Debian Wheezy to Test Kitchen. 164 | 165 | ## v2.3.0: 166 | 167 | * Fixed package installation so that it respects version numbers. 168 | * Added Test Kitchen support for CentOS 5.9. 169 | * Fixed Protocol Buffers interface configuration changes between Riak 1.3 and 170 | 1.4. 171 | 172 | ## v2.2.0: 173 | 174 | * Riak `1.4.0` is the default. 175 | * Debian init scripts now use `start-stop-daemon` for `start`. This caused an 176 | issue with the way we were handling file descriptor limits for Debian. Now 177 | the init script sources `/etc/default/riak`, which contains the appropriate 178 | `ulimit` call. 179 | * Added new options and defaults to `vm.args` and `app.config` attributes. 180 | * Test Kitchen requires version `2.2.4` or greater of the `yum` cookbook 181 | because earlier versions contained a bad test stub. 182 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | 3 | group :lint do 4 | gem 'foodcritic', '~> 4.0' 5 | gem 'rubocop', '= 0.28.0' 6 | end 7 | 8 | group :unit do 9 | gem 'berkshelf', '~> 4.0' 10 | gem 'chefspec', '~> 4.0' 11 | end 12 | 13 | group :kitchen_common do 14 | gem 'test-kitchen', '~> 1.16.0' 15 | end 16 | 17 | group :kitchen_vagrant do 18 | gem 'kitchen-vagrant', '~> 1.0.2' 19 | end 20 | 21 | group :kitchen_cloud do 22 | gem 'kitchen-digitalocean', '~> 0.8' 23 | gem 'kitchen-ec2', '~> 0.8' 24 | end 25 | 26 | group :development do 27 | gem 'rb-fsevent' 28 | gem 'guard', '~> 2.4' 29 | gem 'guard-kitchen' 30 | gem 'guard-foodcritic' 31 | gem 'guard-rspec' 32 | gem 'guard-rubocop' 33 | gem 'rake' 34 | end 35 | -------------------------------------------------------------------------------- /Guardfile: -------------------------------------------------------------------------------- 1 | # More info at https://github.com/guard/guard#readme 2 | 3 | guard 'foodcritic', cookbook_paths: '.', cli: '-t ~FC007 -t ~FC024', all_on_start: false do 4 | watch(/attributes\/.+\.rb$/) 5 | watch(/providers\/.+\.rb$/) 6 | watch(/recipes\/.+\.rb$/) 7 | watch(/resources\/.+\.rb$/) 8 | watch('metadata.rb') 9 | end 10 | 11 | guard 'rubocop' do 12 | watch(/attributes\/.+\.rb$/) 13 | watch(/providers\/.+\.rb$/) 14 | watch(/recipes\/.+\.rb$/) 15 | watch(/resources\/.+\.rb$/) 16 | watch('metadata.rb') 17 | end 18 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # riak 2 | [![Cookbook Version](http://img.shields.io/cookbook/v/riak.svg)][cookbook] 3 | [![Build Status](http://img.shields.io/travis/basho-labs/riak-chef-cookbook.svg)][travis] 4 | 5 | [cookbook]: https://supermarket.chef.io/cookbooks/riak 6 | [travis]: http://travis-ci.org/basho-labs/riak-chef-cookbook 7 | 8 | ## Description 9 | 10 | [Riak](http://basho.com/riak/) is an open source, distributed database that focuses on high availability, horizontal scalability, and *predictable* latency. 11 | 12 | This repository is **community supported**. We both appreciate and need your contribution to keep it stable. For more on how to contribute, [take a look at the contribution process](#contribution). 13 | 14 | Thank you for being part of the community! We love you for it. 15 | 16 | ## Requirements 17 | 18 | * Chef 11 or higher 19 | 20 | ## Platform Support 21 | 22 | * Ubuntu 14.04 23 | * Ubuntu 12.04 24 | * Debian 7.8 25 | * CentOS 7.1 26 | * CentOS 6.6 27 | * CentOS 5.11 28 | * FreeBSD 10.1 29 | * FreeBSD 9.3 30 | 31 | ## Cookbook Dependencies 32 | 33 | * apt 34 | * build-essential 35 | * erlang 36 | * git 37 | * java 38 | * sysctl 39 | * ulimit 40 | * yum 41 | * yum-epel 42 | 43 | ## Attributes 44 | 45 | * `node['riak']['install_method']` - Method to install Riak (`package`, 46 | `enterprise_package`, `source`, `custom_repository`) 47 | * `node['riak']['platform_bin_dir']` - Base directory for binaries. 48 | * `node['riak']['platform_data_dir']` - Base directory for data files. 49 | * `node['riak']['platform_etc_dir']` - Base directory for configuration files. 50 | * `node['riak']['platform_log_dir']` - Base directory for log files. 51 | * `node['riak']['platform_lib_dir']` - Base directory for libraries. 52 | * `node['riak']['patches']` - List of patches to apply by placing in the 53 | `basho-patches` directory. 54 | * `node['riak']['config']['log.console']` - Where to emit the default log 55 | messages (`off`, `file`, `console`, `both`). 56 | * `node['riak']['config']['log']['console']['level']` - Severity level of the 57 | console log (`ebug`, `info`, `warning`, `error`). 58 | * `node['riak']['config']['log']['console']['file']` - When 59 | `node['riak']['config']['log.console']` is set to `file` or `both`, the file 60 | where console messages will be logged. 61 | * `node['riak']['config']['log']['error']['file']` - The file where error 62 | messages will be logged. 63 | * `node['riak']['config']['log']['syslog']` - Enables log output to syslog 64 | (`on`, `off`). 65 | * `node['riak']['config']['log.crash']` - Whether to enable the crash log (`on`, `off`). 66 | * `node['riak']['config']['log']['crash']['file']` - The file where its 67 | messages will be written. 68 | * `node['riak']['config']['log']['crash']['maximum_message_size']` - Maximum 69 | size (in bytes) of individual messages in the crash log. 70 | * `node['riak']['config']['log']['crash']['size']` - Maximum size of the crash 71 | log (in bytes), before it is rotated. 72 | * `node['riak']['config']['log']['crash.rotation']` - The schedule on which to 73 | rotate the crash log. See 74 | [here](https://github.com/basho/lager/blob/master/README.md#internal-log-rotation) 75 | for details. 76 | * `node['riak']['config']['log']['crash']['rotation']['keep']` - The number of 77 | rotated crash logs to keep. 78 | * `node['riak']['config']['nodename']` - Name of the Erlang node. 79 | * `node['riak']['config']['distributed_cookie']` - Cookie for distributed node 80 | communication. 81 | * `node['riak']['config']['erlang']['async_threads']` - Number of threads in 82 | async thread pool (`0`-`1024`). 83 | * `node['riak']['config']['erlang']['max_ports']` - Number of concurrent 84 | ports/sockets (`1024`-`134217727`). 85 | * `node['riak']['config']['ring_size']` - Number of partitions in the cluster 86 | (must be a power of 2). 87 | * `node['riak']['config']['transfer_limit']` - Number of concurrent node-to- 88 | node transfers allowed. 89 | * `node['riak']['config']['ring']['state_dir']` - Location of ring state. 90 | * `node['riak']['config']['ssl']['certfile']` - Default certificate location 91 | for HTTPS. 92 | * `node['riak']['config']['ssl']['keyfile']` - Default key location for HTTPS. 93 | * `node['riak']['config']['ssl']['cacertfile']` - Default signing authority 94 | for HTTPS. 95 | * `node['riak']['config']['dtrace']` - Enable DTrace (`on`, `off`). 96 | * `node['riak']['config']['strong_consistency']` - Enable consensus subsystem (`on`, `off`). 97 | * `node['riak']['config']['listener']['http']['internal']` - IP address and 98 | TCP port that the Riak HTTP interface will bind to. 99 | * `node['riak']['config']['listener']['protobuf']['internal']` - IP address 100 | and TCP port that the Riak Protocol Buffers interface will bind to. 101 | * `node['riak']['config']['protobuf']['backlog']` - Maximum length of pending 102 | connections queue. 103 | * `node['riak']['config']['listener']['https']['internal']` - IP address and 104 | TCP port that the Riak HTTPS interface will bind to. 105 | * `node['riak']['config']['anti_entropy']` - Strategy of repairing out-of-sync 106 | keys (`active`, `passive`, `active-debug`). 107 | * `node['riak']['config']['storage_backend']` - Storage backend for Riak's 108 | key-value and secondary index data (`bitcask`, `leveldb`, `memory`, 109 | `multi`). 110 | * `node['riak']['config']['object']['format']` - Binary representation of a 111 | Riak value stored on disk (`0`, `1`). 112 | * `node['riak']['config']['metadata_cache_size']` - Size of the metadata cache 113 | for each vnode. 114 | * `node['riak']['config']['object']['size']['warning_threshold']` - Reading or 115 | writing objects larger than this size will write a warning in the logs. 116 | * `node['riak']['config']['object']['size']['maximum']` - Writing an object 117 | larger than this will send a failure to the client. 118 | * `node['riak']['config']['object']['siblings']['warning_threshold']` - 119 | Writing an object with more than this number of siblings will generate a 120 | warning in the logs. 121 | * `node['riak']['config']['object']['siblings']['maximum']` - Writing an 122 | object with more than this number of siblings will send a failure to the 123 | client. 124 | * `node['riak']['config']['bitcask']['data_root']` - A path under which 125 | Bitcask data files will be stored. 126 | * `node['riak']['config']['bitcask']['io_mode']` - How Bitcask writes to disk 127 | (`erlang`, `nif`). 128 | * `node['riak']['config']['riak_control.top_level']` - Enable administrative 129 | UI (`on`, `off`). 130 | * `node['riak']['config']['riak_control']['auth']['mode']` - Authentication 131 | mode used for access to the administrative panel. 132 | * `node['riak']['config']['riak_control']['auth']['user']['user']['password']` 133 | - List of usernames and passwords for access to Riak Control. 134 | * `node['riak']['config']['leveldb']['data_root']` - A path under which 135 | LevelDB data files will be stored. 136 | * `node['riak']['config']['leveldb']['maximum_memory']['percent']` - 137 | Percentage of total server memory to assign to LevelDB. 138 | * `node['riak']['config']['leveldb']['compaction']['trigger']['tombstone_count']` 139 | - Controls when background LevelDB compaction initiates. 140 | * `node['riak']['config']['jmx']` - Enable JMX monitoring output (`on`, 141 | `off`). 142 | * `node['riak']['config']['search.top_level']` - Enable Riak Search (`on`, 143 | `off`). 144 | * `node['riak']['config']['search']['solr']['start_timeout']` - How long Riak 145 | will wait for Solr to start. 146 | * `node['riak']['config']['search']['solr']['port']` - Port number Solr will 147 | bind to. 148 | * `node['riak']['config']['search']['solr']['jmx_port']` - Port number which 149 | Solr JMX binds to. 150 | * `node['riak']['config']['search']['solr']['jvm_options']` - Options to pass 151 | to the Solr JVM. 152 | * `node['riak']['config']['search']['anti_entropy']['data_dir']` - Path where 153 | Riak Search's Active Anti-Entropy data files will reside. 154 | * `node['riak']['config']['search']['root_dir']` - Path for Riak Search index 155 | data. 156 | 157 | ### Package 158 | 159 | * `node['riak']['package']['enterprise_key']` - Riak Enterprise key. 160 | * `node['riak']['package']['version']['major']` - Major version number. 161 | * `node['riak']['package']['version']['minor']` - Minor version number. 162 | * `node['riak']['package']['version']['incremental']` - Incremental version number. 163 | * `node['riak']['package']['version']['build']` - Build version number. 164 | * `node['riak']['package']['local']['checksum']` - Checksum for local Riak 165 | package. 166 | 167 | ### Source 168 | 169 | * `node['riak']['source']['url']` - Base path for downloading Riak source 170 | tarballs. 171 | * `node['riak']['source']['version']['major']`- Major version number. 172 | * `node['riak']['source']['version']['minor']` - Minor version number. 173 | * `node['riak']['source']['version']['incremental']` - Incremental version 174 | number. 175 | * `node['riak']['source']['prefix']` - Installation prefix for source install. 176 | * `node['riak']['source']['checksum']` - Checksum for source tarball. 177 | 178 | ### ulimit 179 | 180 | * `node['riak']['limits']['nofile']` - File descriptor limit for user running the Riak service 181 | 182 | ### sysctl 183 | 184 | * `node['riak']['sysctl']['vm']['swappiness']` 185 | * `node['riak']['sysctl']['net']['core']['somaxconn']` 186 | * `node['riak']['sysctl']['net']['ipv4']['tcp_max_syn_backlog']` 187 | * `node['riak']['sysctl']['net']['ipv4']['tcp_sack']` 188 | * `node['riak']['sysctl']['net']['ipv4']['tcp_window_scaling']` 189 | * `node['riak']['sysctl']['net']['ipv4']['tcp_fin_timeout']` 190 | * `node['riak']['sysctl']['net']['ipv4']['tcp_keepalive_intvl']` 191 | * `node['riak']['sysctl']['net']['ipv4']['tcp_tw_reuse']` 192 | * `node['riak']['sysctl']['net']['ipv4']['tcp_moderate_rcvbuf']` 193 | 194 | ### Java 195 | 196 | * `node['riak']['manage_java']` - Installs and configures Java. 197 | 198 | **NOTE**: If `node['riak']['config']['search.top_level']` is set to `on` then Java must be 199 | installed beforehand (either by another recipe or this one) or Riak will fail to start 200 | 201 | **NOTE**: As OpenJDK isn't supported officially and Sun Java for FreeBSD is only 32bit this recipe 202 | doesn't work/isn't tested on FreeBSD. 203 | 204 | ## Usage 205 | 206 | ### Attributes 207 | 208 | You may notice that some attribute names contain `.top_level`. This is to aid 209 | rendering special configuration settings that have other settings nested 210 | beneath them. 211 | 212 | A quick example: 213 | 214 | `search` is a setting, but it also has `search.solr.start_timeout` and 215 | `search.solr.port` beneath it: 216 | 217 | ```ruby 218 | default['riak']['config']['search.top_level'] = 'off' 219 | default['riak']['config']['search']['solr']['start_timeout'] = '30s' 220 | default['riak']['config']['search']['solr']['port'] = 8093 221 | ``` 222 | 223 | These attributes render as: 224 | 225 | ``` 226 | search = off 227 | search.solr.start_timeout = 30s 228 | search.solr.port = 8093 229 | ``` 230 | 231 | ### Installation Methods 232 | 233 | There are several installation methods for Riak supported by this cookbook. 234 | All require that the node's `run_list` contain the default `riak` recipe. 235 | 236 | For more precise examples, please see the `.kitchen.yml` file. 237 | 238 | #### Package 239 | 240 | This is the default method of installation. Ensure that 241 | `node['riak']['install_method']` is set to `package`. 242 | 243 | #### Enterprise Package 244 | 245 | For Riak Enterprise users, installing the Enterprise package requires setting 246 | one attribute: 247 | 248 | ```ruby 249 | default['riak']['package']['enterprise_key'] = '*******' 250 | ``` 251 | 252 | #### Custom Package 253 | 254 | If you want to install a custom package of Riak (that isn't available in your 255 | operating system's package repository), ensure that the following attributes 256 | are set appropriately: 257 | 258 | ```ruby 259 | default['riak']['install_method'] = 'custom_package' 260 | default['riak']['package']['local']['checksum'] = '2b28aeabb21488125b7e39f768c8f3b98ac816d1a30c0d618c9f82f99e6e89d9' 261 | default['riak']['package']['local']['url'] = 'http://s3.amazonaws.com/downloads.basho.com/riak/2.1/2.1.1/ubuntu/trusty' 262 | ``` 263 | 264 | **NOTE**: FreeBSD uses custom_package regardless. 265 | 266 | #### Custom Repository 267 | 268 | If you have a package repository setup on your operating system (that isn't 269 | Basho's) and want to install Riak from there, ensure that 270 | `node['riak']['install_method']` is set to `custom_repository`. 271 | 272 | **NOTE**: This will fail unless the package repository is configured beforehand (earlier in run_list) 273 | 274 | #### Source 275 | 276 | If you want to install Riak (and Erlang) from source, ensure that 277 | `node['riak']['install_method']` is set to `source`. 278 | 279 | 280 | ### Optional Recipes 281 | 282 | #### riak::sysctl 283 | 284 | This is an optional recipe to set sysctl tunings such that Riak will not emit warnings to the log. 285 | As other systems or cookbooks may already configure these tunings, this recipe is optional. It should be placed 286 | in the run_list before `recipe['riak']` if desired. 287 | 288 | ##Contributions 289 | 290 | Basho Labs repos survive because of community contribution. Here’s how to get started. 291 | 292 | * Fork the appropriate sub-projects that are affected by your change 293 | * Create a topic branch for your change and checkout that branch 294 | `git checkout -b some-topic-branch` 295 | * Make your changes and run the test suite if one is provided (see below) 296 | * Commit your changes and push them to your fork 297 | * Open a pull request for the appropriate project 298 | * Contributors will review your pull request, suggest changes, and merge it when it’s ready and/or offer feedback 299 | * To report a bug or issue, please open a new issue against this repository 300 | 301 | ### Maintainers 302 | * Seth Thomas ([GitHub](https://github.com/cheeseplus)) 303 | * and You! [Read up](https://github.com/basho-labs/the-riak-community/blob/master/config-mgmt-strategy.md) and get involved 304 | 305 | You can [read the full guidelines](http://docs.basho.com/riak/latest/community/bugs/) for bug reporting and code contributions on the Riak Docs. And **thank you!** Your contribution is incredibly important to us. 306 | 307 | ## License and Authors 308 | 309 | * Author: Benjamin Black ([GitHub](https://github.com/b)) 310 | * Author: Sean Carey ([GitHub](https://github.com/densone)) 311 | * Author: Hector Castro ([GitHub](https://github.com/hectcastro)) 312 | * Author: Sean Cribbs ([GitHub](https://github.com/seancribbs)) 313 | * Author: Seth Thomas ([GitHub](https://github.com/cheeseplus)) 314 | 315 | Copyright (c) 2015 Basho Technologies, Inc. 316 | 317 | Licensed under the Apache License, Version 2.0 (the "License"); 318 | you may not use this file except in compliance with the License. 319 | You may obtain a copy of the License at 320 | 321 | [http://www.apache.org/licenses/LICENSE-2.0](http://www.apache.org/licenses/LICENSE-2.0) 322 | 323 | Unless required by applicable law or agreed to in writing, software 324 | distributed under the License is distributed on an "AS IS" BASIS, 325 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 326 | See the License for the specific language governing permissions and 327 | limitations under the License. 328 | -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | require 'bundler/setup' 2 | 3 | module TempFixForRakeLastComment 4 | def last_comment 5 | last_description 6 | end 7 | end 8 | Rake::Application.send :include, TempFixForRakeLastComment 9 | 10 | # Style tests. Rubocop and Foodcritic 11 | namespace :style do 12 | require 'rubocop/rake_task' 13 | desc 'Run Ruby style checks' 14 | RuboCop::RakeTask.new(:ruby) 15 | 16 | require 'foodcritic' 17 | desc 'Run Chef style checks' 18 | FoodCritic::Rake::LintTask.new(:chef) do |t| 19 | t.options = { 20 | fail_tags: ['any'] 21 | } 22 | end 23 | end 24 | 25 | desc 'Run all style checks' 26 | task style: ['style:chef', 'style:ruby'] 27 | 28 | # Rspec and ChefSpec 29 | require 'rspec/core/rake_task' 30 | desc 'Run ChefSpec examples' 31 | RSpec::Core::RakeTask.new(:spec) 32 | 33 | # Integration tests. Kitchen.ci 34 | require 'kitchen' 35 | namespace :integration do 36 | desc 'Run Test Kitchen with Vagrant' 37 | task :vagrant do 38 | Kitchen.logger = Kitchen.default_file_logger 39 | Kitchen::Config.new.instances.each do |instance| 40 | instance.test(:always) 41 | end 42 | end 43 | 44 | desc 'Run Test Kitchen with cloud plugins' 45 | task :cloud do 46 | run_kitchen = true 47 | if ENV['TRAVIS'] == 'true' && ENV['TRAVIS_PULL_REQUEST'] != 'false' 48 | run_kitchen = false 49 | end 50 | 51 | if run_kitchen 52 | Kitchen.logger = Kitchen.default_file_logger 53 | @loader = Kitchen::Loader::YAML.new(project_config: './.kitchen.cloud.yml') 54 | config = Kitchen::Config.new(loader: @loader) 55 | config.instances.each do |instance| 56 | instance.test(:always) 57 | end 58 | end 59 | end 60 | end 61 | 62 | namespace :travis do 63 | desc 'Run tests on Travis' 64 | task ci: %w(style spec) 65 | end 66 | 67 | # The default rake task should just run it all 68 | task default: ['style', 'spec', 'integration:vagrant'] 69 | -------------------------------------------------------------------------------- /attributes/default.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Author:: Hector Castro () 3 | # Cookbook Name:: riak 4 | # 5 | # Copyright (c) 2014 Basho Technologies, 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 | default['riak']['install_method'] = 'package' 20 | default['riak']['manage_java'] = false 21 | 22 | # ulimit 23 | default['riak']['limits']['nofile'] = 65_536 24 | 25 | default['riak']['platform_bin_dir'] = '/usr/sbin' 26 | default['riak']['platform_data_dir'] = '/var/lib/riak' 27 | default['riak']['platform_etc_dir'] = '/etc/riak' 28 | default['riak']['platform_log_dir'] = '/var/log/riak' 29 | 30 | if node.platform_family?('rhel') 31 | default['riak']['platform_lib_dir'] = '/usr/lib64/riak/lib' 32 | elsif node.platform_family?('freebsd') 33 | default['riak']['platform_bin_dir'] = '/usr/local/sbin' 34 | default['riak']['platform_data_dir'] = '/var/db/riak' 35 | default['riak']['platform_etc_dir'] = '/usr/local/etc/riak' 36 | default['riak']['platform_lib_dir'] = '/usr/local/lib/riak' 37 | else 38 | default['riak']['platform_lib_dir'] = '/usr/lib/riak/lib' 39 | end 40 | 41 | # patches 42 | default['riak']['patches'] = [] 43 | 44 | # riak.conf 45 | default['riak']['config']['log.console'] = 'file' 46 | default['riak']['config']['log']['console']['level'] = 'info' 47 | default['riak']['config']['log']['console']['file'] = "#{node['riak']['platform_log_dir']}/console.log" 48 | default['riak']['config']['log']['error']['file'] = "#{node['riak']['platform_log_dir']}/error.log" 49 | default['riak']['config']['log']['syslog'] = 'off' 50 | default['riak']['config']['log.crash'] = 'on' 51 | default['riak']['config']['log']['crash']['file'] = "#{node['riak']['platform_log_dir']}/crash.log" 52 | default['riak']['config']['log']['crash']['maximum_message_size'] = '64KB' 53 | default['riak']['config']['log']['crash']['size'] = '10MB' 54 | default['riak']['config']['log']['crash.rotation'] = '$D0' 55 | default['riak']['config']['log']['crash']['rotation']['keep'] = 5 56 | default['riak']['config']['nodename'] = "riak@#{node['fqdn']}" 57 | default['riak']['config']['distributed_cookie'] = 'riak' 58 | default['riak']['config']['erlang']['async_threads'] = 64 59 | default['riak']['config']['erlang']['max_ports'] = 65_536 60 | default['riak']['config']['erlang']['schedulers']['force_wakeup_interval'] = 500 61 | default['riak']['config']['erlang']['schedulers']['compaction_of_load'] = 'false' 62 | default['riak']['config']['ring_size'] = 64 63 | default['riak']['config']['transfer_limit'] = 2 64 | # default['riak']['config']['ssl']['certfile'] = '$(platform_etc_dir)/cert.pem' 65 | # default['riak']['config']['ssl']['keyfile'] = '$(platform_etc_dir)/key.pem' 66 | # default['riak']['config']['ssl']['cacertfile'] = '$(platform_etc_dir)/cacertfile.pem' 67 | default['riak']['config']['dtrace'] = 'off' 68 | default['riak']['config']['platform_bin_dir'] = node['riak']['platform_bin_dir'] 69 | default['riak']['config']['platform_data_dir'] = node['riak']['platform_data_dir'] 70 | default['riak']['config']['platform_etc_dir'] = node['riak']['platform_etc_dir'] 71 | default['riak']['config']['platform_lib_dir'] = node['riak']['platform_lib_dir'] 72 | default['riak']['config']['platform_log_dir'] = node['riak']['platform_log_dir'] 73 | default['riak']['config']['strong_consistency'] = 'off' 74 | default['riak']['config']['listener']['http']['internal'] = "#{node['ipaddress']}:8098" 75 | default['riak']['config']['listener']['protobuf']['internal'] = "#{node['ipaddress']}:8087" 76 | default['riak']['config']['protobuf']['backlog'] = 128 77 | # default['riak']['config']['listener']['https']['internal'] = '127.0.0.1:8098' 78 | default['riak']['config']['anti_entropy'] = 'active' 79 | default['riak']['config']['storage_backend'] = 'bitcask' 80 | default['riak']['config']['object']['format'] = 1 81 | default['riak']['config']['object']['size']['warning_threshold'] = '5MB' 82 | default['riak']['config']['object']['size']['maximum'] = '50MB' 83 | default['riak']['config']['object']['siblings']['warning_threshold'] = 25 84 | default['riak']['config']['object']['siblings']['maximum'] = 100 85 | default['riak']['config']['bitcask']['data_root'] = '$(platform_data_dir)/bitcask' 86 | default['riak']['config']['bitcask']['io_mode'] = 'erlang' 87 | default['riak']['config']['riak_control.top_level'] = 'off' 88 | default['riak']['config']['riak_control']['auth']['mode'] = 'off' 89 | # default['riak']['config']['riak_control']['auth']['user']['user']['password'] = 'pass' 90 | default['riak']['config']['leveldb']['maximum_memory']['percent'] = 70 91 | # default['riak']['config']['jmx.top_level'] = 'off' 92 | default['riak']['config']['search.top_level'] = 'off' 93 | default['riak']['config']['search']['solr']['start_timeout'] = '30s' 94 | default['riak']['config']['search']['solr']['port'] = 8093 95 | default['riak']['config']['search']['solr']['jmx_port'] = 8985 96 | default['riak']['config']['search']['solr']['jvm_options'] = '-d64 -Xms1g -Xmx1g -XX:+UseStringCache -XX:+UseCompressedOops' 97 | -------------------------------------------------------------------------------- /attributes/package.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Author:: Benjamin Black () and Sean Cribbs () 3 | # Cookbook Name:: riak 4 | # 5 | # Copyright (c) 2014 Basho Technologies, 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 | default['riak']['package']['enterprise_key'] = '' 20 | 21 | default['riak']['package']['version']['major'] = '2' 22 | default['riak']['package']['version']['minor'] = '1' 23 | default['riak']['package']['version']['incremental'] = '1' 24 | default['riak']['package']['version']['build'] = '1' 25 | default['riak']['package']['local']['url'] = '' 26 | 27 | default['riak']['package']['local']['checksum'].tap do |checksum| 28 | checksum['ubuntu']['14'] = '2b28aeabb21488125b7e39f768c8f3b98ac816d1a30c0d618c9f82f99e6e89d9' 29 | checksum['ubuntu']['12'] = '3671964ed9289434904b1617f382ee6a228c3be1d8dc6e57b918aa8c530a4038' 30 | checksum['debian']['7'] = '21413331edf57ae912ecdc4d99c7852efd4f58abe5cc26f01c55515b66bcec02' 31 | checksum['centos']['7'] = '8f801c9a33632a7102b5dcf44eea32e7557c9fd6c5e149acbe9de9d1363319ef' 32 | checksum['centos']['6'] = '8133c2af6d4ce0b5705ed34fdebc27cca15478ce8dc608cb2855e24f4b6d5f47' 33 | checksum['centos']['5'] = 'be4a5ccf4f75994fedc4d8c34fe73782df93a160daf079db48671e6c3a2fbbd2' 34 | checksum['fedora']['19'] = 'd710124c0b322830b0c0aa64711bc722522a57b5edacccbaa7eb31f39984703b' 35 | checksum['freebsd']['10'] = 'a5f82486d39ac23bef83091ff40bbcebb3ded342d4b73219295ffb05df115fc4' 36 | checksum['freebsd']['9'] = '7547fd19ee8ddb1a8ae2555c9d0ff859b1ec3e5ecb56cc315eca3500bf905450' 37 | checksum['amazon']['2014'] = checksum['centos']['6'] 38 | end 39 | 40 | default['riak']['package']['enterprise']['checksum'].tap do |checksum| 41 | checksum['ubuntu']['14'] = '0f37783ae2426d60187f24c9edcbf2322db38ff232a7e6b29ca89699ed3c8345' 42 | checksum['ubuntu']['12'] = '072dec713ad1a4f9f5aa7f76f414b02b5f8cbac769fb497c918f2f19cd88c6c3' 43 | checksum['debian']['7'] = '6d7da002dafef53f0c8b6b2f45de68629ad0efbd5a67f167bd56fbdc7467664a' 44 | checksum['centos']['7'] = '52ac620e311caff1d857e705ce717f93d8e53e9fd7d8a29c190007cfed79351c' 45 | checksum['centos']['6'] = '56266a8ced423f3cb53abd06112fe18a9ecb440c86b98d3de9266198e8283bdc' 46 | checksum['centos']['5'] = '2ac99621f04be13ac6137bca538fcef427c0e476099b99a6ad6811b9b5e85c6b' 47 | checksum['fedora']['19'] = '0f6889a81eb32fcd7e823dd5c73d4eb649c25e9f0072e270f50840d0d050141f' 48 | checksum['freebsd']['10'] = 'df8312ef6ce4c8f0531d4c7a7ff1a6f03852702853955b24989fe1494e979c87' 49 | checksum['freebsd']['9'] = '05b419392bc0af30a698acd6e3ac2753b2de5bec12a78789e2e6f6b7b1c95d24' 50 | checksum['amazon']['2014'] = checksum['centos']['6'] 51 | end 52 | -------------------------------------------------------------------------------- /attributes/source.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Author:: Benjamin Black () and Sean Cribbs () 3 | # Cookbook Name:: riak 4 | # 5 | # Copyright (c) 2014 Basho Technologies, 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 | default['riak']['source']['url'] = 'http://s3.amazonaws.com/downloads.basho.com/riak' 20 | default['riak']['source']['version']['major'] = '2' 21 | default['riak']['source']['version']['minor'] = '1' 22 | default['riak']['source']['version']['incremental'] = '1' 23 | default['riak']['source']['prefix'] = '/opt' 24 | 25 | default['riak']['source']['checksum'] = 'b5414e7bab650862c26fbbad382b81d47135ce55eafd02fdac027d3bff90a5ae' 26 | -------------------------------------------------------------------------------- /libraries/cuttlefish.rb: -------------------------------------------------------------------------------- 1 | module Cuttlefish 2 | def self.compile(prefix, config) 3 | case config 4 | when Array 5 | "#{prefix} = #{config.join(' ')}" 6 | when String, Fixnum, Bignum, Float, Symbol 7 | "#{prefix} = #{config}" 8 | when Hash, Chef::Node::Attribute 9 | prefix = "#{prefix}." unless prefix.empty? 10 | config.map { |k, v| compile("#{prefix}#{k.chomp('.top_level')}", v) }.flatten 11 | else 12 | fail Chef::Exceptions::UnsupportedAction, "Riak cookbook can't handle values of type: #{config.class}" 13 | end 14 | end 15 | end 16 | -------------------------------------------------------------------------------- /metadata.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Author:: Benjamin Black (), Sean Cribbs (), Seth Thomas (), and Hector Castro () 3 | # Cookbook Name:: riak 4 | # 5 | # Copyright (c) 2014 Basho Technologies, 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 | name 'riak' 21 | maintainer 'Basho Technologies, Inc.' 22 | maintainer_email 'riak@basho.com' 23 | license 'Apache 2.0' 24 | description 'Installs and configures Riak distributed data store' 25 | version '3.1.4' 26 | 27 | recipe 'riak', 'Installs Riak from a package' 28 | recipe 'riak::source', 'Installs Erlang and Riak from source' 29 | recipe 'riak::java', 'Installs Java for Riak Search' 30 | recipe 'riak::sysctl', 'Applies sysctl tunings for Riak' 31 | 32 | depends 'apt', '>= 2.3' 33 | depends 'build-essential' 34 | depends 'erlang', '>= 1.5.2' 35 | depends 'git' 36 | depends 'java', '>= 1.28.0' 37 | depends 'sysctl' 38 | depends 'ulimit' 39 | depends 'yum', '>= 3.4' 40 | depends 'yum-epel' 41 | depends 'packagecloud' 42 | depends 'pkg_add' 43 | 44 | %w{ubuntu debian centos redhat fedora amazon freebsd}.each do |os| 45 | supports os 46 | end 47 | -------------------------------------------------------------------------------- /recipes/default.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Author:: Seth Thomas () and Hector Castro () 3 | # Cookbook Name:: riak 4 | # Recipe:: default 5 | # 6 | # Copyright (c) 2014 Basho Technologies, 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 'riak::java' if node['riak']['manage_java'] 22 | 23 | # validate the fqdn and if probalo then use IP address 24 | valid_fqdn_regexp = /(?=^.{4,255}$)(^((?!-)[a-zA-Z0-9-]{1,63}(?) 3 | # Cookbook Name:: riak 4 | # Recipe:: java 5 | # 6 | # Copyright (c) 2014 Basho Technologies, 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 | node.default['java']['install_flavor'] = 'oracle' 22 | node.default['java']['jdk_version'] = 8 23 | node.default['java']['jdk']['8']['x86_64']['url'] = 'http://download.oracle.com/otn-pub/java/jdk/8u121-b13/e9e7ea248e2c4826b92b3f075a80e441/jdk-8u121-linux-x64.tar.gz' 24 | node.default['java']['jdk']['8']['x86_64']['checksum'] = '97e30203f1aef324a07c94d9d078f5d19bb6c50e638e4492722debca588210bc' 25 | node.default['java']['oracle']['accept_oracle_download_terms'] = true 26 | 27 | include_recipe 'java' 28 | -------------------------------------------------------------------------------- /recipes/package.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Author:: Benjamin Black (), Sean Cribbs (), 3 | # Seth Thomas (), and Hector Castro () 4 | # Cookbook Name:: riak 5 | # Recipe:: package 6 | # 7 | # Copyright (c) 2014 Basho Technologies, Inc. 8 | # 9 | # Licensed under the Apache License, Version 2.0 (the "License"); 10 | # you may not use this file except in compliance with the License. 11 | # You may obtain a copy of the License at 12 | # 13 | # http://www.apache.org/licenses/LICENSE-2.0 14 | # 15 | # Unless required by applicable law or agreed to in writing, software 16 | # distributed under the License is distributed on an "AS IS" BASIS, 17 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | # See the License for the specific language governing permissions and 19 | # limitations under the License. 20 | # 21 | 22 | oss_or_ee = node['riak']['package']['enterprise_key'].empty? ? 'riak' : 'riak-ee' 23 | version_str = %w(major minor incremental).map { |ver| node['riak']['package']['version'][ver] }.join('.') 24 | major_minor = %w(major minor).map { |ver| node['riak']['package']['version'][ver] }.join('.') 25 | package_version = "#{version_str}-#{node['riak']['package']['version']['build']}" 26 | install_method = node['platform'] == 'freebsd' || oss_or_ee == 'riak-ee' ? 'custom_package' : node['riak']['install_method'] 27 | plat_ver_int = node['platform_version'].to_i 28 | 29 | # Enterprise download URL changed with release of 2.0.8 and greater 30 | if Gem::Version.new(version_str) >= Gem::Version.new('2.0.8') 31 | ee_url_prefix = "http://private.downloads.basho.com/riak_ee/#{node['riak']['package']['enterprise_key']}/#{version_str}" 32 | else 33 | ee_url_prefix = "http://private.downloads.basho.com/riak_ee/#{node['riak']['package']['enterprise_key']}/#{major_minor}/#{version_str}" 34 | end 35 | 36 | case install_method 37 | when 'package', 'custom_repository' 38 | case node['platform'] 39 | when 'ubuntu', 'debian' 40 | packagecloud_repo 'basho/riak' do 41 | type 'deb' 42 | not_if { install_method == 'custom_repository' } 43 | end 44 | 45 | when 'centos', 'redhat', 'amazon', 'fedora' 46 | packagecloud_repo 'basho/riak' do 47 | type 'rpm' 48 | not_if { install_method == 'custom_repository' } 49 | end 50 | 51 | case plat_ver_int 52 | when 6, 2013, 2014 53 | package_version = "#{package_version}.el6" 54 | when 7 55 | package_version = "#{package_version}.el7.centos" 56 | when 19 57 | package_version = "#{package_version}.fc#{plat_ver_int}" 58 | end 59 | end 60 | 61 | package 'riak' do 62 | action :install 63 | version package_version 64 | options '-o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold"' \ 65 | if node['platform_family'] == 'debian' 66 | end 67 | when 'custom_package', 'enterprise_package' 68 | case node['platform'] 69 | when 'debian' 70 | package_file = "#{oss_or_ee}_#{package_version}_amd64.deb" 71 | ee_url_suffix = "/debian/#{plat_ver_int}/#{package_file}" 72 | if Gem::Version.new(version_str) >= Gem::Version.new('2.2.0') 73 | ee_url_suffix = "/debian/#{node['lsb']['codename']}/#{package_file}" 74 | end 75 | if Gem::Version.new(version_str) >= Gem::Version.new('2.0.8') && 76 | Gem::Version.new(version_str) < Gem::Version.new('2.1.0') 77 | ee_url_suffix = "/debian/#{node['lsb']['codename']}/#{package_file}" 78 | end 79 | when 'ubuntu' 80 | package_file = "#{oss_or_ee}_#{package_version}_amd64.deb" 81 | ee_url_suffix = "/ubuntu/#{node['lsb']['codename']}/#{package_file}" 82 | when 'centos', 'redhat' 83 | case plat_ver_int 84 | when 7 85 | package_file = "#{oss_or_ee}-#{package_version}.el7.centos.x86_64.rpm" 86 | when 5, 6 87 | package_file = "#{oss_or_ee}-#{package_version}.el#{plat_ver_int}.x86_64.rpm" 88 | end 89 | ee_url_suffix = "/rhel/#{plat_ver_int}/#{package_file}" 90 | when 'amazon' 91 | package_file = "#{oss_or_ee}-#{package_version}.el6.x86_64.rpm" 92 | ee_url_suffix = "/rhel/6/#{package_file}" 93 | when 'fedora' 94 | package_file = "#{oss_or_ee}-#{package_version}.fc#{plat_ver_int}.x86_64.rpm" 95 | ee_url_suffix = "/fedora/#{plat_ver_int}/#{package_file}" 96 | when 'freebsd' 97 | case plat_ver_int 98 | when 10 99 | package_file = "#{oss_or_ee}-#{version_str}.txz" 100 | ee_url_suffix = "/freebsd/10/#{package_file}" 101 | when 9 102 | package_file = "#{oss_or_ee}-#{version_str}-FreeBSD-amd64.tbz" 103 | ee_url_suffix = "/freebsd/9.2/#{package_file}" 104 | end 105 | end 106 | 107 | if node['riak']['package']['enterprise_key'].empty? 108 | checksum_val = node['riak']['package']['local']['checksum'][node['platform']][plat_ver_int.to_s] 109 | pkg_url = "#{node['riak']['package']['local']['url']}/#{package_file}" 110 | elsif node['riak']['package']['enterprise_key'].length > 0 && node['riak']['package']['local']['url'].length > 0 111 | checksum_val = node['riak']['package']['enterprise']['checksum'][node['platform']][plat_ver_int.to_s] 112 | pkg_url = "#{node['riak']['package']['local']['url']}/#{package_file}" 113 | else 114 | checksum_val = node['riak']['package']['enterprise']['checksum'][node['platform']][plat_ver_int.to_s] 115 | pkg_url = ee_url_prefix + ee_url_suffix 116 | end 117 | 118 | remote_file "#{Chef::Config[:file_cache_path]}/#{package_file}" do 119 | source pkg_url 120 | checksum checksum_val 121 | owner 'root' 122 | mode 0644 123 | end 124 | if node['platform'] == 'freebsd' && plat_ver_int == 9 125 | pkg_add 'riak' do 126 | location pkg_url 127 | action :install 128 | end 129 | else 130 | package oss_or_ee do 131 | source "#{Chef::Config[:file_cache_path]}/#{package_file}" 132 | action :install 133 | provider value_for_platform_family( 134 | %w(debian) => Chef::Provider::Package::Dpkg, 135 | %w(rhel fedora) => Chef::Provider::Package::Rpm) 136 | only_if do 137 | ::File.exist?("#{Chef::Config[:file_cache_path]}/#{package_file}") && 138 | Digest::SHA256.file("#{Chef::Config[:file_cache_path]}/#{package_file}").hexdigest == 139 | checksum_val 140 | end 141 | end 142 | end 143 | end 144 | -------------------------------------------------------------------------------- /recipes/source.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Author:: Seth Thomas () and Hector Castro () 3 | # Cookbook Name:: riak 4 | # Recipe:: source 5 | # 6 | # Copyright (c) 2014 Basho Technologies, 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 | node.default['erlang']['source']['version'] = 'R16B02-basho5' 21 | node.default['erlang']['source']['url'] = "http://s3.amazonaws.com/downloads.basho.com/erlang/otp_src_#{node['erlang']['source']['version']}.tar.gz" 22 | node.default['erlang']['source']['checksum'] = '5c36ed749f0f56d003d28ab352fa7cb405f11dbbfb885370edb69d3c1bd321fb' 23 | node.default['erlang']['source']['build_flags'] = '--disable-hipe --enable-smp-support --without-odbc --enable-m64-build' 24 | 25 | if node['platform_family'] == 'rhel' && node['platform_version'].to_f >= 6.5 26 | node.default['erlang']['source']['cflags'] = '-DOPENSSL_NO_EC=1' 27 | end 28 | 29 | node.default['riak']['platform_bin_dir'] = "#{node['riak']['source']['prefix']}/riak/bin" 30 | node.default['riak']['platform_etc_dir'] = "#{node['riak']['source']['prefix']}/riak/etc" 31 | node.default['riak']['platform_data_dir'] = "#{node['riak']['source']['prefix']}/riak/data" 32 | node.default['riak']['platform_log_dir'] = "#{node['riak']['source']['prefix']}/riak/log" 33 | node.default['riak']['platform_lib_dir'] = "#{node['riak']['source']['prefix']}/riak/lib" 34 | 35 | node.default['riak']['config']['log']['console']['file'] = "#{node['riak']['platform_log_dir']}/console.log" 36 | node.default['riak']['config']['log']['error']['file'] = "#{node['riak']['platform_log_dir']}/error.log" 37 | node.default['riak']['config']['log']['crash']['file'] = "#{node['riak']['platform_log_dir']}/crash.log" 38 | node.default['riak']['config']['ring']['state_dir'] = "#{node['riak']['platform_data_dir']}/ring" 39 | node.default['riak']['config']['bitcask']['data_root'] = "#{node['riak']['platform_data_dir']}/bitcask" 40 | node.default['riak']['config']['leveldb']['data_root'] = "#{node['riak']['platform_data_dir']}/leveldb" 41 | node.default['riak']['config']['search']['anti_entropy']['data_dir'] = "#{node['riak']['platform_data_dir']}/yz_anti_entropy" 42 | node.default['riak']['config']['search']['root_dir'] = "#{node['riak']['platform_data_dir']}/yz" 43 | 44 | include_recipe 'git' 45 | include_recipe 'build-essential' 46 | include_recipe 'erlang::source' 47 | 48 | pam_packages = value_for_platform_family( 49 | %w(debian ubuntu) => ['libpam0g-dev', 'libssl-dev'], 50 | %w(rhel fedora) => ['pam-devel', 'openssl-devel'] 51 | ) 52 | 53 | pam_packages.each do |pam_package| 54 | package pam_package do 55 | action :install 56 | end 57 | end 58 | 59 | source_version = "#{node['riak']['source']['version']['major']}.#{node['riak']['source']['version']['minor']}" 60 | source_uri = "#{node['riak']['source']['url']}/#{source_version}/#{source_version}.#{node['riak']['source']['version']['incremental']}/" 61 | source_file = "riak-#{source_version}.#{node['riak']['source']['version']['incremental']}" 62 | source_filename = "#{source_file}.tar.gz" 63 | 64 | group 'riak' do 65 | system true 66 | end 67 | 68 | user 'riak' do 69 | gid 'riak' 70 | shell '/bin/bash' 71 | home node['riak']['platform_data_dir'] 72 | system true 73 | end 74 | 75 | remote_file "#{Chef::Config[:file_cache_path]}/#{source_filename}" do 76 | source source_uri + source_filename 77 | owner 'root' 78 | mode 0644 79 | 80 | not_if do 81 | ::File.exist?("#{Chef::Config[:file_cache_path]}/#{source_filename}") && 82 | Digest::SHA256.file("#{Chef::Config[:file_cache_path]}/#{source_filename}").hexdigest == node['riak']['source']['checksum'] 83 | end 84 | end 85 | 86 | execute 'riak-src-unpack' do 87 | cwd Chef::Config[:file_cache_path] 88 | command "tar xfz #{source_filename}" 89 | not_if { File.directory?(File.join(Chef::Config[:file_cache_path], source_file)) } 90 | end 91 | 92 | execute 'riak-src-build' do 93 | cwd "#{Chef::Config[:file_cache_path]}/#{source_file}" 94 | command 'make clean locked-deps all rel' 95 | not_if { File.directory?("#{node['riak']['source']['prefix']}/riak") } 96 | end 97 | 98 | execute 'riak-src-install' do 99 | command "mv #{Chef::Config[:file_cache_path]}/#{source_file}/rel/riak #{node['riak']['source']['prefix']}" 100 | not_if { File.directory?("#{node['riak']['source']['prefix']}/riak") } 101 | end 102 | -------------------------------------------------------------------------------- /recipes/sysctl.rb: -------------------------------------------------------------------------------- 1 | # contains the bare minimum sysctl tunings to prevent 2 | # riak from throwing warnings on startup 3 | # This is optional for those with existing 4 | # tuning or wrapper cookbooks 5 | 6 | case node['platform_family'] 7 | when 'debian', 'rhel', 'fedora' 8 | node.default['sysctl']['params']['vm']['swappiness'] = 0 9 | node.default['sysctl']['params']['net']['core']['somaxconn'] = 40_000 10 | 11 | node.default['sysctl']['params']['net']['core'].tap do |core| 12 | core['somaxconn'] = 40_000 13 | core['wmem_default'] = 8_388_608 14 | core['wmem_max'] = 8_388_608 15 | core['rmem_default'] = 8_388_608 16 | core['rmem_max'] = 8_388_608 17 | core['netdev_max_backlog'] = 10_000 18 | end 19 | 20 | node.default['sysctl']['params']['net']['ipv4'].tap do |ipv4| 21 | ipv4['tcp_max_syn_backlog'] = 40_000 22 | ipv4['tcp_sack'] = 1 23 | ipv4['tcp_window_scaling'] = 1 24 | ipv4['tcp_fin_timeout'] = 15 25 | ipv4['tcp_keepalive_intvl'] = 30 26 | ipv4['tcp_tw_reuse'] = 1 27 | ipv4['tcp_moderate_rcvbuf'] = 1 28 | end 29 | 30 | include_recipe 'sysctl::apply' 31 | end 32 | -------------------------------------------------------------------------------- /templates/freebsd/rcd.erb: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Borrowed from: head/databases/riak/files/riak.in 328458 2013-09-27 12:04:42Z bdrewery $ 3 | 4 | # PROVIDE: riak 5 | # REQUIRE: LOGIN cleanvar 6 | # KEYWORD: shutdown 7 | 8 | # 9 | # Add the following lines to /etc/rc.conf to enable riak: 10 | # riak_enable (bool): Set to "NO" by default. 11 | # Set it to "YES" to enable riak on boot. 12 | # 13 | 14 | . /etc/rc.subr 15 | 16 | name="riak" 17 | rcvar=riak_enable 18 | 19 | pidfile=/var/run/riak/riak.pid 20 | 21 | start_cmd="riak_start" 22 | stop_cmd="riak_stop" 23 | restart_cdm="riak_restart" 24 | status_cmd="riak_status" 25 | command="/usr/local/sbin/riak" 26 | 27 | load_rc_config $name 28 | 29 | # Read rc.d config and set defaults 30 | load_rc_config "$name" 31 | : ${riak_enable:="NO"} 32 | : ${riak_user:="riak"} 33 | 34 | riak_start() 35 | { 36 | echo "Starting Riak." 37 | <%= node['riak']['platform_bin_dir'] %>/riak start 38 | return 0 39 | } 40 | 41 | riak_stop() 42 | { 43 | echo "Stopping Riak processes" 44 | <%= node['riak']['platform_bin_dir'] %>/riak stop 45 | killall -9 epmd 46 | return 0 47 | } 48 | 49 | riak_restart() 50 | { 51 | riak_stop 52 | riak_start 53 | return 0 54 | } 55 | 56 | riak_status() 57 | { 58 | if riak_running; then 59 | echo "Riak is running." 60 | return 0 61 | else 62 | echo "Riak is not running" 63 | return 1 64 | fi 65 | } 66 | 67 | riak_running() 68 | { 69 | local pid result ps 70 | pid=`<%= node['riak']['platform_bin_dir'] %>/riak getpid` 71 | result=`echo $?` 72 | if [ "$result" == 0 ]; then 73 | ps=`ps -waux | grep ${pid} | grep riak` 74 | result=`echo $?` 75 | if [ "$result" ]; then 76 | return 0 77 | else 78 | return 1 79 | fi 80 | else 81 | return 1 82 | fi 83 | } 84 | 85 | run_rc_command "$1" -------------------------------------------------------------------------------- /test/integration/custom_package/serverspec/custom_package_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe package('riak') do 4 | it 'is installed' do 5 | expect(subject).to be_installed 6 | end 7 | end 8 | 9 | describe service('riak') do 10 | it 'is enabled' do 11 | expect(subject).to be_enabled 12 | end 13 | 14 | it 'is running' do 15 | expect(subject).to be_running 16 | end 17 | end 18 | 19 | describe port(8098) do 20 | it 'is listening' do 21 | expect(subject).to be_listening 22 | end 23 | end 24 | 25 | describe port(8087) do 26 | it 'is listening' do 27 | expect(subject).to be_listening 28 | end 29 | end 30 | 31 | if %w(freebsd).include?(os[:family]) 32 | describe file('/usr/local/etc/riak/riak.conf') do 33 | it 'is a file' do 34 | expect(subject).to be_file 35 | end 36 | end 37 | else 38 | describe file('/etc/riak/riak.conf') do 39 | it 'is a file' do 40 | expect(subject).to be_file 41 | end 42 | end 43 | end 44 | 45 | if %w(debian ubuntu).include?(os[:family]) 46 | describe command('/etc/init.d/riak ping') do 47 | its(:stdout) { is_expected.to eq "pong\n" } 48 | end 49 | else 50 | describe command('riak ping') do 51 | its(:stdout) { is_expected.to eq "pong\n" } 52 | end 53 | end 54 | -------------------------------------------------------------------------------- /test/integration/custom_package/serverspec/spec_helper.rb: -------------------------------------------------------------------------------- 1 | require 'serverspec' 2 | 3 | # Required by serverspec 4 | set :backend, :exec 5 | 6 | set :path, '/sbin:/usr/sbin:/usr/local/sbin:$PATH' 7 | -------------------------------------------------------------------------------- /test/integration/custom_repository/serverspec/custom_repository_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe package('riak') do 4 | it 'is installed' do 5 | expect(subject).to be_installed 6 | end 7 | end 8 | 9 | describe service('riak') do 10 | it 'is enabled' do 11 | expect(subject).to be_enabled 12 | end 13 | 14 | it 'is running' do 15 | expect(subject).to be_running 16 | end 17 | end 18 | 19 | describe port(8098) do 20 | it 'is listening' do 21 | expect(subject).to be_listening 22 | end 23 | end 24 | 25 | describe port(8087) do 26 | it 'is listening' do 27 | expect(subject).to be_listening 28 | end 29 | end 30 | 31 | if %w(freebsd).include?(os[:family]) 32 | describe file('/usr/local/etc/riak/riak.conf') do 33 | it 'is a file' do 34 | expect(subject).to be_file 35 | end 36 | end 37 | else 38 | describe file('/etc/riak/riak.conf') do 39 | it 'is a file' do 40 | expect(subject).to be_file 41 | end 42 | end 43 | end 44 | 45 | if %w(debian ubuntu).include?(os[:family]) 46 | describe command('/etc/init.d/riak ping') do 47 | its(:stdout) { is_expected.to eq "pong\n" } 48 | end 49 | else 50 | describe command('riak ping') do 51 | its(:stdout) { is_expected.to eq "pong\n" } 52 | end 53 | end 54 | -------------------------------------------------------------------------------- /test/integration/custom_repository/serverspec/spec_helper.rb: -------------------------------------------------------------------------------- 1 | require 'serverspec' 2 | 3 | # Required by serverspec 4 | set :backend, :exec 5 | 6 | set :path, '/sbin:/usr/local/sbin:$PATH' 7 | -------------------------------------------------------------------------------- /test/integration/default/serverspec/default_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe package('riak') do 4 | it 'is installed' do 5 | expect(subject).to be_installed 6 | end 7 | end 8 | 9 | describe service('riak') do 10 | it 'is enabled' do 11 | expect(subject).to be_enabled 12 | end 13 | 14 | it 'is running' do 15 | expect(subject).to be_running 16 | end 17 | end 18 | 19 | describe port(8098) do 20 | it 'is listening' do 21 | expect(subject).to be_listening 22 | end 23 | end 24 | 25 | describe port(8087) do 26 | it 'is listening' do 27 | expect(subject).to be_listening 28 | end 29 | end 30 | 31 | if %w(freebsd).include?(os[:family]) 32 | describe file('/usr/local/etc/riak/riak.conf') do 33 | it 'is a file' do 34 | expect(subject).to be_file 35 | end 36 | end 37 | else 38 | describe file('/etc/riak/riak.conf') do 39 | it 'is a file' do 40 | expect(subject).to be_file 41 | end 42 | end 43 | end 44 | 45 | if %w(debian ubuntu).include?(os[:family]) 46 | describe command('/etc/init.d/riak ping') do 47 | its(:stdout) { is_expected.to eq "pong\n" } 48 | end 49 | else 50 | describe command('riak ping') do 51 | its(:stdout) { is_expected.to eq "pong\n" } 52 | end 53 | end 54 | -------------------------------------------------------------------------------- /test/integration/default/serverspec/spec_helper.rb: -------------------------------------------------------------------------------- 1 | require 'serverspec' 2 | 3 | # Required by serverspec 4 | set :backend, :exec 5 | 6 | set :path, '/sbin:/usr/sbin:/usr/local/sbin:$PATH' 7 | -------------------------------------------------------------------------------- /test/integration/enterprise/serverspec/enterprise_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe package('riak-ee') do 4 | it 'is installed' do 5 | expect(subject).to be_installed 6 | end 7 | end 8 | 9 | describe service('riak') do 10 | it 'is enabled' do 11 | expect(subject).to be_enabled 12 | end 13 | 14 | it 'is running' do 15 | expect(subject).to be_running 16 | end 17 | end 18 | 19 | describe port(8098) do 20 | it 'is listening' do 21 | expect(subject).to be_listening 22 | end 23 | end 24 | 25 | describe port(8087) do 26 | it 'is listening' do 27 | expect(subject).to be_listening 28 | end 29 | end 30 | 31 | if %w(freebsd).include?(os[:family]) 32 | describe file('/usr/local/etc/riak/riak.conf') do 33 | it 'is a file' do 34 | expect(subject).to be_file 35 | end 36 | end 37 | else 38 | describe file('/etc/riak/riak.conf') do 39 | it 'is a file' do 40 | expect(subject).to be_file 41 | end 42 | end 43 | end 44 | 45 | if %w(debian ubuntu).include?(os[:family]) 46 | describe command('/etc/init.d/riak ping') do 47 | its(:stdout) { is_expected.to eq "pong\n" } 48 | end 49 | else 50 | describe command('riak ping') do 51 | its(:stdout) { is_expected.to eq "pong\n" } 52 | end 53 | end 54 | -------------------------------------------------------------------------------- /test/integration/enterprise/serverspec/spec_helper.rb: -------------------------------------------------------------------------------- 1 | require 'serverspec' 2 | 3 | # Required by serverspec 4 | set :backend, :exec 5 | 6 | set :path, '/sbin:/usr/sbin:/usr/local/sbin:$PATH' 7 | -------------------------------------------------------------------------------- /test/integration/search/serverspec/search_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe package('riak') do 4 | it 'is installed' do 5 | expect(subject).to be_installed 6 | end 7 | end 8 | 9 | describe service('riak') do 10 | it 'is enabled' do 11 | expect(subject).to be_enabled 12 | end 13 | 14 | it 'is running' do 15 | expect(subject).to be_running 16 | end 17 | end 18 | 19 | describe command('java -version') do 20 | its(:stderr) { is_expected.to match(/java version "1.8.0_121"/) } 21 | end 22 | 23 | describe process('java') do 24 | it 'is running' do 25 | expect(subject).to be_running 26 | end 27 | end 28 | 29 | describe port(8098) do 30 | it 'is listening' do 31 | expect(subject).to be_listening 32 | end 33 | end 34 | 35 | describe port(8087) do 36 | it 'is listening' do 37 | expect(subject).to be_listening 38 | end 39 | end 40 | 41 | describe port(8093) do 42 | it 'is listening' do 43 | expect(subject).to be_listening 44 | end 45 | end 46 | 47 | describe port(8985) do 48 | it 'is listening' do 49 | expect(subject).to be_listening 50 | end 51 | end 52 | 53 | describe file('/etc/riak/riak.conf') do 54 | it 'is a file' do 55 | expect(subject).to be_file 56 | end 57 | end 58 | 59 | if %w(debian ubuntu).include?(os[:family]) 60 | describe command('/etc/init.d/riak ping') do 61 | its(:stdout) { is_expected.to eq "pong\n" } 62 | end 63 | else 64 | describe command('riak ping') do 65 | its(:stdout) { is_expected.to eq "pong\n" } 66 | end 67 | end 68 | -------------------------------------------------------------------------------- /test/integration/search/serverspec/spec_helper.rb: -------------------------------------------------------------------------------- 1 | require 'serverspec' 2 | 3 | # Required by serverspec 4 | set :backend, :exec 5 | 6 | set :path, '/sbin:/usr/sbin:/usr/local/sbin:$PATH' 7 | -------------------------------------------------------------------------------- /test/integration/source/rspec/Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | 3 | gem 'serverspec', '~> 2.3.1' 4 | gem 'specinfra', '~> 2.3.0' 5 | -------------------------------------------------------------------------------- /test/integration/source/rspec/source_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe file('/opt/riak') do 4 | it { should be_directory } 5 | end 6 | 7 | describe file('/opt/riak/etc/riak.conf') do 8 | it { should be_file } 9 | end 10 | -------------------------------------------------------------------------------- /test/integration/source/rspec/spec_helper.rb: -------------------------------------------------------------------------------- 1 | require 'serverspec' 2 | 3 | # Required by serverspec 4 | set :backend, :exec 5 | 6 | set :path, '/sbin:/usr/local/sbin:$PATH' 7 | 8 | set :formatter, :documentation 9 | -------------------------------------------------------------------------------- /test/integration/sysctl/serverspec/spec_helper.rb: -------------------------------------------------------------------------------- 1 | require 'serverspec' 2 | 3 | # Required by serverspec 4 | set :backend, :exec 5 | 6 | set :path, '/sbin:/usr/sbin:/usr/local/sbin:$PATH' 7 | -------------------------------------------------------------------------------- /test/integration/sysctl/serverspec/sysctl_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe file('/proc/sys/vm/swappiness') do 4 | it { should be_file } 5 | it { should contain '0' } 6 | end 7 | 8 | describe file('/proc/sys/net/core/somaxconn') do 9 | it { should be_file } 10 | it { should contain '40000' } 11 | end 12 | 13 | describe file('/proc/sys/net/core/wmem_default') do 14 | it { should be_file } 15 | it { should contain '8388608' } 16 | end 17 | 18 | describe file('/proc/sys/net/core/wmem_max') do 19 | it { should be_file } 20 | it { should contain '8388608' } 21 | end 22 | 23 | describe file('/proc/sys/net/core/rmem_default') do 24 | it { should be_file } 25 | it { should contain '8388608' } 26 | end 27 | 28 | describe file('/proc/sys/net/core/rmem_max') do 29 | it { should be_file } 30 | it { should contain '8388608' } 31 | end 32 | 33 | describe file('/proc/sys/net/core/netdev_max_backlog') do 34 | it { should be_file } 35 | it { should contain '10000' } 36 | end 37 | 38 | describe file('/proc/sys/net/ipv4/tcp_max_syn_backlog') do 39 | it { should be_file } 40 | it { should contain '40000' } 41 | end 42 | 43 | describe file('/proc/sys/net/ipv4/tcp_sack') do 44 | it { should be_file } 45 | it { should contain '1' } 46 | end 47 | 48 | describe file('/proc/sys/net/ipv4/tcp_window_scaling') do 49 | it { should be_file } 50 | it { should contain '1' } 51 | end 52 | 53 | describe file('/proc/sys/net/ipv4/tcp_fin_timeout') do 54 | it { should be_file } 55 | it { should contain '15' } 56 | end 57 | 58 | describe file('/proc/sys/net/ipv4/tcp_keepalive_intvl') do 59 | it { should be_file } 60 | it { should contain '30' } 61 | end 62 | 63 | describe file('/proc/sys/net/ipv4/tcp_tw_reuse') do 64 | it { should be_file } 65 | it { should contain '1' } 66 | end 67 | 68 | describe file('/proc/sys/net/ipv4/tcp_moderate_rcvbuf') do 69 | it { should be_file } 70 | it { should contain '1' } 71 | end 72 | 73 | persistence_file = case host_inventory['platform'] 74 | when 'redhat', 'fedora', 'amazon', 'debian', 'ubuntu' 75 | '/etc/sysctl.d/99-chef-attributes.conf' 76 | else 77 | '/etc/sysctl.conf' 78 | end 79 | 80 | describe file(persistence_file) do 81 | it { should be_file } 82 | it { should contain 'vm.swappiness=0' } 83 | it { should contain 'net.core.somaxconn=40000' } 84 | it { should contain 'net.core.wmem_default=8388608' } 85 | it { should contain 'net.core.wmem_max=8388608' } 86 | it { should contain 'net.core.rmem_default=8388608' } 87 | it { should contain 'net.core.rmem_max=8388608' } 88 | it { should contain 'net.core.netdev_max_backlog=10000' } 89 | it { should contain 'net.ipv4.tcp_max_syn_backlog=40000' } 90 | it { should contain 'net.ipv4.tcp_sack=1' } 91 | it { should contain 'net.ipv4.tcp_window_scaling=1' } 92 | it { should contain 'net.ipv4.tcp_fin_timeout=15' } 93 | it { should contain 'net.ipv4.tcp_keepalive_intvl=30' } 94 | it { should contain 'net.ipv4.tcp_tw_reuse=1' } 95 | it { should contain 'net.ipv4.tcp_moderate_rcvbuf=1' } 96 | end 97 | -------------------------------------------------------------------------------- /vagrantfile_bsd.erb: -------------------------------------------------------------------------------- 1 | Vagrant.configure("2") do |c| 2 | c.vm.box = "<%= config[:box] %>" 3 | c.vm.box_url = "<%= config[:box_url] %>" 4 | 5 | <% if config[:vm_hostname] %> 6 | c.vm.hostname = "<%= config[:vm_hostname] %>" 7 | <% end %> 8 | <% if config[:guest] %> 9 | c.vm.guest = <%= config[:guest] %> 10 | <% end %> 11 | <% if config[:username] %> 12 | c.ssh.username = "<%= config[:username] %>" 13 | <% end %> 14 | <% if config[:ssh_key] %> 15 | c.ssh.private_key_path = "<%= config[:ssh_key] %>" 16 | <% end %> 17 | 18 | c.ssh.shell = "sh" 19 | 20 | <% Array(config[:network]).each do |opts| %> 21 | c.vm.network(:<%= opts[0] %>, <%= opts[1..-1].join(", ") %>) 22 | <% end %> 23 | 24 | c.vm.synced_folder ".", "/vagrant", disabled: true 25 | <% config[:synced_folders].each do |source, destination, options| %> 26 | c.vm.synced_folder "<%= source %>", "<%= destination %>", <%= options %> 27 | <% end %> 28 | 29 | c.vm.provider :<%= config[:provider] %> do |p| 30 | <% config[:customize].each do |key, value| %> 31 | <% case config[:provider] 32 | when "virtualbox" %> 33 | p.customize ["modifyvm", :id, "--<%= key %>", "<%= value %>"] 34 | <% when "rackspace", "softlayer" %> 35 | p.<%= key %> = "<%= value%>" 36 | <% when /^vmware_/ %> 37 | <% if key == :memory %> 38 | <% unless config[:customize].include?(:memsize) %> 39 | p.vmx["memsize"] = "<%= value %>" 40 | <% end %> 41 | <% else %> 42 | p.vmx["<%= key %>"] = "<%= value %>" 43 | <% end %> 44 | <% end %> 45 | <% end %> 46 | end 47 | 48 | end --------------------------------------------------------------------------------