r10k 2.0.3 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (198) hide show
  1. checksums.yaml +8 -8
  2. data/CHANGELOG.mkd +150 -0
  3. data/README.mkd +10 -1
  4. data/doc/dynamic-environments/configuration.mkd +31 -0
  5. data/doc/dynamic-environments/quickstart.mkd +33 -79
  6. data/doc/faq.mkd +67 -0
  7. data/doc/git/providers.mkd +37 -0
  8. data/doc/puppetfile.mkd +73 -0
  9. data/integration/lib/r10k_utils.rb +47 -2
  10. data/integration/pre-suite/01_git_config.rb +9 -8
  11. data/integration/pre-suite/02_pe_r10k.rb +5 -8
  12. data/integration/scripts/setup_r10k_env_centos5.sh +1 -1
  13. data/integration/scripts/setup_r10k_env_centos6.sh +1 -1
  14. data/integration/scripts/setup_r10k_env_rhel7.sh +1 -1
  15. data/integration/scripts/setup_r10k_env_sles11.sh +1 -1
  16. data/integration/scripts/setup_r10k_env_sles12.sh +1 -1
  17. data/integration/scripts/setup_r10k_env_ubuntu1004.sh +1 -1
  18. data/integration/scripts/setup_r10k_env_ubuntu1204.sh +1 -1
  19. data/integration/scripts/setup_r10k_env_ubuntu1404.sh +1 -1
  20. data/integration/test_run_scripts/all_tests-rugged-pe-centos6.sh +1 -1
  21. data/integration/test_run_scripts/all_tests-rugged-pe-rhel7.sh +1 -1
  22. data/integration/test_run_scripts/all_tests-rugged-pe-sles11.sh +1 -1
  23. data/integration/test_run_scripts/all_tests-rugged-pe-ubuntu1204.sh +1 -1
  24. data/integration/test_run_scripts/all_tests-rugged-pe-ubuntu1404.sh +1 -1
  25. data/integration/test_run_scripts/all_tests-shellgit-pe-centos6.sh +1 -1
  26. data/integration/test_run_scripts/all_tests-shellgit-pe-rhel7.sh +1 -1
  27. data/integration/test_run_scripts/all_tests-shellgit-pe-sles11.sh +1 -1
  28. data/integration/test_run_scripts/all_tests-shellgit-pe-ubuntu1204.sh +1 -1
  29. data/integration/test_run_scripts/all_tests-shellgit-pe-ubuntu1404.sh +1 -1
  30. data/integration/test_run_scripts/basic_functionality/all_tests-pe-centos6.sh +1 -1
  31. data/integration/test_run_scripts/command_line/all_tests-pe-centos6.sh +1 -1
  32. data/integration/test_run_scripts/git_source/all_tests-pe-centos6.sh +1 -1
  33. data/integration/test_run_scripts/user_scenario/basic_workflow/all_tests-pe-centos6.sh +1 -1
  34. data/integration/test_run_scripts/user_scenario/complex_workflow/all_tests-pe-centos6.sh +1 -1
  35. data/integration/tests/basic_functionality/install_pe_only_module_with_puppetfile.rb +83 -0
  36. data/integration/tests/basic_functionality/negative/attempt_to_install_peonly_module_without_license.rb +71 -0
  37. data/integration/tests/basic_functionality/negative/neg_deploy_with_invalid_r10k_yaml.rb +7 -2
  38. data/integration/tests/basic_functionality/negative/neg_deploy_with_missing_r10k_yaml.rb +3 -2
  39. data/integration/tests/basic_functionality/negative/neg_invalid_git_provider.rb +3 -2
  40. data/integration/tests/basic_functionality/negative/negative_bad_proxy.rb +56 -0
  41. data/integration/tests/basic_functionality/proxy_specified_in_configuration.rb +103 -0
  42. data/integration/tests/basic_functionality/proxy_with_puppetfile.rb +61 -0
  43. data/integration/tests/basic_functionality/rugged_git_provider_with_ssh.rb +2 -1
  44. data/integration/tests/basic_functionality/rugged_git_provider_without_ssh.rb +2 -1
  45. data/integration/tests/command_line/deploy_env_without_mod_update.rb +3 -2
  46. data/integration/tests/command_line/negative/neg_deploy_env_with_module_update.rb +3 -2
  47. data/integration/tests/command_line/negative/neg_invalid_cli_dep_flag.rb +2 -1
  48. data/integration/tests/command_line/negative/neg_invalid_cli_env_flag.rb +2 -1
  49. data/integration/tests/command_line/negative/neg_invalid_cmd_line_arg.rb +3 -4
  50. data/integration/tests/git_source/git_source_git.rb +7 -2
  51. data/integration/tests/git_source/git_source_ssh.rb +3 -2
  52. data/integration/tests/git_source/git_source_submodule.rb +2 -1
  53. data/integration/tests/git_source/negative/neg_git_broken_remote.rb +2 -1
  54. data/integration/tests/git_source/negative/neg_git_unauthorized_https.rb +2 -1
  55. data/integration/tests/git_source/negative/neg_git_unauthorized_ssh.rb +2 -1
  56. data/integration/tests/git_source/negative/neg_git_unicode_branch.rb +2 -1
  57. data/integration/tests/user_scenario/basic_workflow/multi_env_1000_branches.rb +3 -3
  58. data/integration/tests/user_scenario/basic_workflow/multi_env_custom_forge_git_module.rb +2 -1
  59. data/integration/tests/user_scenario/basic_workflow/multi_env_custom_forge_git_module_static.rb +9 -5
  60. data/integration/tests/user_scenario/basic_workflow/multi_env_hiera.rb +9 -2
  61. data/integration/tests/user_scenario/basic_workflow/multi_env_multi_source.rb +2 -1
  62. data/integration/tests/user_scenario/basic_workflow/multi_source_custom_forge_git_module.rb +2 -1
  63. data/integration/tests/user_scenario/basic_workflow/negative/neg_bad_basedir.rb +2 -1
  64. data/integration/tests/user_scenario/basic_workflow/negative/neg_bad_forge_module.rb +7 -2
  65. data/integration/tests/user_scenario/basic_workflow/negative/neg_bad_git_module.rb +3 -4
  66. data/integration/tests/user_scenario/basic_workflow/negative/neg_bad_git_module_ref.rb +2 -1
  67. data/integration/tests/user_scenario/basic_workflow/negative/neg_bad_git_remote.rb +2 -1
  68. data/integration/tests/user_scenario/basic_workflow/negative/neg_branch_name_collision.rb +2 -1
  69. data/integration/tests/user_scenario/basic_workflow/negative/neg_disk_full.rb +2 -1
  70. data/integration/tests/user_scenario/basic_workflow/negative/neg_duplicate_module_names.rb +10 -4
  71. data/integration/tests/user_scenario/basic_workflow/negative/neg_inaccessible_forge.rb +9 -2
  72. data/integration/tests/user_scenario/basic_workflow/negative/neg_invalid_env_name.rb +2 -1
  73. data/integration/tests/user_scenario/basic_workflow/negative/neg_invalid_puppet_file.rb +2 -1
  74. data/integration/tests/user_scenario/basic_workflow/negative/neg_module_specified_at_deleted_release.rb +7 -2
  75. data/integration/tests/user_scenario/basic_workflow/negative/neg_read_only.rb +2 -1
  76. data/integration/tests/user_scenario/basic_workflow/negative/neg_specify_deleted_forge_module.rb +9 -2
  77. data/integration/tests/user_scenario/basic_workflow/single_env_10000_files.rb +2 -1
  78. data/integration/tests/user_scenario/basic_workflow/single_env_custom_forge_git_module.rb +2 -1
  79. data/integration/tests/user_scenario/basic_workflow/single_env_custom_forge_module.rb +2 -1
  80. data/integration/tests/user_scenario/basic_workflow/single_env_custom_module.rb +2 -1
  81. data/integration/tests/user_scenario/basic_workflow/single_env_large_files.rb +2 -1
  82. data/integration/tests/user_scenario/basic_workflow/single_env_module_already_installed.rb +2 -1
  83. data/integration/tests/user_scenario/basic_workflow/single_env_module_last_release_deleted.rb +2 -1
  84. data/integration/tests/user_scenario/basic_workflow/single_env_non-existent_base_dir.rb +2 -1
  85. data/integration/tests/user_scenario/basic_workflow/single_env_purge_unmanaged_modules.rb +3 -2
  86. data/integration/tests/user_scenario/basic_workflow/single_env_switch_forge_git_module.rb +3 -2
  87. data/integration/tests/user_scenario/basic_workflow/single_env_unicode_paths.rb +2 -1
  88. data/integration/tests/user_scenario/basic_workflow/single_env_upgrade_forge_mod_revert_change.rb +4 -3
  89. data/integration/tests/user_scenario/complex_workflow/multi_env_add_change_remove.rb +3 -2
  90. data/integration/tests/user_scenario/complex_workflow/multi_env_remove_re-add.rb +4 -3
  91. data/integration/tests/user_scenario/complex_workflow/multi_env_unamanaged.rb +3 -2
  92. data/integration/tests/user_scenario/complex_workflow/single_env_git_module_update.rb +3 -2
  93. data/lib/r10k/action/base.rb +31 -0
  94. data/lib/r10k/action/deploy/deploy_helpers.rb +34 -0
  95. data/lib/r10k/action/deploy/display.rb +57 -75
  96. data/lib/r10k/action/deploy/environment.rb +52 -15
  97. data/lib/r10k/action/deploy/module.rb +13 -18
  98. data/lib/r10k/action/puppetfile/check.rb +8 -18
  99. data/lib/r10k/action/puppetfile/install.rb +13 -27
  100. data/lib/r10k/action/puppetfile/purge.rb +8 -17
  101. data/lib/r10k/action/runner.rb +39 -3
  102. data/lib/r10k/cli.rb +1 -3
  103. data/lib/r10k/cli/deploy.rb +3 -1
  104. data/lib/r10k/cli/puppetfile.rb +2 -2
  105. data/lib/r10k/deployment.rb +8 -6
  106. data/lib/r10k/deployment/config.rb +18 -65
  107. data/lib/r10k/environment/base.rb +19 -0
  108. data/lib/r10k/environment/git.rb +9 -0
  109. data/lib/r10k/environment/svn.rb +9 -0
  110. data/lib/r10k/forge/module_release.rb +21 -14
  111. data/lib/r10k/git.rb +6 -0
  112. data/lib/r10k/git/alternates.rb +20 -6
  113. data/lib/r10k/git/cache.rb +1 -1
  114. data/lib/r10k/git/rugged/bare_repository.rb +5 -0
  115. data/lib/r10k/git/rugged/base_repository.rb +6 -20
  116. data/lib/r10k/git/rugged/credentials.rb +66 -0
  117. data/lib/r10k/git/rugged/thin_repository.rb +16 -11
  118. data/lib/r10k/git/rugged/working_repository.rb +15 -7
  119. data/lib/r10k/git/shellgit/bare_repository.rb +9 -4
  120. data/lib/r10k/git/shellgit/thin_repository.rb +8 -10
  121. data/lib/r10k/git/stateful_repository.rb +1 -1
  122. data/lib/r10k/initializers.rb +55 -0
  123. data/lib/r10k/module.rb +1 -0
  124. data/lib/r10k/module/base.rb +3 -2
  125. data/lib/r10k/module/forge.rb +14 -6
  126. data/lib/r10k/module/local.rb +36 -0
  127. data/lib/r10k/module/metadata_file.rb +2 -2
  128. data/lib/r10k/puppetfile.rb +1 -1
  129. data/lib/r10k/settings.rb +86 -0
  130. data/lib/r10k/settings/collection.rb +118 -0
  131. data/lib/r10k/settings/definition.rb +112 -0
  132. data/lib/r10k/settings/enum_definition.rb +22 -0
  133. data/lib/r10k/settings/loader.rb +96 -0
  134. data/lib/r10k/settings/uri_definition.rb +19 -0
  135. data/lib/r10k/util/subprocess/runner/windows.rb +4 -4
  136. data/lib/r10k/version.rb +1 -1
  137. data/r10k.gemspec +2 -3
  138. data/spec/fixtures/unit/puppetfile/argument-error/Puppetfile +1 -0
  139. data/spec/fixtures/unit/util/subprocess/{posix/runner → runner}/no-execute.sh +0 -0
  140. data/spec/integration/git/rugged/thin_repository_spec.rb +2 -2
  141. data/spec/integration/git/rugged/working_repository_spec.rb +9 -0
  142. data/spec/integration/git/shellgit/thin_repository_spec.rb +2 -2
  143. data/spec/integration/git/stateful_repository_spec.rb +1 -1
  144. data/spec/r10k-mocks/mock_config.rb +10 -13
  145. data/spec/r10k-mocks/mock_env.rb +8 -0
  146. data/spec/shared-examples/deploy-actions.rb +69 -0
  147. data/spec/shared-examples/puppetfile-action.rb +17 -0
  148. data/spec/unit/action/cri_runner_spec.rb +3 -1
  149. data/spec/unit/action/deploy/deploy_helpers_spec.rb +38 -0
  150. data/spec/unit/action/deploy/display_spec.rb +31 -0
  151. data/spec/unit/action/deploy/environment_spec.rb +56 -0
  152. data/spec/unit/action/deploy/module_spec.rb +17 -0
  153. data/spec/unit/action/puppetfile/check_spec.rb +26 -0
  154. data/spec/unit/action/puppetfile/install_spec.rb +68 -0
  155. data/spec/unit/action/puppetfile/purge_spec.rb +19 -0
  156. data/spec/unit/action/runner_spec.rb +10 -9
  157. data/spec/unit/deployment/config_spec.rb +20 -44
  158. data/spec/unit/deployment_spec.rb +1 -1
  159. data/spec/unit/environment/git_spec.rb +20 -0
  160. data/spec/unit/environment/svn_spec.rb +20 -0
  161. data/spec/unit/forge/module_release_spec.rb +6 -3
  162. data/spec/unit/git/alternates_spec.rb +38 -12
  163. data/spec/unit/git/cache_spec.rb +4 -0
  164. data/spec/unit/git/rugged/credentials_spec.rb +74 -0
  165. data/spec/unit/initializers_spec.rb +68 -0
  166. data/spec/unit/module/base_spec.rb +2 -2
  167. data/spec/unit/module/forge_spec.rb +11 -3
  168. data/spec/unit/module/metadata_file_spec.rb +0 -1
  169. data/spec/unit/puppetfile_spec.rb +11 -0
  170. data/spec/unit/settings/collection_spec.rb +122 -0
  171. data/spec/unit/settings/definition_spec.rb +78 -0
  172. data/spec/unit/settings/enum_definition_spec.rb +20 -0
  173. data/spec/unit/{deployment/config → settings}/loader_spec.rb +50 -2
  174. data/spec/unit/settings/uri_definition_spec.rb +23 -0
  175. data/spec/unit/settings_spec.rb +151 -0
  176. data/spec/unit/util/subprocess/runner/posix_spec.rb +1 -1
  177. data/spec/unit/util/subprocess/runner/windows_spec.rb +7 -0
  178. metadata +53 -90
  179. data/lib/r10k/deployment/config/loader.rb +0 -59
  180. data/lib/shared/puppet/module_tool/metadata.rb +0 -197
  181. data/lib/shared/puppet_forge/connection.rb +0 -64
  182. data/lib/shared/puppet_forge/connection/connection_failure.rb +0 -26
  183. data/lib/shared/puppet_forge/error.rb +0 -41
  184. data/lib/shared/puppet_forge/tar.rb +0 -10
  185. data/lib/shared/puppet_forge/tar/mini.rb +0 -81
  186. data/lib/shared/puppet_forge/unpacker.rb +0 -68
  187. data/lib/shared/puppet_forge/v3.rb +0 -13
  188. data/lib/shared/puppet_forge/v3/module.rb +0 -69
  189. data/lib/shared/puppet_forge/v3/module_release.rb +0 -85
  190. data/lib/shared/puppet_forge/version.rb +0 -3
  191. data/spec/unit/puppet/module_tool/metadata_spec.rb +0 -301
  192. data/spec/unit/puppet_forge/connection/connection_failure_spec.rb +0 -28
  193. data/spec/unit/puppet_forge/connection_spec.rb +0 -41
  194. data/spec/unit/puppet_forge/tar/mini_spec.rb +0 -87
  195. data/spec/unit/puppet_forge/tar_spec.rb +0 -9
  196. data/spec/unit/puppet_forge/unpacker_spec.rb +0 -59
  197. data/spec/unit/puppet_forge/v3/module_release_spec.rb +0 -83
  198. data/spec/unit/puppet_forge/v3/module_spec.rb +0 -75
@@ -50,3 +50,70 @@ on your remote repositories:
50
50
  [bitbucket-default-branch]: https://answers.atlassian.com/questions/280944/how-to-change-main-branch-in-bitbucket "Changing the default branch on Bitbucket"
51
51
  [gitolite-v2-default-branch]: http://stackoverflow.com/questions/7091599/git-default-remote-branch-with-gitolite "Changing the default branch on Gitolite v2"
52
52
  [gitolite-v3-default-branch]: http://stackoverflow.com/questions/13949093/git-change-default-branch-gitolite "Changing the default branch on Gitolite v3"
53
+
54
+ ### How do I prevent r10k from removing modules in the `/modules` directory of my Git repository?
55
+
56
+ By default, r10k will install modules specified in the Puppetfile into the
57
+ `/modules` directory of each environment, but if you already use that directory
58
+ and keep modules in it, r10k may think those modules are not meant to exist and
59
+ may remove them.
60
+
61
+ There are three ways of fixing this: including your local modules in the
62
+ Puppetfile, moving the directory where r10k install Puppetfile sourced modules,
63
+ or moving your modules.
64
+
65
+ #### Including your local modules in the Puppetfile
66
+
67
+ The Puppetfile has a concept of a "local" module, otherwise known as a module
68
+ that r10k did not directly placed there but should not be removed. If you want
69
+ to continue keep your modules in the `/modules` directory and still install
70
+ external modules from the Puppetfile into that directory, you can add a `mod`
71
+ directive to the Puppetfile for each of your local modules.
72
+
73
+ ```
74
+
75
+ mod 'my_ntp', :local => true
76
+ mod 'roles', :local => true
77
+ mod 'profiles', :local => true
78
+
79
+ # Include your external modules as usual
80
+ mod 'puppetlabs/stdlib'
81
+ mod 'puppetlabs/apache'
82
+ ```
83
+
84
+ #### Move where the Puppetfile installs external modules
85
+
86
+ Instead of having to add a module entry for each of your local modules, you can
87
+ simply move where the Puppetfile installs modules with the `moduledir` setting.
88
+
89
+ ```
90
+ # The moduledir setting must be set before any modules are created
91
+ moduledir "external-modules"
92
+
93
+ mod 'puppetlabs/stdlib'
94
+ mod 'puppetlabs/apache'
95
+ ```
96
+
97
+ In Puppet 3.6 and later you can create an `environment.conf` in the root of your
98
+ environment to indicate which directories contain modules:
99
+
100
+ ```
101
+ # environment.conf
102
+ modulepath: modules:external-modules
103
+ ```
104
+
105
+ #### Move your local modules
106
+
107
+ Lastly, you can simply move your locally versioned modules to a separate
108
+ directory to avoid conflicting over the `/modules` directory entirely. With this
109
+ example as well you can use the `environment.conf file to tell Puppet which
110
+ directories contain modules.
111
+
112
+ ```
113
+ # environment.conf
114
+ modulepath: internal-modules::modules
115
+ ```
116
+
117
+ #### What does the name mean?
118
+
119
+ It's explained in [this blog post](http://somethingsinistral.net/blog/rethinking-puppet-deployment/#addendum).
@@ -50,6 +50,43 @@ git:
50
50
  username: 'git'
51
51
  ```
52
52
 
53
+ #### Supported transports with Rugged
54
+
55
+ Rugged compiles libgit2 and and the Ruby bindings when the gem is installed. You
56
+ may need libraries installed before you install the gem to use certain protocols
57
+ to access git remote repositories.
58
+
59
+ For ssh support, you need to have libssh2 installed (along with the relevant dev
60
+ package/headers) before you install the Rugged gem.
61
+
62
+ For https support on Linux, you need to have OpenSSL installed (along with the
63
+ relevant dev package/headers) before you install the Rugged gem. OS X and
64
+ Windows support should automatically include https support.
65
+
66
+ You can check whether https or ssh support is included in your Rugged
67
+ installation by using the following in irb and making sure the required feature
68
+ is listed:
69
+
70
+ ```ruby
71
+ irb(main):001:0> require('rugged')
72
+ => true
73
+ irb(main):002:0> Rugged.features
74
+ => [:threads, :https, :ssh]
75
+ irb(main):003:0>
76
+ ```
77
+ You will require the ':https' or ':ssh' features to use the respective protocols
78
+ in your Puppetfile module references or in r10k.yaml. R10K 2.0.0 and later will
79
+ automatically issue a warning if either feature is missing.
80
+
81
+ libssh2 on Debian and Ubuntu is compiled against libgcrypto instead of OpenSSL
82
+ [due to licensing reasons](https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=668271), and
83
+ unfortunately libgcrypto does not support a number of required operations,
84
+ including reading from a private key file. You will need to either use shellgit
85
+ or recompile your own libssh2-1 package to use OpenSSL on these distributions.
86
+ If you see the following error message, this is the likely cause:
87
+
88
+ Failed to authenticate SSH session: Unable to extract public key from private key file: Method unimplemented in libgcrypt backend at /var/cache/r10k/ssh---git@git.example.com-sys-puppet.git
89
+
53
90
  Configuration
54
91
  -------------
55
92
 
@@ -184,6 +184,79 @@ credentials may be visible in the process table when r10k is running. If you
184
184
  choose to supply SVN credentials make sure that the system running r10k is
185
185
  appropriately secured.
186
186
 
187
+ ### Local
188
+
189
+ In the event you want to store locally written modules in your r10k-managed
190
+ repository in the Puppetfile managed path, you can use the `:local` type.
191
+
192
+ For instance, if you have a Git repository with the following structure:
193
+
194
+ ```
195
+ # tree -L 2
196
+ .
197
+ ├── environment.conf
198
+ ├── modules
199
+ │   └── local_module
200
+ └── Puppetfile
201
+
202
+ 4 directories, 2 files
203
+ ```
204
+
205
+ And you want to prevent `local_module` from being removed, you can add a 'local'
206
+ module in your Puppetfile:
207
+
208
+ ```
209
+ mod 'local_module', :local => true
210
+
211
+ # Include your other modules as normal
212
+ mod 'branan/eight_hundred'
213
+ mod 'puppetlabs/apache'
214
+ ```
215
+
216
+ If you run r10k against this Git branch, you'll get the following:
217
+
218
+ ```
219
+ # tree -L 2
220
+ .
221
+ ├── environment.conf
222
+ ├── modules
223
+ │   ├── apache
224
+ │   ├── eight_hundred
225
+ │   └── local_module
226
+ └── Puppetfile
227
+
228
+ 4 directories, 2 files
229
+ ```
230
+
231
+ #### Caveats
232
+
233
+ This is a workaround for r10k not being able to determine that modules
234
+ created via VCS should not be purged, but is not meant to be a long term
235
+ solution. The general practice around having local and remote modules in the
236
+ same Git repository is to move modules versioned into a separate directory, like
237
+ so:
238
+
239
+ ```
240
+ # tree -L 2
241
+ .
242
+ ├── environment.conf
243
+ ├── site-modules
244
+ │   └── local_module
245
+ ├── modules
246
+ │   ├── apache
247
+ │   └── eight_hundred
248
+ └── Puppetfile
249
+
250
+ 4 directories, 2 files
251
+ ```
252
+
253
+ Moving modules stored in the Git repository into a separate directory will
254
+ remove the need to have Puppetfile entries for every locally versioned Puppet
255
+ module.
256
+
257
+ For more information see the [FAQ entry](faq.mkd#how-do-i-prevent-r10k-from-removing-modules-in-the-modules-directory-of-my-git-repository)
258
+ on managing internal and external modules in the same directory.
259
+
187
260
  ## Environment variables
188
261
 
189
262
  It is possible to set an alternate name/location for your `Puppetfile` and
@@ -97,12 +97,13 @@ def clean_up_r10k(master, commit_sha, git_repo_path)
97
97
  environment_path = on(master, puppet('config', 'print', 'environmentpath')).stdout.rstrip
98
98
  prod_env_modules_path = File.join(environment_path, 'production', 'modules')
99
99
  prod_env_site_path = File.join(environment_path, 'production', 'site')
100
+ r10k_fqp = get_r10k_fqp(master)
100
101
 
101
102
  step 'Reset Git Repo to Known Good State'
102
103
  r10k_revert_environment(master, commit_sha, git_repo_path)
103
104
 
104
105
  step 'Restore Original "production" Environment'
105
- on(master, 'r10k deploy environment -v')
106
+ on(master, "#{r10k_fqp} deploy environment -v")
106
107
 
107
108
  step 'Verify "production" Environment is at Original State'
108
109
  verify_production_environment(master)
@@ -134,6 +135,7 @@ def init_r10k_source_from_prod(master, git_repo_parent_path, git_repo_name, git_
134
135
  #Init
135
136
  env_path = on(master, puppet('config print environmentpath')).stdout.rstrip
136
137
  prod_env_path = File.join(env_path, 'production')
138
+ r10k_fqp = get_r10k_fqp(master)
137
139
 
138
140
  local_files_root_path = ENV['FILES'] || 'files'
139
141
  prod_env_config_path = 'pre-suite/prod_env.config'
@@ -161,6 +163,49 @@ def init_r10k_source_from_prod(master, git_repo_parent_path, git_repo_name, git_
161
163
 
162
164
  #Attempt to deploy environments.
163
165
  if deploy
164
- on(master, 'r10k deploy environment -v')
166
+ on(master, "#{r10k_fqp} deploy environment -v")
165
167
  end
166
168
  end
169
+
170
+ # Get the fully qualified path for r10k.
171
+ #
172
+ # ==== Arguments
173
+ #
174
+ # * +host+ - The Beaker host to introspect
175
+ #
176
+ # ==== Returns
177
+ #
178
+ # +string+ - The fully qualified path for r10k
179
+ #
180
+ # ==== Examples
181
+ #
182
+ # get_r10k_fqp(master)
183
+ def get_r10k_fqp(host)
184
+ puppet_version = get_puppet_version(host)
185
+ if puppet_version < 4.0
186
+ fqp = '/opt/puppet/bin/r10k'
187
+ else
188
+ fqp = '/opt/puppetlabs/puppet/bin/r10k'
189
+ end
190
+ fqp
191
+ end
192
+
193
+ # Get the version of puppet that is installed on a host.
194
+ #
195
+ # ==== Arguments
196
+ #
197
+ # * +host+ - The Beaker host to introspect
198
+ #
199
+ # ==== Returns
200
+ #
201
+ # +float+ - the version of puppet as a float
202
+ #
203
+ # ==== Examples
204
+ #
205
+ # get_puppet_version(master)
206
+ def get_puppet_version(host)
207
+ on(host, puppet('--version')) do |result|
208
+ @version = result.stdout.match(/(\d){1}.(\d){1,2}.(\d){1,2}/)[0].to_f
209
+ end
210
+ @version
211
+ end
@@ -19,20 +19,21 @@ git_manifest_template_path = File.join(local_files_root_path, 'pre-suite', 'git_
19
19
  git_manifest = ERB.new(File.read(git_manifest_template_path)).result(binding)
20
20
 
21
21
  step 'Get PE Version'
22
- pe_major = on(master, 'facter -p pe_major_version').stdout.rstrip
23
- pe_minor = on(master, 'facter -p pe_minor_version').stdout.rstrip
24
- pe_version = "#{pe_major}.#{pe_minor}".to_f
25
-
26
- if pe_version < 3.7
27
- fail_test('This pre-suite requires PE 3.7 or above!')
28
- end
22
+ pe_version = get_puppet_version(master)
23
+ fail_test('This pre-suite requires PE 3.7 or above!') if pe_version < 3.7
29
24
 
30
25
  #Setup
31
26
  step 'Stub Forge on Master'
32
27
  stub_forge_on(master)
33
28
 
29
+ step 'Read module path'
30
+ on(master, puppet('config print basemodulepath')) do |result|
31
+ (result.stdout.include? ':') ? separator = ':' : separator = ';'
32
+ @module_path = result.stdout.split(separator).first
33
+ end
34
+
34
35
  step 'Install "git" Module'
35
- on(master, puppet('module install puppetlabs-git --modulepath /opt/puppet/share/puppet/modules'))
36
+ on(master, puppet("module install puppetlabs-git --modulepath #{@module_path}"))
36
37
 
37
38
  step 'Install and Configure Git'
38
39
  on(master, puppet('apply'), :stdin => git_manifest, :acceptable_exit_codes => [0,2]) do |result|
@@ -13,14 +13,11 @@ git_repo_path = '/git_repos'
13
13
  git_repo_name = 'environments'
14
14
  git_control_remote = File.join(git_repo_path, "#{git_repo_name}.git")
15
15
  git_provider = ENV['GIT_PROVIDER'] || 'shellgit'
16
+ r10k_fqp = get_r10k_fqp(master)
16
17
 
17
- pe_major = on(master, 'facter -p pe_major_version').stdout.rstrip
18
- pe_minor = on(master, 'facter -p pe_minor_version').stdout.rstrip
19
- pe_version = "#{pe_major}.#{pe_minor}".to_f
20
-
21
- if pe_version < 3.7
22
- fail_test('This pre-suite requires PE 3.7 or above!')
23
- end
18
+ step 'Get PE Version'
19
+ pe_version = get_puppet_version(master)
20
+ fail_test('This pre-suite requires PE 3.7 or above!') if pe_version < 3.7
24
21
 
25
22
  #In-line files
26
23
  r10k_conf = <<-CONF
@@ -42,7 +39,7 @@ create_remote_file(master, r10k_config_path, r10k_conf)
42
39
  on(master, "chmod 644 #{r10k_config_path}")
43
40
 
44
41
  step 'Deploy "production" Environment via r10k'
45
- on(master, 'r10k deploy environment -v')
42
+ on(master, "#{r10k_fqp} deploy environment -v")
46
43
 
47
44
  step 'Disable Environment Caching on Master'
48
45
  on(master, puppet('config set environment_timeout 0 --section main'))
@@ -7,7 +7,7 @@ if [ $SCRIPT_BASE_PATH = "scripts" ]; then
7
7
  cd ../
8
8
  fi
9
9
 
10
- export pe_dist_dir=http://neptune.puppetlabs.lan/3.8/ci-ready/
10
+ export pe_dist_dir=http://neptune.puppetlabs.lan/4.0/ci-ready/
11
11
  export GIT_PROVIDER=shellgit
12
12
 
13
13
  bundle install --path .bundle/gems
@@ -7,7 +7,7 @@ if [ $SCRIPT_BASE_PATH = "scripts" ]; then
7
7
  cd ../
8
8
  fi
9
9
 
10
- export pe_dist_dir=http://neptune.puppetlabs.lan/3.8/ci-ready/
10
+ export pe_dist_dir=http://neptune.puppetlabs.lan/4.0/ci-ready/
11
11
  export GIT_PROVIDER=shellgit
12
12
 
13
13
  bundle install --path .bundle/gems
@@ -7,7 +7,7 @@ if [ $SCRIPT_BASE_PATH = "scripts" ]; then
7
7
  cd ../
8
8
  fi
9
9
 
10
- export pe_dist_dir=http://neptune.puppetlabs.lan/3.8/ci-ready/
10
+ export pe_dist_dir=http://neptune.puppetlabs.lan/4.0/ci-ready/
11
11
  export GIT_PROVIDER=shellgit
12
12
 
13
13
  bundle install --path .bundle/gems
@@ -7,7 +7,7 @@ if [ $SCRIPT_BASE_PATH = "scripts" ]; then
7
7
  cd ../
8
8
  fi
9
9
 
10
- export pe_dist_dir=http://neptune.puppetlabs.lan/3.8/ci-ready/
10
+ export pe_dist_dir=http://neptune.puppetlabs.lan/4.0/ci-ready/
11
11
  export GIT_PROVIDER=shellgit
12
12
 
13
13
  bundle install --path .bundle/gems
@@ -7,7 +7,7 @@ if [ $SCRIPT_BASE_PATH = "scripts" ]; then
7
7
  cd ../
8
8
  fi
9
9
 
10
- export pe_dist_dir=http://neptune.puppetlabs.lan/3.8/ci-ready/
10
+ export pe_dist_dir=http://neptune.puppetlabs.lan/4.0/ci-ready/
11
11
  export GIT_PROVIDER=shellgit
12
12
 
13
13
  bundle install --path .bundle/gems
@@ -7,7 +7,7 @@ if [ $SCRIPT_BASE_PATH = "scripts" ]; then
7
7
  cd ../
8
8
  fi
9
9
 
10
- export pe_dist_dir=http://neptune.puppetlabs.lan/3.8/ci-ready/
10
+ export pe_dist_dir=http://neptune.puppetlabs.lan/4.0/ci-ready/
11
11
  export GIT_PROVIDER=shellgit
12
12
 
13
13
  bundle install --path .bundle/gems
@@ -7,7 +7,7 @@ if [ $SCRIPT_BASE_PATH = "scripts" ]; then
7
7
  cd ../
8
8
  fi
9
9
 
10
- export pe_dist_dir=http://neptune.puppetlabs.lan/3.8/ci-ready/
10
+ export pe_dist_dir=http://neptune.puppetlabs.lan/4.0/ci-ready/
11
11
  export GIT_PROVIDER=shellgit
12
12
 
13
13
  bundle install --path .bundle/gems
@@ -7,7 +7,7 @@ if [ $SCRIPT_BASE_PATH = "scripts" ]; then
7
7
  cd ../
8
8
  fi
9
9
 
10
- export pe_dist_dir=http://neptune.puppetlabs.lan/3.8/ci-ready/
10
+ export pe_dist_dir=http://neptune.puppetlabs.lan/4.0/ci-ready/
11
11
  export GIT_PROVIDER=shellgit
12
12
 
13
13
  bundle install --path .bundle/gems
@@ -7,7 +7,7 @@ if [ $SCRIPT_BASE_PATH = "test_run_scripts" ]; then
7
7
  cd ../
8
8
  fi
9
9
 
10
- export pe_dist_dir=http://neptune.puppetlabs.lan/3.8/ci-ready/
10
+ export pe_dist_dir=http://neptune.puppetlabs.lan/2015.2/ci-ready/
11
11
  export GIT_PROVIDER=rugged
12
12
 
13
13
  beaker \
@@ -7,7 +7,7 @@ if [ $SCRIPT_BASE_PATH = "test_run_scripts" ]; then
7
7
  cd ../
8
8
  fi
9
9
 
10
- export pe_dist_dir=http://neptune.puppetlabs.lan/3.8/ci-ready/
10
+ export pe_dist_dir=http://neptune.puppetlabs.lan/2015.2/ci-ready/
11
11
  export GIT_PROVIDER=rugged
12
12
 
13
13
  beaker \
@@ -7,7 +7,7 @@ if [ $SCRIPT_BASE_PATH = "test_run_scripts" ]; then
7
7
  cd ../
8
8
  fi
9
9
 
10
- export pe_dist_dir=http://neptune.puppetlabs.lan/3.8/ci-ready/
10
+ export pe_dist_dir=http://neptune.puppetlabs.lan/2015.2/ci-ready/
11
11
  export GIT_PROVIDER=rugged
12
12
 
13
13
  beaker \
@@ -7,7 +7,7 @@ if [ $SCRIPT_BASE_PATH = "test_run_scripts" ]; then
7
7
  cd ../
8
8
  fi
9
9
 
10
- export pe_dist_dir=http://neptune.puppetlabs.lan/3.8/ci-ready/
10
+ export pe_dist_dir=http://neptune.puppetlabs.lan/2015.2/ci-ready/
11
11
  export GIT_PROVIDER=rugged
12
12
 
13
13
  beaker \
@@ -7,7 +7,7 @@ if [ $SCRIPT_BASE_PATH = "test_run_scripts" ]; then
7
7
  cd ../
8
8
  fi
9
9
 
10
- export pe_dist_dir=http://neptune.puppetlabs.lan/3.8/ci-ready/
10
+ export pe_dist_dir=http://neptune.puppetlabs.lan/2015.2/ci-ready/
11
11
  export GIT_PROVIDER=rugged
12
12
 
13
13
  beaker \