diff --git a/README.md b/README.md index 5360d27..9ea57b5 100644 --- a/README.md +++ b/README.md @@ -19,8 +19,8 @@ Place the `rs-base::default` recipe in the runlist. # Attributes -* `node['rs-base']['swap']['size']` - The swap file size in MB. This attribute must be a numeric value. - Default is `1024`. +* `node['rs-base']['swap']['size']` - The swap file size in GB. This attribute must be an integer. + Default is `1`. * `node['rs-base']['swap']['file']` - The location of the swap file. This attribute must be a valid filename. Default is `'/mnt/ephemeral/swapfile'`. * `node['rs-base']['ntp']['servers']` - List of fully qualified domain names for the array of servers that are used for @@ -36,7 +36,7 @@ All-in-one recipe to run all recipes in rs-base cookbook. ## rs-base::swap -Creates a swapfile of the specified size `node['rs-base']['swap']['size']` in the +Creates a swapfile of the specified size (in GB) `node['rs-base']['swap']['size']` in the specified location `node['rs-base']['swap']['file']` and enables it's usage. The swap file is added to `/etc/fstab` and will persist across reboots. If the size or the file location is invalid this recipe will fail with an error message indicating what the @@ -53,8 +53,8 @@ used as the remote syslog server. Otherwise local machine is used. ## rs-base::collectd -Installs the collectd client with some of the basic plugins, syslog, interface, df, disk, memory, load, -processes, users, and network. +Installs the collectd client with some of the basic plugins, syslog, interface, df, disk, memory, load, +processes, users, and network. # Author diff --git a/attributes/swap.rb b/attributes/swap.rb index 42e8423..8a10387 100644 --- a/attributes/swap.rb +++ b/attributes/swap.rb @@ -1,6 +1,6 @@ # # Cookbook Name:: rs-base -# Attributes:: swap +# Attributes:: swap # # Copyright (C) 2013 RightScale, Inc. # @@ -17,5 +17,5 @@ # limitations under the License. # -default['rs-base']['swap']['size'] = 1024 # MB +default['rs-base']['swap']['size'] = 1 # GB default['rs-base']['swap']['file'] = "/mnt/ephemeral/swapfile" diff --git a/metadata.rb b/metadata.rb index 2b456e0..5f7d434 100644 --- a/metadata.rb +++ b/metadata.rb @@ -37,6 +37,15 @@ "ec2-us-west.time.rightscale.com" ] +attribute "rs-base/swap/size", + :display_name => "Swap Size", + :description => + "The size of the swap file (in Gigabytes). This value should be an integer." + + " Example: 1", + :recipes => ["rs-base::default", "rs-base::swap"], + :required => "optional", + :default => "1" + attribute "rs-base/rsyslog_server", :display_name => "Remote rsyslog Server", :description => diff --git a/recipes/swap.rb b/recipes/swap.rb index 221697f..965f584 100644 --- a/recipes/swap.rb +++ b/recipes/swap.rb @@ -3,13 +3,13 @@ # Recipe:: swap # # Copyright (C) 2013 RightScale, Inc. -# +# # 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. @@ -32,9 +32,10 @@ end swap_file node['rs-base']['swap']['file'] do - size node['rs-base']['swap']['size'].to_i + # The swap cookbook expects the size to be in MB. So convert the size in GB to MB. + size node['rs-base']['swap']['size'].to_i * 1024 persist true action :create end -#TODO deal with collectd +#TODO deal with collectd diff --git a/test/integration/swap/bats/swap.bats b/test/integration/swap/bats/swap.bats index 7dca158..cebdc61 100644 --- a/test/integration/swap/bats/swap.bats +++ b/test/integration/swap/bats/swap.bats @@ -7,7 +7,7 @@ SWAPFILE="/mnt/ephemeral/swapfile" } @test "Has the correct swapfile size." { - ls -l --human-readable --block-size=M $SWAPFILE | grep "1024M" + ls -l --human-readable --block-size=G $SWAPFILE | grep "1G" } @test "Swapfile is enabled." {