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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ff65491c9f932358f16f93d1c5c63c16eefee422
4
- data.tar.gz: a0113275a878180adb29cd41b9acfedb32446084
3
+ metadata.gz: 8a669262d9b0838f6a37ace1a3ba9702366ec425
4
+ data.tar.gz: bd7db8ceabcead76e3a777d51c261c7eb6f165c9
5
5
  SHA512:
6
- metadata.gz: fcc95a0cef4e0874116236106eaad27da2dbfefc1f51ce8588a74618ada5e47af2e5f6d910bfcc4e9171ac16039c15240f714ba170c8d0303b508680e5edd892
7
- data.tar.gz: 89387d1ff650780c6783acef63a14f06f8b69cb6a50003a3b51e0333fd4f74f9d22eb7850615ee23a677327405aab2415870ac98eda857511e2f0b9465b3d675
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("Vagrant Hook Provision: #{@machine}")
35
- #@file = env.tmp_path.join("hosts.#{@machine}")
36
- @time = Time.new
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 (machine.communicate.test("test -d $Env:SystemRoot"))
45
+ elsif (@machinfo.communicate.test("test -d $Env:SystemRoot"))
50
46
  windir = ""
51
- machine.communicate.execute("echo %SYSTEMROOT%", {:shell => :cmd}) do |type, contents|
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.#{machine.name}_#{@commit_hash}")
62
- machine.communicate.sudo("touch #{reallogfile}")
63
- machine.communicate.sudo("chmod 777 #{reallogfile}")
64
- machine.communicate.sudo("touch /tmp/provision_logs")
65
- machine.communicate.sudo("chmod 777 /tmp/provision_logs")
66
- machine.communicate.download(reallogfile, file)
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, machine, false)
68
+ if update_file(file, @machinfo, false)
69
69
 
70
70
  # upload modified file and remove temporary file
71
- machine.communicate.upload(file, '/tmp/provision_logs')
71
+ @machinfo.communicate.upload(file, '/tmp/provision_logs')
72
72
  if windir
73
- machine.communicate.sudo("#{move_cmd} /tmp/provision_logs/hosts.#{machine.name} #{reallogfile}")
74
- elsif machine.communicate.test('test -f /.dockerinit')
75
- machine.communicate.sudo("cat /tmp/provision_logs > #{reallogfile}")
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
- machine.communicate.sudo("#{move_cmd} /tmp/provision_logs #{reallogfile}")
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
@@ -1,5 +1,5 @@
1
1
  module VagrantPlugins
2
2
  module Tagprovision
3
- VERSION = "0.0.6"
3
+ VERSION = "0.1.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vagrant-tagprovision
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - jimrobinson