Created
July 12, 2010 15:26
-
-
Save MaherSaif/472588 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
#!/bin/ruby | |
nodes = [ { :name => "station1", | |
:services => { :ssh => { :listenaddress => "192.168.0.254", | |
:sshd_port => "2222" | |
} | |
} | |
}, | |
{ :name => "station2", | |
:services => { :ssh => { :listenaddress => "192.168.0.254", | |
:sshd_port => "2222" | |
} | |
} | |
} | |
] | |
#p nodes | |
nodesFile = File.new('nodes', 'w') | |
nodes.each do |n| | |
out = "" | |
out << "\nnode '#{n[:name]}.example.com'\n" | |
out << "{\n" | |
n[:services].each do |s, config| | |
if s == :ssh | |
out << "\tinclude SSH:Deploy\n" | |
out << "\n" | |
out << "\tSSH:config { '#{n[:name]}':\n" | |
out << "\t\tlistenaddress => '#{config[:listenaddress]}',\n" | |
out << "\t\tsshd_port => '#{config[:sshd_port]}',\n" | |
out << "\t}\n" | |
end | |
end | |
out << "}\n\n" | |
#puts out | |
nodesFile.write out | |
end | |
nodesFile.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment