14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
# File 'lib/migrant/provisioners/chef_solo.rb', line 14
def upload
server = @environment.server
vagrant_environment = Vagrant::Environment.new
vagrant_provisioner_config = vagrant_environment.config.vm.provisioners.first.config
cookbook_paths = vagrant_provisioner_config.cookbooks_path
roles_path = vagrant_provisioner_config.roles_path
server.ssh "rm -rf /tmp/migrant && mkdir -p /tmp/migrant"
@environment.ui.info "Uploading Cookbooks"
cookbook_dest_paths = []
cookbook_paths.each do |path|
dest_path = "/tmp/migrant/#{File.basename(path)}"
server.scp path, dest_path, :recursive => true
cookbook_dest_paths << dest_path
end
role_dest_paths = []
dest_path = "/tmp/migrant/#{File.basename(roles_path)}"
server.scp roles_path, dest_path, :recursive => true
role_dest_paths << dest_path
@environment.ui.info "Generating Chef Solo Config Files"
File.open('/tmp/migrant-solo.rb','w') do |f|
f.write(TemplateRenderer.render('chef/solo.rb', {
:cookbook_path => cookbook_dest_paths,
:role_path => role_dest_paths
}))
end
server.scp "/tmp/migrant-solo.rb","/tmp/migrant/solo.rb"
File.open('/tmp/migrant-dna.json','w') do |f|
f.write(TemplateRenderer.render('chef/dna.json', {
:run_list => vagrant_provisioner_config.run_list
}))
end
server.scp "/tmp/migrant-dna.json","/tmp/migrant/dna.json"
end
|