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.
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.
- Ruby
2
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.
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'
Another alternative is to include it in your Run List:
{
"name": "app001.example.com",
"[...]": "[...]",
"run_list": [
"[...]",
"recipe[swap_tuning]"
]
}
See TESTING.md.
Please do not hesitate to open an issue with any questions or problems.
See CONTRIBUTING.md.
See TODO.md.
Author: | Xabier de Zuazo (xabier@zuazo.org) |
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
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.