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 +4 -4
- data/Gemfile +3 -3
- data/Vagrantfile +11 -3
- data/lib/vagrant-tagprovision/action.rb +68 -7
- data/lib/vagrant-tagprovision/version.rb +1 -1
- metadata +2 -2
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: ff65491c9f932358f16f93d1c5c63c16eefee422
         | 
| 4 | 
            +
              data.tar.gz: a0113275a878180adb29cd41b9acfedb32446084
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: fcc95a0cef4e0874116236106eaad27da2dbfefc1f51ce8588a74618ada5e47af2e5f6d910bfcc4e9171ac16039c15240f714ba170c8d0303b508680e5edd892
         | 
| 7 | 
            +
              data.tar.gz: 89387d1ff650780c6783acef63a14f06f8b69cb6a50003a3b51e0333fd4f74f9d22eb7850615ee23a677327405aab2415870ac98eda857511e2f0b9465b3d675
         | 
    
        data/Gemfile
    CHANGED
    
    
    
        data/Vagrantfile
    CHANGED
    
    | @@ -1,5 +1,13 @@ | |
| 1 1 | 
             
            Vagrant.configure("2") do |config|
         | 
| 2 | 
            -
             | 
| 3 | 
            -
               | 
| 4 | 
            -
              config.vm. | 
| 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 | 
            -
             | 
| 27 | 
            -
             | 
| 28 | 
            -
             | 
| 29 | 
            -
             | 
| 30 | 
            -
             | 
| 31 | 
            -
                       | 
| 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
         | 
    
        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. | 
| 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- | 
| 11 | 
            +
            date: 2016-01-11 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: bundler
         |