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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
# File 'lib/vagrant-ansible-local/provisioner.rb', line 16
def provision
options = %W[--connection=local]
options << "#{config.raw_arguments}" if config.raw_arguments
if config.
= config..map do |k,v|
v = v.gsub('"', '\\"')
if v.include?(' ')
v = v.gsub("'", "\\'")
v = "'#{v}'"
end
"#{k}=#{v}"
end
options << "--extra-vars=\"#{.join(" ")}\""
end
options << "#{self.get_verbosity_argument}" if config.verbose
options << "--tags=#{as_list_argument(config.tags)}" if config.tags
options << "--skip-tags=#{as_list_argument(config.skip_tags)}" if config.skip_tags
options << "--limit=#{as_list_argument(config.limit)}" if config.limit
options << "--start-at-task=#{config.start_at_task}" if config.start_at_task
command = "export ANSIBLE_FORCE_COLOR=true\n"
command += "export ANSIBLE_HOST_KEY_CHECKING=#{config.host_key_checking}\n"
command += "export PYTHONUNBUFFERED=1\n"
command += (%w(ansible-playbook) << (File.join(config.guest_folder, File.basename(config.playbook).to_s)) << options).flatten.join(' ')
@machine.communicate.tap do |comm|
comm.execute(command, sudo: config.privileged) do |type, data|
if [:stderr, :stdout].include?(type)
@machine.env.ui.info(data, :new_line => false, :prefix => false)
end
end
end
end
|