vagrant-ohai 0.1.7 → 0.1.8

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,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- ZjdmMDhkNjEwYmU2Yzg5ODM5ZGEzYWI1Y2Y2NDM5ZWM3ZDkzNWEzOA==
5
- data.tar.gz: !binary |-
6
- MmUwNDIwN2EwNDQ5ZDJjZWVmYmI3MDdmNTE3OGU2YzEwYWVlOWNlYg==
7
- !binary "U0hBNTEy":
8
- metadata.gz: !binary |-
9
- NzYxZjU0ZGFlMjdiMGUxNGUzZTE3MGIxOGRiYWRkNDMxM2E1NjMzMzk1YmE4
10
- ZWE1NTA1MGQ4NGFlY2UxNmE2NDQwZDNjOTcwZWI0YThhZDNlMTI4YTIzYzEx
11
- ZDU3NmY3YTBmNTVkYzE5MDAyNmQ2OGJhOGYwNzg5NDNiYjUyNDU=
12
- data.tar.gz: !binary |-
13
- NDZjYTFkYTVlZDlmZDFhY2I0OTlkZTRkYTQ1OWM1YmMyZDgxYThjMWVjYmE1
14
- OGZlYjg1NzVkZDEyYmM4OGQ2YjQxNGZiYjgxMDExOWJkMWYzZTAwM2I0YjA3
15
- MTIyNzdmYzFiZjZjOGNmNzJlZjRkOWUzZmE1Mjc3M2M2YTU4NmI=
2
+ SHA1:
3
+ metadata.gz: 467ca797e2547af64cd69480e69b09b405f1f5a9
4
+ data.tar.gz: 4b1b7eb2e238de17be072f7a3d14e9e6c0b16783
5
+ SHA512:
6
+ metadata.gz: 09f6532b1220a561e0efd968a1e19b569f25db6ada53a959a3f1cb38e8c785a05b69c533d60093e81ec5a85afdf52fe164bb5e722acf4003fd9a04c923f6471d
7
+ data.tar.gz: 914ab895dd5d5771e2d92424d08649eec8b27552b2ccb69edb3a6fd8c7faec758496d51ca96f4435cf71aca42a6867211d11501bb8046e51696c21ca55520052
data/lib/ohai/vagrant.rb CHANGED
@@ -1,19 +1,36 @@
1
- hints = hint?("vagrant")
1
+ Ohai.plugin(:VboxIpaddress) do
2
2
 
3
- provides "vagrant"
4
- provides "cloud"
3
+ provides 'ipaddress'
5
4
 
6
- vagrant Mash.new
7
- cloud Mash.new
5
+ depends 'ipaddress'
6
+ depends 'network/interfaces'
7
+ depends 'virtualization/system'
8
+ depends 'etc/passwd'
8
9
 
9
- if hints
10
- vagrant.merge!(hints)
11
- require_plugin "cloud"
12
- if vagrant[:primary_nic]
13
- ipaddress network[:interfaces][vagrant[:primary_nic]][:addresses].find{|addr, addr_opts| addr_opts[:family] == "inet"}.first
14
- elsif vagrant[:private_ipv4]
15
- cloud[:local_ipv4] = vagrant[:private_ipv4]
16
- ipaddress vagrant[:private_ipv4]
10
+ # Ohai hint
11
+ unless File.exist?('/etc/chef/ohai_plugins/vagrant.json')
12
+ Chef::Log.fail('Ohai has not set :ipaddress (Missing vagrant.json)')
13
+ return
14
+ end
15
+ vagrant = JSON.parse(IO.read('/etc/chef/ohai_plugins/vagrant.json'))
16
+
17
+ # requested nit
18
+ nic = vagrant['primary_nic']
19
+ if nic.nil?
20
+ Chef::Log.debug('nic not set for vagrant-ohai plugin. Skipping')
21
+ return
22
+ end
23
+
24
+ collect_data(:default) do
25
+ if etc['passwd'].any? { |k, _v| k == 'vagrant' }
26
+ if network['interfaces'][nic] && virtualization['system'] == 'vbox'
27
+ network['interfaces'][nic]['addresses'].each do |ip, params|
28
+ if params['family'] == ('inet')
29
+ ipaddress ip
30
+ Chef::Log.info("Ohai override :ipaddress to #{ip} from #{nic}")
31
+ end
32
+ end
33
+ end
34
+ end
17
35
  end
18
- cloud[:provider] = "vagrant"
19
36
  end
@@ -14,23 +14,23 @@ module VagrantPlugins
14
14
  end
15
15
 
16
16
  def call(env)
17
+ is_chef_used = chef_provisioners.any?
17
18
  @app.call(env)
18
19
  return unless @machine.communicate.ready?
19
20
 
20
- if chef_provisioners.any? and @machine.config.ohai.enable
21
+ if is_chef_used && @machine.config.ohai.enable
21
22
  @machine.ui.info("Installing Ohai plugin")
22
23
  create_ohai_folders
23
24
  copy_ohai_plugin
24
- hint_ohai
25
25
  end
26
26
  end
27
27
 
28
28
  private
29
+
29
30
  def create_ohai_folders
30
31
  @machine.communicate.tap do |comm|
31
- comm.sudo("mkdir -p /etc/chef/ohai/hints")
32
32
  comm.sudo("mkdir -p /etc/chef/ohai_plugins")
33
- comm.sudo("chown -R #{@machine.ssh_info[:username]} /etc/chef/ohai/hints /etc/chef/ohai_plugins")
33
+ comm.sudo("chown -R #{@machine.ssh_info[:username]} /etc/chef/ohai_plugins")
34
34
  end
35
35
  end
36
36
 
@@ -42,20 +42,18 @@ module VagrantPlugins
42
42
 
43
43
  def vagrant_info
44
44
  info = {}
45
- info[:private_ipv4] = private_ipv4 if private_ipv4
46
45
  info[:box] = @machine.config.vm.box
47
46
  info[:primary_nic] = @machine.config.ohai.primary_nic
48
47
  info
49
48
  end
50
49
 
51
- def hint_ohai
50
+ def copy_ohai_plugin
51
+
52
52
  hint_file = Tempfile.new(["vagrant-ohai", ".json"])
53
53
  hint_file.write(vagrant_info.to_json)
54
54
  hint_file.close
55
- @machine.communicate.upload(hint_file.path, "/etc/chef/ohai/hints/vagrant.json")
56
- end
55
+ @machine.communicate.upload(hint_file.path, "/etc/chef/ohai_plugins/vagrant.json")
57
56
 
58
- def copy_ohai_plugin
59
57
  @machine.communicate.upload(OHAI_PLUGIN_PATH, "/etc/chef/ohai_plugins/vagrant.rb")
60
58
  end
61
59
 
@@ -1,12 +1,12 @@
1
1
  module VagrantPlugins
2
2
  module Ohai
3
+ #
3
4
  module Helpers
4
-
5
5
  def chef_provisioners
6
- @machine.config.vm.provisioners.find_all {|provisioner|
7
- [:chef_client, :chef_solo].include? provisioner.name }
6
+ @machine.config.vm.provisioners.find_all do |provisioner|
7
+ [:shell, :chef_client, :chef_solo, :chef_zero, :chef_apply].include? provisioner.type
8
+ end
8
9
  end
9
-
10
10
  end
11
11
  end
12
12
  end
@@ -4,7 +4,7 @@ require "vagrant/plugin"
4
4
  raise RuntimeError, "vagrant-ohai will only work with Vagrant 1.2.3 and above!" if Vagrant::VERSION <= "1.2.3"
5
5
 
6
6
  module VagrantPlugins
7
- module Ohai
7
+ module Ohai
8
8
  class Plugin < Vagrant.plugin("2")
9
9
  name "vagrant-ohai"
10
10
  description <<-DESC
@@ -12,16 +12,13 @@ module VagrantPlugins
12
12
  correspond to Vagrant's private network
13
13
  DESC
14
14
 
15
- hook_block = proc do |hook|
15
+ action_hook(:install_ohai_plugin, Plugin::ALL_ACTIONS) do |hook|
16
16
  require_relative 'action_install_ohai_plugin'
17
17
  require_relative 'action_configure_chef'
18
18
  hook.after(Vagrant::Action::Builtin::Provision, ActionInstallOhaiPlugin)
19
19
  hook.before(Vagrant::Action::Builtin::ConfigValidate, ActionConfigureChef)
20
20
  end
21
21
 
22
- action_hook(:install_ohai_plugin, :machine_action_provision, &hook_block)
23
- action_hook(:install_ohai_plugin, :machine_action_up, &hook_block)
24
-
25
22
  config(:ohai) do
26
23
  require_relative "config"
27
24
  Config
@@ -1,5 +1,5 @@
1
1
  module VagrantPlugins
2
2
  module Ohai
3
- VERSION = "0.1.7"
3
+ VERSION = "0.1.8"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,41 +1,41 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vagrant-ohai
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Avishai Ish-Shalom
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-11-27 00:00:00.000000000 Z
11
+ date: 2014-12-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.3'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.3'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ! '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ! '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  description: Vagrant plugin which installs an Ohai plugn to properly detect private
@@ -46,7 +46,7 @@ executables: []
46
46
  extensions: []
47
47
  extra_rdoc_files: []
48
48
  files:
49
- - .gitignore
49
+ - ".gitignore"
50
50
  - Gemfile
51
51
  - LICENSE.txt
52
52
  - README.md
@@ -71,17 +71,17 @@ require_paths:
71
71
  - lib
72
72
  required_ruby_version: !ruby/object:Gem::Requirement
73
73
  requirements:
74
- - - ! '>='
74
+ - - ">="
75
75
  - !ruby/object:Gem::Version
76
76
  version: '0'
77
77
  required_rubygems_version: !ruby/object:Gem::Requirement
78
78
  requirements:
79
- - - ! '>='
79
+ - - ">="
80
80
  - !ruby/object:Gem::Version
81
81
  version: '0'
82
82
  requirements: []
83
83
  rubyforge_project:
84
- rubygems_version: 2.0.5
84
+ rubygems_version: 2.4.3
85
85
  signing_key:
86
86
  specification_version: 4
87
87
  summary: Vagrant plugin which installs an Ohai plugn to properly detect private ipaddress