Skip to content

Instantly share code, notes, and snippets.

@MaherSaif
Created July 12, 2010 15:26
Show Gist options
  • Save MaherSaif/472588 to your computer and use it in GitHub Desktop.
Save MaherSaif/472588 to your computer and use it in GitHub Desktop.
#!/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