class Hocho::Drivers::ItamaeSsh

Public Class Methods

new(host, base_dir: '.', initializers: [], itamae_options: []) click to toggle source
Calls superclass method Hocho::Drivers::Base::new
# File lib/hocho/drivers/itamae_ssh.rb, line 7
def initialize(host, base_dir: '.', initializers: [], itamae_options: [])
  super host, base_dir: base_dir, initializers: initializers
  @itamae_options = itamae_options
end

Public Instance Methods

run(dry_run: false) click to toggle source
# File lib/hocho/drivers/itamae_ssh.rb, line 12
def run(dry_run: false)
  with_node_json_file do |node_json|
    env = {}.tap do |e|
      e['SUDO_PASSWORD'] = host.sudo_password if host.sudo_password
    end
    cmd = ["itamae", "ssh", *@itamae_options, "-j", node_json, "-h", host.hostname]

    cmd.push('-u', host.user) if host.user
    cmd.push('-p', host.ssh_port.to_s) if host.ssh_port
    cmd.push('--dry-run') if dry_run
    cmd.push('--color') if $stdout.tty?

    cmd.push(*run_list)

    puts "=> $ #{cmd.shelljoin}"
    system(env, *cmd, chdir: base_dir) or raise "itamae ssh failed"
  end
end