Skip to content

Commit

Permalink
Merge pull request #25 from rightscale-cookbooks/st_15_02_swap_issue_…
Browse files Browse the repository at this point in the history
…on_rhel_7

Added workaround for creating swap on RHEL 7.0.
  • Loading branch information
Lopaka Delp committed Jan 27, 2015
2 parents ba04afd + 632eab2 commit 3e49177
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ rs-base Cookbook CHANGELOG

This file is used to list changes made in each version of the rs-base cookbook.

v1.1.4
------

- Workaround added creating swap file on RedHat Enterprise Linux 7.0.

v1.1.3
------

Expand Down
2 changes: 1 addition & 1 deletion metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
license 'Apache 2.0'
description 'Installs/Configures rs-base'
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version '1.1.3'
version '1.1.4'

supports "centos"
supports "ubuntu"
Expand Down
15 changes: 12 additions & 3 deletions recipes/swap.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Cookbook Name:: rs-base
# Recipe:: swap
#
# Copyright (C) 2013 RightScale, Inc.
# Copyright (C) 2015 RightScale, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -31,8 +31,17 @@
action :create
end

# The swap cookbook expects the size to be in MB. So convert the size in GB to MB.
size_mb = node['rs-base']['swap']['size'].to_i * 1024

# RHEL 7.0 currently fails using an 'fallocate' file as swap which is what is done by the 'swap' community cookbook.
# Following is a workaround to create the file first with 'dd'.
# 'dd' command generated from https://github.com/sethvargo-cookbooks/swap/blob/v0.3.8/libraries/swapfile_provider.rb#L141
if node['platform'] == 'redhat' && node['platform_version'] == '7.0'
execute "dd if=/dev/zero of=#{node['rs-base']['swap']['file']} bs=1048576 count=#{size_mb}"
end

swap_file node['rs-base']['swap']['file'] do
# 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
size size_mb
action :create
end

0 comments on commit 3e49177

Please sign in to comment.