Created
October 28, 2009 15:28
-
-
Save stormsilver/220541 to your computer and use it in GitHub Desktop.
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
default[:networking][:static_hosts] = {} | |
# read the existing hosts file on first run and preserve any entries found there | |
f = File.new("/etc/hosts") | |
static_hosts = {} | |
f.each_line do |line| | |
# ... | |
static_hosts[ip] = hostname | |
# ... | |
end | |
f.close | |
# preserve any attributes were here before | |
# self refers to a node object, which is the context in which this file is evaulated | |
(self[:networking][:static_hosts]).each do |ip, hostname| | |
# ... | |
static_hosts[ip] = hostname | |
# ... | |
end | |
# unequivocally set the attribute | |
set[:networking][:static_hosts] = static_hosts |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment