vagrant-r10k 0.2.0 → 0.3.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/.gitignore +3 -2
- data/.pullreview.yml +4 -0
- data/.rspec +5 -0
- data/.ruby-version +1 -1
- data/.travis.yml +3 -1
- data/CHANGES.md +26 -0
- data/Gemfile +7 -2
- data/Gemfile.lock +181 -0
- data/README.md +122 -7
- data/Rakefile +111 -0
- data/lib/vagrant-r10k/action/base.rb +44 -0
- data/lib/vagrant-r10k/action/deploy.rb +91 -0
- data/lib/vagrant-r10k/action/validate.rb +46 -0
- data/lib/vagrant-r10k/config.rb +13 -4
- data/lib/vagrant-r10k/helpers.rb +174 -0
- data/lib/vagrant-r10k/plugin.rb +11 -5
- data/lib/vagrant-r10k/version.rb +2 -1
- data/spec/acceptance/skeletons/correct/Vagrantfile +21 -0
- data/spec/acceptance/skeletons/correct/gitcheck.sh +20 -0
- data/spec/acceptance/skeletons/correct/puppet/NOTmodules/.gitkeep +0 -0
- data/spec/acceptance/skeletons/correct/puppet/Puppetfile +12 -0
- data/spec/acceptance/skeletons/correct/puppet/manifests/default.pp +1 -0
- data/spec/acceptance/skeletons/correct/puppet/modules/.gitkeep +0 -0
- data/spec/acceptance/skeletons/could_not_resolve_host/Vagrantfile +21 -0
- data/spec/acceptance/skeletons/could_not_resolve_host/gitcheck.sh +20 -0
- data/spec/acceptance/skeletons/could_not_resolve_host/puppet/NOTmodules/.gitkeep +0 -0
- data/spec/acceptance/skeletons/could_not_resolve_host/puppet/Puppetfile +7 -0
- data/spec/acceptance/skeletons/could_not_resolve_host/puppet/manifests/default.pp +1 -0
- data/spec/acceptance/skeletons/could_not_resolve_host/puppet/modules/.gitkeep +0 -0
- data/spec/acceptance/skeletons/different_mod_path/Vagrantfile +19 -0
- data/spec/acceptance/skeletons/different_mod_path/gitcheck.sh +20 -0
- data/spec/acceptance/skeletons/different_mod_path/puppet/NOTmodules/.gitkeep +0 -0
- data/spec/acceptance/skeletons/different_mod_path/puppet/Puppetfile +12 -0
- data/spec/acceptance/skeletons/different_mod_path/puppet/manifests/default.pp +1 -0
- data/spec/acceptance/skeletons/different_mod_path/puppet/modules/.gitkeep +0 -0
- data/spec/acceptance/skeletons/no_mod_path/Vagrantfile +17 -0
- data/spec/acceptance/skeletons/no_mod_path/gitcheck.sh +20 -0
- data/spec/acceptance/skeletons/no_mod_path/puppet/NOTmodules/.gitkeep +0 -0
- data/spec/acceptance/skeletons/no_mod_path/puppet/Puppetfile +12 -0
- data/spec/acceptance/skeletons/no_mod_path/puppet/manifests/default.pp +1 -0
- data/spec/acceptance/skeletons/no_mod_path/puppet/modules/.gitkeep +0 -0
- data/spec/acceptance/skeletons/no_puppet_dir/Vagrantfile +18 -0
- data/spec/acceptance/skeletons/no_puppet_dir/gitcheck.sh +20 -0
- data/spec/acceptance/skeletons/no_vagrant_r10k/Vagrantfile +14 -0
- data/spec/acceptance/skeletons/no_vagrant_r10k/gitcheck.sh +20 -0
- data/spec/acceptance/skeletons/no_vagrant_r10k/puppet/NOTmodules/.gitkeep +0 -0
- data/spec/acceptance/skeletons/no_vagrant_r10k/puppet/Puppetfile +12 -0
- data/spec/acceptance/skeletons/no_vagrant_r10k/puppet/manifests/default.pp +1 -0
- data/spec/acceptance/skeletons/no_vagrant_r10k/puppet/modules/.gitkeep +0 -0
- data/spec/acceptance/skeletons/puppetfile_syntax_error/Vagrantfile +18 -0
- data/spec/acceptance/skeletons/puppetfile_syntax_error/gitcheck.sh +20 -0
- data/spec/acceptance/skeletons/puppetfile_syntax_error/puppet/Puppetfile +1 -0
- data/spec/acceptance/skeletons/puppetfile_syntax_error/puppet/manifests/default.pp +1 -0
- data/spec/acceptance/skeletons/puppetfile_syntax_error/puppet/modules/.gitkeep +0 -0
- data/spec/acceptance/vagrant-r10k/vagrant-r10k_spec.rb +255 -0
- data/spec/spec_helper.rb +10 -7
- data/spec/unit/action_base_spec.rb +57 -0
- data/spec/unit/action_deploy_spec.rb +550 -0
- data/spec/unit/action_validate_spec.rb +240 -0
- data/spec/unit/helpers_spec.rb +307 -0
- data/spec/unit/plugin_spec.rb +49 -0
- data/support/testrunner.py +189 -0
- data/vagrant-r10k.gemspec +1 -1
- data/vagrant-spec.config.rb +18 -0
- metadata +111 -19
- data/lib/vagrant-r10k/modulegetter.rb +0 -145
- data/spec/unit/modulegetter_spec.rb +0 -369
@@ -0,0 +1,189 @@
|
|
1
|
+
#!/usr/bin/env python
|
2
|
+
|
3
|
+
import os
|
4
|
+
from lxml import etree
|
5
|
+
import datetime
|
6
|
+
import json
|
7
|
+
from fabric.operations import local
|
8
|
+
from fabric.api import settings
|
9
|
+
import shutil
|
10
|
+
import commands
|
11
|
+
from copy import deepcopy
|
12
|
+
from dealer.git import git
|
13
|
+
import sys
|
14
|
+
import re
|
15
|
+
from time import sleep
|
16
|
+
|
17
|
+
out_dir = 'acceptance_results'
|
18
|
+
|
19
|
+
def get_du(path):
|
20
|
+
"""get disk usage for a given path"""
|
21
|
+
cmd = 'df %s | grep -v "^File" | head -1 | awk \'{print $3}\'' % path
|
22
|
+
res = int(commands.getoutput(cmd).strip())
|
23
|
+
return res
|
24
|
+
|
25
|
+
def get_interfaces():
|
26
|
+
ifaces = {}
|
27
|
+
cmd = 'nmcli -t -f DEVICE,TYPE,STATE d'
|
28
|
+
res = commands.getoutput(cmd).strip()
|
29
|
+
if 'nmcli-CRITICAL' in res:
|
30
|
+
return {}
|
31
|
+
lines = res.split("\n")
|
32
|
+
for line in lines:
|
33
|
+
name, dev_type, state = line.split(':')
|
34
|
+
ifaces[name] = {'type': dev_type, 'state': state}
|
35
|
+
return ifaces
|
36
|
+
|
37
|
+
def parse_junit(fname):
|
38
|
+
xml = etree.parse(fname)
|
39
|
+
root = xml.getroot()
|
40
|
+
suite = root.xpath('/testsuite')[0]
|
41
|
+
result = deepcopy(dict(suite.attrib))
|
42
|
+
result['tests'] = []
|
43
|
+
for test in root.xpath('/testsuite/testcase'):
|
44
|
+
t = deepcopy(dict(test.attrib))
|
45
|
+
t['success'] = True
|
46
|
+
t['fail_message'] = ''
|
47
|
+
failures = test.xpath('failure')
|
48
|
+
if len(failures) > 0:
|
49
|
+
t['success'] = False
|
50
|
+
t['fail_message'] = failures[0].attrib['message']
|
51
|
+
result['tests'].append(t)
|
52
|
+
return result
|
53
|
+
|
54
|
+
def get_vboxinfo():
|
55
|
+
# this largely uses code from Vagrant -
|
56
|
+
# plugins/providers/virtualbox/driver/version_4_3.rb
|
57
|
+
res = {}
|
58
|
+
try:
|
59
|
+
res['hostonlyifs'] = get_vbox_hostonlyifs()
|
60
|
+
except:
|
61
|
+
print("ERROR: unable to get VirtualBox hostonlyifs")
|
62
|
+
try:
|
63
|
+
res['dhcpservers'] = get_vbox_dhcpservers()
|
64
|
+
except:
|
65
|
+
print("ERROR: unable to get VirtualBox dhcpservers")
|
66
|
+
return res
|
67
|
+
|
68
|
+
def get_vbox_hostonlyifs():
|
69
|
+
ifnum = 0
|
70
|
+
out = commands.getoutput('VBoxManage list hostonlyifs')
|
71
|
+
ifs = out.split("\n\n")
|
72
|
+
result = {}
|
73
|
+
for iface in ifs:
|
74
|
+
lines = iface.split("\n")
|
75
|
+
data = {}
|
76
|
+
for line in lines:
|
77
|
+
line = line.strip()
|
78
|
+
if line == '':
|
79
|
+
continue
|
80
|
+
parts = line.split(' ', 1)
|
81
|
+
data[parts[0].strip().strip(':')] = parts[1].strip()
|
82
|
+
key = 'unknown_{n}'.format(n=ifnum)
|
83
|
+
ifnum += 1
|
84
|
+
for x in ['Name', 'VBoxNetworkName', 'GUID']:
|
85
|
+
if x in data:
|
86
|
+
key = data[x]
|
87
|
+
break
|
88
|
+
result[key] = data
|
89
|
+
return result
|
90
|
+
|
91
|
+
def get_vbox_dhcpservers():
|
92
|
+
ifnum = 0
|
93
|
+
out = commands.getoutput('VBoxManage list dhcpservers')
|
94
|
+
ifs = out.split("\n\n")
|
95
|
+
result = {}
|
96
|
+
for iface in ifs:
|
97
|
+
lines = iface.split("\n")
|
98
|
+
data = {}
|
99
|
+
for line in lines:
|
100
|
+
line = line.strip()
|
101
|
+
if line == '':
|
102
|
+
continue
|
103
|
+
parts = line.split(' ', 1)
|
104
|
+
data[parts[0].strip().strip(':')] = parts[1].strip()
|
105
|
+
key = 'unknown_{n}'.format(n=ifnum)
|
106
|
+
ifnum += 1
|
107
|
+
if 'NetworkName' in data:
|
108
|
+
key = data['NetworkName']
|
109
|
+
result[key] = data
|
110
|
+
return result
|
111
|
+
|
112
|
+
def do_test(num, testcmd):
|
113
|
+
data = {'num': num}
|
114
|
+
data['git_rev'] = git.revision
|
115
|
+
data['git_tag'] = git.tag
|
116
|
+
|
117
|
+
# output path and command to execute
|
118
|
+
outfile = '{o}/do_test_{n}.out'.format(n=num, o=out_dir)
|
119
|
+
data['outfile'] = outfile
|
120
|
+
cmd = testcmd + ' 2>&1 | tee ' + outfile + ' ; ( exit ${PIPESTATUS[0]} )'
|
121
|
+
|
122
|
+
print("################ BEGIN test {n} ###############################".format(n=num))
|
123
|
+
start_dt = datetime.datetime.now()
|
124
|
+
|
125
|
+
# run the command, send stdout/stderr to console, capture exit code; do not die on non-0 exit
|
126
|
+
with settings(warn_only=True):
|
127
|
+
result = local(cmd, capture=False, shell='/bin/bash')
|
128
|
+
print("################ END test {n} ###############################".format(n=num))
|
129
|
+
|
130
|
+
# calculate duration
|
131
|
+
end_dt = datetime.datetime.now()
|
132
|
+
duration = (end_dt - start_dt).total_seconds()
|
133
|
+
print("Command exited {x} in {d} seconds".format(x=result.return_code, d=duration))
|
134
|
+
|
135
|
+
# update data
|
136
|
+
data['success'] = result.succeeded
|
137
|
+
data['return_code'] = result.return_code
|
138
|
+
data['duration'] = duration
|
139
|
+
|
140
|
+
# system state
|
141
|
+
du = get_du('/tmp/vagrant-r10k-spec')
|
142
|
+
data['tmp_disk_used_KB'] = du
|
143
|
+
data['interfaces'] = get_interfaces()
|
144
|
+
|
145
|
+
# VBox info
|
146
|
+
data['vboxinfo'] = get_vboxinfo()
|
147
|
+
|
148
|
+
# JUnit
|
149
|
+
if os.path.exists('results.xml'):
|
150
|
+
fpath = '{o}/results_{n}.xml'.format(n=num, o=out_dir)
|
151
|
+
shutil.move('results.xml', fpath)
|
152
|
+
data['junit'] = parse_junit(fpath)
|
153
|
+
data['junit_path'] = fpath
|
154
|
+
|
155
|
+
json_path = '{o}/data_{n}.json'.format(n=num, o=out_dir)
|
156
|
+
with open(json_path, 'w') as fh:
|
157
|
+
fh.write(json.dumps(data))
|
158
|
+
print("\tData written to: {j}".format(j=json_path))
|
159
|
+
|
160
|
+
def get_next_test_num(dirname):
|
161
|
+
file_re = re.compile('^data_(\d+)\.json$')
|
162
|
+
num = 0
|
163
|
+
for f in os.listdir(dirname):
|
164
|
+
m = file_re.match(f)
|
165
|
+
if not m:
|
166
|
+
continue
|
167
|
+
n = int(m.group(1))
|
168
|
+
if n > num:
|
169
|
+
num = n
|
170
|
+
return (num + 1)
|
171
|
+
|
172
|
+
if __name__ == "__main__":
|
173
|
+
if len(sys.argv) < 2:
|
174
|
+
sys.stderr.write("USAGE: testrunner.py <# to run>\n")
|
175
|
+
raise SystemExit(1)
|
176
|
+
|
177
|
+
num_to_run = int(sys.argv[1])
|
178
|
+
|
179
|
+
if not os.path.exists(out_dir):
|
180
|
+
os.mkdir(out_dir)
|
181
|
+
|
182
|
+
start_num = get_next_test_num(out_dir)
|
183
|
+
|
184
|
+
print("About to run {n} tests...".format(n=num_to_run))
|
185
|
+
for i in range(start_num, (start_num + num_to_run)):
|
186
|
+
print(">>>> Doing test {i}".format(i=i))
|
187
|
+
do_test(i, 'bundle exec rake --trace acceptance:virtualbox')
|
188
|
+
print(">>> Sleeping 30s between test runs")
|
189
|
+
sleep(30)
|
data/vagrant-r10k.gemspec
CHANGED
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'pathname'
|
2
|
+
require "vagrant-spec/acceptance"
|
3
|
+
require 'rspec_junit_formatter'
|
4
|
+
require 'rspec_matcher_num_times'
|
5
|
+
|
6
|
+
Vagrant::Spec::Acceptance.configure do |c|
|
7
|
+
acceptance_dir = Pathname.new File.expand_path("../spec/acceptance", __FILE__)
|
8
|
+
c.component_paths = [acceptance_dir.to_s]
|
9
|
+
c.skeleton_paths = [(acceptance_dir + 'skeletons').to_s]
|
10
|
+
c.rspec_args_append = [
|
11
|
+
'--format',
|
12
|
+
'RspecJunitFormatter',
|
13
|
+
'--out',
|
14
|
+
'results.xml',
|
15
|
+
]
|
16
|
+
|
17
|
+
c.provider ENV['VS_PROVIDER'], box: ENV['VS_BOX_PATH'], skeleton_path: c.skeleton_paths
|
18
|
+
end
|
metadata
CHANGED
@@ -1,55 +1,55 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vagrant-r10k
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jason Antman
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-09-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: r10k
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ~>
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: 1.2.1
|
20
20
|
type: :runtime
|
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.2.1
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ~>
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '1.
|
33
|
+
version: '1.5'
|
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
|
-
version: '1.
|
40
|
+
version: '1.5'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rake
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - '>='
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - '>='
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
description: Vagrant middleware plugin to allow you to have just a Puppetfile and
|
@@ -60,25 +60,75 @@ executables: []
|
|
60
60
|
extensions: []
|
61
61
|
extra_rdoc_files: []
|
62
62
|
files:
|
63
|
-
-
|
64
|
-
-
|
65
|
-
-
|
63
|
+
- .gitignore
|
64
|
+
- .pullreview.yml
|
65
|
+
- .rspec
|
66
|
+
- .ruby-version
|
67
|
+
- .travis.yml
|
66
68
|
- CHANGES.md
|
67
69
|
- Gemfile
|
70
|
+
- Gemfile.lock
|
68
71
|
- LICENSE.txt
|
69
72
|
- README.md
|
70
73
|
- Rakefile
|
71
74
|
- lib/vagrant-r10k.rb
|
75
|
+
- lib/vagrant-r10k/action/base.rb
|
76
|
+
- lib/vagrant-r10k/action/deploy.rb
|
77
|
+
- lib/vagrant-r10k/action/validate.rb
|
72
78
|
- lib/vagrant-r10k/config.rb
|
73
|
-
- lib/vagrant-r10k/
|
79
|
+
- lib/vagrant-r10k/helpers.rb
|
74
80
|
- lib/vagrant-r10k/plugin.rb
|
75
81
|
- lib/vagrant-r10k/version.rb
|
82
|
+
- spec/acceptance/skeletons/correct/Vagrantfile
|
83
|
+
- spec/acceptance/skeletons/correct/gitcheck.sh
|
84
|
+
- spec/acceptance/skeletons/correct/puppet/NOTmodules/.gitkeep
|
85
|
+
- spec/acceptance/skeletons/correct/puppet/Puppetfile
|
86
|
+
- spec/acceptance/skeletons/correct/puppet/manifests/default.pp
|
87
|
+
- spec/acceptance/skeletons/correct/puppet/modules/.gitkeep
|
88
|
+
- spec/acceptance/skeletons/could_not_resolve_host/Vagrantfile
|
89
|
+
- spec/acceptance/skeletons/could_not_resolve_host/gitcheck.sh
|
90
|
+
- spec/acceptance/skeletons/could_not_resolve_host/puppet/NOTmodules/.gitkeep
|
91
|
+
- spec/acceptance/skeletons/could_not_resolve_host/puppet/Puppetfile
|
92
|
+
- spec/acceptance/skeletons/could_not_resolve_host/puppet/manifests/default.pp
|
93
|
+
- spec/acceptance/skeletons/could_not_resolve_host/puppet/modules/.gitkeep
|
94
|
+
- spec/acceptance/skeletons/different_mod_path/Vagrantfile
|
95
|
+
- spec/acceptance/skeletons/different_mod_path/gitcheck.sh
|
96
|
+
- spec/acceptance/skeletons/different_mod_path/puppet/NOTmodules/.gitkeep
|
97
|
+
- spec/acceptance/skeletons/different_mod_path/puppet/Puppetfile
|
98
|
+
- spec/acceptance/skeletons/different_mod_path/puppet/manifests/default.pp
|
99
|
+
- spec/acceptance/skeletons/different_mod_path/puppet/modules/.gitkeep
|
100
|
+
- spec/acceptance/skeletons/no_mod_path/Vagrantfile
|
101
|
+
- spec/acceptance/skeletons/no_mod_path/gitcheck.sh
|
102
|
+
- spec/acceptance/skeletons/no_mod_path/puppet/NOTmodules/.gitkeep
|
103
|
+
- spec/acceptance/skeletons/no_mod_path/puppet/Puppetfile
|
104
|
+
- spec/acceptance/skeletons/no_mod_path/puppet/manifests/default.pp
|
105
|
+
- spec/acceptance/skeletons/no_mod_path/puppet/modules/.gitkeep
|
106
|
+
- spec/acceptance/skeletons/no_puppet_dir/Vagrantfile
|
107
|
+
- spec/acceptance/skeletons/no_puppet_dir/gitcheck.sh
|
108
|
+
- spec/acceptance/skeletons/no_vagrant_r10k/Vagrantfile
|
109
|
+
- spec/acceptance/skeletons/no_vagrant_r10k/gitcheck.sh
|
110
|
+
- spec/acceptance/skeletons/no_vagrant_r10k/puppet/NOTmodules/.gitkeep
|
111
|
+
- spec/acceptance/skeletons/no_vagrant_r10k/puppet/Puppetfile
|
112
|
+
- spec/acceptance/skeletons/no_vagrant_r10k/puppet/manifests/default.pp
|
113
|
+
- spec/acceptance/skeletons/no_vagrant_r10k/puppet/modules/.gitkeep
|
114
|
+
- spec/acceptance/skeletons/puppetfile_syntax_error/Vagrantfile
|
115
|
+
- spec/acceptance/skeletons/puppetfile_syntax_error/gitcheck.sh
|
116
|
+
- spec/acceptance/skeletons/puppetfile_syntax_error/puppet/Puppetfile
|
117
|
+
- spec/acceptance/skeletons/puppetfile_syntax_error/puppet/manifests/default.pp
|
118
|
+
- spec/acceptance/skeletons/puppetfile_syntax_error/puppet/modules/.gitkeep
|
119
|
+
- spec/acceptance/vagrant-r10k/vagrant-r10k_spec.rb
|
76
120
|
- spec/spec_helper.rb
|
121
|
+
- spec/unit/action_base_spec.rb
|
122
|
+
- spec/unit/action_deploy_spec.rb
|
123
|
+
- spec/unit/action_validate_spec.rb
|
77
124
|
- spec/unit/config_spec.rb
|
78
|
-
- spec/unit/
|
125
|
+
- spec/unit/helpers_spec.rb
|
126
|
+
- spec/unit/plugin_spec.rb
|
79
127
|
- spec/unit/shared_expectations.rb
|
80
128
|
- spec/unit/sharedcontext.rb
|
129
|
+
- support/testrunner.py
|
81
130
|
- vagrant-r10k.gemspec
|
131
|
+
- vagrant-spec.config.rb
|
82
132
|
homepage: https://github.com/jantman/vagrant-r10k
|
83
133
|
licenses:
|
84
134
|
- Apache-2.0
|
@@ -89,23 +139,65 @@ require_paths:
|
|
89
139
|
- lib
|
90
140
|
required_ruby_version: !ruby/object:Gem::Requirement
|
91
141
|
requirements:
|
92
|
-
- -
|
142
|
+
- - '>='
|
93
143
|
- !ruby/object:Gem::Version
|
94
144
|
version: '0'
|
95
145
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
96
146
|
requirements:
|
97
|
-
- -
|
147
|
+
- - '>='
|
98
148
|
- !ruby/object:Gem::Version
|
99
149
|
version: '0'
|
100
150
|
requirements: []
|
101
151
|
rubyforge_project:
|
102
|
-
rubygems_version: 2.
|
152
|
+
rubygems_version: 2.4.7
|
103
153
|
signing_key:
|
104
154
|
specification_version: 4
|
105
155
|
summary: Vagrant middleware plugin to retrieve puppet modules using r10k.
|
106
156
|
test_files:
|
157
|
+
- spec/acceptance/skeletons/correct/Vagrantfile
|
158
|
+
- spec/acceptance/skeletons/correct/gitcheck.sh
|
159
|
+
- spec/acceptance/skeletons/correct/puppet/NOTmodules/.gitkeep
|
160
|
+
- spec/acceptance/skeletons/correct/puppet/Puppetfile
|
161
|
+
- spec/acceptance/skeletons/correct/puppet/manifests/default.pp
|
162
|
+
- spec/acceptance/skeletons/correct/puppet/modules/.gitkeep
|
163
|
+
- spec/acceptance/skeletons/could_not_resolve_host/Vagrantfile
|
164
|
+
- spec/acceptance/skeletons/could_not_resolve_host/gitcheck.sh
|
165
|
+
- spec/acceptance/skeletons/could_not_resolve_host/puppet/NOTmodules/.gitkeep
|
166
|
+
- spec/acceptance/skeletons/could_not_resolve_host/puppet/Puppetfile
|
167
|
+
- spec/acceptance/skeletons/could_not_resolve_host/puppet/manifests/default.pp
|
168
|
+
- spec/acceptance/skeletons/could_not_resolve_host/puppet/modules/.gitkeep
|
169
|
+
- spec/acceptance/skeletons/different_mod_path/Vagrantfile
|
170
|
+
- spec/acceptance/skeletons/different_mod_path/gitcheck.sh
|
171
|
+
- spec/acceptance/skeletons/different_mod_path/puppet/NOTmodules/.gitkeep
|
172
|
+
- spec/acceptance/skeletons/different_mod_path/puppet/Puppetfile
|
173
|
+
- spec/acceptance/skeletons/different_mod_path/puppet/manifests/default.pp
|
174
|
+
- spec/acceptance/skeletons/different_mod_path/puppet/modules/.gitkeep
|
175
|
+
- spec/acceptance/skeletons/no_mod_path/Vagrantfile
|
176
|
+
- spec/acceptance/skeletons/no_mod_path/gitcheck.sh
|
177
|
+
- spec/acceptance/skeletons/no_mod_path/puppet/NOTmodules/.gitkeep
|
178
|
+
- spec/acceptance/skeletons/no_mod_path/puppet/Puppetfile
|
179
|
+
- spec/acceptance/skeletons/no_mod_path/puppet/manifests/default.pp
|
180
|
+
- spec/acceptance/skeletons/no_mod_path/puppet/modules/.gitkeep
|
181
|
+
- spec/acceptance/skeletons/no_puppet_dir/Vagrantfile
|
182
|
+
- spec/acceptance/skeletons/no_puppet_dir/gitcheck.sh
|
183
|
+
- spec/acceptance/skeletons/no_vagrant_r10k/Vagrantfile
|
184
|
+
- spec/acceptance/skeletons/no_vagrant_r10k/gitcheck.sh
|
185
|
+
- spec/acceptance/skeletons/no_vagrant_r10k/puppet/NOTmodules/.gitkeep
|
186
|
+
- spec/acceptance/skeletons/no_vagrant_r10k/puppet/Puppetfile
|
187
|
+
- spec/acceptance/skeletons/no_vagrant_r10k/puppet/manifests/default.pp
|
188
|
+
- spec/acceptance/skeletons/no_vagrant_r10k/puppet/modules/.gitkeep
|
189
|
+
- spec/acceptance/skeletons/puppetfile_syntax_error/Vagrantfile
|
190
|
+
- spec/acceptance/skeletons/puppetfile_syntax_error/gitcheck.sh
|
191
|
+
- spec/acceptance/skeletons/puppetfile_syntax_error/puppet/Puppetfile
|
192
|
+
- spec/acceptance/skeletons/puppetfile_syntax_error/puppet/manifests/default.pp
|
193
|
+
- spec/acceptance/skeletons/puppetfile_syntax_error/puppet/modules/.gitkeep
|
194
|
+
- spec/acceptance/vagrant-r10k/vagrant-r10k_spec.rb
|
107
195
|
- spec/spec_helper.rb
|
196
|
+
- spec/unit/action_base_spec.rb
|
197
|
+
- spec/unit/action_deploy_spec.rb
|
198
|
+
- spec/unit/action_validate_spec.rb
|
108
199
|
- spec/unit/config_spec.rb
|
109
|
-
- spec/unit/
|
200
|
+
- spec/unit/helpers_spec.rb
|
201
|
+
- spec/unit/plugin_spec.rb
|
110
202
|
- spec/unit/shared_expectations.rb
|
111
203
|
- spec/unit/sharedcontext.rb
|
@@ -1,145 +0,0 @@
|
|
1
|
-
require 'r10k/logging'
|
2
|
-
require 'vagrant/errors'
|
3
|
-
|
4
|
-
# this is an ugly monkeypatch, since we're running inside of Vagrant,
|
5
|
-
# which has already defined logger but not with the debug1 and debug2 custom levels
|
6
|
-
module Log4r
|
7
|
-
class Logger
|
8
|
-
|
9
|
-
def debug1(msg)
|
10
|
-
self.debug(msg)
|
11
|
-
end
|
12
|
-
def debug2(msg)
|
13
|
-
self.debug(msg)
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
# patch this so we can get programmatic access to the errors
|
19
|
-
module R10K
|
20
|
-
class TaskRunner
|
21
|
-
def get_errors
|
22
|
-
@errors
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
module VagrantPlugins
|
28
|
-
module R10k
|
29
|
-
class Modulegetter
|
30
|
-
include R10K::Logging
|
31
|
-
def initialize(app, env)
|
32
|
-
@app = app
|
33
|
-
end
|
34
|
-
|
35
|
-
def call(env)
|
36
|
-
require 'r10k/puppetfile'
|
37
|
-
require 'r10k/task_runner'
|
38
|
-
require 'r10k/task/puppetfile'
|
39
|
-
|
40
|
-
@env = env
|
41
|
-
env_dir = @env[:root_path]
|
42
|
-
|
43
|
-
# since this plugin runs in a hackish way (to force it to be before puppet provisioner's
|
44
|
-
# config validation), check here that our config items are set, else bail out
|
45
|
-
unset = Vagrant::Plugin::V2::Config::UNSET_VALUE
|
46
|
-
if @env[:machine].config.r10k.puppet_dir == unset or @env[:machine].config.r10k.puppetfile_path == unset
|
47
|
-
@env[:ui].detail "vagrant-r10k: puppet_dir and/or puppetfile_path not set in config; not running"
|
48
|
-
@app.call(env)
|
49
|
-
return
|
50
|
-
end
|
51
|
-
|
52
|
-
puppetfile_path = File.join(env_dir, @env[:machine].config.r10k.puppetfile_path)
|
53
|
-
|
54
|
-
module_path = nil
|
55
|
-
# override the default mechanism for building a module_path with the optional config argument
|
56
|
-
if @env[:machine].config.r10k.module_path != unset
|
57
|
-
module_path = @env[:machine].config.r10k.module_path
|
58
|
-
end
|
59
|
-
|
60
|
-
manifest_file = nil
|
61
|
-
manifests_path = nil
|
62
|
-
@env[:machine].config.vm.provisioners.each do |prov|
|
63
|
-
if prov.respond_to?(:type)
|
64
|
-
next if prov.type != :puppet
|
65
|
-
else
|
66
|
-
next if prov.name != :puppet
|
67
|
-
end
|
68
|
-
# if module_path has been set before, check if it fits to one defined in the provisioner config
|
69
|
-
if module_path != nil
|
70
|
-
if prov.config.module_path.is_a?(Array) and ! prov.config.module_path.include?(module_path)
|
71
|
-
@env[:ui].detail "vagrant-r10k: module_path \"#{module_path}\" is not within the ones defined in puppet provisioner; not running"
|
72
|
-
@app.call(env)
|
73
|
-
return
|
74
|
-
elsif ! prov.config.module_path.is_a?(Array) and prov.config.module_path != module_path
|
75
|
-
@env[:ui].detail "vagrant-r10k: module_path \"#{module_path}\" is not the same as in puppet provisioner; not running"
|
76
|
-
@app.call(env)
|
77
|
-
return
|
78
|
-
end
|
79
|
-
# no modulepath explict set in config, build one from the provisioner config
|
80
|
-
else
|
81
|
-
module_path = prov.config.module_path.is_a?(Array) ? prov.config.module_path[0] : prov.config.module_path
|
82
|
-
@env[:ui].info "vagrant-r10k: Building the r10k module path with puppet provisioner module_path \"#{module_path}\". (if module_path is an array, first element is used)"
|
83
|
-
end
|
84
|
-
|
85
|
-
manifest_file = File.join(env_dir, prov.config.manifest_file)
|
86
|
-
manifests_path = File.join(env_dir, prov.config.manifests_path[1])
|
87
|
-
end
|
88
|
-
|
89
|
-
# now join the module_path with the env_dir to have an absolute path
|
90
|
-
module_path = File.join(env_dir, module_path)
|
91
|
-
@env[:ui].info "vagrant-r10k: Beginning r10k deploy of puppet modules into #{module_path} using #{puppetfile_path}"
|
92
|
-
|
93
|
-
if ENV["VAGRANT_LOG"] == "debug"
|
94
|
-
R10K::Logging.level = 0
|
95
|
-
else
|
96
|
-
R10K::Logging.level = 3
|
97
|
-
end
|
98
|
-
|
99
|
-
if !File.file?(puppetfile_path)
|
100
|
-
raise ErrorWrapper.new(RuntimeError.new("Puppetfile at #{puppetfile_path} does not exist."))
|
101
|
-
end
|
102
|
-
|
103
|
-
# do the actual module buildout
|
104
|
-
runner = R10K::TaskRunner.new([])
|
105
|
-
begin
|
106
|
-
puppetfile = R10K::Puppetfile.new(File.join(env_dir, @env[:machine].config.r10k.puppet_dir), module_path, puppetfile_path)
|
107
|
-
task = R10K::Task::Puppetfile::Sync.new(puppetfile)
|
108
|
-
runner.append_task task
|
109
|
-
runner.run
|
110
|
-
rescue SyntaxError => ex
|
111
|
-
@env[:ui].error "Invalid syntax in Puppetfile at #{puppetfile_path}"
|
112
|
-
raise ErrorWrapper.new(ex)
|
113
|
-
end
|
114
|
-
if !runner.succeeded?
|
115
|
-
runner.get_errors().each do |error|
|
116
|
-
raise ErrorWrapper.new(RuntimeError.new(error[1]))
|
117
|
-
end
|
118
|
-
end
|
119
|
-
@env[:ui].info "vagrant-r10k: Deploy finished"
|
120
|
-
@app.call(env)
|
121
|
-
end
|
122
|
-
|
123
|
-
end
|
124
|
-
|
125
|
-
class ErrorWrapper < ::Vagrant::Errors::VagrantError
|
126
|
-
attr_reader :original
|
127
|
-
|
128
|
-
def initialize(original)
|
129
|
-
@original = original
|
130
|
-
end
|
131
|
-
|
132
|
-
def to_s
|
133
|
-
"#{original.class}: #{original.to_s}"
|
134
|
-
end
|
135
|
-
|
136
|
-
private
|
137
|
-
|
138
|
-
def method_missing(fun, *args, &block)
|
139
|
-
original.send(fun, *args, &block)
|
140
|
-
end
|
141
|
-
|
142
|
-
end
|
143
|
-
|
144
|
-
end
|
145
|
-
end
|