vagrant-hiera 0.3.5 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/vagrant-hiera/config.rb +18 -13
- data/lib/vagrant-hiera/middleware/setup.rb +21 -16
- data/lib/vagrant-hiera/version.rb +1 -1
- metadata +2 -2
data/lib/vagrant-hiera/config.rb
CHANGED
@@ -8,10 +8,10 @@ module VagrantHiera
|
|
8
8
|
attr_accessor :guest_data_path
|
9
9
|
|
10
10
|
attr_accessor :puppet_apt_source
|
11
|
+
attr_accessor :apt_opts
|
11
12
|
attr_accessor :puppet_version
|
12
13
|
attr_accessor :hiera_puppet_version
|
13
14
|
attr_accessor :hiera_version
|
14
|
-
attr_accessor :apt_opts
|
15
15
|
|
16
16
|
def guest_config_path
|
17
17
|
@guest_config_path.nil? ? (@guest_config_path = '/tmp/vagrant-hiera/config') : @guest_config_path
|
@@ -22,23 +22,23 @@ module VagrantHiera
|
|
22
22
|
end
|
23
23
|
|
24
24
|
def puppet_apt_source
|
25
|
-
@puppet_apt_source.nil? ? (@puppet_apt_source = 'deb http://apt.puppetlabs.com/
|
25
|
+
@puppet_apt_source.nil? ? (@puppet_apt_source = 'deb http://apt.puppetlabs.com/ stable main') : @puppet_apt_source
|
26
|
+
end
|
27
|
+
|
28
|
+
def apt_opts
|
29
|
+
@apt_opts.nil? ? (@apt_opts = '-y --force-yes -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold"') : @apt_opts
|
26
30
|
end
|
27
31
|
|
28
32
|
def puppet_version
|
29
|
-
@puppet_version.nil? ? (@puppet_version = '3.0.0-
|
33
|
+
@puppet_version.nil? ? (@puppet_version = '3.0.0-1puppetlabs1') : @puppet_version
|
30
34
|
end
|
31
35
|
|
32
36
|
def hiera_puppet_version
|
33
|
-
@hiera_puppet_version
|
37
|
+
@hiera_puppet_version
|
34
38
|
end
|
35
39
|
|
36
40
|
def hiera_version
|
37
|
-
@hiera_version.nil? ? (@hiera_version = '1.0.0-
|
38
|
-
end
|
39
|
-
|
40
|
-
def apt_opts
|
41
|
-
@apt_opts.nil? ? (@apt_opts = '-y --force-yes -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold"') : @apt_opts
|
41
|
+
@hiera_version.nil? ? (@hiera_version = '1.0.0-1puppetlabs2') : @hiera_version
|
42
42
|
end
|
43
43
|
|
44
44
|
def config_path
|
@@ -53,15 +53,20 @@ module VagrantHiera
|
|
53
53
|
config_path || config_file || data_path
|
54
54
|
end
|
55
55
|
|
56
|
+
def install_puppet_heira?
|
57
|
+
puppet_version.to_i < 3
|
58
|
+
end
|
59
|
+
|
56
60
|
def validate(env, errors)
|
61
|
+
return unless set?
|
62
|
+
|
57
63
|
errors.add("Config path can not be empty.") if config_path.nil?
|
58
64
|
errors.add("Config file can not be empty.") if config_file.nil?
|
59
65
|
errors.add("Data path can not be empty.") if data_path.nil?
|
60
|
-
errors.add("Puppet apt source can not be empty.") if puppet_apt_source.nil?
|
61
66
|
errors.add("Puppet version path can not be empty.") if puppet_version.nil?
|
62
|
-
errors.add("
|
63
|
-
errors.add("Hiera version
|
64
|
-
errors.add("
|
67
|
+
errors.add("Puppet apt source can not be empty.") if puppet_apt_source.nil?
|
68
|
+
errors.add("Hiera puppet version can not be empty if puppet_version < 3.0.") if install_puppet_heira? && hiera_puppet_version.nil?
|
69
|
+
errors.add("Hiera version can not be empty.") if hiera_version.nil?
|
65
70
|
config = File.join("#{config_path}", "#{config_file}")
|
66
71
|
errors.add("Config file not found at '#{config}'.") unless File.exists?(config)
|
67
72
|
errors.add("Data directory not found at '#{data_path}'.") unless File.exists?("#{data_path}")
|
@@ -2,6 +2,8 @@ module VagrantHiera
|
|
2
2
|
module Middleware
|
3
3
|
|
4
4
|
class Setup
|
5
|
+
APT_SOURCE_FILE = '/etc/apt/sources.list.d/puppetlabs.list'
|
6
|
+
|
5
7
|
def initialize(app, env)
|
6
8
|
@app = app
|
7
9
|
@env = env
|
@@ -11,11 +13,11 @@ module VagrantHiera
|
|
11
13
|
@config_path = @env[:vm].config.hiera.config_path
|
12
14
|
@data_path = @env[:vm].config.hiera.data_path
|
13
15
|
@config_file = @env[:vm].config.hiera.config_file
|
14
|
-
@puppet_apt_source = @env[:vm].config.hiera.puppet_apt_source
|
15
16
|
@puppet_version = @env[:vm].config.hiera.puppet_version
|
17
|
+
@puppet_apt_source = @env[:vm].config.hiera.puppet_apt_source
|
18
|
+
@apt_opts = @env[:vm].config.hiera.apt_opts
|
16
19
|
@hiera_puppet_version = @env[:vm].config.hiera.hiera_puppet_version
|
17
20
|
@hiera_version = @env[:vm].config.hiera.hiera_version
|
18
|
-
@apt_opts = @env[:vm].config.hiera.apt_opts
|
19
21
|
end
|
20
22
|
|
21
23
|
def call(env)
|
@@ -24,26 +26,18 @@ module VagrantHiera
|
|
24
26
|
add_apt_repo unless apt_repo_set?
|
25
27
|
install_puppet unless puppet_installed?
|
26
28
|
install_hiera unless hiera_installed?
|
27
|
-
|
29
|
+
if @env[:vm].config.hiera.install_puppet_heira?
|
30
|
+
install_hiera_puppet unless hiera_puppet_installed?
|
31
|
+
end
|
28
32
|
create_shared_folders
|
29
33
|
create_symlink_to_hiera_config
|
30
34
|
end
|
31
35
|
@app.call(env)
|
32
36
|
end
|
33
37
|
|
34
|
-
def hiera_installed?
|
35
|
-
installed = ( @env[:vm].channel.execute("dpkg -l | grep puppet | grep #{@puppet_version}", :error_check => false) == 0 )
|
36
|
-
@env[:ui].success I18n.t('vagrant.plugins.hiera.middleware.setup.hiera_installed') if installed
|
37
|
-
installed
|
38
|
-
end
|
39
|
-
|
40
|
-
def install_hiera
|
41
|
-
@env[:ui].warn I18n.t('vagrant.plugins.hiera.middleware.setup.install_hiera')
|
42
|
-
@env[:vm].channel.sudo("apt-get #{@apt_opts} install hiera=#{@hiera_version}")
|
43
|
-
end
|
44
|
-
|
45
38
|
def apt_repo_set?
|
46
|
-
|
39
|
+
cmd = "test -f #{APT_SOURCE_FILE} && grep '#{@puppet_apt_source}' #{APT_SOURCE_FILE}"
|
40
|
+
setup = ( @env[:vm].channel.execute(cmd, :error_check => false) == 0 )
|
47
41
|
@env[:ui].success I18n.t('vagrant.plugins.hiera.middleware.setup.apt_repo_set') if setup
|
48
42
|
setup
|
49
43
|
end
|
@@ -52,10 +46,21 @@ module VagrantHiera
|
|
52
46
|
@env[:ui].warn I18n.t('vagrant.plugins.hiera.middleware.setup.add_apt_repo')
|
53
47
|
@env[:vm].channel.sudo("wget http://apt.puppetlabs.com/puppetlabs-release-stable.deb")
|
54
48
|
@env[:vm].channel.sudo("dpkg -i puppetlabs-release-stable.deb")
|
55
|
-
@env[:vm].channel.sudo("echo '#{@puppet_apt_source}' >>
|
49
|
+
@env[:vm].channel.sudo("echo '#{@puppet_apt_source}' >> #{APT_SOURCE_FILE}")
|
56
50
|
@env[:vm].channel.sudo("apt-get update")
|
57
51
|
end
|
58
52
|
|
53
|
+
def hiera_installed?
|
54
|
+
installed = ( @env[:vm].channel.execute("dpkg -l | grep puppet | grep #{@puppet_version}", :error_check => false) == 0 )
|
55
|
+
@env[:ui].success I18n.t('vagrant.plugins.hiera.middleware.setup.hiera_installed') if installed
|
56
|
+
installed
|
57
|
+
end
|
58
|
+
|
59
|
+
def install_hiera
|
60
|
+
@env[:ui].warn I18n.t('vagrant.plugins.hiera.middleware.setup.install_hiera')
|
61
|
+
@env[:vm].channel.sudo("apt-get #{@apt_opts} install hiera=#{@hiera_version}")
|
62
|
+
end
|
63
|
+
|
59
64
|
def puppet_installed?
|
60
65
|
installed = ( @env[:vm].channel.execute("dpkg -l | grep puppet | grep #{@puppet_version}", :error_check => false) == 0 )
|
61
66
|
@env[:ui].success I18n.t('vagrant.plugins.hiera.middleware.setup.puppet_installed') if installed
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vagrant-hiera
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-10-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: vagrant
|