vagrant-invade 0.4.0.pre.alpha → 0.4.0
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.lock +2 -2
- data/invade.yml.dist +16 -2
- data/lib/vagrant-invade/action/init.rb +21 -20
- data/lib/vagrant-invade/action/validate.rb +6 -4
- data/lib/vagrant-invade/builder/network.rb +3 -3
- data/lib/vagrant-invade/builder/plugin/r10k.rb +36 -81
- data/lib/vagrant-invade/builder/plugin.rb +3 -3
- data/lib/vagrant-invade/builder/provider.rb +2 -2
- data/lib/vagrant-invade/builder/provision/puppet_agent.rb +47 -0
- data/lib/vagrant-invade/builder/provision/puppet_apply.rb +46 -0
- data/lib/vagrant-invade/builder/provision.rb +4 -2
- data/lib/vagrant-invade/builder/synced_folder.rb +2 -2
- data/lib/vagrant-invade/generator/section/provision.rb +4 -2
- data/lib/vagrant-invade/template/plugin/r10k.erb +3 -3
- data/lib/vagrant-invade/template/provision/puppet_agent.erb +20 -0
- data/lib/vagrant-invade/template/provision/puppet_apply.erb +20 -0
- data/lib/vagrant-invade/validator/plugin/r10k.rb +1 -1
- data/lib/vagrant-invade/validator/provision/puppet_agent.rb +68 -0
- data/lib/vagrant-invade/validator/provision/puppet_apply.rb +62 -0
- data/lib/vagrant-invade/validator/provision/shell.rb +2 -1
- data/lib/vagrant-invade/validator/provision/shell_inline.rb +2 -1
- data/lib/vagrant-invade/validator/provision.rb +11 -9
- data/lib/vagrant-invade/validator.rb +31 -12
- data/lib/vagrant-invade/version.rb +1 -1
- metadata +10 -7
- data/lib/vagrant-invade/builder/provision/puppet.rb +0 -46
- data/lib/vagrant-invade/template/provision/puppet.erb +0 -17
- data/lib/vagrant-invade/validator/provision/puppet.rb +0 -61
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c16b7033c6270a5f452c2c2b4471a01b1b7ecc93
|
|
4
|
+
data.tar.gz: 6bda2175ce3d5ba0b770ef39e96b5a67d79ce009
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ac47faa4103c8cdc9afed1b24bbbf20dbcd7c8e2bcabee977581482642498f4117d87091de43cb663aecaea9efdd053afe31ba721f9b423d6baad345a8a22e7e
|
|
7
|
+
data.tar.gz: 90b2415c3db43d9b148eeb52bd6b66c8828802089542a7d218659ce9379c80d4a4476c3d1b0ecb559b8dbc69cd3c595ba39db2ec965e4a87480216e32470e1ea
|
data/Gemfile.lock
CHANGED
data/invade.yml.dist
CHANGED
|
@@ -19,10 +19,12 @@ machines:
|
|
|
19
19
|
|
|
20
20
|
# Provider related settings. Performance, naming
|
|
21
21
|
provider:
|
|
22
|
+
|
|
22
23
|
vmware:
|
|
23
24
|
name: 'invade'
|
|
24
25
|
cores: 4
|
|
25
26
|
memory: 512
|
|
27
|
+
|
|
26
28
|
virtualbox:
|
|
27
29
|
name: 'invade'
|
|
28
30
|
cores: 4
|
|
@@ -40,23 +42,35 @@ machines:
|
|
|
40
42
|
# shell:
|
|
41
43
|
# name: 'set-permissions'
|
|
42
44
|
# inline: 'chmod 777 /tmp'
|
|
45
|
+
|
|
43
46
|
# shell:
|
|
44
47
|
# name: 'run-composer'
|
|
45
48
|
# path: '/home/vagrant/provision/shell/run-composer.sh'
|
|
49
|
+
|
|
46
50
|
# puppet:
|
|
47
51
|
# manifests_path: './puppet/manifests'
|
|
48
52
|
# manifest_file: 'init.pp'
|
|
49
|
-
# module_path:
|
|
50
|
-
#
|
|
53
|
+
# module_path:
|
|
54
|
+
# - './puppet/modules'
|
|
55
|
+
# - './puppet/vendor'
|
|
56
|
+
# facter: {}
|
|
51
57
|
|
|
52
58
|
plugin:
|
|
53
59
|
hostmanager:
|
|
54
60
|
enabled: true
|
|
55
61
|
aliases:
|
|
56
62
|
- my-1337-project.local
|
|
63
|
+
|
|
57
64
|
# winnfsd:
|
|
58
65
|
# enabled: true
|
|
66
|
+
|
|
59
67
|
# r10k:
|
|
60
68
|
# puppet_dir: './puppet'
|
|
61
69
|
# puppetfile_path: './puppet/Puppetfile'
|
|
62
70
|
# module_path: './puppet/vendor'
|
|
71
|
+
# modules: {
|
|
72
|
+
# 'sql' => {
|
|
73
|
+
# 'url' => 'https://github.com/example42/puppet-mysql.git',
|
|
74
|
+
# 'version' => '2.1.5'
|
|
75
|
+
# }
|
|
76
|
+
# }
|
|
@@ -18,45 +18,46 @@ module VagrantPlugins
|
|
|
18
18
|
if !invade_config_exists || @env[:invade_command_init_force]
|
|
19
19
|
write_invade_config
|
|
20
20
|
else
|
|
21
|
-
@env[:ui].error "[Invade]
|
|
21
|
+
@env[:ui].error "[Invade] 'invade.yml' file already exists. Use '--force' to replace file."
|
|
22
22
|
end
|
|
23
23
|
|
|
24
24
|
@app.call(env)
|
|
25
25
|
end
|
|
26
26
|
|
|
27
27
|
def invade_config_exists
|
|
28
|
-
|
|
29
|
-
invade_config_file = "#{@dir}/invade.yml"
|
|
30
|
-
if File.exist?(invade_config_file)
|
|
31
|
-
return true
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
false
|
|
28
|
+
File.exist?("#{@dir}/invade.yml")
|
|
35
29
|
end
|
|
36
30
|
|
|
37
31
|
def invade_template_exists
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
return true
|
|
41
|
-
end
|
|
32
|
+
File.exist?("#{@dir}/invade.yml.dist")
|
|
33
|
+
end
|
|
42
34
|
|
|
43
|
-
|
|
35
|
+
def invade_user_customized_config_exists
|
|
36
|
+
File.exist?(File.expand_path('~/.invade/invade.yml.dist'))
|
|
44
37
|
end
|
|
45
38
|
|
|
39
|
+
# Writes configuration file 'invade.yml'
|
|
40
|
+
# if template file in project folder does exist it copies it#
|
|
41
|
+
# if template file in project folder doesn't exist and a '~/.invade/invade.yml.dist' file exists it copies it
|
|
42
|
+
# if template file in project folder doesn't exist it uses plugins default file
|
|
46
43
|
def write_invade_config
|
|
47
|
-
|
|
48
|
-
config_file_path = "#{@dir}/invade.yml"
|
|
44
|
+
invade_config_file = "#{@dir}/invade.yml"
|
|
49
45
|
|
|
50
46
|
if invade_template_exists
|
|
51
47
|
template_file_path = "#{@dir}/invade.yml.dist"
|
|
52
|
-
FileUtils.cp(template_file_path,
|
|
53
|
-
@env[:ui].success "[Invade]
|
|
48
|
+
FileUtils.cp(template_file_path, invade_config_file)
|
|
49
|
+
@env[:ui].success "[Invade] Project template file '#{template_file_path}' was found!"
|
|
50
|
+
elsif invade_user_customized_config_exists && !invade_template_exists
|
|
51
|
+
FileUtils.cp(File.expand_path('~/.invade/invade.yml.dist'), invade_config_file)
|
|
52
|
+
@env[:ui].success "[Invade] User customized template file '~/.invade/invade.yml.dist' was found!"
|
|
54
53
|
else
|
|
55
54
|
plugin_root_path = File.expand_path('../../../../', __FILE__)
|
|
56
|
-
|
|
57
|
-
FileUtils.cp(
|
|
58
|
-
@env[:ui].
|
|
55
|
+
default_invade_config_file = plugin_root_path + '/invade.yml.dist'
|
|
56
|
+
FileUtils.cp(default_invade_config_file, invade_config_file)
|
|
57
|
+
@env[:ui].warn '[Invade] Project template file or customized user configuration file NOT found!'
|
|
59
58
|
end
|
|
59
|
+
|
|
60
|
+
@env[:ui].success '[Invade] \'invade.yml\' created successfully. Please make your changes.'
|
|
60
61
|
end
|
|
61
62
|
end
|
|
62
63
|
|
|
@@ -101,8 +101,10 @@ module VagrantPlugins
|
|
|
101
101
|
provision = Validator::Provision::Shell.new(env, provision).validate
|
|
102
102
|
when 'shellinline', 'shell-inline'
|
|
103
103
|
provision = Validator::Provision::ShellInline.new(env, provision).validate
|
|
104
|
-
when 'puppet'
|
|
105
|
-
provision = Validator::Provision::
|
|
104
|
+
when 'puppet', 'puppetapply', 'puppet-apply'
|
|
105
|
+
provision = Validator::Provision::PuppetApply.new(env, provision).validate
|
|
106
|
+
when 'puppet-agent', 'puppetagent', 'puppet-server', 'puppet-master'
|
|
107
|
+
provision = Validator::Provision::PuppetAgent.new(env, provision).validate
|
|
106
108
|
else
|
|
107
109
|
raise StandardError, "Provision type unknown or not set. Please check configuration file."
|
|
108
110
|
end
|
|
@@ -137,8 +139,8 @@ module VagrantPlugins
|
|
|
137
139
|
end
|
|
138
140
|
end
|
|
139
141
|
|
|
140
|
-
if Validator
|
|
141
|
-
@env[:ui].warn('[Invade] Configuration has validation warnings.
|
|
142
|
+
if Validator.get_validation_errors > 0
|
|
143
|
+
@env[:ui].warn('[Invade] Configuration has validation warnings. Run \'vagrant invade validate\' to see details.')
|
|
142
144
|
else
|
|
143
145
|
@env[:ui].success('[Invade] Configuration validated successfully.')
|
|
144
146
|
end
|
|
@@ -3,9 +3,9 @@ module VagrantPlugins
|
|
|
3
3
|
module Builder
|
|
4
4
|
module Network
|
|
5
5
|
|
|
6
|
-
autoload :ForwardedPort, 'vagrant-invade/builder/network/forwarded_port
|
|
7
|
-
autoload :PrivateNetwork, 'vagrant-invade/builder/network/private_network
|
|
8
|
-
autoload :PublicNetwork, 'vagrant-invade/builder/network/public_network
|
|
6
|
+
autoload :ForwardedPort, 'vagrant-invade/builder/network/forwarded_port'
|
|
7
|
+
autoload :PrivateNetwork, 'vagrant-invade/builder/network/private_network'
|
|
8
|
+
autoload :PublicNetwork, 'vagrant-invade/builder/network/public_network'
|
|
9
9
|
|
|
10
10
|
end
|
|
11
11
|
end
|
|
@@ -26,25 +26,36 @@ module VagrantPlugins
|
|
|
26
26
|
@result = ""
|
|
27
27
|
else
|
|
28
28
|
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
b = binding
|
|
30
|
+
template_file = "#{TEMPLATE_PATH}/plugin/r10k.erb"
|
|
31
31
|
|
|
32
32
|
begin
|
|
33
33
|
|
|
34
|
-
# Only generate puppetfile if
|
|
34
|
+
# Only generate puppetfile if plugin is enabled and modules are configured
|
|
35
35
|
if @r10k_data['enabled'] && @r10k_data['modules']
|
|
36
36
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
37
|
+
# Configured puppet dir must exists. Otherwise skip generating Puppetfile.
|
|
38
|
+
unless Dir.exists?(@r10k['puppet_dir'])
|
|
39
|
+
@ui.error("[Invade] Puppet dir '#{@r10k_data['puppet_dir']}' does not exists. Can't load specified modules.")
|
|
40
|
+
else
|
|
41
|
+
basic_modules = {
|
|
42
|
+
'stdlib' => {
|
|
43
|
+
'url' => 'https://github.com/puppetlabs/puppetlabs-stdlib.git'
|
|
44
|
+
},
|
|
45
|
+
'apt' => {
|
|
46
|
+
'url' => 'https://github.com/puppetlabs/puppetlabs-apt.git'
|
|
47
|
+
},
|
|
48
|
+
'puppi' => {
|
|
49
|
+
'url' => 'https://github.com/example42/puppi.git'
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
puppetfile_path = File.expand_path(@r10k_data['puppetfile_path'])
|
|
54
|
+
|
|
55
|
+
# Generate Puppetfile
|
|
56
|
+
merged_modules = basic_modules.merge(@r10k_data['modules'])
|
|
57
|
+
generate_puppetfile(merged_modules, puppetfile_path)
|
|
58
|
+
end
|
|
48
59
|
end
|
|
49
60
|
|
|
50
61
|
# Get machine name
|
|
@@ -66,43 +77,33 @@ module VagrantPlugins
|
|
|
66
77
|
|
|
67
78
|
private
|
|
68
79
|
|
|
69
|
-
|
|
80
|
+
# Generates a puppetfile needed by r10k plugin to manage dependencies
|
|
81
|
+
def generate_puppetfile(modules, puppetfile)
|
|
70
82
|
|
|
71
83
|
begin
|
|
72
84
|
if File.exist?(puppetfile)
|
|
73
85
|
File.delete(puppetfile)
|
|
74
86
|
end
|
|
75
87
|
|
|
76
|
-
|
|
88
|
+
# Create file first and add header
|
|
89
|
+
File.open(puppetfile, 'w+') {
|
|
90
|
+
|f| f.write("#Modules\n")
|
|
91
|
+
}
|
|
77
92
|
|
|
78
|
-
modules.
|
|
93
|
+
modules.each do |name, module_data|
|
|
79
94
|
File.open(puppetfile, 'a+') do |f|
|
|
80
|
-
f.puts
|
|
81
|
-
modules[index][0],
|
|
82
|
-
module_version: modules[index][1],
|
|
83
|
-
module_name: modules[index][2]
|
|
84
|
-
)
|
|
95
|
+
f.puts parse_puppetfile_data(name, module_data['url'], module_version: module_data['version'])
|
|
85
96
|
end
|
|
86
97
|
end
|
|
98
|
+
|
|
87
99
|
rescue StandardError => error
|
|
88
100
|
print "\nIO failed: #{error}"
|
|
89
101
|
raise
|
|
90
102
|
end
|
|
91
103
|
end
|
|
92
104
|
|
|
93
|
-
#
|
|
94
|
-
def
|
|
95
|
-
unless ext_array.to_a.empty? || ext_array.to_a.nil?
|
|
96
|
-
ext_array.each do |modules|
|
|
97
|
-
base_array.push(modules.flatten)
|
|
98
|
-
end
|
|
99
|
-
end
|
|
100
|
-
|
|
101
|
-
base_array
|
|
102
|
-
end
|
|
103
|
-
|
|
104
|
-
# Generates the Puppetfile needed by r10k plugin to download puppet modules
|
|
105
|
-
def generate_puppetfile_data(module_url, module_version: nil, module_name: nil)
|
|
105
|
+
# Parses the puppetfile data
|
|
106
|
+
def parse_puppetfile_data(module_name, module_url, module_version: nil)
|
|
106
107
|
|
|
107
108
|
# build name part
|
|
108
109
|
if module_name.nil? || module_name.empty?
|
|
@@ -119,52 +120,6 @@ module VagrantPlugins
|
|
|
119
120
|
|
|
120
121
|
definition.concat("\n")
|
|
121
122
|
end
|
|
122
|
-
|
|
123
|
-
# Gets module name from a repository URL
|
|
124
|
-
def get_module_name_from_repo_url(repository_url)
|
|
125
|
-
|
|
126
|
-
# URL must include '/'
|
|
127
|
-
unless repository_url.include? '/'
|
|
128
|
-
self.add_invade_text(
|
|
129
|
-
MESSAGE_EXIT,
|
|
130
|
-
sprintf(
|
|
131
|
-
"Invalid repository path: '%s'. Path must include username and repository name. Example: 'magneton/xmen-protocol'.",
|
|
132
|
-
repository_url
|
|
133
|
-
)
|
|
134
|
-
)
|
|
135
|
-
end
|
|
136
|
-
|
|
137
|
-
# Get last part of the URI
|
|
138
|
-
repository_name = URI(repository_url).path.split('/').last
|
|
139
|
-
|
|
140
|
-
# Removes .git from name
|
|
141
|
-
repository_name = repository_name.partition('.').first
|
|
142
|
-
|
|
143
|
-
# Dashs in combination with lower dashs in a path are not allowed
|
|
144
|
-
dash_count = repository_name.count('-')
|
|
145
|
-
lower_dash_count = repository_name.count('_')
|
|
146
|
-
|
|
147
|
-
if dash_count > 0 && lower_dash_count > 0
|
|
148
|
-
self.add_invade_text(MESSAGE_EXIT,
|
|
149
|
-
sprintf(
|
|
150
|
-
"Invalid repository path: '%s'. It includes at least one dash and one lower dash. Can't generate a repository name. Please use the optional module_name paramater to manually define a name for this module.",
|
|
151
|
-
repository_name
|
|
152
|
-
)
|
|
153
|
-
)
|
|
154
|
-
else
|
|
155
|
-
if dash_count > 0
|
|
156
|
-
cut_character = '-'
|
|
157
|
-
repository_name = repository_name.partition(cut_character).last
|
|
158
|
-
elsif lower_dash_count > 0
|
|
159
|
-
cut_character = '_'
|
|
160
|
-
repository_name = repository_name.partition(cut_character).last
|
|
161
|
-
else
|
|
162
|
-
return repository_name
|
|
163
|
-
end
|
|
164
|
-
end
|
|
165
|
-
|
|
166
|
-
repository_name
|
|
167
|
-
end
|
|
168
123
|
end
|
|
169
124
|
end
|
|
170
125
|
end
|
|
@@ -3,9 +3,9 @@ module VagrantPlugins
|
|
|
3
3
|
module Builder
|
|
4
4
|
module Plugin
|
|
5
5
|
|
|
6
|
-
autoload :HostManager, 'vagrant-invade/builder/plugin/hostmanager
|
|
7
|
-
autoload :WinNFSd, 'vagrant-invade/builder/plugin/winnfsd
|
|
8
|
-
autoload :R10k, 'vagrant-invade/builder/plugin/r10k
|
|
6
|
+
autoload :HostManager, 'vagrant-invade/builder/plugin/hostmanager'
|
|
7
|
+
autoload :WinNFSd, 'vagrant-invade/builder/plugin/winnfsd'
|
|
8
|
+
autoload :R10k, 'vagrant-invade/builder/plugin/r10k'
|
|
9
9
|
|
|
10
10
|
end
|
|
11
11
|
end
|
|
@@ -3,8 +3,8 @@ module VagrantPlugins
|
|
|
3
3
|
module Builder
|
|
4
4
|
module Provider
|
|
5
5
|
|
|
6
|
-
autoload :VirtualBox, 'vagrant-invade/builder/provider/virtualbox
|
|
7
|
-
autoload :VMware, 'vagrant-invade/builder/provider/vmware
|
|
6
|
+
autoload :VirtualBox, 'vagrant-invade/builder/provider/virtualbox'
|
|
7
|
+
autoload :VMware, 'vagrant-invade/builder/provider/vmware'
|
|
8
8
|
|
|
9
9
|
end
|
|
10
10
|
end
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
module VagrantPlugins
|
|
2
|
+
module Invade
|
|
3
|
+
module Builder
|
|
4
|
+
module Provision
|
|
5
|
+
|
|
6
|
+
require 'erubis'
|
|
7
|
+
|
|
8
|
+
class PuppetAgent
|
|
9
|
+
|
|
10
|
+
attr_reader :result
|
|
11
|
+
attr_accessor :machine_name, :puppet_agent_data
|
|
12
|
+
|
|
13
|
+
def initialize(machine_name, puppet_agent_data, result: nil)
|
|
14
|
+
@machine_name = machine_name
|
|
15
|
+
@puppet_agent_data = puppet_agent_data
|
|
16
|
+
@result = result
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def build
|
|
20
|
+
b = binding
|
|
21
|
+
template_file = "#{TEMPLATE_PATH}/provision/puppet_agent.erb"
|
|
22
|
+
|
|
23
|
+
begin
|
|
24
|
+
|
|
25
|
+
# Get machine name
|
|
26
|
+
machine_name = @machine_name
|
|
27
|
+
|
|
28
|
+
# Values for provider puppet_agent section
|
|
29
|
+
puppet_server = @puppet_agent_data['puppet_server']
|
|
30
|
+
puppet_node = @puppet_agent_data['puppet_node']
|
|
31
|
+
client_cert_path = @puppet_agent_data['client_cert_path']
|
|
32
|
+
client_private_key_path = @puppet_agent_data['client_private_key_path']
|
|
33
|
+
facter = @puppet_agent_data['facter']
|
|
34
|
+
options = @puppet_agent_data['options']
|
|
35
|
+
|
|
36
|
+
eruby = Erubis::Eruby.new(File.read(template_file))
|
|
37
|
+
@result = eruby.result b
|
|
38
|
+
rescue TypeError, SyntaxError, SystemCallError => e
|
|
39
|
+
raise(e)
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
module VagrantPlugins
|
|
2
|
+
module Invade
|
|
3
|
+
module Builder
|
|
4
|
+
module Provision
|
|
5
|
+
|
|
6
|
+
require 'erubis'
|
|
7
|
+
|
|
8
|
+
class PuppetApply
|
|
9
|
+
|
|
10
|
+
attr_reader :result
|
|
11
|
+
attr_accessor :machine_name, :puppet_apply_data
|
|
12
|
+
|
|
13
|
+
def initialize(machine_name, puppet_apply_data, result: nil)
|
|
14
|
+
@machine_name = machine_name
|
|
15
|
+
@puppet_apply_data = puppet_apply_data
|
|
16
|
+
@result = result
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def build
|
|
20
|
+
b = binding
|
|
21
|
+
template_file = "#{TEMPLATE_PATH}/provision/puppet_apply.erb"
|
|
22
|
+
|
|
23
|
+
begin
|
|
24
|
+
|
|
25
|
+
# Get machine name
|
|
26
|
+
machine_name = @machine_name
|
|
27
|
+
|
|
28
|
+
# Values for provider puppet_apply section
|
|
29
|
+
module_path = @puppet_apply_data['module_path']
|
|
30
|
+
manifests_path = @puppet_apply_data['manifests_path']
|
|
31
|
+
manifest_file = @puppet_apply_data['manifest_file']
|
|
32
|
+
hiera_config_path = @puppet_apply_data['hiera_config_path']
|
|
33
|
+
facter = @puppet_apply_data['facter']
|
|
34
|
+
|
|
35
|
+
eruby = Erubis::Eruby.new(File.read(template_file))
|
|
36
|
+
@result = eruby.result b
|
|
37
|
+
rescue TypeError, SyntaxError, SystemCallError => e
|
|
38
|
+
raise(e)
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
@@ -3,8 +3,10 @@ module VagrantPlugins
|
|
|
3
3
|
module Builder
|
|
4
4
|
module Provision
|
|
5
5
|
|
|
6
|
-
autoload :Shell, 'vagrant-invade/builder/provision/shell
|
|
7
|
-
autoload :
|
|
6
|
+
autoload :Shell, 'vagrant-invade/builder/provision/shell'
|
|
7
|
+
autoload :ShellInline, 'vagrant-invade/builder/provision/shell_inline'
|
|
8
|
+
autoload :PuppetApply, 'vagrant-invade/builder/provision/puppet_apply'
|
|
9
|
+
autoload :PuppetAgent, 'vagrant-invade/builder/provision/puppet_agent'
|
|
8
10
|
|
|
9
11
|
end
|
|
10
12
|
end
|
|
@@ -3,8 +3,8 @@ module VagrantPlugins
|
|
|
3
3
|
module Builder
|
|
4
4
|
module SyncedFolder
|
|
5
5
|
|
|
6
|
-
autoload :VirtualBox, 'vagrant-invade/builder/synced_folder/virtualbox
|
|
7
|
-
autoload :NFS, 'vagrant-invade/builder/synced_folder/nfs
|
|
6
|
+
autoload :VirtualBox, 'vagrant-invade/builder/synced_folder/virtualbox'
|
|
7
|
+
autoload :NFS, 'vagrant-invade/builder/synced_folder/nfs'
|
|
8
8
|
|
|
9
9
|
end
|
|
10
10
|
end
|
|
@@ -19,8 +19,10 @@ module VagrantPlugins
|
|
|
19
19
|
provision = Builder::Provision::Shell.new(@machine_name, @provision_data)
|
|
20
20
|
when 'shell_inline', 'inline', 'shellinline'
|
|
21
21
|
provision = Builder::Provision::ShellInline.new(@machine_name, @provision_data)
|
|
22
|
-
when 'puppet'
|
|
23
|
-
provision = Builder::Provision::
|
|
22
|
+
when 'puppet', 'puppetappy', 'puppet-apply'
|
|
23
|
+
provision = Builder::Provision::PuppetApply.new(@machine_name, @provision_data)
|
|
24
|
+
when 'puppet-agent', 'puppetagent'
|
|
25
|
+
provision = Builder::Provision::PuppetAgent.new(@machine_name, @provision_data)
|
|
24
26
|
else
|
|
25
27
|
raise StandardError, "Provisioner unknown or not set. Please check the provision configuration."
|
|
26
28
|
end
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<% if enabled %>
|
|
2
|
-
<%=
|
|
3
|
-
<%=
|
|
4
|
-
<%=
|
|
2
|
+
<%= machine_name %>.r10k.puppet_dir = '<%= puppet_dir %>'
|
|
3
|
+
<%= machine_name %>.r10k.puppetfile_path = '<%= puppetfile_path %>'
|
|
4
|
+
<%= machine_name %>.r10k.module_path = '<%= module_path %>'
|
|
5
5
|
<% end %>
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
<%= machine_name %>.vm.provision "puppet_server" do |puppet_agent|
|
|
2
|
+
<% if puppet_server %>
|
|
3
|
+
puppet_agent.puppet_server = '<%= puppet_server %>'
|
|
4
|
+
<% end %>
|
|
5
|
+
<% if puppet_node %>
|
|
6
|
+
puppet_agent.puppet_node = '<%= puppet_node %>'
|
|
7
|
+
<% end %>
|
|
8
|
+
<% if client_cert_path %>
|
|
9
|
+
puppet_agent.client_cert_path = '<%= client_cert_path %>'
|
|
10
|
+
<% end %>
|
|
11
|
+
<% if client_private_key_path %>
|
|
12
|
+
puppet_agent.client_private_key_path = '<%= client_private_key_path %>'
|
|
13
|
+
<% end %>
|
|
14
|
+
<% if facter %>
|
|
15
|
+
puppet_agent.facter = <%= facter %>
|
|
16
|
+
<% end %>
|
|
17
|
+
<% if options %>
|
|
18
|
+
puppet_agent.options = <%= options %>
|
|
19
|
+
<% end %>
|
|
20
|
+
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
<%= machine_name %>.vm.provision "puppet" do |puppet_apply|
|
|
2
|
+
<% if manifests_path %>
|
|
3
|
+
puppet_apply.manifests_path = '<%= manifests_path %>'
|
|
4
|
+
<% end %>
|
|
5
|
+
<% if manifest_file %>
|
|
6
|
+
puppet_apply.manifest_file = '<%= manifest_file %>'
|
|
7
|
+
<% end %>
|
|
8
|
+
<% if module_path && module_path.kind_of?(String) %>
|
|
9
|
+
puppet_apply.module_path = '<%= module_path %>'
|
|
10
|
+
<% end %>
|
|
11
|
+
<% if module_path && module_path.kind_of?(Array) %>
|
|
12
|
+
puppet_apply.module_path = <%= module_path %>
|
|
13
|
+
<% end %>
|
|
14
|
+
<% if hiera_config_path %>
|
|
15
|
+
puppet_apply.hiera_config_path = '<%= hiera_config_path %>'
|
|
16
|
+
<% end %>
|
|
17
|
+
<% if facter %>
|
|
18
|
+
puppet_apply.facter = <%= facter %>
|
|
19
|
+
<% end %>
|
|
20
|
+
end
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
require 'rbconfig'
|
|
2
|
+
|
|
3
|
+
module VagrantPlugins
|
|
4
|
+
module Invade
|
|
5
|
+
module Validator
|
|
6
|
+
module Provision
|
|
7
|
+
|
|
8
|
+
# (see: https://docs.vagrantup.com/v2/provisioning/puppet_agent.html)
|
|
9
|
+
class PuppetAgent
|
|
10
|
+
|
|
11
|
+
attr_accessor :env
|
|
12
|
+
attr_accessor :puppet_agent
|
|
13
|
+
|
|
14
|
+
DEFAULT = {
|
|
15
|
+
'puppet_server' => nil,
|
|
16
|
+
'puppet_node' => nil,
|
|
17
|
+
'client_cert_path' => nil,
|
|
18
|
+
'client_private_key_path' => nil,
|
|
19
|
+
'facter' => nil,
|
|
20
|
+
'options' => nil
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
def initialize(env, puppet_agent)
|
|
24
|
+
@env = env
|
|
25
|
+
@puppet_agent = puppet_agent
|
|
26
|
+
@invade = env[:invade]
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def validate
|
|
30
|
+
return nil unless @puppet_agent
|
|
31
|
+
|
|
32
|
+
# PUPPET SERVER
|
|
33
|
+
@puppet_agent['puppet_server'] = Validator.validate_string(
|
|
34
|
+
@puppet_agent['puppet_server'], 'puppet_server', DEFAULT['puppet_server']
|
|
35
|
+
)
|
|
36
|
+
|
|
37
|
+
# PUPPET NODE
|
|
38
|
+
@puppet_agent['puppet_node'] = Validator.validate_string(
|
|
39
|
+
@puppet_agent['puppet_node'], 'puppet_node', DEFAULT['puppet_node']
|
|
40
|
+
)
|
|
41
|
+
|
|
42
|
+
# CLIENT CERT PATH
|
|
43
|
+
@puppet_agent['client_cert_path'] = Validator.validate_array(
|
|
44
|
+
@puppet_agent['client_cert_path'], 'client_cert_path', DEFAULT['client_cert_path']
|
|
45
|
+
)
|
|
46
|
+
|
|
47
|
+
# CLIENT PRIVATE KEY PATH
|
|
48
|
+
@puppet_agent['client_private_key_path'] = Validator.validate_array(
|
|
49
|
+
@puppet_agent['client_private_key_path'], 'client_private_key_path', DEFAULT['client_private_key_path']
|
|
50
|
+
)
|
|
51
|
+
|
|
52
|
+
# FACTER
|
|
53
|
+
@puppet_agent['facter'] = Validator.validate_array(
|
|
54
|
+
@puppet_agent['facter'], 'facter', DEFAULT['facter']
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
# OPTIONS
|
|
58
|
+
@puppet_agent['options'] = Validator.validate_string(
|
|
59
|
+
@puppet_agent['options'], 'options', DEFAULT['options']
|
|
60
|
+
)
|
|
61
|
+
|
|
62
|
+
@puppet_agent
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
end
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
require 'rbconfig'
|
|
2
|
+
|
|
3
|
+
module VagrantPlugins
|
|
4
|
+
module Invade
|
|
5
|
+
module Validator
|
|
6
|
+
module Provision
|
|
7
|
+
|
|
8
|
+
# (see: https://docs.vagrantup.com/v2/provisioning/puppet_apply.html)
|
|
9
|
+
class PuppetApply
|
|
10
|
+
|
|
11
|
+
attr_accessor :env
|
|
12
|
+
attr_accessor :puppet_apply
|
|
13
|
+
|
|
14
|
+
DEFAULT = {
|
|
15
|
+
'modules_path' => '.puppet/modules',
|
|
16
|
+
'manifests_path' => './puppet/manifests',
|
|
17
|
+
'manifest_file' => 'init.pp',
|
|
18
|
+
'hiera_config_path' => nil,
|
|
19
|
+
'facter' => {}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
def initialize(env, puppet_apply)
|
|
23
|
+
@env = env
|
|
24
|
+
@puppet_apply = puppet_apply
|
|
25
|
+
@invade = env[:invade]
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def validate
|
|
29
|
+
return nil unless @puppet_apply
|
|
30
|
+
|
|
31
|
+
# MODULES PATH
|
|
32
|
+
@puppet_apply['modules_path'] = Validator.validate_array(
|
|
33
|
+
@puppet_apply['modules_path'], 'modules_path', DEFAULT['modules_path']
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
# MANIFESTS PATH
|
|
37
|
+
@puppet_apply['manifests_path'] = Validator.validate_string(
|
|
38
|
+
@puppet_apply['manifests_path'], 'manifests_path', DEFAULT['manifests_path']
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
# MANIFEST FILE
|
|
42
|
+
@puppet_apply['manifest_file'] = Validator.validate_string(
|
|
43
|
+
@puppet_apply['manifest_file'], 'manifest_file', DEFAULT['manifest_file']
|
|
44
|
+
)
|
|
45
|
+
|
|
46
|
+
# HIERA CONFIG PATH
|
|
47
|
+
@puppet_apply['hiera_config_path'] = Validator.validate_string(
|
|
48
|
+
@puppet_apply['hiera_config_path'], 'hiera_config_path', DEFAULT['hiera_config_path']
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
# FACTER
|
|
52
|
+
@puppet_apply['facter'] = Validator.validate_hash(
|
|
53
|
+
@puppet_apply['facter'], 'facter', DEFAULT['facter']
|
|
54
|
+
)
|
|
55
|
+
|
|
56
|
+
@puppet_apply
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
end
|
|
@@ -3,6 +3,7 @@ module VagrantPlugins
|
|
|
3
3
|
module Validator
|
|
4
4
|
module Provision
|
|
5
5
|
|
|
6
|
+
# (see: https://docs.vagrantup.com/v2/provisioning/shell.html)
|
|
6
7
|
class Shell
|
|
7
8
|
|
|
8
9
|
attr_accessor :env
|
|
@@ -17,7 +18,7 @@ module VagrantPlugins
|
|
|
17
18
|
|
|
18
19
|
def initialize(env, shell)
|
|
19
20
|
@env = env
|
|
20
|
-
@shell =
|
|
21
|
+
@shell = shell
|
|
21
22
|
end
|
|
22
23
|
|
|
23
24
|
def validate
|
|
@@ -3,6 +3,7 @@ module VagrantPlugins
|
|
|
3
3
|
module Validator
|
|
4
4
|
module Provision
|
|
5
5
|
|
|
6
|
+
# (see: https://docs.vagrantup.com/v2/provisioning/shell.html)
|
|
6
7
|
class ShellInline
|
|
7
8
|
|
|
8
9
|
attr_accessor :env
|
|
@@ -17,7 +18,7 @@ module VagrantPlugins
|
|
|
17
18
|
|
|
18
19
|
def initialize(env, shell_inline)
|
|
19
20
|
@env = env
|
|
20
|
-
@shell_inline =
|
|
21
|
+
@shell_inline = shell_inline
|
|
21
22
|
end
|
|
22
23
|
|
|
23
24
|
def validate
|
|
@@ -1,21 +1,23 @@
|
|
|
1
1
|
module VagrantPlugins
|
|
2
2
|
module Invade
|
|
3
3
|
module Validator
|
|
4
|
+
|
|
5
|
+
# (see: https://docs.vagrantup.com/v2/provisioning/index.html)
|
|
4
6
|
module Provision
|
|
5
7
|
|
|
6
8
|
autoload :Shell, 'vagrant-invade/validator/provision/shell'
|
|
7
9
|
autoload :ShellInline, 'vagrant-invade/validator/provision/shell_inline'
|
|
8
|
-
autoload :
|
|
9
|
-
#autoload :
|
|
10
|
+
#autoload :Ansible, 'vagrant-invade/validator/provision/ansible'
|
|
11
|
+
#autoload :CFEngine, 'vagrant-invade/validator/provision/cfengine'
|
|
12
|
+
#autoload :ChefSolo, 'vagrant-invade/validator/provision/chef_solo'
|
|
13
|
+
#autoload :ChefZero, 'vagrant-invade/validator/provision/chef_zero'
|
|
14
|
+
#autoload :ChefClient, 'vagrant-invade/validator/provision/chef_client'
|
|
15
|
+
#autoload :ChefApply, 'vagrant-invade/validator/provision/chef_apply'
|
|
10
16
|
#autoload :Docker, 'vagrant-invade/validator/provision/docker'
|
|
17
|
+
autoload :PuppetApply, 'vagrant-invade/validator/provision/puppet_apply'
|
|
18
|
+
autoload :PuppetAgent, 'vagrant-invade/validator/provision/puppet_agent'
|
|
19
|
+
#autoload :Salt, 'vagrant-invade/validator/provision/salt'
|
|
11
20
|
|
|
12
|
-
DEFAULT = {}
|
|
13
|
-
|
|
14
|
-
def self.validate_base(env, provision)
|
|
15
|
-
return nil unless provision
|
|
16
|
-
|
|
17
|
-
provision
|
|
18
|
-
end
|
|
19
21
|
end
|
|
20
22
|
end
|
|
21
23
|
end
|
|
@@ -11,11 +11,9 @@ module VagrantPlugins
|
|
|
11
11
|
autoload :SSH, 'vagrant-invade/validator/ssh'
|
|
12
12
|
autoload :Plugin, 'vagrant-invade/validator/plugin'
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
attr_accessor :env
|
|
17
|
-
attr_accessor :invade
|
|
14
|
+
attr_accessor :env, :invade, :validation_errors
|
|
18
15
|
|
|
16
|
+
@validation_errors = 0
|
|
19
17
|
@env = nil
|
|
20
18
|
|
|
21
19
|
def self.set_env(env)
|
|
@@ -33,8 +31,8 @@ module VagrantPlugins
|
|
|
33
31
|
@env[:ui].warn("\t#{name} not set. Use Vagrant default.") unless @env[:invade_validate_quiet]
|
|
34
32
|
return default
|
|
35
33
|
else
|
|
36
|
-
@env[:ui].
|
|
37
|
-
|
|
34
|
+
@env[:ui].error("\tError: #{name} => #{value} is not a boolean. Set '#{name}' to default value #{default.to_s.upcase}.") unless @env[:invade_validate_quiet]
|
|
35
|
+
@validation_errors = @validation_errors + 1
|
|
38
36
|
return default
|
|
39
37
|
end
|
|
40
38
|
|
|
@@ -55,8 +53,8 @@ module VagrantPlugins
|
|
|
55
53
|
@env[:ui].warn("\tEmpty string is not valid. Set '#{name}' => '#{default}'.") unless @env[:invade_validate_quiet]
|
|
56
54
|
return default
|
|
57
55
|
else
|
|
58
|
-
@env[:ui].
|
|
59
|
-
|
|
56
|
+
@env[:ui].error("\tError: '#{value}' is not a string. Set to '#{name}' to default value '#{default}'.") unless @env[:invade_validate_quiet]
|
|
57
|
+
@validation_errors = @validation_errors + 1
|
|
60
58
|
return default
|
|
61
59
|
end
|
|
62
60
|
|
|
@@ -74,8 +72,8 @@ module VagrantPlugins
|
|
|
74
72
|
@env[:ui].warn("\t#{name} not set. Use Vagrant default.") unless @env[:invade_validate_quiet]
|
|
75
73
|
return default
|
|
76
74
|
else
|
|
77
|
-
@env[:ui].
|
|
78
|
-
|
|
75
|
+
@env[:ui].error("\tError: '#{value}' is not an integer. Set '#{name}' to default value #{default}.") unless @env[:invade_validate_quiet]
|
|
76
|
+
@validation_errors = @validation_errors + 1
|
|
79
77
|
return default
|
|
80
78
|
end
|
|
81
79
|
|
|
@@ -91,14 +89,35 @@ module VagrantPlugins
|
|
|
91
89
|
@env[:ui].warn("\t#{name} not set. Use Vagrant default.") unless @env[:invade_validate_quiet]
|
|
92
90
|
return default
|
|
93
91
|
else
|
|
94
|
-
@env[:ui].
|
|
95
|
-
|
|
92
|
+
@env[:ui].error("\tError: '#{value}' is not an array. Set '#{name}' to default value #{default}.") unless @env[:invade_validate_quiet]
|
|
93
|
+
@validation_errors = @validation_errors + 1
|
|
96
94
|
return default
|
|
97
95
|
end
|
|
98
96
|
|
|
99
97
|
value
|
|
100
98
|
end
|
|
101
99
|
|
|
100
|
+
# Validates to HASH and returns the value at success or a default if not
|
|
101
|
+
def self.validate_hash(value, name, default)
|
|
102
|
+
|
|
103
|
+
if value.is_a? Hash
|
|
104
|
+
@env[:ui].success("\t#{name} => #{value}") unless @env[:invade_validate_quiet]
|
|
105
|
+
elsif value === nil
|
|
106
|
+
@env[:ui].warn("\t#{name} not set. Use Vagrant default.") unless @env[:invade_validate_quiet]
|
|
107
|
+
return default
|
|
108
|
+
else
|
|
109
|
+
@env[:ui].error("\tError: '#{value}' is not a Hash. Set '#{name}' to default value #{default}.") unless @env[:invade_validate_quiet]
|
|
110
|
+
@validation_errors = @validation_errors + 1
|
|
111
|
+
return default
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
value
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
def self.get_validation_errors
|
|
118
|
+
@validation_errors
|
|
119
|
+
end
|
|
120
|
+
|
|
102
121
|
def self.is_number(value)
|
|
103
122
|
value.to_f.to_s == value.to_s || value.to_i.to_s == value.to_s
|
|
104
123
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: vagrant-invade
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.4.0
|
|
4
|
+
version: 0.4.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Lennart Stein
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2015-10-
|
|
11
|
+
date: 2015-10-13 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -83,7 +83,8 @@ files:
|
|
|
83
83
|
- lib/vagrant-invade/builder/provider/virtualbox.rb
|
|
84
84
|
- lib/vagrant-invade/builder/provider/vmware.rb
|
|
85
85
|
- lib/vagrant-invade/builder/provision.rb
|
|
86
|
-
- lib/vagrant-invade/builder/provision/
|
|
86
|
+
- lib/vagrant-invade/builder/provision/puppet_agent.rb
|
|
87
|
+
- lib/vagrant-invade/builder/provision/puppet_apply.rb
|
|
87
88
|
- lib/vagrant-invade/builder/provision/shell.rb
|
|
88
89
|
- lib/vagrant-invade/builder/provision/shell_inline.rb
|
|
89
90
|
- lib/vagrant-invade/builder/synced_folder.rb
|
|
@@ -116,7 +117,8 @@ files:
|
|
|
116
117
|
- lib/vagrant-invade/template/plugin/winnfsd.erb
|
|
117
118
|
- lib/vagrant-invade/template/provider/virtualbox.erb
|
|
118
119
|
- lib/vagrant-invade/template/provider/vmware.erb
|
|
119
|
-
- lib/vagrant-invade/template/provision/
|
|
120
|
+
- lib/vagrant-invade/template/provision/puppet_agent.erb
|
|
121
|
+
- lib/vagrant-invade/template/provision/puppet_apply.erb
|
|
120
122
|
- lib/vagrant-invade/template/provision/shell.erb
|
|
121
123
|
- lib/vagrant-invade/template/provision/shell_inline.erb
|
|
122
124
|
- lib/vagrant-invade/template/synced_folder/nfs.erb
|
|
@@ -137,7 +139,8 @@ files:
|
|
|
137
139
|
- lib/vagrant-invade/validator/provider/virtualbox.rb
|
|
138
140
|
- lib/vagrant-invade/validator/provider/vmware.rb
|
|
139
141
|
- lib/vagrant-invade/validator/provision.rb
|
|
140
|
-
- lib/vagrant-invade/validator/provision/
|
|
142
|
+
- lib/vagrant-invade/validator/provision/puppet_agent.rb
|
|
143
|
+
- lib/vagrant-invade/validator/provision/puppet_apply.rb
|
|
141
144
|
- lib/vagrant-invade/validator/provision/shell.rb
|
|
142
145
|
- lib/vagrant-invade/validator/provision/shell_inline.rb
|
|
143
146
|
- lib/vagrant-invade/validator/ssh.rb
|
|
@@ -162,9 +165,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
162
165
|
version: 2.0.0
|
|
163
166
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
164
167
|
requirements:
|
|
165
|
-
- - '
|
|
168
|
+
- - '>='
|
|
166
169
|
- !ruby/object:Gem::Version
|
|
167
|
-
version:
|
|
170
|
+
version: '0'
|
|
168
171
|
requirements: []
|
|
169
172
|
rubyforge_project:
|
|
170
173
|
rubygems_version: 2.4.8
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
module VagrantPlugins
|
|
2
|
-
module Invade
|
|
3
|
-
module Builder
|
|
4
|
-
module Provision
|
|
5
|
-
|
|
6
|
-
require 'erubis'
|
|
7
|
-
|
|
8
|
-
class Puppet
|
|
9
|
-
|
|
10
|
-
attr_reader :result
|
|
11
|
-
attr_accessor :machine_name, :puppet_data
|
|
12
|
-
|
|
13
|
-
def initialize(machine_name, puppet_data, result: nil)
|
|
14
|
-
@machine_name = machine_name
|
|
15
|
-
@puppet_data = puppet_data
|
|
16
|
-
@result = result
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
def build
|
|
20
|
-
b = binding
|
|
21
|
-
template_file = "#{TEMPLATE_PATH}/provision/puppet.erb"
|
|
22
|
-
|
|
23
|
-
begin
|
|
24
|
-
|
|
25
|
-
# Get machine name
|
|
26
|
-
machine_name = @machine_name
|
|
27
|
-
|
|
28
|
-
# Values for provider puppet section
|
|
29
|
-
module_path = @puppet_data['module_path']
|
|
30
|
-
manifests_path = @puppet_data['manifests_path']
|
|
31
|
-
manifest_file = @puppet_data['manifest_file']
|
|
32
|
-
hiera_config_path = @puppet_data['hiera_config_path']
|
|
33
|
-
facter = @puppet_data['facter']
|
|
34
|
-
|
|
35
|
-
eruby = Erubis::Eruby.new(File.read(template_file))
|
|
36
|
-
@result = eruby.result b
|
|
37
|
-
rescue TypeError, SyntaxError, SystemCallError => e
|
|
38
|
-
raise(e)
|
|
39
|
-
end
|
|
40
|
-
end
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
end
|
|
44
|
-
end
|
|
45
|
-
end
|
|
46
|
-
end
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
<%= machine_name %>.vm.provision :puppet do |puppet|
|
|
2
|
-
<% if manifests_path %>
|
|
3
|
-
puppet.manifests_path = '<%= manifests_path %>'
|
|
4
|
-
<% end %>
|
|
5
|
-
<% if manifest_file %>
|
|
6
|
-
puppet.manifest_file = '<%= manifest_file %>'
|
|
7
|
-
<% end %>
|
|
8
|
-
<% if module_path %>
|
|
9
|
-
puppet.module_path = '<%= module_path %>'
|
|
10
|
-
<% end %>
|
|
11
|
-
<% if hiera_config_path %>
|
|
12
|
-
puppet.hiera_config_path = '<%= hiera_config_path %>'
|
|
13
|
-
<% end %>
|
|
14
|
-
<% if facter %>
|
|
15
|
-
puppet.facter = <%= facter %>
|
|
16
|
-
<% end %>
|
|
17
|
-
end
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
require 'rbconfig'
|
|
2
|
-
|
|
3
|
-
module VagrantPlugins
|
|
4
|
-
module Invade
|
|
5
|
-
module Validator
|
|
6
|
-
module Provision
|
|
7
|
-
|
|
8
|
-
class Puppet
|
|
9
|
-
|
|
10
|
-
attr_accessor :env
|
|
11
|
-
attr_accessor :puppet
|
|
12
|
-
|
|
13
|
-
DEFAULT = {
|
|
14
|
-
'modules_path' => '.puppet/modules',
|
|
15
|
-
'manifests_path' => './puppet/manifests',
|
|
16
|
-
'manifest_file' => 'init.pp',
|
|
17
|
-
'hiera_config_path' => nil,
|
|
18
|
-
'facter' => {}
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
def initialize(env, puppet)
|
|
22
|
-
@env = env
|
|
23
|
-
@puppet = Provision.validate_base(env, puppet)
|
|
24
|
-
@invade = env[:invade]
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
def validate
|
|
28
|
-
return nil unless @puppet
|
|
29
|
-
|
|
30
|
-
# MODULES PATH
|
|
31
|
-
@puppet['modules_path'] = Validator.validate_array(
|
|
32
|
-
@puppet['modules_path'], 'modules_path', DEFAULT['modules_path']
|
|
33
|
-
)
|
|
34
|
-
|
|
35
|
-
# MANIFESTS PATH
|
|
36
|
-
@puppet['manifests_path'] = Validator.validate_string(
|
|
37
|
-
@puppet['manifests_path'], 'manifests_path', DEFAULT['manifests_path']
|
|
38
|
-
)
|
|
39
|
-
|
|
40
|
-
# MANIFEST FILE
|
|
41
|
-
@puppet['manifest_file'] = Validator.validate_string(
|
|
42
|
-
@puppet['manifest_file'], 'manifest_file', DEFAULT['manifest_file']
|
|
43
|
-
)
|
|
44
|
-
|
|
45
|
-
# HIERA CONFIG PATH
|
|
46
|
-
@puppet['hiera_config_path'] = Validator.validate_string(
|
|
47
|
-
@puppet['hiera_config_path'], 'hiera_config_path', DEFAULT['hiera_config_path']
|
|
48
|
-
)
|
|
49
|
-
|
|
50
|
-
# FACTER
|
|
51
|
-
@puppet['facter'] = Validator.validate_array(
|
|
52
|
-
@puppet['facter'], 'facter', DEFAULT['facter']
|
|
53
|
-
)
|
|
54
|
-
|
|
55
|
-
@puppet
|
|
56
|
-
end
|
|
57
|
-
end
|
|
58
|
-
end
|
|
59
|
-
end
|
|
60
|
-
end
|
|
61
|
-
end
|