Sha256: 4b81ded8c282c5dc03d97b767b437b1c1e1f4919c9e2cac652727ce96c876fad
Contents?: true
Size: 1.48 KB
Versions: 4
Compression:
Stored size: 1.48 KB
Contents
require 'thor' require File.join(File.dirname(__FILE__), 'cookbooks/lxc/libraries/lxc.rb') %w(helpers vagabondfile internal_configuration).each do |dep| require "vagabond/#{dep}" end module Vagabond class Knife < Thor include Thor::Actions include Helpers def initialize(*args) super end desc 'knife COMMAND', 'Run knife commands against local Chef server' def knife(command, *args) @options = options.dup @vagabondfile = Vagabondfile.new(options[:vagabond_file]) options[:disable_solo] = true options[:sudo] = sudo Lxc.use_sudo = @vagabondfile[:sudo].nil? ? true : @vagabondfile[:sudo] @internal_config = InternalConfiguration.new(@vagabondfile, nil, options) unless(options[:local_server]) if(@vagabondfile[:local_chef_server] && @vagabondfile[:local_chef_server][:enabled]) srv = Lxc.new(@internal_config[:mappings][:server]) if(srv.running?) proto = @vagabondfile[:local_chef_server][:zero] ? 'http' : 'https' options[:knife_opts] = " --server-url #{proto}://#{srv.container_ip(10, true)}" else options[:knife_opts] = ' -s https://no-local-server' end end end command_string = [command, args.map{|s| "'#{s}'"}].flatten.compact.join(' ') if(ENV['VAGABOND_KNIFE_DEBUG']) puts "knife #{command_string} #{options[:knife_opts]}" end exec("knife #{command_string} #{options[:knife_opts]}") end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
vagabond-0.2.8 | lib/vagabond/knife.rb |
vagabond-0.2.6 | lib/vagabond/knife.rb |
vagabond-0.2.4 | lib/vagabond/knife.rb |
vagabond-0.2.2 | lib/vagabond/knife.rb |