Class: SSP::App::Remote
- Inherits:
-
Thor
- Object
- Thor
- SSP::App::Remote
- Defined in:
- lib/ssp/application/remote.rb
Instance Method Summary collapse
Instance Method Details
#command(nodes, *args) ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/ssp/application/remote.rb', line 49 def command(nodes, *args) chef_config nodes = nodes.split(" ").map {|n| n.index('.') or n.index(':') ? n : "#{n}.sspti.me"} user = ssh_user(nodes) cwd = working_dir(user) command = "cd #{cwd}\n#{args.join(" ")}" say "Running #{shell.set_color(args.join(" ").inspect, :green)} in #{shell.set_color(cwd, :yellow)} as #{shell.set_color(user, :blue)} on #{nodes.map {|n| shell.set_color(n, :cyan)}.join(", ").gsub(/,([^,]*)$/, " and\\1")}" ssh_run nodes.join(" "), command, user end |
#log(logfile) ⇒ Object
79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/ssp/application/remote.rb', line 79 def log(logfile) @working_dir = [:cwd] || [:node] == "dtm-db-2" ? "/srv/rsyslog" : "/var/log" @working_dir += '/' + [:host] if [:host] @working_dir += '/' + [:date].tr('-', '/') if [:node] == "dtm-db-2" @dont_print_hosts = true tail = "-f " if [:date] == Time.now.utc.strftime("%Y-%m-%d") command([:node], "tail -n#{[:history]} #{tail}#{logfile}") rescue Interrupt # we don't care about interrupting a tail end |
#rake(nodes, *args) ⇒ Object
62 63 64 65 |
# File 'lib/ssp/application/remote.rb', line 62 def rake(nodes, *args) args.unshift("rake") command(nodes, *args) end |