vagrant-tagprovision 0.0.6 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/vagrant-tagprovision/action.rb +32 -38
- data/lib/vagrant-tagprovision/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8a669262d9b0838f6a37ace1a3ba9702366ec425
|
4
|
+
data.tar.gz: bd7db8ceabcead76e3a777d51c261c7eb6f165c9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 68c5409eda074c01fcfc4cbe5fbb2fb16b81882c629250bfaf98912d0639430cb70c12d80596926d881532c7551f49ef0b8eba2bcbfbf372fc5ddbad558bab3e
|
7
|
+
data.tar.gz: 67a097342c639f490ebc0893bf2d29db8db5815e0716442f2fb2658d1a5225b547b16578e09fd9124f46ce57eee89264d521c92737a875c1d4c18f8399738498
|
@@ -10,7 +10,13 @@ module VagrantPlugins
|
|
10
10
|
@machine = env[:machine].name.to_s
|
11
11
|
@machinfo = env[:machine]
|
12
12
|
@commit_hash = `git rev-parse HEAD`
|
13
|
+
@commit_hash.strip!
|
13
14
|
@current_user = `whoami`
|
15
|
+
@time = Time.new
|
16
|
+
@tag = "provisioned_#{@machine}_#{@time.year}#{@time.month}#{@time.day}#{@time.hour}#{@time.min}#{@time.sec}"
|
17
|
+
machine_env = @machinfo.env;
|
18
|
+
@tmp_path = machine_env.tmp_path;
|
19
|
+
|
14
20
|
end
|
15
21
|
|
16
22
|
def call(env)
|
@@ -26,29 +32,19 @@ module VagrantPlugins
|
|
26
32
|
|
27
33
|
case action
|
28
34
|
when :up
|
29
|
-
env[:ui].info("Vagrant Hook Up: #{@machine}")
|
35
|
+
#env[:ui].info("Vagrant Hook Up: #{@machine}")
|
30
36
|
when :reload
|
31
|
-
env[:ui].info("Vagrant Hook Reload: #{@machine}")
|
37
|
+
#env[:ui].info("Vagrant Hook Reload: #{@machine}")
|
32
38
|
|
33
39
|
when :provision
|
34
|
-
env[:ui].info("
|
35
|
-
|
36
|
-
@
|
37
|
-
@tag = "provisioned_#{@machine}_#{@time.year}#{@time.month}#{@time.day}#{@time.hour}#{@time.min}#{@time.sec}"
|
38
|
-
@pwd = `pwd`
|
39
|
-
machine_env = @machinfo.env;
|
40
|
-
@tmp_path = machine_env.tmp_path;
|
41
|
-
|
42
|
-
|
43
|
-
machine = @machinfo
|
44
|
-
|
45
|
-
|
46
|
-
if (machine.communicate.test("uname -s | grep SunOS"))
|
40
|
+
env[:ui].info("Logging provisioning information to guest machine: #{@machine}")
|
41
|
+
|
42
|
+
if (@machinfo.communicate.test("uname -s | grep SunOS"))
|
47
43
|
reallogfile = '/var/log/provision_log'
|
48
44
|
move_cmd = 'mv'
|
49
|
-
elsif (
|
45
|
+
elsif (@machinfo.communicate.test("test -d $Env:SystemRoot"))
|
50
46
|
windir = ""
|
51
|
-
|
47
|
+
@machinfo.communicate.execute("echo %SYSTEMROOT%", {:shell => :cmd}) do |type, contents|
|
52
48
|
windir << contents.gsub("\r\n", '') if type == :stdout
|
53
49
|
end
|
54
50
|
reallogfile = "#{windir}\\System32\\drivers\\var\\provision_log"
|
@@ -58,33 +54,35 @@ module VagrantPlugins
|
|
58
54
|
move_cmd = 'mv -f'
|
59
55
|
end
|
60
56
|
|
61
|
-
file = @tmp_path.join("hosts.#{
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
57
|
+
file = @tmp_path.join("hosts.#{@machinfo.name}_#{@commit_hash}")
|
58
|
+
|
59
|
+
# Make sure the log files exist and are writable.
|
60
|
+
@machinfo.communicate.sudo("touch #{reallogfile}")
|
61
|
+
@machinfo.communicate.sudo("chmod 666 #{reallogfile}")
|
62
|
+
@machinfo.communicate.sudo("touch /tmp/provision_logs")
|
63
|
+
@machinfo.communicate.sudo("chmod 666 /tmp/provision_logs")
|
64
|
+
|
65
|
+
# download the current log file
|
66
|
+
@machinfo.communicate.download(reallogfile, file)
|
67
67
|
|
68
|
-
if update_file(file,
|
68
|
+
if update_file(file, @machinfo, false)
|
69
69
|
|
70
70
|
# upload modified file and remove temporary file
|
71
|
-
|
71
|
+
@machinfo.communicate.upload(file, '/tmp/provision_logs')
|
72
72
|
if windir
|
73
|
-
|
74
|
-
elsif
|
75
|
-
|
73
|
+
@machinfo.communicate.sudo("#{move_cmd} /tmp/provision_logs/hosts.#{@machinfo.name} #{reallogfile}")
|
74
|
+
elsif @machinfo.communicate.test('test -f /.dockerinit')
|
75
|
+
@machinfo.communicate.sudo("cat /tmp/provision_logs > #{reallogfile}")
|
76
76
|
else
|
77
|
-
|
77
|
+
@machinfo.communicate.sudo("#{move_cmd} /tmp/provision_logs #{reallogfile}")
|
78
78
|
end
|
79
|
-
end
|
80
|
-
|
81
|
-
|
82
|
-
env[:ui].info("Vagrant Hook Provision: #{@tmp_path}")
|
83
|
-
|
79
|
+
end
|
80
|
+
env[:ui].info("Finished logging provisioning information to guest machine: #{@machine}")
|
84
81
|
end
|
85
82
|
end
|
86
83
|
|
87
84
|
def update_file(file, resolving_machine = nil, include_id = true)
|
85
|
+
#update the file with the current state of the vagrant config and the user provisioning
|
88
86
|
file = Pathname.new(file)
|
89
87
|
file_content_line = "Provisioned on #{@time.inspect} using commit #{@commit_hash} by #{@current_user}"
|
90
88
|
old_file_content = file.read
|
@@ -92,10 +90,6 @@ module VagrantPlugins
|
|
92
90
|
file.open('wb') { |io| io.write(new_file_content) }
|
93
91
|
old_file_content != new_file_content
|
94
92
|
end
|
95
|
-
|
96
|
-
def notification(config, config_file)
|
97
|
-
|
98
|
-
end
|
99
93
|
end
|
100
94
|
end
|
101
95
|
end
|