vagabond 0.1.4 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +12 -0
- data/README.md +48 -48
- data/USAGE.md +197 -0
- data/bin/vagabond +24 -2
- data/lib/vagabond/actions/create.rb +14 -5
- data/lib/vagabond/actions/destroy.rb +10 -8
- data/lib/vagabond/actions/freeze.rb +2 -1
- data/lib/vagabond/actions/provision.rb +6 -3
- data/lib/vagabond/actions/rebuild.rb +6 -5
- data/lib/vagabond/actions/ssh.rb +3 -2
- data/lib/vagabond/actions/start.rb +2 -1
- data/lib/vagabond/actions/status.rb +19 -3
- data/lib/vagabond/actions/thaw.rb +2 -1
- data/lib/vagabond/actions/up.rb +16 -3
- data/lib/vagabond/constants.rb +36 -0
- data/lib/vagabond/cookbooks/lxc/libraries/lxc.rb +5 -4
- data/lib/vagabond/cookbooks/lxc/metadata.rb +2 -2
- data/lib/vagabond/cookbooks/lxc/providers/container.rb +0 -1
- data/lib/vagabond/cookbooks/vagabond/attributes/default.rb +5 -0
- data/lib/vagabond/cookbooks/vagabond/recipes/default.rb +32 -9
- data/lib/vagabond/helpers/cheffile_loader.rb +20 -0
- data/lib/vagabond/helpers.rb +66 -1
- data/lib/vagabond/internal_configuration.rb +43 -19
- data/lib/vagabond/kitchen.rb +311 -0
- data/lib/vagabond/knife.rb +22 -17
- data/lib/vagabond/server.rb +42 -32
- data/lib/vagabond/vagabond.rb +147 -55
- data/lib/vagabond/vagabondfile.rb +31 -6
- data/lib/vagabond/version.rb +1 -1
- data/vagabond.gemspec +3 -0
- metadata +54 -4
- data/lib/vagabond/commands.rb +0 -87
- data/lib/vagabond/config.rb +0 -7
data/lib/vagabond/knife.rb
CHANGED
@@ -1,34 +1,39 @@
|
|
1
|
-
require '
|
1
|
+
require 'thor'
|
2
|
+
require File.join(File.dirname(__FILE__), 'cookbooks/lxc/libraries/lxc.rb')
|
3
|
+
|
4
|
+
%w(helpers vagabondfile internal_configuration).each do |dep|
|
5
|
+
require "vagabond/#{dep}"
|
6
|
+
end
|
2
7
|
|
3
8
|
module Vagabond
|
4
|
-
class Knife
|
9
|
+
class Knife < Thor
|
5
10
|
|
11
|
+
include Thor::Actions
|
6
12
|
include Helpers
|
7
13
|
|
8
|
-
|
14
|
+
def initialize(*args)
|
15
|
+
super
|
16
|
+
end
|
9
17
|
|
10
|
-
|
11
|
-
|
12
|
-
@
|
13
|
-
|
14
|
-
|
18
|
+
desc 'knife COMMAND', 'Run knife commands against local Chef server'
|
19
|
+
def knife(command, *args)
|
20
|
+
@options = options.dup
|
21
|
+
@vagabondfile = Vagabondfile.new(options[:vagabond_file])
|
22
|
+
options[:disable_solo] = true
|
23
|
+
options[:sudo] = sudo
|
15
24
|
Lxc.use_sudo = @vagabondfile[:sudo].nil? ? true : @vagabondfile[:sudo]
|
16
|
-
@internal_config = InternalConfiguration.new(@vagabondfile, nil)
|
17
|
-
unless(
|
25
|
+
@internal_config = InternalConfiguration.new(@vagabondfile, nil, options)
|
26
|
+
unless(options[:local_server])
|
18
27
|
if(@vagabondfile[:local_chef_server] && @vagabondfile[:local_chef_server][:enabled])
|
19
28
|
srv = Lxc.new(@internal_config[:mappings][:server])
|
20
29
|
if(srv.running?)
|
21
|
-
|
30
|
+
options[:knife_opts] = " -s https://#{srv.container_ip(10, true)}"
|
22
31
|
else
|
23
|
-
|
32
|
+
options[:knife_opts] = ' -s https://no-local-server'
|
24
33
|
end
|
25
34
|
end
|
26
35
|
end
|
27
|
-
|
28
|
-
end
|
29
|
-
|
30
|
-
def execute
|
31
|
-
exec("knife #{name_args.join(' ')} #{Config[:knife_opts]}")
|
36
|
+
exec("knife #{[command, args].flatten.compact.join(' ')} #{options[:knife_opts]}")
|
32
37
|
end
|
33
38
|
|
34
39
|
|
data/lib/vagabond/server.rb
CHANGED
@@ -5,16 +5,23 @@ require 'digest/md5'
|
|
5
5
|
module Vagabond
|
6
6
|
|
7
7
|
class Server < Vagabond
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
setup_ui
|
14
|
-
load_configurations
|
15
|
-
Config[:disable_auto_provision] = true
|
8
|
+
|
9
|
+
class << self
|
10
|
+
def basename
|
11
|
+
'vagabond server'
|
12
|
+
end
|
16
13
|
end
|
14
|
+
|
15
|
+
self.class_exec(false, &Vagabond::COMMANDS)
|
17
16
|
|
17
|
+
def initialize(*args)
|
18
|
+
super
|
19
|
+
@name = 'server'
|
20
|
+
@base_template = 'ubuntu_1204' # TODO: Make this dynamic
|
21
|
+
setup(nil, name)
|
22
|
+
end
|
23
|
+
|
24
|
+
desc 'server stop', 'Stops the local Chef server'
|
18
25
|
def stop
|
19
26
|
if(lxc.exists?)
|
20
27
|
if(lxc.running?)
|
@@ -29,6 +36,7 @@ module Vagabond
|
|
29
36
|
end
|
30
37
|
end
|
31
38
|
|
39
|
+
desc 'auto_upload', 'Uploads all assets'
|
32
40
|
def auto_upload
|
33
41
|
ui.info 'Auto uploading all assets to local Chef server...'
|
34
42
|
upload_roles
|
@@ -38,26 +46,28 @@ module Vagabond
|
|
38
46
|
ui.info ui.color(' -> All assets uploaded!', :green)
|
39
47
|
end
|
40
48
|
|
49
|
+
desc 'upload_roles', 'Upload all roles'
|
41
50
|
def upload_roles
|
42
51
|
am_uploading('roles') do
|
43
|
-
com = "knife role from file #{File.join(base_dir, 'roles/*')} #{
|
52
|
+
com = "knife role from file #{File.join(base_dir, 'roles/*')} #{options[:knife_opts]}"
|
44
53
|
debug(com)
|
45
|
-
cmd = Mixlib::ShellOut.new(com, :live_stream =>
|
54
|
+
cmd = Mixlib::ShellOut.new(com, :live_stream => options[:debug])
|
46
55
|
cmd.run_command
|
47
56
|
cmd.error!
|
48
57
|
end
|
49
58
|
end
|
50
59
|
|
60
|
+
desc 'upload_databags', 'Upload all data bags'
|
51
61
|
def upload_databags
|
52
62
|
am_uploading('data bags') do
|
53
63
|
Dir.glob(File.join(base_dir, "data_bags/*")).each do |b|
|
54
64
|
next if %w(. ..).include?(b)
|
55
65
|
coms = [
|
56
|
-
"knife data bag create #{File.basename(b)} #{
|
57
|
-
"knife data bag from file #{File.basename(b)} #{
|
66
|
+
"knife data bag create #{File.basename(b)} #{options[:knife_opts]}",
|
67
|
+
"knife data bag from file #{File.basename(b)} #{options[:knife_opts]} --all"
|
58
68
|
].each do |com|
|
59
69
|
debug(com)
|
60
|
-
cmd = Mixlib::ShellOut.new(com, :live_stream =>
|
70
|
+
cmd = Mixlib::ShellOut.new(com, :live_stream => options[:debug])
|
61
71
|
cmd.run_command
|
62
72
|
cmd.error!
|
63
73
|
end
|
@@ -65,16 +75,18 @@ module Vagabond
|
|
65
75
|
end
|
66
76
|
end
|
67
77
|
|
78
|
+
desc 'upload_environments', 'Upload all environments'
|
68
79
|
def upload_environments
|
69
80
|
am_uploading('environments') do
|
70
|
-
com = "knife environment from file #{File.join(base_dir, 'environments/*')} #{
|
81
|
+
com = "knife environment from file #{File.join(base_dir, 'environments/*')} #{options[:knife_opts]}"
|
71
82
|
debug(com)
|
72
|
-
cmd = Mixlib::ShellOut.new(com, :live_stream =>
|
83
|
+
cmd = Mixlib::ShellOut.new(com, :live_stream => options[:debug])
|
73
84
|
cmd.run_command
|
74
85
|
cmd.error!
|
75
86
|
end
|
76
87
|
end
|
77
88
|
|
89
|
+
desc 'upload_cookbooks', 'Upload all cookbooks'
|
78
90
|
def upload_cookbooks
|
79
91
|
am_uploading('cookbooks') do
|
80
92
|
if(vagabondfile[:local_chef_server][:berkshelf])
|
@@ -87,6 +99,13 @@ module Vagabond
|
|
87
99
|
|
88
100
|
private
|
89
101
|
|
102
|
+
def validate!
|
103
|
+
end
|
104
|
+
|
105
|
+
def setup(action, name=nil, *args)
|
106
|
+
super(action, 'server', *args)
|
107
|
+
end
|
108
|
+
|
90
109
|
def am_uploading(thing)
|
91
110
|
ui.info "#{ui.color('Local chef server:', :bold)} Uploading #{ui.color(thing, :green)}"
|
92
111
|
yield
|
@@ -110,19 +129,10 @@ module Vagabond
|
|
110
129
|
end
|
111
130
|
end
|
112
131
|
|
113
|
-
def generated_name
|
114
|
-
unless(@_gn)
|
115
|
-
s = Digest::MD5.new
|
116
|
-
s << vagabondfile.path
|
117
|
-
@_gn = "server-#{s.hexdigest}"
|
118
|
-
end
|
119
|
-
@_gn
|
120
|
-
end
|
121
|
-
|
122
132
|
def do_create
|
123
|
-
com = "#{
|
133
|
+
com = "#{options[:sudo]}lxc-clone -n #{generated_name} -o #{@base_template}"
|
124
134
|
debug(com)
|
125
|
-
cmd = Mixlib::ShellOut.new(com, :live_stream =>
|
135
|
+
cmd = Mixlib::ShellOut.new(com, :live_stream => options[:debug])
|
126
136
|
cmd.run_command
|
127
137
|
cmd.error!
|
128
138
|
@lxc = Lxc.new(generated_name)
|
@@ -132,13 +142,13 @@ module Vagabond
|
|
132
142
|
lxc.start
|
133
143
|
ui.info ui.color(' -> Bootstrapping erchef...', :cyan)
|
134
144
|
tem_file = File.expand_path(File.join(File.dirname(__FILE__), 'bootstraps/server.erb'))
|
135
|
-
com = "#{
|
145
|
+
com = "#{options[:sudo]}knife bootstrap #{lxc.container_ip(10, true)} --template-file #{tem_file} -i /opt/hw-lxc-config/id_rsa"
|
136
146
|
debug(com)
|
137
|
-
cmd = Mixlib::ShellOut.new(com, :live_stream =>
|
147
|
+
cmd = Mixlib::ShellOut.new(com, :live_stream => options[:debug], :timeout => 1200)
|
138
148
|
cmd.run_command
|
139
149
|
cmd.error!
|
140
150
|
ui.info ui.color(' -> Chef Server CREATED!', :green)
|
141
|
-
|
151
|
+
options[:knife_opts] = " --server-url https://#{lxc.container_ip(20, true)}"
|
142
152
|
auto_upload if vagabondfile[:local_chef_server][:auto_upload]
|
143
153
|
end
|
144
154
|
|
@@ -146,16 +156,16 @@ module Vagabond
|
|
146
156
|
write_berks_config
|
147
157
|
com = "berks upload -c #{File.join(vagabond_dir, 'berks.json')}"
|
148
158
|
debug(com)
|
149
|
-
cmd = Mixlib::ShellOut.new(com, :live_stream =>
|
159
|
+
cmd = Mixlib::ShellOut.new(com, :live_stream => options[:debug])
|
150
160
|
cmd.run_command
|
151
161
|
cmd.error!
|
152
162
|
ui.info "Berks cookbook upload complete!"
|
153
163
|
end
|
154
164
|
|
155
165
|
def raw_upload
|
156
|
-
com = "knife cookbook upload#{
|
166
|
+
com = "knife cookbook upload#{options[:knife_opts]} --all"
|
157
167
|
debug(com)
|
158
|
-
cmd = Mixlib::ShellOut.new(com, :live_stream =>
|
168
|
+
cmd = Mixlib::ShellOut.new(com, :live_stream => options[:debug])
|
159
169
|
cmd.run_command
|
160
170
|
cmd.error!
|
161
171
|
ui.info "Cookbook upload complete!"
|
data/lib/vagabond/vagabond.rb
CHANGED
@@ -1,101 +1,189 @@
|
|
1
|
+
require 'thor'
|
2
|
+
require 'chef/knife/core/ui'
|
3
|
+
require File.join(File.dirname(__FILE__), 'cookbooks/lxc/libraries/lxc.rb')
|
4
|
+
|
5
|
+
%w(vagabondfile internal_configuration helpers).each do |dep|
|
6
|
+
require "vagabond/#{dep}"
|
7
|
+
end
|
8
|
+
|
1
9
|
Dir.glob(
|
2
10
|
File.join(
|
3
11
|
File.dirname(__FILE__), 'actions', '*.rb'
|
4
12
|
)
|
5
|
-
).each do |
|
6
|
-
require
|
13
|
+
).each do |action|
|
14
|
+
require "vagabond/actions/#{File.basename(action).sub('.rb', '')}"
|
7
15
|
end
|
8
16
|
|
9
|
-
require 'vagabond/vagabondfile'
|
10
|
-
require 'vagabond/internal_configuration'
|
11
|
-
require 'vagabond/helpers'
|
12
|
-
require 'chef/knife/core/ui'
|
13
|
-
require File.join(File.dirname(__FILE__), 'cookbooks/lxc/libraries/lxc.rb')
|
14
|
-
|
15
17
|
module Vagabond
|
16
|
-
class Vagabond
|
17
|
-
|
18
|
+
class Vagabond < Thor
|
19
|
+
|
20
|
+
include Thor::Actions
|
18
21
|
include Helpers
|
19
22
|
|
20
|
-
|
21
|
-
|
23
|
+
Actions.constants.each do |const|
|
24
|
+
klass = Actions.const_get(const)
|
25
|
+
include klass if klass.is_a?(Module)
|
22
26
|
end
|
23
27
|
|
24
|
-
# Load available actions
|
25
|
-
Actions.constants.each do |const_sym|
|
26
|
-
const = Actions.const_get(const_sym)
|
27
|
-
include const if const.is_a?(Module)
|
28
|
-
end
|
29
|
-
|
30
28
|
attr_reader :name
|
31
|
-
attr_reader :lxc
|
32
29
|
attr_reader :vagabondfile
|
33
|
-
attr_reader :config
|
34
30
|
attr_reader :internal_config
|
35
31
|
attr_reader :ui
|
32
|
+
attr_reader :options
|
33
|
+
|
34
|
+
attr_accessor :mappings_key
|
35
|
+
attr_accessor :lxc
|
36
|
+
attr_accessor :config
|
37
|
+
attr_accessor :action
|
38
|
+
|
39
|
+
CLI_OPTIONS = lambda do
|
40
|
+
class_option(:debug,
|
41
|
+
:type => :boolean,
|
42
|
+
:default => false
|
43
|
+
)
|
44
|
+
|
45
|
+
class_option(:force_solo,
|
46
|
+
:aliases => '--force-configure',
|
47
|
+
:type => :boolean,
|
48
|
+
:default => false,
|
49
|
+
:desc => 'Force configuration of system'
|
50
|
+
)
|
36
51
|
|
52
|
+
class_option(:color,
|
53
|
+
:type => :boolean,
|
54
|
+
:default => true,
|
55
|
+
:desc => 'Enable/disable colorized output'
|
56
|
+
)
|
57
|
+
|
58
|
+
class_option(:vagabond_file,
|
59
|
+
:aliases => '-f',
|
60
|
+
:type => :string,
|
61
|
+
:desc => 'Provide path to Vagabondfile'
|
62
|
+
)
|
63
|
+
|
64
|
+
class_option(:local_server,
|
65
|
+
:type => :boolean,
|
66
|
+
:default => true,
|
67
|
+
:desc => 'Enable/disable local Chef server usage if available'
|
68
|
+
)
|
69
|
+
end
|
70
|
+
|
71
|
+
CLI_OPTIONS.call
|
72
|
+
|
73
|
+
|
37
74
|
# action:: Action to perform
|
38
75
|
# name:: Name of vagabond
|
39
76
|
# config:: Hash configuration
|
40
77
|
#
|
41
|
-
# Creates an instance
|
42
|
-
def initialize(
|
78
|
+
# Creates an instance
|
79
|
+
def initialize(*args)
|
80
|
+
super
|
81
|
+
@mappings_key = :mappings
|
82
|
+
end
|
83
|
+
|
84
|
+
## COMMANDS
|
85
|
+
|
86
|
+
COMMANDS = lambda do |show_node=true|
|
87
|
+
Actions.constants.find_all do |const|
|
88
|
+
Actions.const_get(const).is_a?(Module)
|
89
|
+
end.map(&:to_s).map(&:downcase).each do |meth|
|
90
|
+
if(self.respond_to?("_#{meth}_desc"))
|
91
|
+
args = self.send("_#{meth}_desc")
|
92
|
+
else
|
93
|
+
args = ["#{meth}#{' NODE' if show_node}", "#{meth.capitalize} instance#{' of NODE' if show_node}"]
|
94
|
+
end
|
95
|
+
desc(*args)
|
96
|
+
if(self.respond_to?("_#{meth}_options"))
|
97
|
+
self.send("_#{meth}_options").each do |opts|
|
98
|
+
method_option(*opts)
|
99
|
+
end
|
100
|
+
end
|
101
|
+
define_method meth do |*args|
|
102
|
+
setup(meth, *args)
|
103
|
+
execute
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
COMMANDS.call
|
109
|
+
|
110
|
+
protected
|
111
|
+
|
112
|
+
def version
|
43
113
|
setup_ui
|
114
|
+
ui.info "#{ui.color('Vagabond:', :yellow, :bold)} - Advocating idleness and work-shyness"
|
115
|
+
ui.info " #{ui.color('Version:', :blue)} - #{VERSION.version} (#{VERSION.codename})"
|
116
|
+
exit EXIT_CODES[:success]
|
117
|
+
end
|
118
|
+
|
119
|
+
def execute
|
120
|
+
self.send("_#{@action}")
|
121
|
+
end
|
122
|
+
|
123
|
+
def setup(action, name=nil, *args)
|
44
124
|
@action = action
|
45
|
-
@name =
|
125
|
+
@name = name
|
126
|
+
@options = options.dup
|
127
|
+
if(args.last.is_a?(Hash))
|
128
|
+
_ui = args.delete(:ui)
|
129
|
+
@options.merge!(args.last)
|
130
|
+
end
|
131
|
+
setup_ui(_ui)
|
46
132
|
load_configurations
|
47
133
|
validate!
|
48
134
|
end
|
49
135
|
|
136
|
+
def name_required!
|
137
|
+
unless(name)
|
138
|
+
ui.fatal "Node name is required!"
|
139
|
+
exit EXIT_CODES[:missing_node_name]
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
def provision_solo(path)
|
144
|
+
ui.info "#{ui.color('Vagabond:', :bold)} Provisioning node: #{ui.color(name, :magenta)}"
|
145
|
+
lxc.container_ip(20) # force wait for container to appear and do so quietly
|
146
|
+
direct_container_command(
|
147
|
+
"chef-solo -c #{File.join(path, 'solo.rb')} -j #{File.join(path, 'dna.json')}",
|
148
|
+
:live_stream => STDOUT
|
149
|
+
)
|
150
|
+
end
|
151
|
+
|
50
152
|
def load_configurations
|
51
|
-
@vagabondfile = Vagabondfile.new(
|
52
|
-
|
53
|
-
|
153
|
+
@vagabondfile = Vagabondfile.new(options[:vagabond_file])
|
154
|
+
options[:sudo] = sudo
|
155
|
+
options[:disable_solo] = true if @action.to_s == 'status' && lxc_installed?
|
54
156
|
Lxc.use_sudo = @vagabondfile[:sudo].nil? ? true : @vagabondfile[:sudo]
|
55
|
-
@internal_config = InternalConfiguration.new(@vagabondfile, ui)
|
157
|
+
@internal_config = InternalConfiguration.new(@vagabondfile, ui, options)
|
56
158
|
@config = @vagabondfile[:boxes][name]
|
57
|
-
@lxc = Lxc.new(@internal_config[
|
58
|
-
|
159
|
+
@lxc = Lxc.new(@internal_config[mappings_key][name] || '____nonreal____')
|
160
|
+
if(options[:local_server] && lxc_installed?)
|
59
161
|
if(@vagabondfile[:local_chef_server] && @vagabondfile[:local_chef_server][:enabled])
|
60
|
-
|
61
|
-
|
62
|
-
|
162
|
+
srv_name = @internal_config[:mappings][:server]
|
163
|
+
srv = Lxc.new(srv_name) if srv_name
|
164
|
+
if(srv_name && srv.running?)
|
165
|
+
options[:knife_opts] = " --server-url https://#{srv.container_ip(10, true)}"
|
63
166
|
else
|
64
167
|
ui.warn 'Local chef server is not currently running!' unless @action.to_sym == :status
|
65
|
-
|
168
|
+
options[:knife_opts] = ' --server-url https://no-local-server'
|
66
169
|
end
|
67
170
|
end
|
68
171
|
end
|
69
172
|
end
|
70
173
|
|
71
|
-
protected
|
72
|
-
|
73
|
-
def setup_ui
|
74
|
-
Chef::Config[:color] = Config[:color].nil? ? true : Config[:color]
|
75
|
-
@ui = Chef::Knife::UI.new(STDOUT, STDERR, STDIN, {})
|
76
|
-
self.class.ui = @ui
|
77
|
-
end
|
78
|
-
|
79
174
|
def validate!
|
80
175
|
if(name.to_s == 'server')
|
81
|
-
ui.fatal "
|
176
|
+
ui.fatal "RESERVED node name supplied: #{ui.color(name, :red)}"
|
82
177
|
ui.info ui.color(" -> Try: vagabond server #{@action}", :cyan)
|
83
|
-
exit
|
178
|
+
exit EXIT_CODES[:reserved_name]
|
84
179
|
end
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
send(@action)
|
90
|
-
else
|
91
|
-
ui.error "Invalid action received: #{@action}"
|
180
|
+
if(name && config.nil? && !options[:disable_name_validate])
|
181
|
+
ui.fatal "Invalid node name supplied: #{ui.color(name, :red)}"
|
182
|
+
ui.info ui.color(" -> Available: #{vagabondfile[:nodes].keys.sort.join(', ')}", :cyan)
|
183
|
+
exit EXIT_CODES[:invalid_name]
|
92
184
|
end
|
93
185
|
end
|
94
|
-
|
95
|
-
def generate_hash
|
96
|
-
Digest::MD5.hexdigest(@vagabondfile.path)
|
97
|
-
end
|
98
|
-
|
186
|
+
|
99
187
|
def check_existing!
|
100
188
|
if(@lxc.exists?)
|
101
189
|
ui.error "LXC: #{name} already exists!"
|
@@ -110,5 +198,9 @@ module Vagabond
|
|
110
198
|
def vagabond_dir
|
111
199
|
File.join(base_dir, '.vagabond')
|
112
200
|
end
|
201
|
+
|
202
|
+
def lxc_installed?
|
203
|
+
system('which lxc-info > /dev/null')
|
204
|
+
end
|
113
205
|
end
|
114
206
|
end
|
@@ -6,19 +6,44 @@ module Vagabond
|
|
6
6
|
attr_reader :path
|
7
7
|
attr_reader :config
|
8
8
|
|
9
|
-
|
9
|
+
ALIASES = Mash.new(:boxes => :nodes, :nodes => :boxes)
|
10
|
+
|
11
|
+
def initialize(path=nil, *args)
|
10
12
|
path = discover_path(Dir.pwd) unless path
|
11
13
|
@path = path
|
12
|
-
load_configuration!
|
14
|
+
load_configuration!(args.include?(:allow_missing))
|
13
15
|
end
|
14
16
|
|
15
17
|
def [](k)
|
16
|
-
@config[k]
|
18
|
+
aliased(k) || @config[k]
|
17
19
|
end
|
18
20
|
|
19
|
-
def
|
20
|
-
|
21
|
-
|
21
|
+
def aliased(k)
|
22
|
+
if(ALIASES.has_key?(k))
|
23
|
+
v = [@config[k], @config[ALIASES[k]]].compact
|
24
|
+
if(v.size > 1)
|
25
|
+
case v.first.class
|
26
|
+
when Array
|
27
|
+
m = :|
|
28
|
+
when Hash
|
29
|
+
m = :merge
|
30
|
+
else
|
31
|
+
m = :+
|
32
|
+
end
|
33
|
+
v.inject(&m)
|
34
|
+
else
|
35
|
+
v.first
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def load_configuration!(no_raise = false)
|
41
|
+
if(@path && File.exists?(@path))
|
42
|
+
@config = Mash.new(self.instance_eval(IO.read(@path), @path, 1))
|
43
|
+
else
|
44
|
+
raise 'No Vagabondfile file found!' unless no_raise
|
45
|
+
@config = Mash.new
|
46
|
+
end
|
22
47
|
end
|
23
48
|
|
24
49
|
def discover_path(path)
|
data/lib/vagabond/version.rb
CHANGED
data/vagabond.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vagabond
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-03-
|
12
|
+
date: 2013-03-23 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: chef
|
@@ -27,6 +27,54 @@ dependencies:
|
|
27
27
|
- - ! '>='
|
28
28
|
- !ruby/object:Gem::Version
|
29
29
|
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: librarian
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: test-kitchen
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - '='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: 1.0.0.alpha.0
|
54
|
+
type: :runtime
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - '='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 1.0.0.alpha.0
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: thor
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
type: :runtime
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
30
78
|
description: Vagabonds, lazing about
|
31
79
|
email: chrisroberts.code@gmail.com
|
32
80
|
executables:
|
@@ -76,15 +124,16 @@ files:
|
|
76
124
|
- lib/vagabond/cookbooks/vagabond/attributes/default.rb
|
77
125
|
- lib/vagabond/cookbooks/vagabond/libraries/vagabond.rb
|
78
126
|
- lib/vagabond/cookbooks/vagabond/recipes/default.rb
|
79
|
-
- lib/vagabond/commands.rb
|
80
127
|
- lib/vagabond/server.rb
|
128
|
+
- lib/vagabond/kitchen.rb
|
81
129
|
- lib/vagabond/vagabondfile.rb
|
82
130
|
- lib/vagabond/bootstraps/server.erb
|
83
131
|
- lib/vagabond/version.rb
|
84
132
|
- lib/vagabond/knife.rb
|
85
133
|
- lib/vagabond/vagabond.rb
|
134
|
+
- lib/vagabond/constants.rb
|
86
135
|
- lib/vagabond/helpers.rb
|
87
|
-
- lib/vagabond/
|
136
|
+
- lib/vagabond/helpers/cheffile_loader.rb
|
88
137
|
- lib/vagabond/internal_configuration.rb
|
89
138
|
- lib/vagabond/actions/up.rb
|
90
139
|
- lib/vagabond/actions/create.rb
|
@@ -100,6 +149,7 @@ files:
|
|
100
149
|
- README.md
|
101
150
|
- vagabond.gemspec
|
102
151
|
- bin/vagabond
|
152
|
+
- USAGE.md
|
103
153
|
- CHANGELOG.md
|
104
154
|
homepage: http://github.com/chrisroberts/vagabond
|
105
155
|
licenses: []
|