Sha256: fe24209413933f33712b36345e948920e2495ae53c30220f8c69216dc3dac219

Contents?: true

Size: 1.07 KB

Versions: 12

Compression:

Stored size: 1.07 KB

Contents

class Subspace::Commands::Bootstrap < Subspace::Commands::Base

  def initialize(args, options)
    @host_spec = args.first
    @options = options
    @ask_pass = options.password
    @yum = options.yum
    run
  end

  def run
    # ansible atlanta -m copy -a "src=/etc/hosts dest=/tmp/hosts"
    hosts = inventory.find_hosts!(@host_spec)
    update_ansible_cfg
    hosts.each do |host|
      say "Bootstapping #{host.vars["hostname"]}..."
      learn_host(host)
      install_python(host)
    end
  end

  private

  def learn_host(host)
    system "ssh-keygen -R #{host.vars["ansible_host"]}"
    system "ssh-keyscan -H #{host.vars["ansible_host"]} >> ~/.ssh/known_hosts"
  end

  def install_python(host)
    cmd = ["ansible",
      host.name,
      "--private-key",
      "config/subspace/subspace.pem",
      "-m",
      "raw",
      "-a",
      "test -e /usr/bin/python3 || (apt -y update && apt install -y python3)",
      "--become"
    ]
    bootstrap_command cmd
  end

  def bootstrap_command(cmd)
    if @ask_pass
      cmd.push("--ask-pass")
    end
    ansible_command *cmd
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
subspace-3.0.13 lib/subspace/commands/bootstrap.rb
subspace-3.0.12 lib/subspace/commands/bootstrap.rb
subspace-3.0.11 lib/subspace/commands/bootstrap.rb
subspace-3.0.10 lib/subspace/commands/bootstrap.rb
subspace-3.0.9 lib/subspace/commands/bootstrap.rb
subspace-3.0.6 lib/subspace/commands/bootstrap.rb
subspace-3.0.5 lib/subspace/commands/bootstrap.rb
subspace-3.0.4 lib/subspace/commands/bootstrap.rb
subspace-3.0.3 lib/subspace/commands/bootstrap.rb
subspace-3.0.2 lib/subspace/commands/bootstrap.rb
subspace-3.0.0 lib/subspace/commands/bootstrap.rb
subspace-3.0.0.rc1 lib/subspace/commands/bootstrap.rb