Adoptable Cookbooks List

Looking for a cookbook to adopt? You can now see a list of cookbooks available for adoption!
List of Adoptable Cookbooks

Supermarket Belongs to the Community

Supermarket belongs to the community. While Chef has the responsibility to keep it running and be stewards of its functionality, what it does and how it works is driven by the community. The chef/supermarket repository will continue to be where development of the Supermarket application takes place. Come be part of shaping the direction of Supermarket by opening issues and pull requests or by joining us on the Chef Mailing List.

Select Badges

Select Supported Platforms

Select Status


swap_tuning (6) Versions 0.2.0

Creates a swap file of the recommended size considering the system memory.

cookbook 'swap_tuning', '~> 0.2.0', :supermarket
cookbook 'swap_tuning', '~> 0.2.0'
knife supermarket install swap_tuning
knife supermarket download swap_tuning
Quality 17%

Swap Tuning Cookbook

Cookbook Version
Dependency Status
Code Climate
Build Status
Coverage Status

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:

RAM Size Recommended Swap
≤ 2 GB 2 × RAM
2 GB - 8 GB = RAM
8 GB - 64 GB ½ × RAM
> 64 GB workload dependent

In case you already have swap in the system, creates another swap file with the difference if necessary.


Supported Platforms

This cookbook has been tested on the following platforms:

  • Amazon
  • Arch Linux
  • CentOS
  • Debian
  • Fedora
  • OpenSUSE
  • RedHat
  • SUSE
  • Ubuntu

Please, let us know if you use it successfully on any other platform.

Required Cookbooks

Required Applications

  • Ruby 1.9.3 or higher.


Attribute Default Description
node['swap_tuning']['size'] calculated Total swap size in MB.
node['swap_tuning']['minimum_size'] nil Swap minimum size in MB.
node['swap_tuning']['file_prefix'] '/swapfile' Swap file name prefix.
node['swap_tuning']['persist'] true Swap file persist.



Creates the swap file.


Including in a Cookbook Recipe

You can simply include it in a recipe:

# in your recipe
include_recipe 'swap_tuning'

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": "",
  "[...]": "[...]",
  "run_list": [




Please do not hesitate to open an issue with any questions or problems.




License and Author

Author: Xabier de Zuazo (
Copyright: Copyright (c) 2015, Xabier de Zuazo
Copyright: Copyright (c) 2014, Onddo Labs, SL.
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

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
See the License for the specific language governing permissions and
limitations under the License.

Dependent cookbooks

swap ~> 0.3

Contingent cookbooks

There are no cookbooks that are contingent upon this one.

CHANGELOG for swap_tuning

This file is used to list changes made in each version of the swap_tuning cookbook.

v0.2.0 (2015-08-30)

  • Fix new RuboCop offense: SwapTuning#memory2bytes refactorized.
  • Update chef links to use domain.
  • Update contact information and links after migration.
  • metadata: Add source_url and issues_url.
  • Add SUSE support.

  • Documentation:

    • README:
    • Improve title.
    • Improve JSON examples.
  • Testing:

    • Travis CI: Add Ruby 2.2.
    • Test coverage to 100%.
    • Configure test coverage and
    • Add ChefSpec tests for swapfiles0-9 files creation.
    • Move ChefSpec tests to test/unit.
    • Update .kitchen.yml file.
    • Rakefile: Add clean task.
    • Gemfile updates:
    • Remove gnuplot dependency.
    • Update RuboCop to 0.33.0.
    • Disable guard-kitchen.
    • Use fixed versions for some gems.
    • Build against Chef 11 & 12.

v0.1.4 (2014-10-26)

  • Fix Chef < 11.12 support (fixes issue #1, thanks @amirarabi for the help).
  • Fix "cloning resource attributes from prior resource" warning.
  • Add more integrations tests and a swap_tuning_test cookbook.
  • Revert /[0-9]+KBI/ memory format support, bad fix (partial revert of b55c9ab in 2e198af).
  • Integrate tests with should_not gem.
  • spec/recipes/default_spec.rb chef_run code simplified.
  • Add complete unit tests for SwapTuning::RecipeHelpers library.

v0.1.3 (2014-10-20)

  • Support for /[0-9]+KBI/ memory format, fixes some Ubuntu 14.04 installations (fixes issue #1, thanks @amirarabi for the help).
  • updated.
  • README: include_recipe example without recipe name.

v0.1.2 (2014-10-17)

  • Chef::SwapTuning: add a missing space.
  • metadata: depends swap with pessimistic operator.
  • ChefSpec: use SoloRunner instead of Runner.
  • Fix RuboCop offense.
  • Add Serverspec tests.
    • Add Gemfile to Serverspec tests.
  • Use swap cookbook 0.3.8 ChefSpec matchers.
  • kitchen.yml: include more platform versions.
  • travis.yml: exclude some groups from bundle.
  • Add rubocop.yml with AllCops:Include.
  • Berkfile: use a generic Berksfile template.
  • Gemfile:
    • Update versions.
    • Berkshelf update to 3.1.
    • Refactor to use style, unit and integration groups.
    • Replace vagrant gem by vagrant-wrapper.
  • Rakefile: Add docu link and include kitchen only when needed.
  • Add Guardfile.
  • Add license header file to all ruby files.
    • Use markdown tables.
    • Use single quotes in examples.
  • TODO: use checkboxes.
  • Some small documentation improvements.

v0.1.1 (2014-07-26)

    • added an empty line above a table tag.
    • created CONTRIBUTING, TESTING and TODO files.
    • error fix: #<Encoding::InvalidByteSequenceError: "\xE2" on US-ASCII.
  • TODO: added some tasks.
  • Remove old comment from spec/spec_helper.rb.
  • Added RedHat as supported.

v0.1.0 (2014-07-14)

  • Initial release of swap_tuning.

Collaborator Number Metric

0.2.0 failed this metric

Failure: Cookbook has 1 collaborators. A cookbook must have at least 2 collaborators to pass this metric.

Contributing File Metric

0.2.0 failed this metric

Failure: To pass this metric, your cookbook metadata must include a source url, the source url must be in the form of, and your repo must contain a file

Foodcritic Metric

0.2.0 failed this metric

FC066: Ensure chef_version is set in metadata: swap_tuning/metadata.rb:1
FC069: Ensure standardized license defined in metadata: swap_tuning/metadata.rb:1
FC072: Metadata should not contain "attribute" keyword: swap_tuning/metadata.rb:1
FC121: Cookbook depends on cookbook made obsolete by Chef 14: swap_tuning/metadata.rb:1
Run with Foodcritic Version 16.3.0 with tags metadata,correctness ~FC031 ~FC045 and failure tags any

No Binaries Metric

0.2.0 passed this metric

Testing File Metric

0.2.0 failed this metric

Failure: To pass this metric, your cookbook metadata must include a source url, the source url must be in the form of, and your repo must contain a file

Version Tag Metric

0.2.0 failed this metric

Failure: To pass this metric, your cookbook metadata must include a source url, the source url must be in the form of, and your repo must include a tag that matches this cookbook version number