vagrant-ohai 0.1.7 → 0.1.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +6 -14
- data/lib/ohai/vagrant.rb +31 -14
- data/lib/vagrant-ohai/action_install_ohai_plugin.rb +7 -9
- data/lib/vagrant-ohai/helpers.rb +4 -4
- data/lib/vagrant-ohai/vagrant-ohai.rb +2 -5
- data/lib/vagrant-ohai/version.rb +1 -1
- metadata +10 -10
checksums.yaml
CHANGED
@@ -1,15 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
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
|
-
|
1
|
+
Ohai.plugin(:VboxIpaddress) do
|
2
2
|
|
3
|
-
provides
|
4
|
-
provides "cloud"
|
3
|
+
provides 'ipaddress'
|
5
4
|
|
6
|
-
|
7
|
-
|
5
|
+
depends 'ipaddress'
|
6
|
+
depends 'network/interfaces'
|
7
|
+
depends 'virtualization/system'
|
8
|
+
depends 'etc/passwd'
|
8
9
|
|
9
|
-
|
10
|
-
vagrant.
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
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
|
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/
|
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
|
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/
|
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
|
|
data/lib/vagrant-ohai/helpers.rb
CHANGED
@@ -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
|
7
|
-
|
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
|
-
|
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
|
data/lib/vagrant-ohai/version.rb
CHANGED
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.
|
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:
|
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.
|
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
|