cookbook 'swap_tuning', '= 0.1.0'
swap_tuning (6) Versions 0.1.0 Follow4
Creates a swap file of the recommended size considering the system memory.
cookbook 'swap_tuning', '= 0.1.0', :supermarket
knife supermarket install swap_tuning
knife supermarket download swap_tuning
Description
Chef cookbook to create a swap file of the recommended size considering the system memory.
This can be considered a general purpose cookbook but certainly not recommended for all cases.
Swap size is chosen based on the following documentation:
RedHat 7 Recommended Partitioning Scheme
<table>
<tr>
<th>RAM Size</th>
<th>Recommended Swap</th>
</tr>
<tr>
<td>≤ 2 GB</td>
<td>2 × RAM</td>
</tr>
<tr>
<td>2 GB – 8 GB</td>
<td>= RAM</td>
</tr>
<tr>
<td>8 GB – 64 GB</td>
<td>½ × RAM</td>
</tr>
<tr>
<td>> 64 GB</td>
<td>workload dependent</td>
</tr>
</table>
In case you already have swap in the system, creates another swap file with the difference if necessary.
Requirements
Platform:
This cookbook has been tested on the following platforms:
- Arch Linux
- CentOS
- Debian
- Fedora
- Ubuntu
- Amazon
Let us know if you use it successfully on any other platform.
Cookbooks:
Applications:
- Ruby 1.9.3 or higher.
Attributes
<table>
<tr>
<th>Attribute</th>
<th>Description</th>
<th>Default</th>
</tr>
<tr>
<td><code>node['swap_tuning']['size']</code></td>
<td>Total swap size in MB.</td>
<td><em>calculated</em></td>
</tr>
<tr>
<td><code>node['swap_tuning']['minimum_size']</code></td>
<td>Swap minimum size in MB.</td>
<td><code>nil</code></td>
</tr>
<tr>
<td><code>node['swap_tuning']['file_prefix']</code></td>
<td>Swap file name prefix.</td>
<td><code>"/swapfile"</code></td>
</tr>
<tr>
<td><code>node['swap_tuning']['persist']</code></td>
<td>Swap file persist.</td>
<td><code>true</code></td>
</tr>
</table>
Recipes
swap_tuning::default
Creates the swap file.
Usage
Including in a Cookbook Recipe
You can simply include it in a recipe:
# in your recipe include_recipe "swap_tuning::default"
Don't forget to include the swap_tuning
cookbook as a dependency in the metadata:
# metadata.rb depends "swap_tuning"
Including in the Run List
Another alternative is to include it in your Run List:
{ "name": "app001.onddo.com", [...] "run_list": [ [...] "recipe[swap_tuning]" ] }
Testing
Requirements
vagrant
foodcritic
rubocop
berkshelf
chefspec
test-kitchen
kitchen-vagrant
You must have VirtualBox and Vagrant installed.
You can install gem dependencies with bundler:
$ gem install bundler
$ bundle install
Running the Syntax Style Tests
$ bundle exec rake style
Running the Unit Tests
$ bundle exec rake unit
Running the Integration Tests
$ bundle exec rake integration
Or:
$ bundle exec kitchen list
$ bundle exec kitchen test
[...]
Running Integration Tests in the Cloud
Requirements:
kitchen-vagrant
kitchen-digitalocean
kitchen-ec2
You can run the tests in the cloud instead of using vagrant. First, you must set the following environment variables:
AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY
-
AWS_KEYPAIR_NAME
: EC2 SSH public key name. This is the name used in Amazon EC2 Console's Key Pars section. -
EC2_SSH_KEY_PATH
: EC2 SSH private key local full path. Only when you are not using an SSH Agent. DIGITALOCEAN_CLIENT_ID
DIGITALOCEAN_API_KEY
-
DIGITALOCEAN_SSH_KEY_IDS
: DigitalOcean SSH numeric key IDs. -
DIGITALOCEAN_SSH_KEY_PATH
: DigitalOcean SSH private key local full path. Only when you are not using an SSH Agent.
Then, you must configure test-kitchen to use .kitchen.cloud.yml
configuration file:
$ export KITCHEN_LOCAL_YAML=".kitchen.cloud.yml"
$ bundle exec kitchen list
[...]
Contributing
- Fork the repository on Github.
- Create a named feature branch (
$ git checkout -b my-new-feature
). - Write your change.
- Write tests for your change (if applicable).
- Run the tests, ensuring they all pass (
$ bundle exec rake
). - Commit your change (
$ git commit -am 'Add some feature'
). - Push to the branch (
$ git push origin my-new-feature
). - Submit a Pull Request using Github.
TODO
- Consider the available disk space.
License and Author
Author: | Xabier de Zuazo (xabier@onddo.com) |
Copyright: | Copyright (c) 2014, Onddo Labs, SL. (www.onddo.com) |
License: | Apache License, Version 2.0 |
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Dependent cookbooks
swap >= 0.0.0 |
Contingent cookbooks
There are no cookbooks that are contingent upon this one.