vagrant-ohai 0.1.12 → 0.1.13

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: a3932d09503b417f318d348c6e88413c5935a117
4
- data.tar.gz: 64225a6638bf7d80efd1cd126f8e19e78d0450e1
3
+ metadata.gz: 73ce468107ce76701b2482582e1687926d540432
4
+ data.tar.gz: c2437560561622a680e3a376e85b858dcdf09940
5
5
  SHA512:
6
- metadata.gz: 3e29c9e0abb9346e6cb31fd678b787575d4683f442de2f99bc6f3548782bac692bc499a1da07bf47021b9311661dafabf49b645d818bc737e422f5b99c5abbc3
7
- data.tar.gz: 8fe4fe67f71fc709800cf2bd3177e932280c04e2e30912b423cfb716b8f1e29127d8da3135e6172df0f4c692c044cce9968a2b97728ea04e0784eb04aed7c628
6
+ metadata.gz: f1b1daf578e9b8949c6053d1bc2345c22010f7b84f6e9c4460d18a03c7d56326a908f7e25ebbe4fe42a2cf6410119c0d6650984d6e3d6c3f964d0e5ea42bdc63
7
+ data.tar.gz: aa6c7f51cf10555125d8cca6209b65a9ae5e3f21aaaef5bfc8f794bada351f180d6b9a5c5eae8176ad4dab06fcd3082bb136e82e02fec4bcc0daea0bdaa83672
data/README.md CHANGED
@@ -7,18 +7,23 @@ In particular, the ipaddress is set to the private network defined in vagrant, i
7
7
 
8
8
  vagrant plugin install vagrant-ohai
9
9
 
10
-
11
10
  ## Usage
12
11
 
13
- The plugin will automatcially activate when using the `:chef_solo`, `:chef_zero`, `:chef_apply` or `:chef_client` provisioners. If you want to disable it, put `config.ohai.enable = false` in your Vagrantfile.
12
+ The plugin will automatically activate when using the `:chef_solo`, `:chef_zero`, `:chef_apply`, `:chef_client` or `:shell` provisioners. If you want to disable it, put `config.ohai.enable = false` in your Vagrantfile.
14
13
  If you wish to use a primary nic which is not a private network, e.g. when using a bridge, set the `primary_nic` option:
15
14
 
16
15
  config.ohai.primary_nic = "eth1"
17
16
 
18
- ## Compatability
17
+ To activate custom plugin support put `config.ohai.plugins_dir = <full_path_to_plugins_dir>` in your Vagrantfile
18
+
19
+ config.ohai.plugins_dir = "/var/ohai/custom_plugins"
20
+
21
+ ## Compatibility
19
22
 
20
23
  This plugin works with Vagrant 1.2.3 and above.
21
24
 
25
+ It has only been tested on VirtualBox but should also work with other Vagrant providers.
26
+
22
27
  ## Contributing
23
28
 
24
29
  1. Fork it
data/lib/ohai/vagrant.rb CHANGED
@@ -47,19 +47,17 @@ Ohai.plugin(:VboxIpaddress) do
47
47
 
48
48
  # requested nit
49
49
  nic = vagrant['primary_nic']
50
- if etc['passwd'].keys.include?('vagrant') && virtualization['system'] == 'vbox'
51
- if nic
52
- nic, addr = lookup_address_by_nic(network, nic)
53
- elsif vagrant['private_ipv4']
54
- nic, addr = lookup_address_by_ipaddress(network, vagrant['private_ipv4'])
55
- else
56
- nic, addr = nil, nil
57
- Ohai::Log.info("Neither nic nor private_ipv4 are set, skipping")
58
- end
59
- if addr
60
- Ohai::Log.info("Ohai override :ipaddress to #{addr} from #{nic}")
61
- ipaddress addr
62
- end
50
+ if nic
51
+ nic, addr = lookup_address_by_nic(network, nic)
52
+ elsif vagrant['private_ipv4']
53
+ nic, addr = lookup_address_by_ipaddress(network, vagrant['private_ipv4'])
54
+ else
55
+ nic, addr = nil, nil
56
+ Ohai::Log.info("Neither nic nor private_ipv4 are set, skipping")
57
+ end
58
+ if addr
59
+ Ohai::Log.info("Ohai override :ipaddress to #{addr} from #{nic}")
60
+ ipaddress addr
63
61
  end
64
62
  end
65
63
  end
@@ -26,7 +26,7 @@ module VagrantPlugins
26
26
  end
27
27
 
28
28
  def register_custom_chef_config
29
- return unless @machine.config.ohai.enable
29
+ return unless @machine.config.ohai.enable or @machine.config.ohai.plugins_dir
30
30
  chef_provisioners.each do |provisioner|
31
31
  if provisioner.config.respond_to? :custom_config_path and not provisioner.config.custom_config_path == Plugin::UNSET_VALUE
32
32
  current_custom_config_path = provisioner.config.custom_config_path
@@ -23,6 +23,11 @@ module VagrantPlugins
23
23
  create_ohai_folders
24
24
  copy_ohai_plugin
25
25
  end
26
+ if is_chef_used && @machine.config.ohai.plugins_dir
27
+ @machine.ui.info("Installing Custom Ohai plugin")
28
+ create_ohai_folders
29
+ copy_ohai_custom_plugins
30
+ end
26
31
  end
27
32
 
28
33
  private
@@ -58,6 +63,15 @@ module VagrantPlugins
58
63
  @machine.communicate.upload(OHAI_PLUGIN_PATH, "/etc/chef/ohai_plugins/vagrant.rb")
59
64
  end
60
65
 
66
+ def copy_ohai_custom_plugins
67
+
68
+ files = Dir.entries(@machine.config.ohai.plugins_dir).select { |e| e =~ /^[a-z]+\.rb/ }
69
+ files.each do |file|
70
+ custom_ohai_plugin_path = File.expand_path("#{@machine.config.ohai.plugins_dir}/#{file}", __FILE__)
71
+ @machine.communicate.upload(custom_ohai_plugin_path, "/etc/chef/ohai_plugins/#{file}")
72
+ end
73
+ end
74
+
61
75
  end
62
76
  end
63
77
  end
@@ -3,14 +3,17 @@ module VagrantPlugins
3
3
  class Config < Vagrant.plugin(2, :config)
4
4
  attr_accessor :enable
5
5
  attr_accessor :primary_nic
6
+ attr_accessor :plugins_dir
6
7
 
7
8
  def initialize
8
9
  @enable = UNSET_VALUE
9
10
  @primary_nic = UNSET_VALUE
11
+ @plugins_dir = UNSET_VALUE
10
12
  end
11
13
  def finalize!
12
14
  @enable = true if @enable == UNSET_VALUE
13
15
  @primary_nic = nil if @primary_nic == UNSET_VALUE
16
+ @plugins_dir = nil if @plugins_dir == UNSET_VALUE
14
17
  end
15
18
 
16
19
  def validate(machine)
@@ -28,6 +31,16 @@ module VagrantPlugins
28
31
  else
29
32
  {"enable" => ["enable must be true or false"] }
30
33
  end
34
+ case @plugins_dir
35
+ when nil
36
+ {}
37
+ else
38
+ if !File.directory?(@plugins_dir.to_s) or @plugins_dir.to_s !~ /^\//
39
+ {"plugins_dir" => ["plugins_dir must be an absolute path to a folder"]}
40
+ else
41
+ {}
42
+ end
43
+ end
31
44
  end
32
45
 
33
46
  end
@@ -1,5 +1,5 @@
1
1
  module VagrantPlugins
2
2
  module Ohai
3
- VERSION = "0.1.12"
3
+ VERSION = "0.1.13"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vagrant-ohai
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.12
4
+ version: 0.1.13
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: 2015-04-08 00:00:00.000000000 Z
11
+ date: 2015-10-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler