Sha256: 29cde675c979907cf13cec07b3b480606c39ecfc9be2365850f5669f143998cc

Contents?: true

Size: 1.24 KB

Versions: 13

Compression:

Stored size: 1.24 KB

Contents

class Subspace::Commands::Bootstrap < Subspace::Commands::Base
  def initialize(args, options)
    @host_spec = args.first
    @ask_pass = options.password
    @yum = options.yum
    run
  end

  def run
    # ansible atlanta -m copy -a "src=/etc/hosts dest=/tmp/hosts"
    install_python
    ensure_ssh_dir
    copy_authorized_keys
  end

  private

  def ensure_ssh_dir
    cmd = ["ansible",
      @host_spec,
      "-m",
      "file",
      "-a",
      "path=/home/{{ansible_ssh_user}}/.ssh state=directory mode=0700",
      "-vvvv"
    ]
    bootstrap_command cmd
  end

  def copy_authorized_keys
    # -m file -a "dest=/srv/foo/a.txt mode=600"
    cmd = ["ansible",
      @host_spec,
      "-m",
      "copy",
      "-a",
      "src=authorized_keys dest=/home/{{ansible_ssh_user}}/.ssh/authorized_keys mode=600",
      "-vvvv"
    ]
    bootstrap_command cmd
  end

  def install_python
    update_ansible_cfg
    cmd = ["ansible",
      @host_spec,
      "-m",
      "raw",
      "-a",
      "test -e /usr/bin/python || (apt -y update && apt install -y python-minimal)",
      "--become",
      "-vvvv"
    ]
    bootstrap_command cmd
  end

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

end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
subspace-0.4.13 lib/subspace/commands/bootstrap.rb
subspace-0.4.11 lib/subspace/commands/bootstrap.rb
subspace-0.4.10 lib/subspace/commands/bootstrap.rb
subspace-0.4.9 lib/subspace/commands/bootstrap.rb
subspace-0.4.8 lib/subspace/commands/bootstrap.rb
subspace-0.4.7 lib/subspace/commands/bootstrap.rb
subspace-0.4.6 lib/subspace/commands/bootstrap.rb
subspace-0.4.5 lib/subspace/commands/bootstrap.rb
subspace-0.4.4 lib/subspace/commands/bootstrap.rb
subspace-0.4.3 lib/subspace/commands/bootstrap.rb
subspace-0.4.2 lib/subspace/commands/bootstrap.rb
subspace-0.4.1 lib/subspace/commands/bootstrap.rb
subspace-0.4.0 lib/subspace/commands/bootstrap.rb