Created
January 21, 2012 21:45
-
-
Save ajdecon/1654155 to your computer and use it in GitHub Desktop.
nfs compute node recipe for blog post
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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