class Grifork::Executor::Grifork

Public Instance Methods

run(node) click to toggle source

Run grifork command on remote node.

  1. Create Griforkfile and copy it to remote

  2. Login remote host by ssh and execute grifork command

# File lib/grifork/executor/grifork.rb, line 8
def run(node)
  c = config.grifork
  ssh node.host, %(test -d "#{c.workdir}" || mkdir -p "#{c.workdir}")
  rsync(node.host, config.griforkfile, "#{c.workdir}/Griforkfile")
  prepare_grifork_hosts_file_on_remote(node)
  ssh node.host, %(cd #{c.dir} && #{c.cmd} --file #{c.workdir}/Griforkfile --override-by #{c.workdir}/Griforkfile.hosts --on-remote)
end

Private Instance Methods

prepare_grifork_hosts_file_on_remote(node) click to toggle source
# File lib/grifork/executor/grifork.rb, line 18
  def prepare_grifork_hosts_file_on_remote(node)
    c = config.grifork
    hostsfile = Tempfile.create('Griforkfile.hosts')
    hostsfile.write(<<-EOS)
      hosts #{node.all_descendant_nodes.map(&:host)}
    EOS
    hostsfile.flush
    rsync(node.host, hostsfile.path, "#{c.workdir}/Griforkfile.hosts")
    hostsfile.close
  end