vagrant-tagprovision 0.0.5 → 0.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 81bbb236dcbe93fb89361b2d398fd6f1914f337c
4
- data.tar.gz: 8919d93f112bc207fca770bf1f88bb016d0411b3
3
+ metadata.gz: ff65491c9f932358f16f93d1c5c63c16eefee422
4
+ data.tar.gz: a0113275a878180adb29cd41b9acfedb32446084
5
5
  SHA512:
6
- metadata.gz: 7f276c788aa973941c757e928585ff996dff84adea7d92eb742ebf50e3fffc4b33acfb05d2682de22aa6cfe4ec464a21020b6358de0f03ac3cdfef40a4c98e9a
7
- data.tar.gz: 357ca9e7fca0d4eccc5cc17d48883ced7adfb3b8d3ffd838d873613b22ba1d59a3e0299a3a92022d21a35024dd7dd72c91115eb4183fb57b16e6c81123fb9c4e
6
+ metadata.gz: fcc95a0cef4e0874116236106eaad27da2dbfefc1f51ce8588a74618ada5e47af2e5f6d910bfcc4e9171ac16039c15240f714ba170c8d0303b508680e5edd892
7
+ data.tar.gz: 89387d1ff650780c6783acef63a14f06f8b69cb6a50003a3b51e0333fd4f74f9d22eb7850615ee23a677327405aab2415870ac98eda857511e2f0b9465b3d675
data/Gemfile CHANGED
@@ -7,6 +7,6 @@ group :development do
7
7
  gem "vagrant", :git => "git://github.com/mitchellh/vagrant.git"
8
8
  end
9
9
  #
10
- # group :plugins do
11
- # gem "vagrant-tagprovision", path: "."
12
- # end
10
+ group :plugins do
11
+ gem "vagrant-tagprovision", path: "."
12
+ end
data/Vagrantfile CHANGED
@@ -1,5 +1,13 @@
1
1
  Vagrant.configure("2") do |config|
2
- config.vm.box = "precise64"
3
- config.vm.box_url = "http://files.vagrantup.com/precise64.box"
4
- config.vm.provision :shell, inline: "echo 'Testing Notifications to Pushbullet'"
2
+
3
+
4
+ config.vm.define "web" do |web|
5
+ web.vm.box_url = "http://files.vagrantup.com/precise64.box"
6
+ web.vm.box = "precise64"
7
+ end
8
+
9
+ config.vm.define "db" do |db|
10
+ db.vm.box_url = "http://files.vagrantup.com/precise64.box"
11
+ db.vm.box = "precise64"
12
+ end
5
13
  end
@@ -9,6 +9,8 @@ module VagrantPlugins
9
9
  @ui = env[:ui]
10
10
  @machine = env[:machine].name.to_s
11
11
  @machinfo = env[:machine]
12
+ @commit_hash = `git rev-parse HEAD`
13
+ @current_user = `whoami`
12
14
  end
13
15
 
14
16
  def call(env)
@@ -23,15 +25,74 @@ module VagrantPlugins
23
25
  provision = env[:provision_enabled]
24
26
 
25
27
  case action
26
- when :up
27
- client.push_note(iden, "Vagrant Hook Up: #{@machine}", '')
28
- when :reload
29
- client.push_note(iden, "Vagrant Hook Reload: #{@machine}", '')
30
- when :provision
31
- client.push_note(iden, "Vagrant Hoo Provision: #{@machine}", '')
28
+ when :up
29
+ env[:ui].info("Vagrant Hook Up: #{@machine}")
30
+ when :reload
31
+ env[:ui].info("Vagrant Hook Reload: #{@machine}")
32
+
33
+ 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"))
47
+ reallogfile = '/var/log/provision_log'
48
+ move_cmd = 'mv'
49
+ elsif (machine.communicate.test("test -d $Env:SystemRoot"))
50
+ windir = ""
51
+ machine.communicate.execute("echo %SYSTEMROOT%", {:shell => :cmd}) do |type, contents|
52
+ windir << contents.gsub("\r\n", '') if type == :stdout
53
+ end
54
+ reallogfile = "#{windir}\\System32\\drivers\\var\\provision_log"
55
+ move_cmd = 'mv -force'
56
+ else
57
+ reallogfile = '/var/log/provision_log'
58
+ move_cmd = 'mv -f'
59
+ end
60
+
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)
67
+
68
+ if update_file(file, machine, false)
69
+
70
+ # upload modified file and remove temporary file
71
+ machine.communicate.upload(file, '/tmp/provision_logs')
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}")
76
+ else
77
+ machine.communicate.sudo("#{move_cmd} /tmp/provision_logs #{reallogfile}")
78
+ end
79
+ end
80
+
81
+
82
+ env[:ui].info("Vagrant Hook Provision: #{@tmp_path}")
83
+
32
84
  end
33
85
  end
34
-
86
+
87
+ def update_file(file, resolving_machine = nil, include_id = true)
88
+ file = Pathname.new(file)
89
+ file_content_line = "Provisioned on #{@time.inspect} using commit #{@commit_hash} by #{@current_user}"
90
+ old_file_content = file.read
91
+ new_file_content = old_file_content + "\n#{file_content_line}"
92
+ file.open('wb') { |io| io.write(new_file_content) }
93
+ old_file_content != new_file_content
94
+ end
95
+
35
96
  def notification(config, config_file)
36
97
 
37
98
  end
@@ -1,5 +1,5 @@
1
1
  module VagrantPlugins
2
2
  module Tagprovision
3
- VERSION = "0.0.5"
3
+ VERSION = "0.0.6"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vagrant-tagprovision
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - jimrobinson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-01-08 00:00:00.000000000 Z
11
+ date: 2016-01-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler