Sha256: ea2a3d200cfed4dd350ea3410755d27acf92b387197307d247155f325d62e21c

Contents?: true

Size: 1.1 KB

Versions: 1

Compression:

Stored size: 1.1 KB

Contents

require 'thor'
require 'json'
require 'yaml'

module Koma
  class CLI < Thor
    desc 'ssh', 'stdout remote host inventory'
    option :key,
           type: :string,
           banner: '<key1,key2,..>',
           desc: 'inventory keys',
           aliases: :k
    option :identity_file,
           type: :string,
           banner: '<identity_file>',
           desc: 'identity file',
           aliases: :i
    option :port,
           type: :numeric,
           banner: '<port>',
           desc: 'port',
           aliases: :p
    def ssh(host)
      backend = Koma::Backend::Ssh.new(host, options)
      puts JSON.pretty_generate(backend.gather)
    end

    desc 'exec', 'stdout local host inventory'
    option :key,
           type: :string,
           banner: '<key1,key2,..>',
           desc: 'inventory keys',
           aliases: :k
    def exec
      backend = Koma::Backend::Exec.new(nil, options)
      puts JSON.pretty_generate(backend.gather)
    end

    desc 'keys', 'host inventory keys'
    def keys
      Specinfra::HostInventory.inventory_keys.each do |key|
        puts key
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
koma-0.5.0 lib/koma/cli.rb