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.
Files changed (68) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +3 -2
  3. data/.pullreview.yml +4 -0
  4. data/.rspec +5 -0
  5. data/.ruby-version +1 -1
  6. data/.travis.yml +3 -1
  7. data/CHANGES.md +26 -0
  8. data/Gemfile +7 -2
  9. data/Gemfile.lock +181 -0
  10. data/README.md +122 -7
  11. data/Rakefile +111 -0
  12. data/lib/vagrant-r10k/action/base.rb +44 -0
  13. data/lib/vagrant-r10k/action/deploy.rb +91 -0
  14. data/lib/vagrant-r10k/action/validate.rb +46 -0
  15. data/lib/vagrant-r10k/config.rb +13 -4
  16. data/lib/vagrant-r10k/helpers.rb +174 -0
  17. data/lib/vagrant-r10k/plugin.rb +11 -5
  18. data/lib/vagrant-r10k/version.rb +2 -1
  19. data/spec/acceptance/skeletons/correct/Vagrantfile +21 -0
  20. data/spec/acceptance/skeletons/correct/gitcheck.sh +20 -0
  21. data/spec/acceptance/skeletons/correct/puppet/NOTmodules/.gitkeep +0 -0
  22. data/spec/acceptance/skeletons/correct/puppet/Puppetfile +12 -0
  23. data/spec/acceptance/skeletons/correct/puppet/manifests/default.pp +1 -0
  24. data/spec/acceptance/skeletons/correct/puppet/modules/.gitkeep +0 -0
  25. data/spec/acceptance/skeletons/could_not_resolve_host/Vagrantfile +21 -0
  26. data/spec/acceptance/skeletons/could_not_resolve_host/gitcheck.sh +20 -0
  27. data/spec/acceptance/skeletons/could_not_resolve_host/puppet/NOTmodules/.gitkeep +0 -0
  28. data/spec/acceptance/skeletons/could_not_resolve_host/puppet/Puppetfile +7 -0
  29. data/spec/acceptance/skeletons/could_not_resolve_host/puppet/manifests/default.pp +1 -0
  30. data/spec/acceptance/skeletons/could_not_resolve_host/puppet/modules/.gitkeep +0 -0
  31. data/spec/acceptance/skeletons/different_mod_path/Vagrantfile +19 -0
  32. data/spec/acceptance/skeletons/different_mod_path/gitcheck.sh +20 -0
  33. data/spec/acceptance/skeletons/different_mod_path/puppet/NOTmodules/.gitkeep +0 -0
  34. data/spec/acceptance/skeletons/different_mod_path/puppet/Puppetfile +12 -0
  35. data/spec/acceptance/skeletons/different_mod_path/puppet/manifests/default.pp +1 -0
  36. data/spec/acceptance/skeletons/different_mod_path/puppet/modules/.gitkeep +0 -0
  37. data/spec/acceptance/skeletons/no_mod_path/Vagrantfile +17 -0
  38. data/spec/acceptance/skeletons/no_mod_path/gitcheck.sh +20 -0
  39. data/spec/acceptance/skeletons/no_mod_path/puppet/NOTmodules/.gitkeep +0 -0
  40. data/spec/acceptance/skeletons/no_mod_path/puppet/Puppetfile +12 -0
  41. data/spec/acceptance/skeletons/no_mod_path/puppet/manifests/default.pp +1 -0
  42. data/spec/acceptance/skeletons/no_mod_path/puppet/modules/.gitkeep +0 -0
  43. data/spec/acceptance/skeletons/no_puppet_dir/Vagrantfile +18 -0
  44. data/spec/acceptance/skeletons/no_puppet_dir/gitcheck.sh +20 -0
  45. data/spec/acceptance/skeletons/no_vagrant_r10k/Vagrantfile +14 -0
  46. data/spec/acceptance/skeletons/no_vagrant_r10k/gitcheck.sh +20 -0
  47. data/spec/acceptance/skeletons/no_vagrant_r10k/puppet/NOTmodules/.gitkeep +0 -0
  48. data/spec/acceptance/skeletons/no_vagrant_r10k/puppet/Puppetfile +12 -0
  49. data/spec/acceptance/skeletons/no_vagrant_r10k/puppet/manifests/default.pp +1 -0
  50. data/spec/acceptance/skeletons/no_vagrant_r10k/puppet/modules/.gitkeep +0 -0
  51. data/spec/acceptance/skeletons/puppetfile_syntax_error/Vagrantfile +18 -0
  52. data/spec/acceptance/skeletons/puppetfile_syntax_error/gitcheck.sh +20 -0
  53. data/spec/acceptance/skeletons/puppetfile_syntax_error/puppet/Puppetfile +1 -0
  54. data/spec/acceptance/skeletons/puppetfile_syntax_error/puppet/manifests/default.pp +1 -0
  55. data/spec/acceptance/skeletons/puppetfile_syntax_error/puppet/modules/.gitkeep +0 -0
  56. data/spec/acceptance/vagrant-r10k/vagrant-r10k_spec.rb +255 -0
  57. data/spec/spec_helper.rb +10 -7
  58. data/spec/unit/action_base_spec.rb +57 -0
  59. data/spec/unit/action_deploy_spec.rb +550 -0
  60. data/spec/unit/action_validate_spec.rb +240 -0
  61. data/spec/unit/helpers_spec.rb +307 -0
  62. data/spec/unit/plugin_spec.rb +49 -0
  63. data/support/testrunner.py +189 -0
  64. data/vagrant-r10k.gemspec +1 -1
  65. data/vagrant-spec.config.rb +18 -0
  66. metadata +111 -19
  67. data/lib/vagrant-r10k/modulegetter.rb +0 -145
  68. data/spec/unit/modulegetter_spec.rb +0 -369
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a4666dcc1faa126330ef66752ae6271931d6d856
4
- data.tar.gz: 335eee055654f32f1ac8605dc5368ca1ec6857dd
3
+ metadata.gz: 8d10d813ebfeaaab6624535df85adf644ef33920
4
+ data.tar.gz: 18b0c7240ad342c182695b215b2eedd83a399437
5
5
  SHA512:
6
- metadata.gz: 4e378b000c0d0772d99c1bd5a34b415f0c821a1249cc1893846702d84aa10cd606fb596ab54ad1fdb04e7f03d6426d5ddc9622bec119e4c2573fadebe9c9b740
7
- data.tar.gz: e66844a6f7c8e937c3bd6b92a465b34b14a1eac75033fb2f6c10888faa2535ccd9bf31d0db9a1dc85b59f18660f4b3bf4af90f8b19baf8316cd9de4f85868ed5
6
+ metadata.gz: 8a590b625431419a985732cb0950339d3ac217dc6294a30696396685f61963bd62291b2ef81905414763f7f6fe1b39d15ab694d57d03e93936c15584d628867e
7
+ data.tar.gz: d57a257ed713e38dd6dcb6e722746197b7829e578a5a9c1f70757353dda7d2e262252077d6e86a769ef309c67ec5c77f2391dda80b9265c85c638cbfe840465c
data/.gitignore CHANGED
@@ -3,7 +3,6 @@
3
3
  .bundle
4
4
  .config
5
5
  .yardoc
6
- Gemfile.lock
7
6
  InstalledFiles
8
7
  _yardoc
9
8
  coverage
@@ -21,6 +20,8 @@ tmp
21
20
  *.a
22
21
  mkmf.log
23
22
  vendor
24
- Vagrantfile
25
23
  .vagrant
26
24
  coverage
25
+ results.xml
26
+ spec/boxes
27
+ acceptance.out
data/.pullreview.yml ADDED
@@ -0,0 +1,4 @@
1
+ ---
2
+ notifications:
3
+ pullrequest:
4
+ comment: verbose
data/.rspec ADDED
@@ -0,0 +1,5 @@
1
+ --format documentation
2
+ --color
3
+ --order random
4
+ --format RspecJunitFormatter
5
+ --out results.xml
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- ruby-2.1.1
1
+ ruby-2.0.0
data/.travis.yml CHANGED
@@ -1,8 +1,9 @@
1
1
  ---
2
+ sudo: false
2
3
  language: ruby
3
4
  before_install:
4
5
  - gem install bundler --version $BUNDLER_VERSION
5
- install: bundle _${BUNDLER_VERSION}_ install
6
+ install: bundle _${BUNDLER_VERSION}_ install --retry 5
6
7
  script: bundle _${BUNDLER_VERSION}_ exec rspec --color --format documentation
7
8
  notifications:
8
9
  email: true
@@ -12,6 +13,7 @@ env:
12
13
  global:
13
14
  - NOKOGIRI_USE_SYSTEM_LIBRARIES=true
14
15
  matrix:
16
+ - VAGRANT_VERSION=1.5.0 BUNDLER_VERSION=1.5.2
15
17
  - VAGRANT_VERSION=1.6.5 BUNDLER_VERSION=1.6.9
16
18
  - VAGRANT_VERSION=1.7.0 BUNDLER_VERSION=1.7.9
17
19
  - BUNDLER_VERSION=1.7.9
data/CHANGES.md CHANGED
@@ -1,5 +1,31 @@
1
1
  # vagrant-r10k changelog
2
2
 
3
+ ## master (unreleased)
4
+
5
+ ## 0.3.0 2015-09-04 Jason Antman <jason@jasonantman.com>
6
+
7
+ * [#9](https://github.com/jantman/vagrant-r10k/issues/9) major refactor to separate config validation and provisioning, and prevent multiple provisioning runs
8
+ * [#15](https://github.com/jantman/vagrant-r10k/issues/17) document how to install Forge modules
9
+ * [#16](https://github.com/jantman/vagrant-r10k/issues/16) more helpful error message if r10k deploy fails with 'Could not resolve host'
10
+ * Change gemspec from ``bundler ~> 1.6`` to ``bundler ~> 1.5`` for testing Vagrant 1.5.0
11
+ * Updates to ``README.md``
12
+ * Testing changes
13
+ * [#12](https://github.com/jantman/vagrant-r10k/issues/12) [vagrant-spec](https://github.com/mitchellh/vagrant-spec/)-based acceptance tests for VirtualBox
14
+ * [#20](https://github.com/jantman/vagrant-r10k/issues/20) vmware-workstation spec tests are broken and disabled
15
+ * Major overhaul to spec and acceptance tests
16
+ * Ignore ``spec/`` in coverage
17
+ * Add increased coverage of ``plugin.rb``
18
+ * Change to documentation output for rspec
19
+ * Don't gitignore ``Gemfile.lock``
20
+ * Randomize test execution order
21
+ * Add JUnit XML results output
22
+ * Ignore some un-testable code from coverage analysis
23
+ * Add Travis testing for Vagrant 1.5.0
24
+ * Add ``--retry`` to ``bundle install`` to fix Travis timeout errors
25
+ * Downgrade bundler from 1.6 to 1.5 to work with older testing versions
26
+ * Bump bundled Vagrant version from 1.7.2 to 1.7.4
27
+ * [#22](https://github.com/jantman/vagrant-r10k/issues/22) enable pullreview.com code analysis and comments, and make some recommended changes
28
+
3
29
  ## 0.2.0 2015-01-10 Jason Antman <jason@jasonantman.com>
4
30
 
5
31
  * Add unit tests for modulegetter and config.
data/Gemfile CHANGED
@@ -1,4 +1,6 @@
1
1
  source 'https://rubygems.org'
2
+ # this next line is needed for vagrant-vmware-workstation for acceptance testing
3
+ #source "http://gems.hashicorp.com"
2
4
 
3
5
  group :development do
4
6
  if ENV.has_key?('VAGRANT_VERSION')
@@ -6,12 +8,15 @@ group :development do
6
8
  else
7
9
  gem "vagrant", git: "https://github.com/mitchellh/vagrant.git", branch: 'master'
8
10
  end
9
- # Pinned on 12/10/2014. Compatible with Vagrant 1.5.x, 1.6.x and 1.7.x.
10
- gem 'vagrant-spec', :github => 'mitchellh/vagrant-spec', :ref => '1df5a3a'
11
+ # pinned to branch for https://github.com/mitchellh/vagrant-spec/pull/16
12
+ gem 'vagrant-spec', :github => 'jantman/vagrant-spec', :ref => 'junit_and_env'
11
13
  gem 'simplecov', :require => false
12
14
  gem 'codecov', :require => false
15
+ gem "rspec_junit_formatter", :require => false
16
+ gem 'rspec-matcher-num-times', git: "https://github.com/jantman/rspec-matcher-num-times.git", branch: 'rspec2'
13
17
  end
14
18
 
15
19
  group :plugins do
16
20
  gemspec
21
+ #gem 'vagrant-vmware-workstation', '3.2.8'
17
22
  end
data/Gemfile.lock ADDED
@@ -0,0 +1,181 @@
1
+ GIT
2
+ remote: git://github.com/jantman/vagrant-spec.git
3
+ revision: d85c6fd2887358b7adc145cf89a4bfb420f7f714
4
+ ref: junit_and_env
5
+ specs:
6
+ vagrant-spec (0.0.1)
7
+ childprocess (~> 0.5.0)
8
+ log4r (~> 1.1.9)
9
+ rspec (~> 2.14)
10
+ thor (~> 0.18.1)
11
+
12
+ GIT
13
+ remote: https://github.com/jantman/rspec-matcher-num-times.git
14
+ revision: a34cf9b95ff94512d4c515056ef25a73dbf8d544
15
+ branch: rspec2
16
+ specs:
17
+ rspec-matcher-num-times (0.0.1)
18
+ rspec (>= 2.0)
19
+
20
+ GIT
21
+ remote: https://github.com/mitchellh/vagrant.git
22
+ revision: cd25b820c4425c77b833550e1f1d90f9a7c8be14
23
+ branch: master
24
+ specs:
25
+ vagrant (1.7.4)
26
+ bundler (>= 1.5.2, <= 1.10.5)
27
+ childprocess (~> 0.5.0)
28
+ erubis (~> 2.7.0)
29
+ hashicorp-checkpoint (~> 0.1.1)
30
+ i18n (>= 0.6.0, <= 0.8.0)
31
+ listen (~> 3.0.2)
32
+ log4r (~> 1.1.9, < 1.1.11)
33
+ net-scp (~> 1.1.0)
34
+ net-sftp (~> 2.1)
35
+ net-ssh (>= 2.6.6, < 2.10.0)
36
+ nokogiri (= 1.6.3.1)
37
+ rb-kqueue (~> 0.2.0)
38
+ rest-client (>= 1.6.0, < 2.0)
39
+ wdm (~> 0.1.0)
40
+ winrm (~> 1.3)
41
+ winrm-fs (~> 0.2.0)
42
+
43
+ PATH
44
+ remote: .
45
+ specs:
46
+ vagrant-r10k (0.3.0)
47
+ r10k (~> 1.2.1)
48
+
49
+ GEM
50
+ remote: https://rubygems.org/
51
+ specs:
52
+ builder (3.2.2)
53
+ childprocess (0.5.6)
54
+ ffi (~> 1.0, >= 1.0.11)
55
+ codecov (0.0.4)
56
+ json
57
+ simplecov
58
+ url
59
+ colored (1.2)
60
+ cri (2.5.0)
61
+ colored (~> 1.2)
62
+ diff-lcs (1.2.5)
63
+ docile (1.1.5)
64
+ domain_name (0.5.24)
65
+ unf (>= 0.0.5, < 1.0.0)
66
+ erubis (2.7.0)
67
+ faraday (0.8.9)
68
+ multipart-post (~> 1.2.0)
69
+ faraday_middleware (0.9.1)
70
+ faraday (>= 0.7.4, < 0.10)
71
+ faraday_middleware-multi_json (0.0.6)
72
+ faraday_middleware
73
+ multi_json
74
+ ffi (1.9.10)
75
+ gssapi (1.2.0)
76
+ ffi (>= 1.0.1)
77
+ gyoku (1.3.1)
78
+ builder (>= 2.1.2)
79
+ hashicorp-checkpoint (0.1.4)
80
+ http-cookie (1.0.2)
81
+ domain_name (~> 0.5)
82
+ httpclient (2.6.0.1)
83
+ i18n (0.7.0)
84
+ json (1.8.2)
85
+ json_pure (1.8.1)
86
+ listen (3.0.3)
87
+ rb-fsevent (>= 0.9.3)
88
+ rb-inotify (>= 0.9)
89
+ little-plugger (1.1.3)
90
+ log4r (1.1.10)
91
+ logging (1.8.2)
92
+ little-plugger (>= 1.1.3)
93
+ multi_json (>= 1.8.4)
94
+ mime-types (2.6.1)
95
+ mini_portile (0.6.0)
96
+ multi_json (1.8.4)
97
+ multipart-post (1.2.0)
98
+ net-scp (1.1.2)
99
+ net-ssh (>= 2.6.5)
100
+ net-sftp (2.1.2)
101
+ net-ssh (>= 2.6.5)
102
+ net-ssh (2.9.2)
103
+ netrc (0.10.3)
104
+ nokogiri (1.6.3.1)
105
+ mini_portile (= 0.6.0)
106
+ nori (2.6.0)
107
+ r10k (1.2.1)
108
+ colored (>= 1.2)
109
+ cri (~> 2.5.0)
110
+ faraday (~> 0.8.8)
111
+ faraday_middleware (~> 0.9.0)
112
+ faraday_middleware-multi_json (~> 0.0.5)
113
+ json_pure (~> 1.8.1)
114
+ log4r (>= 1.1.10)
115
+ multi_json (~> 1.8.2)
116
+ systemu (~> 2.5.2)
117
+ rake (10.4.2)
118
+ rb-fsevent (0.9.5)
119
+ rb-inotify (0.9.5)
120
+ ffi (>= 0.5.0)
121
+ rb-kqueue (0.2.4)
122
+ ffi (>= 0.5.0)
123
+ rest-client (1.8.0)
124
+ http-cookie (>= 1.0.2, < 2.0)
125
+ mime-types (>= 1.16, < 3.0)
126
+ netrc (~> 0.7)
127
+ rspec (2.99.0)
128
+ rspec-core (~> 2.99.0)
129
+ rspec-expectations (~> 2.99.0)
130
+ rspec-mocks (~> 2.99.0)
131
+ rspec-core (2.99.2)
132
+ rspec-expectations (2.99.2)
133
+ diff-lcs (>= 1.1.3, < 2.0)
134
+ rspec-mocks (2.99.2)
135
+ rspec_junit_formatter (0.2.0)
136
+ builder (< 4)
137
+ rspec (>= 2, < 4)
138
+ rspec-core (!= 2.12.0)
139
+ rubyntlm (0.4.0)
140
+ rubyzip (1.1.7)
141
+ simplecov (0.9.2)
142
+ docile (~> 1.1.0)
143
+ multi_json (~> 1.0)
144
+ simplecov-html (~> 0.9.0)
145
+ simplecov-html (0.9.0)
146
+ systemu (2.5.2)
147
+ thor (0.18.1)
148
+ unf (0.1.4)
149
+ unf_ext
150
+ unf_ext (0.0.7.1)
151
+ url (0.3.2)
152
+ uuidtools (2.1.5)
153
+ wdm (0.1.1)
154
+ winrm (1.3.3)
155
+ builder (>= 2.1.2)
156
+ gssapi (~> 1.2)
157
+ gyoku (~> 1.0)
158
+ httpclient (~> 2.2, >= 2.2.0.2)
159
+ logging (~> 1.6, >= 1.6.1)
160
+ nori (~> 2.0)
161
+ rubyntlm (~> 0.4.0)
162
+ uuidtools (~> 2.1.2)
163
+ winrm-fs (0.2.2)
164
+ erubis (~> 2.7)
165
+ logging (~> 1.6, >= 1.6.1)
166
+ rubyzip (~> 1.1)
167
+ winrm (~> 1.3.0)
168
+
169
+ PLATFORMS
170
+ ruby
171
+
172
+ DEPENDENCIES
173
+ bundler (~> 1.5)
174
+ codecov
175
+ rake
176
+ rspec-matcher-num-times!
177
+ rspec_junit_formatter
178
+ simplecov
179
+ vagrant!
180
+ vagrant-r10k!
181
+ vagrant-spec!
data/README.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Vagrant::R10k
2
2
 
3
+ [![Build Status](https://travis-ci.org/jantman/vagrant-r10k.svg?branch=master)](https://travis-ci.org/jantman/vagrant-r10k)
4
+ [![Code Coverage](https://codecov.io/github/jantman/vagrant-r10k/coverage.svg?branch=master)](https://codecov.io/github/jantman/vagrant-r10k?branch=master)
5
+ [![Code Climate](https://codeclimate.com/github/jantman/vagrant-r10k/badges/gpa.svg)](https://codeclimate.com/github/jantman/vagrant-r10k)
6
+ [![Gem Version](https://img.shields.io/gem/v/vagrant-r10k.svg)](https://rubygems.org/gems/vagrant-r10k)
7
+ [![Total Downloads](https://img.shields.io/gem/dt/vagrant-r10k.svg)](https://rubygems.org/gems/vagrant-r10k)
8
+ [![Github Issues](https://img.shields.io/github/issues/jantman/vagrant-r10k.svg)](https://github.com/jantman/vagrant-r10k/issues)
3
9
  [![Project Status: Active - The project has reached a stable, usable state and is being actively developed.](http://www.repostatus.org/badges/0.1.0/active.svg)](http://www.repostatus.org/#active)
4
10
 
5
11
  vagrant-r10k is a [Vagrant](http://www.vagrantup.com/) 1.2+ middleware plugin to allow you to have just a Puppetfile and
@@ -56,7 +62,39 @@ The configuration for r10k and puppet would look like:
56
62
 
57
63
  If you provide an array of directories in puppet.module_path, vagrant-r10k will use the first directory listed for auto configuration. If you want to let r10k use a different directory, see below.
58
64
 
59
- ## Usage with explicit path to module installation directory
65
+ ### Puppet Forge Modules in Puppetfile
66
+
67
+ In order to prevent conflicts with other plugins and allow you to use whatever Puppet version you need, ``puppet`` itself is not included
68
+ in this plugin. This means that, _as-is, this plugin can't install Forge modules in your Puppetfile_, only modules from Git or SVN. This
69
+ is because installing Forge modules requires ``puppet`` itself to download the module.
70
+
71
+ The two possible ways to deal with this are:
72
+
73
+ 1. Only use git or svn repo references in your Puppetfile.
74
+ 2. Install ``puppet`` into Vagrant's gems
75
+
76
+ For #2, installing puppet into Vagrant's gems, simply ``vagrant plugin install puppet``; for further information,
77
+ see the [vagrant plugin documentation](https://docs.vagrantup.com/v2/plugins/usage.html). If you do this, you should
78
+ probably ensure that puppet is present by putting something like this at the top of your Vagrantfile:
79
+
80
+ ```
81
+ # test that puppet is installed as a Vagrant plugin
82
+ # you can't use ``Vagrant.has_plugin?("puppet")`` because Vagrant's built-in
83
+ # Puppet Provisioner provides a plugin named "puppet", so this always evaluates to true.
84
+ begin
85
+ gem "puppet"
86
+ rescue Gem::LoadError
87
+ raise "puppet is not installed in vagrant gems! please run 'vagrant plugin install puppet'"
88
+ end
89
+ ```
90
+
91
+ If you want to check for a specific version of Puppet, you can replace the content of the ``begin`` block with something like:
92
+
93
+ ```
94
+ gem "puppet", ">=3.8"
95
+ ```
96
+
97
+ ### Usage with explicit path to module installation directory
60
98
 
61
99
  Add the following to your Vagrantfile, before the puppet section:
62
100
 
@@ -94,6 +132,29 @@ The configuration for r10k and puppet would look like:
94
132
  puppet.module_path = ["puppet/modules", "puppet/vendor"]
95
133
  end
96
134
 
135
+ ## Getting Help
136
+
137
+ Bug reports, feature requests, and pull requests are always welcome. At this time, the
138
+ [GitHub Issues Tracker](https://github.com/jantman/vagrant-r10k/issues)
139
+ is the only place for support, so questions and comments are welcome there as well,
140
+ but please be sure they haven't already been asked and answered.
141
+
142
+ Bug reports should include the following information in order to be investigated:
143
+
144
+ 1. A detailed description of the problem, including the behavior you expected and
145
+ the actual behavior that you're observing.
146
+ 2. The output of ``vagrant plugin list`` showing all of the plugins you're running
147
+ and their versions.
148
+ 3. The versions of Ruby (``ruby --version``) and Vagrant (``vagrant --version``)
149
+ itself that you're running.
150
+ 4. A copy of the Vagrantfile that was being used. Please include all lines in it;
151
+ if you have any confidential or proprietary information, feel free to replace
152
+ usernames, passwords, URLs, IPs, etc. with "X"s, but please don't remove
153
+ large portions of it.
154
+ 5. A debug-level log of the command you're having problems with. i.e. if your
155
+ problem is experienced when running ``vagrant up``, please include the full
156
+ output of ``VAGRANT_LOG=debug vagrant up``.
157
+
97
158
  ## Contributing
98
159
 
99
160
  1. Fork it ( https://github.com/jantman/vagrant-r10k/fork )
@@ -107,14 +168,66 @@ The configuration for r10k and puppet would look like:
107
168
 
108
169
  * Oliver Bertuch - [https://github.com/poikilotherm](https://github.com/poikilotherm)
109
170
 
110
- ## Testing
111
-
112
- Still need to write tests... but they'll be using bundler and rspec.
171
+ ## Development
113
172
 
114
- __Note__ that developming vagrant plugins _requires_ ruby 2.0.0 or newer.
173
+ __Note__ that developing vagrant plugins _requires_ ruby 2.0.0 or newer.
115
174
  A `.ruby-version` is provided to get [rvm](https://rvm.io/workflow/projects)
116
175
  to use 2.1.1.
117
176
 
177
+ ### Unit Tests
178
+
179
+ These will be automatically run by TravisCI for any pull requests or commits
180
+ to the repository. To run manually:
181
+
182
+ bundle install --path vendor
183
+ bundle exec rake spec
184
+
185
+ ### Acceptance Tests
186
+
187
+ Unfortunately, "acceptance" testing Vagrant requires the various providers
188
+ be functional; i.e. to test the [VMWare Providers](https://www.vagrantup.com/vmware)
189
+ requires both a license for them from Hashicorp, and the VMWare products
190
+ themselves. Similarly, testing the AWS providers requires an AWS account and
191
+ actually running EC2 instances. As such, acceptance tests are provided separately
192
+ for each provider.
193
+
194
+ Note that the acceptance tests are tested with bundler 1.7.14. Also note that
195
+ the first time the VMWare provider is run in a given installation, it will
196
+ present an interactive sudo prompt in order to be able to interact with
197
+ VMWare.
198
+
199
+ Running Virtualbox acceptance tests:
200
+
201
+ bundle exec rake acceptance:virtualbox
202
+
203
+ When tests fail, they leave Virtualbox ``hostonlyif``s around; this can quickly clutter up the
204
+ system and cause other problems. As a result, after the virtualbox tests, we invoke the Vagrant
205
+ VirtualBox Provider's [delete_unused_host_only_networks](https://github.com/mitchellh/vagrant/blob/b118ab10c8e0f8e62a547249805f05240e6e4ee9/plugins/providers/virtualbox/driver/version_5_0.rb#L69)
206
+ method. This can also be manually run via ``bundle exec rake clean_vbox``.
207
+
208
+ These tests may generate a _lot_ of output; since there's no nice standalone junit XML viewer,
209
+ it may be helpful to run the tests as:
210
+
211
+ bundle exec rake acceptance:virtualbox 2>&1 | tee acceptance.out
212
+
213
+ And then examine ``acceptance.out`` as needed.
214
+
215
+
216
+ __Note__ that the vmware-workstation provider acceptance tests are not currently
217
+ functional; I've only been able to get the VirtualBox acceptance tests working.
218
+ If many users report vmware-specific problems, I'll give the tests another try.
219
+ Helpful information for them is available at http://www.codingonstilts.com/2013/07/how-to-bundle-exec-vagrant-up-with.html
220
+ and https://groups.google.com/d/topic/vagrant-up/J8J6LmhzBqM/discussion
221
+ I had these working at some point, but have been unable to get them working since;
222
+ it seems that (a bit painfully and ironically), mitchellh's [vagrant-spec](https://github.com/mitchellh/vagrant-spec/)
223
+ doesn't seem to work cleanly with Hashicorp's paid/licensed Vagrant providers.
224
+
225
+ Running (currently broken) VMWare Workstation acceptance tests:
226
+
227
+ bundle exec rake acceptance:vmware_workstation
228
+
229
+ ### Manually Testing Vagrant
230
+
118
231
  For manual testing:
119
232
 
120
233
  bundle install --path vendor
@@ -124,11 +237,13 @@ To use an existing project's Vagrantfile, you can just specify the directory tha
124
237
  is in using the ``VAGRANT_CWD`` environment variable (i.e. prepend ``VAGRANT_CWD=/path/to/project``
125
238
  to the above command).
126
239
 
127
- ## Debugging
240
+ Note that this will not work easily with the VMWare provider, or any other Hashicorp paid/licensed provider.
241
+
242
+ ### Debugging
128
243
 
129
244
  Exporting ``VAGRANT_LOG=debug`` will also turn on debug-level logging for r10k.
130
245
 
131
- ## Releasing
246
+ ### Releasing
132
247
 
133
248
  1. Ensure all tests are passing, coverage is acceptable, etc.
134
249
  2. Increment the version number in ``lib/vagrant-r10k/version.rb``
data/Rakefile CHANGED
@@ -11,7 +11,118 @@ begin
11
11
  rescue LoadError
12
12
  end
13
13
 
14
+ def system_or_die(cmd, fail_msg=nil)
15
+ puts "running: '#{cmd}'"
16
+ res = system(cmd)
17
+ if ! res
18
+ if fail_msg.nil?
19
+ $stderr.puts "Command exited non-zero: #{cmd}"
20
+ else
21
+ $stderr.puts fail_msg
22
+ end
23
+ exit!(1)
24
+ end
25
+ end
26
+
27
+ def get_box_path(provider)
28
+ boxes_dir = File.join(File.dirname(__FILE__), 'spec', 'boxes')
29
+ Dir.mkdir(boxes_dir) if not File.directory?(boxes_dir)
30
+ if provider == 'virtualbox'
31
+ boxurl = 'https://s3.amazonaws.com/puppetlabs-vagrantcloud/centos-7.0-x86_64-virtualbox-puppet-1.0.1.box'
32
+ elsif provider == 'aws'
33
+ boxurl = 'https://github.com/mitchellh/vagrant-aws/raw/master/dummy.box'
34
+ elsif provider == 'vmware_workstation'
35
+ boxurl = 'https://s3.amazonaws.com/puppetlabs-vagrantcloud/centos-7.0-x86_64-vmware-puppet-1.0.1.box'
36
+ else
37
+ STDERR.puts "ERROR: no box URL known for provider '#{provider}'"
38
+ exit!(1)
39
+ end
40
+ box_path = File.join(boxes_dir, "dummy_#{provider}.box")
41
+ if File.exist?(box_path)
42
+ puts "#{provider} box exists at #{box_path}"
43
+ else
44
+ puts "Downloading #{provider} box from #{boxurl} to #{box_path}"
45
+ system_or_die("curl -o #{box_path} '#{boxurl}'")
46
+ end
47
+ return box_path
48
+ end
49
+
50
+ def fix_results_xml()
51
+ # mainly a workaround for https://github.com/sj26/rspec_junit_formatter/issues/31
52
+ return if ! File.exist?('results.xml')
53
+ puts "Munging invalid control chracters in results.xml"
54
+ content = File.read('results.xml')
55
+ content.gsub!(/\033/, "\uFFFD")
56
+ File.open('results.xml', 'w') { |file| file.write(content) }
57
+ end
58
+
59
+ def vmware_workstation_prep()
60
+ # make vmware_workstation provider work in bundler install
61
+ # see: http://www.codingonstilts.com/2013/07/how-to-bundle-exec-vagrant-up-with.html
62
+ plugin_dir = Gem::Specification.find_by_name("vagrant-vmware-workstation").gem_dir
63
+ puts "Found vmware_workstation plugin dir as: #{plugin_dir}"
64
+ loader_link_path = File.join(plugin_dir, "rgloader")
65
+ if not File.exist?(loader_link_path)
66
+ rgloader_path = '/opt/vagrant/embedded/rgloader'
67
+ if not File.exist?(rgloader_path)
68
+ puts "ERROR: could not find rgloader in ~/.vagrant.d"
69
+ exit!(1)
70
+ end
71
+ puts "Found rgloader path as: #{rgloader_path}"
72
+ File.symlink(rgloader_path, loader_link_path)
73
+ puts "Symlinked #{loader_link_path} to #{rgloader_path}"
74
+ end
75
+ ENV['VAGRANT_INSTALLER_EMBEDDED_DIR'] = '/opt/vagrant/embedded'
76
+ lic_link_path = File.join(plugin_dir, "license-vagrant-vmware-workstation.lic")
77
+ if not File.exist?(lic_link_path)
78
+ lic_path = File.join(File.expand_path("~"), ".vagrant.d", "license-vagrant-vmware-workstation.lic")
79
+ if not File.exist?(lic_path)
80
+ puts "ERROR: could not find license file at #{lic_path}"
81
+ exit!(1)
82
+ end
83
+ File.symlink(lic_path, lic_link_path)
84
+ puts "Symlinked #{lic_link_path} to #{lic_path}"
85
+ end
86
+ end
87
+
14
88
  desc "Display the list of available rake tasks"
15
89
  task :help do
16
90
  system("rake -T")
17
91
  end
92
+
93
+ desc "Cleanup VirtualBox hostonlyifs"
94
+ task :clean_vbox do
95
+ puts "Initializing Vagrant ProviderVirtualBox plugin"
96
+ require 'vagrant'
97
+ dm = VagrantPlugins::ProviderVirtualBox::Driver::Meta.new
98
+ puts "Deleting unused VirtualBox host-only networks"
99
+ dm.delete_unused_host_only_networks
100
+ end
101
+
102
+ namespace :acceptance do
103
+ providers = ['virtualbox', 'vmware_workstation']
104
+
105
+ # isolate our temp directories so we can easily remove them
106
+ tmp_dir_path = '/tmp/vagrant-r10k-spec'
107
+ Dir.mkdir(tmp_dir_path) unless Dir.exists?(tmp_dir_path)
108
+
109
+ providers.each do |prov|
110
+ desc "Run acceptance tests for #{prov}"
111
+ task prov do |task|
112
+ provider = task.name.split(':')[1]
113
+ puts "Running acceptance tests for #{provider}"
114
+ if provider == 'vmware_workstation'
115
+ puts "ERROR: vmware_workstation acceptance tests are broken. Please see https://github.com/jantman/vagrant-r10k/issues/20"
116
+ exit!(1)
117
+ vmware_workstation_prep()
118
+ end
119
+ box_path = get_box_path(provider)
120
+ system_or_die("VS_PROVIDER=#{provider} VS_BOX_PATH=#{box_path} TMPDIR=#{tmp_dir_path} bundle exec vagrant-spec test")
121
+ system("rm -Rf #{tmp_dir_path}/*")
122
+ fix_results_xml()
123
+ if provider == 'virtualbox'
124
+ Rake::Task['clean_vbox'].invoke
125
+ end
126
+ end
127
+ end
128
+ end
@@ -0,0 +1,44 @@
1
+ require 'vagrant/action'
2
+ require_relative '../helpers'
3
+
4
+ module VagrantPlugins
5
+ module R10k
6
+ module Action
7
+ # base class for vagrant-r10k hook actions
8
+ class Base
9
+
10
+ include R10K::Logging
11
+
12
+ # validate hook
13
+ def self.validate
14
+ Vagrant::Action::Builder.new.tap do |b|
15
+ b.use Action::Validate
16
+ end
17
+ end
18
+
19
+ # r10k deploy hook
20
+ def self.deploy
21
+ Vagrant::Action::Builder.new.tap do |b|
22
+ b.use Action::Validate
23
+ b.use Action::Deploy
24
+ end
25
+ end
26
+
27
+ include VagrantPlugins::R10k::Helpers
28
+
29
+ def initialize(app, env)
30
+ @app = app
31
+ @env = env
32
+ klass = self.class.name.downcase.split('::').last
33
+ @logger = Log4r::Logger.new("vagrant::r10k::#{klass}")
34
+ if ENV["VAGRANT_LOG"] == "debug"
35
+ R10K::Logging.level = 0
36
+ @logger.level = 0
37
+ else
38
+ R10K::Logging.level = 3
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
44
+ end