Skip to content

Instantly share code, notes, and snippets.

@ajdecon
Created January 21, 2012 21:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ajdecon/1654155 to your computer and use it in GitHub Desktop.
Save ajdecon/1654155 to your computer and use it in GitHub Desktop.
nfs compute node recipe for blog post
package("nfs-common")
# Make sure the diretory to be exported exists
node.nfs['shared_dirs'].each do |dir|
directory dir do
mode "0777"
action :create
end
end
file "/etc/fstab" do
sourceip = node.nfs['headnode_addr']
dirs = node.nfs['shared_dirs']
# Generate the new fstab lines
new_lines = ""
dirs.each do |d|
new_lines = new_lines + "#{sourceip}:#{d} #{d} nfs defaults 0 0\n"
end
print "*** Mount line: #{new_lines}\n"
# Get current content, check for duplication
only_if do
current_content = File.read('/etc/fstab')
current_content.index(new_lines).nil?
end
print "*** Passed the conditional for current content\n"
# Set up the file and content
owner "root"
group "root"
mode "0644"
current_content = File.read('/etc/fstab')
new_content = current_content + new_lines
content new_content
end
execute "mount" do
command "mount -a"
action :run
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment