Created
March 2, 2012 15:57
-
-
Save fearoffish/1959301 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
require 'net/ssh' | |
class Host | |
def initialize(host, user, options={}) | |
@ssh = Net::SSH.start(host, user, options) | |
end | |
def close | |
@ssh.close | |
end | |
def run_chef(chef_command="sudo chef-client") | |
@ssh.exec! chef_command | |
end | |
def installed_packages | |
@packages ||= @ssh.exec! 'dpkg --get-selections' | |
@packages.split("\n").collect {|pkg| pkg.split(" ")[0] } | |
end | |
def users | |
@users ||= @ssh.exec! 'cat /etc/passwd' | |
@users.split("\n").collect {|u| u.split(":")[0] } | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment