Class: Vagabond::Server
Constant Summary
Constants included
from Vagabond
BASE_TEMPLATES, COLORS, EXIT_CODES, VERSION
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Vagabond
get_bytes
Constructor Details
#initialize(*args) ⇒ Server
Returns a new instance of Server.
17
18
19
20
21
22
|
# File 'lib/vagabond/server.rb', line 17
def initialize(*args)
super
@name = 'server'
@base_template = 'ubuntu_1204' setup(nil, name)
end
|
Class Method Details
.basename ⇒ Object
10
11
12
|
# File 'lib/vagabond/server.rb', line 10
def basename
'vagabond server'
end
|
Instance Method Details
#auto_upload ⇒ Object
40
41
42
43
44
45
46
47
|
# File 'lib/vagabond/server.rb', line 40
def auto_upload
ui.info 'Auto uploading all assets to local Chef server...'
upload_roles
upload_databags
upload_environments
upload_cookbooks
ui.info ui.color(' -> All assets uploaded!', :green)
end
|
#stop ⇒ Object
25
26
27
28
29
30
31
32
33
34
35
36
37
|
# File 'lib/vagabond/server.rb', line 25
def stop
if(lxc.exists?)
if(lxc.running?)
ui.info 'Shutting down Chef server container...'
lxc.shutdown
ui.info 'Chef server container shut down!'
else
ui.error 'Chef server container not currently running'
end
else
ui.error 'Chef server container has not been created'
end
end
|
#upload_cookbooks ⇒ Object
90
91
92
93
94
95
96
97
98
|
# File 'lib/vagabond/server.rb', line 90
def upload_cookbooks
am_uploading('cookbooks') do
if(vagabondfile[:local_chef_server][:berkshelf])
berks_upload
else
raw_upload
end
end
end
|
#upload_databags ⇒ Object
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
# File 'lib/vagabond/server.rb', line 61
def upload_databags
am_uploading('data bags') do
Dir.glob(File.join(base_dir, "data_bags/*")).each do |b|
next if %w(. ..).include?(b)
coms = [
"knife data bag create #{File.basename(b)} #{options[:knife_opts]}",
"knife data bag from file #{File.basename(b)} #{options[:knife_opts]} --all"
].each do |com|
debug(com)
cmd = Mixlib::ShellOut.new(com, :live_stream => options[:debug])
cmd.run_command
cmd.error!
end
end
end
end
|
#upload_environments ⇒ Object
79
80
81
82
83
84
85
86
87
|
# File 'lib/vagabond/server.rb', line 79
def upload_environments
am_uploading('environments') do
com = "knife environment from file #{File.join(base_dir, 'environments/*')} #{options[:knife_opts]}"
debug(com)
cmd = Mixlib::ShellOut.new(com, :live_stream => options[:debug])
cmd.run_command
cmd.error!
end
end
|
#upload_roles ⇒ Object
50
51
52
53
54
55
56
57
58
|
# File 'lib/vagabond/server.rb', line 50
def upload_roles
am_uploading('roles') do
com = "knife role from file #{File.join(base_dir, 'roles/*')} #{options[:knife_opts]}"
debug(com)
cmd = Mixlib::ShellOut.new(com, :live_stream => options[:debug])
cmd.run_command
cmd.error!
end
end
|