akerl-r10k 3.14.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (405) hide show
  1. checksums.yaml +7 -0
  2. data/.gitattributes +1 -0
  3. data/.github/pull_request_template.md +4 -0
  4. data/.github/workflows/docker.yml +64 -0
  5. data/.github/workflows/release.yml +37 -0
  6. data/.github/workflows/rspec_tests.yml +81 -0
  7. data/.github/workflows/stale.yml +21 -0
  8. data/.gitignore +10 -0
  9. data/.travis.yml +42 -0
  10. data/CHANGELOG.mkd +1879 -0
  11. data/CODEOWNERS +2 -0
  12. data/CONTRIBUTING.mkd +105 -0
  13. data/Gemfile +15 -0
  14. data/LICENSE +14 -0
  15. data/README.mkd +139 -0
  16. data/Rakefile +3 -0
  17. data/bin/r10k +17 -0
  18. data/doc/common-patterns.mkd +45 -0
  19. data/doc/dynamic-environments/configuration.mkd +850 -0
  20. data/doc/dynamic-environments/git-environments.mkd +75 -0
  21. data/doc/dynamic-environments/introduction.mkd +69 -0
  22. data/doc/dynamic-environments/master-configuration.mkd +40 -0
  23. data/doc/dynamic-environments/quickstart.mkd +201 -0
  24. data/doc/dynamic-environments/svn-environments.mkd +45 -0
  25. data/doc/dynamic-environments/usage.mkd +163 -0
  26. data/doc/dynamic-environments/workflow-guide.mkd +247 -0
  27. data/doc/dynamic-environments.mkd +31 -0
  28. data/doc/faq.mkd +164 -0
  29. data/doc/git/cloning-and-mirroring.mkd +60 -0
  30. data/doc/git/providers.mkd +133 -0
  31. data/doc/puppetfile.mkd +355 -0
  32. data/doc/updating-your-puppetfile.mkd +38 -0
  33. data/docker/.gitignore +1 -0
  34. data/docker/.rspec +4 -0
  35. data/docker/Gemfile +11 -0
  36. data/docker/Makefile +99 -0
  37. data/docker/README.md +28 -0
  38. data/docker/docker-compose.yml +18 -0
  39. data/docker/r10k/Dockerfile +68 -0
  40. data/docker/r10k/adduser.sh +13 -0
  41. data/docker/r10k/docker-entrypoint.d/10-analytics.sh +30 -0
  42. data/docker/r10k/docker-entrypoint.sh +10 -0
  43. data/docker/r10k/release.Dockerfile +55 -0
  44. data/docker/spec/dockerfile_spec.rb +37 -0
  45. data/docker/spec/fixtures/Puppetfile +2 -0
  46. data/integration/Gemfile +19 -0
  47. data/integration/README.mkd +29 -0
  48. data/integration/Rakefile +79 -0
  49. data/integration/component/pre-suite/05_install_dev_r10k.rb +12 -0
  50. data/integration/files/README.mkd +4 -0
  51. data/integration/files/hiera.yaml +8 -0
  52. data/integration/files/modules/helloworld/manifests/init.pp +3 -0
  53. data/integration/files/modules/hieratest/manifests/init.pp +3 -0
  54. data/integration/files/modules/unicode/files/pretend_unicode +1 -0
  55. data/integration/files/modules/unicode/manifests/init.pp +6 -0
  56. data/integration/files/pre-suite/git_config.pp.erb +19 -0
  57. data/integration/files/pre-suite/prod_env.config +3 -0
  58. data/integration/files/r10k_conf.yaml.erb +9 -0
  59. data/integration/lib/README.mkd +4 -0
  60. data/integration/lib/git_utils.rb +205 -0
  61. data/integration/lib/master_manipulator.rb +205 -0
  62. data/integration/lib/r10k_utils.rb +222 -0
  63. data/integration/manifests/README.mkd +4 -0
  64. data/integration/pre-suite/00_pe_install.rb +6 -0
  65. data/integration/pre-suite/10_git_config.rb +48 -0
  66. data/integration/pre-suite/20_pe_r10k.rb +55 -0
  67. data/integration/pre-suite/README.mkd +5 -0
  68. data/integration/tests/Puppetfile/HTTP_PROXY_affects_forge_source.rb +72 -0
  69. data/integration/tests/Puppetfile/HTTP_PROXY_affects_git_source.rb +70 -0
  70. data/integration/tests/README.mkd +4 -0
  71. data/integration/tests/basic_functionality/basic_deployment.rb +176 -0
  72. data/integration/tests/basic_functionality/install_pe_only_module_with_puppetfile.rb +83 -0
  73. data/integration/tests/basic_functionality/negative/neg_deploy_with_invalid_r10k_yaml.rb +51 -0
  74. data/integration/tests/basic_functionality/negative/neg_deploy_with_missing_r10k_yaml.rb +28 -0
  75. data/integration/tests/basic_functionality/negative/neg_invalid_git_provider.rb +45 -0
  76. data/integration/tests/basic_functionality/negative/negative_bad_proxy.rb +34 -0
  77. data/integration/tests/basic_functionality/proxy_specified_in_configuration.rb +103 -0
  78. data/integration/tests/basic_functionality/proxy_with_pe_only_module.rb +128 -0
  79. data/integration/tests/basic_functionality/proxy_with_puppetfile.rb +61 -0
  80. data/integration/tests/basic_functionality/rugged_git_provider_with_ssh.rb +109 -0
  81. data/integration/tests/basic_functionality/rugged_git_provider_without_ssh.rb +108 -0
  82. data/integration/tests/command_line/deploy_env_without_mod_update.rb +76 -0
  83. data/integration/tests/command_line/negative/neg_deploy_env_with_module_update.rb +77 -0
  84. data/integration/tests/command_line/negative/neg_invalid_cmd_line_arg.rb +23 -0
  85. data/integration/tests/git_source/HTTP_proxy_and_git_source.rb +70 -0
  86. data/integration/tests/git_source/git_source_git.rb +128 -0
  87. data/integration/tests/git_source/git_source_repeated_remote.rb +68 -0
  88. data/integration/tests/git_source/git_source_ssh.rb +87 -0
  89. data/integration/tests/git_source/git_source_submodule.rb +70 -0
  90. data/integration/tests/git_source/negative/neg_git_broken_remote.rb +38 -0
  91. data/integration/tests/git_source/negative/neg_git_unauthorized_https.rb +46 -0
  92. data/integration/tests/git_source/negative/neg_git_unauthorized_ssh.rb +73 -0
  93. data/integration/tests/git_source/negative/neg_git_unicode_branch.rb +35 -0
  94. data/integration/tests/i18n/deploy_module_with_unicode_in_file_name.rb +64 -0
  95. data/integration/tests/purging/content_not_purged_at_root.rb +89 -0
  96. data/integration/tests/purging/default_purging.rb +125 -0
  97. data/integration/tests/purging/does_not_purge_files_on_white_list.rb +93 -0
  98. data/integration/tests/purging/invalid_whitelist_types.rb +63 -0
  99. data/integration/tests/user_scenario/basic_workflow/multi_env_1000_branches.rb +66 -0
  100. data/integration/tests/user_scenario/basic_workflow/multi_env_custom_forge_git_module.rb +112 -0
  101. data/integration/tests/user_scenario/basic_workflow/multi_env_custom_forge_git_module_static.rb +118 -0
  102. data/integration/tests/user_scenario/basic_workflow/multi_env_hiera.rb +100 -0
  103. data/integration/tests/user_scenario/basic_workflow/multi_env_multi_source.rb +133 -0
  104. data/integration/tests/user_scenario/basic_workflow/multi_source_custom_forge_git_module.rb +161 -0
  105. data/integration/tests/user_scenario/basic_workflow/negative/neg_bad_basedir.rb +46 -0
  106. data/integration/tests/user_scenario/basic_workflow/negative/neg_bad_forge_module.rb +48 -0
  107. data/integration/tests/user_scenario/basic_workflow/negative/neg_bad_git_module.rb +45 -0
  108. data/integration/tests/user_scenario/basic_workflow/negative/neg_bad_git_module_ref.rb +43 -0
  109. data/integration/tests/user_scenario/basic_workflow/negative/neg_bad_git_remote.rb +45 -0
  110. data/integration/tests/user_scenario/basic_workflow/negative/neg_branch_name_collision.rb +64 -0
  111. data/integration/tests/user_scenario/basic_workflow/negative/neg_disk_full.rb +75 -0
  112. data/integration/tests/user_scenario/basic_workflow/negative/neg_duplicate_module_names.rb +44 -0
  113. data/integration/tests/user_scenario/basic_workflow/negative/neg_inaccessible_forge.rb +58 -0
  114. data/integration/tests/user_scenario/basic_workflow/negative/neg_invalid_env_name.rb +34 -0
  115. data/integration/tests/user_scenario/basic_workflow/negative/neg_invalid_puppet_file.rb +36 -0
  116. data/integration/tests/user_scenario/basic_workflow/negative/neg_module_specified_at_deleted_release.rb +49 -0
  117. data/integration/tests/user_scenario/basic_workflow/negative/neg_read_only.rb +58 -0
  118. data/integration/tests/user_scenario/basic_workflow/negative/neg_specify_deleted_forge_module.rb +45 -0
  119. data/integration/tests/user_scenario/basic_workflow/single_env_10000_files.rb +75 -0
  120. data/integration/tests/user_scenario/basic_workflow/single_env_custom_forge_git_module.rb +105 -0
  121. data/integration/tests/user_scenario/basic_workflow/single_env_custom_forge_module.rb +81 -0
  122. data/integration/tests/user_scenario/basic_workflow/single_env_custom_module.rb +49 -0
  123. data/integration/tests/user_scenario/basic_workflow/single_env_large_files.rb +75 -0
  124. data/integration/tests/user_scenario/basic_workflow/single_env_module_already_installed.rb +82 -0
  125. data/integration/tests/user_scenario/basic_workflow/single_env_module_last_release_deleted.rb +68 -0
  126. data/integration/tests/user_scenario/basic_workflow/single_env_non-existent_base_dir.rb +94 -0
  127. data/integration/tests/user_scenario/basic_workflow/single_env_purge_unmanaged_modules.rb +89 -0
  128. data/integration/tests/user_scenario/basic_workflow/single_env_switch_forge_git_module.rb +117 -0
  129. data/integration/tests/user_scenario/basic_workflow/single_env_unicode_paths.rb +60 -0
  130. data/integration/tests/user_scenario/basic_workflow/single_env_upgrade_forge_mod_revert_change.rb +166 -0
  131. data/integration/tests/user_scenario/complex_workflow/multi_env_add_change_remove.rb +163 -0
  132. data/integration/tests/user_scenario/complex_workflow/multi_env_remove_re-add.rb +111 -0
  133. data/integration/tests/user_scenario/complex_workflow/multi_env_unamanaged.rb +78 -0
  134. data/integration/tests/user_scenario/complex_workflow/single_env_git_module_update.rb +100 -0
  135. data/lib/r10k/action/base.rb +41 -0
  136. data/lib/r10k/action/cri_runner.rb +72 -0
  137. data/lib/r10k/action/deploy/deploy_helpers.rb +38 -0
  138. data/lib/r10k/action/deploy/display.rb +128 -0
  139. data/lib/r10k/action/deploy/environment.rb +260 -0
  140. data/lib/r10k/action/deploy/module.rb +139 -0
  141. data/lib/r10k/action/deploy.rb +9 -0
  142. data/lib/r10k/action/puppetfile/check.rb +35 -0
  143. data/lib/r10k/action/puppetfile/cri_runner.rb +26 -0
  144. data/lib/r10k/action/puppetfile/install.rb +48 -0
  145. data/lib/r10k/action/puppetfile/purge.rb +37 -0
  146. data/lib/r10k/action/puppetfile.rb +10 -0
  147. data/lib/r10k/action/runner.rb +171 -0
  148. data/lib/r10k/action/visitor.rb +34 -0
  149. data/lib/r10k/cli/deploy.rb +126 -0
  150. data/lib/r10k/cli/ext/logging.rb +15 -0
  151. data/lib/r10k/cli/help.rb +7 -0
  152. data/lib/r10k/cli/puppetfile.rb +73 -0
  153. data/lib/r10k/cli/version.rb +31 -0
  154. data/lib/r10k/cli.rb +51 -0
  155. data/lib/r10k/content_synchronizer.rb +95 -0
  156. data/lib/r10k/deployment/config.rb +56 -0
  157. data/lib/r10k/deployment.rb +132 -0
  158. data/lib/r10k/environment/bare.rb +13 -0
  159. data/lib/r10k/environment/base.rb +230 -0
  160. data/lib/r10k/environment/git.rb +93 -0
  161. data/lib/r10k/environment/name.rb +109 -0
  162. data/lib/r10k/environment/plain.rb +16 -0
  163. data/lib/r10k/environment/svn.rb +98 -0
  164. data/lib/r10k/environment/tarball.rb +78 -0
  165. data/lib/r10k/environment/with_modules.rb +174 -0
  166. data/lib/r10k/environment.rb +39 -0
  167. data/lib/r10k/errors/formatting.rb +28 -0
  168. data/lib/r10k/errors.rb +66 -0
  169. data/lib/r10k/feature/collection.rb +23 -0
  170. data/lib/r10k/feature.rb +56 -0
  171. data/lib/r10k/features.rb +20 -0
  172. data/lib/r10k/forge/module_release.rb +229 -0
  173. data/lib/r10k/git/alternates.rb +63 -0
  174. data/lib/r10k/git/cache.rb +107 -0
  175. data/lib/r10k/git/errors.rb +34 -0
  176. data/lib/r10k/git/rugged/bare_repository.rb +85 -0
  177. data/lib/r10k/git/rugged/base_repository.rb +104 -0
  178. data/lib/r10k/git/rugged/cache.rb +19 -0
  179. data/lib/r10k/git/rugged/credentials.rb +205 -0
  180. data/lib/r10k/git/rugged/thin_repository.rb +96 -0
  181. data/lib/r10k/git/rugged/working_repository.rb +149 -0
  182. data/lib/r10k/git/rugged.rb +17 -0
  183. data/lib/r10k/git/shellgit/bare_repository.rb +43 -0
  184. data/lib/r10k/git/shellgit/base_repository.rb +137 -0
  185. data/lib/r10k/git/shellgit/cache.rb +11 -0
  186. data/lib/r10k/git/shellgit/thin_repository.rb +73 -0
  187. data/lib/r10k/git/shellgit/working_repository.rb +112 -0
  188. data/lib/r10k/git/shellgit.rb +9 -0
  189. data/lib/r10k/git/stateful_repository.rb +109 -0
  190. data/lib/r10k/git.rb +200 -0
  191. data/lib/r10k/initializers.rb +93 -0
  192. data/lib/r10k/instance_cache.rb +32 -0
  193. data/lib/r10k/keyed_factory.rb +39 -0
  194. data/lib/r10k/logging/terminaloutputter.rb +36 -0
  195. data/lib/r10k/logging.rb +186 -0
  196. data/lib/r10k/module/base.rb +182 -0
  197. data/lib/r10k/module/definition.rb +64 -0
  198. data/lib/r10k/module/forge.rb +208 -0
  199. data/lib/r10k/module/git.rb +156 -0
  200. data/lib/r10k/module/local.rb +40 -0
  201. data/lib/r10k/module/metadata_file.rb +31 -0
  202. data/lib/r10k/module/svn.rb +129 -0
  203. data/lib/r10k/module/tarball.rb +101 -0
  204. data/lib/r10k/module.rb +57 -0
  205. data/lib/r10k/module_loader/puppetfile/dsl.rb +42 -0
  206. data/lib/r10k/module_loader/puppetfile.rb +290 -0
  207. data/lib/r10k/puppetfile.rb +211 -0
  208. data/lib/r10k/settings/collection.rb +123 -0
  209. data/lib/r10k/settings/container.rb +97 -0
  210. data/lib/r10k/settings/definition.rb +124 -0
  211. data/lib/r10k/settings/enum_definition.rb +30 -0
  212. data/lib/r10k/settings/helpers.rb +38 -0
  213. data/lib/r10k/settings/list.rb +107 -0
  214. data/lib/r10k/settings/loader.rb +99 -0
  215. data/lib/r10k/settings/mixin.rb +54 -0
  216. data/lib/r10k/settings/uri_definition.rb +19 -0
  217. data/lib/r10k/settings.rb +312 -0
  218. data/lib/r10k/source/base.rb +93 -0
  219. data/lib/r10k/source/exec.rb +51 -0
  220. data/lib/r10k/source/git.rb +178 -0
  221. data/lib/r10k/source/hash.rb +182 -0
  222. data/lib/r10k/source/svn.rb +142 -0
  223. data/lib/r10k/source/yaml.rb +20 -0
  224. data/lib/r10k/source/yamldir.rb +32 -0
  225. data/lib/r10k/source.rb +42 -0
  226. data/lib/r10k/svn/remote.rb +68 -0
  227. data/lib/r10k/svn/working_dir.rb +125 -0
  228. data/lib/r10k/svn.rb +6 -0
  229. data/lib/r10k/tarball.rb +183 -0
  230. data/lib/r10k/util/attempt.rb +84 -0
  231. data/lib/r10k/util/basedir.rb +65 -0
  232. data/lib/r10k/util/cacheable.rb +31 -0
  233. data/lib/r10k/util/cleaner.rb +21 -0
  234. data/lib/r10k/util/commands.rb +31 -0
  235. data/lib/r10k/util/downloader.rb +134 -0
  236. data/lib/r10k/util/exec_env.rb +36 -0
  237. data/lib/r10k/util/license.rb +24 -0
  238. data/lib/r10k/util/platform.rb +42 -0
  239. data/lib/r10k/util/purgeable.rb +154 -0
  240. data/lib/r10k/util/setopts.rb +78 -0
  241. data/lib/r10k/util/subprocess/result.rb +56 -0
  242. data/lib/r10k/util/subprocess/runner/jruby.rb +23 -0
  243. data/lib/r10k/util/subprocess/runner/posix.rb +103 -0
  244. data/lib/r10k/util/subprocess/runner/pump.rb +59 -0
  245. data/lib/r10k/util/subprocess/runner/windows.rb +23 -0
  246. data/lib/r10k/util/subprocess/runner.rb +26 -0
  247. data/lib/r10k/util/subprocess/subprocess_error.rb +24 -0
  248. data/lib/r10k/util/subprocess.rb +85 -0
  249. data/lib/r10k/util/symbolize_keys.rb +35 -0
  250. data/lib/r10k/version.rb +6 -0
  251. data/lib/r10k.rb +11 -0
  252. data/locales/config.yaml +21 -0
  253. data/locales/r10k.pot +693 -0
  254. data/r10k.gemspec +52 -0
  255. data/r10k.yaml.example +140 -0
  256. data/spec/fixtures/empty/.empty +0 -0
  257. data/spec/fixtures/integration/git/puppet-boolean-bare.tar +0 -0
  258. data/spec/fixtures/module/forge/bad_module/metadata.json +1 -0
  259. data/spec/fixtures/module/forge/eight_hundred/Modulefile +8 -0
  260. data/spec/fixtures/module/forge/eight_hundred/metadata.json +19 -0
  261. data/spec/fixtures/tarball/tarball.tar.gz +0 -0
  262. data/spec/fixtures/unit/action/r10k.yaml +5 -0
  263. data/spec/fixtures/unit/action/r10k_cachedir.yaml +2 -0
  264. data/spec/fixtures/unit/action/r10k_creds.yaml +9 -0
  265. data/spec/fixtures/unit/action/r10k_forge_auth.yaml +4 -0
  266. data/spec/fixtures/unit/action/r10k_forge_auth_no_url.yaml +3 -0
  267. data/spec/fixtures/unit/action/r10k_generate_types.yaml +3 -0
  268. data/spec/fixtures/unit/action/r10k_logging.yaml +12 -0
  269. data/spec/fixtures/unit/action/r10k_puppet_path.yaml +3 -0
  270. data/spec/fixtures/unit/puppetfile/argument-error/Puppetfile +1 -0
  271. data/spec/fixtures/unit/puppetfile/default-branch-override/Puppetfile +5 -0
  272. data/spec/fixtures/unit/puppetfile/duplicate-module-error/Puppetfile +10 -0
  273. data/spec/fixtures/unit/puppetfile/forge-override/Puppetfile +8 -0
  274. data/spec/fixtures/unit/puppetfile/invalid-syntax/Puppetfile +1 -0
  275. data/spec/fixtures/unit/puppetfile/load-error/Puppetfile +1 -0
  276. data/spec/fixtures/unit/puppetfile/name-error/Puppetfile +1 -0
  277. data/spec/fixtures/unit/puppetfile/valid-forge-with-version/Puppetfile +1 -0
  278. data/spec/fixtures/unit/puppetfile/valid-forge-without-version/Puppetfile +1 -0
  279. data/spec/fixtures/unit/puppetfile/various-modules/Puppetfile +10 -0
  280. data/spec/fixtures/unit/puppetfile/various-modules/Puppetfile.new +10 -0
  281. data/spec/fixtures/unit/puppetfile/various-modules/modules/apt/.gitkeep +1 -0
  282. data/spec/fixtures/unit/puppetfile/various-modules/modules/baz/.gitkeep +1 -0
  283. data/spec/fixtures/unit/puppetfile/various-modules/modules/buzz/.gitkeep +1 -0
  284. data/spec/fixtures/unit/puppetfile/various-modules/modules/canary/.gitkeep +1 -0
  285. data/spec/fixtures/unit/puppetfile/various-modules/modules/fizz/.gitkeep +1 -0
  286. data/spec/fixtures/unit/puppetfile/various-modules/modules/rpm/.gitkeep +1 -0
  287. data/spec/fixtures/unit/util/purgeable/managed_one/expected_1 +0 -0
  288. data/spec/fixtures/unit/util/purgeable/managed_one/managed_subdir_1/managed_symlink_file +1 -0
  289. data/spec/fixtures/unit/util/purgeable/managed_one/managed_subdir_1/subdir_allowlisted_2/ignored_1 +0 -0
  290. data/spec/fixtures/unit/util/purgeable/managed_one/managed_subdir_1/subdir_expected_1 +0 -0
  291. data/spec/fixtures/unit/util/purgeable/managed_one/managed_subdir_1/subdir_unmanaged_1 +0 -0
  292. data/spec/fixtures/unit/util/purgeable/managed_one/managed_subdir_1/unmanaged_symlink_dir +1 -0
  293. data/spec/fixtures/unit/util/purgeable/managed_one/managed_symlink_dir +1 -0
  294. data/spec/fixtures/unit/util/purgeable/managed_one/unmanaged_1 +0 -0
  295. data/spec/fixtures/unit/util/purgeable/managed_one/unmanaged_symlink_file +1 -0
  296. data/spec/fixtures/unit/util/purgeable/managed_two/.hidden/unmanaged_3 +0 -0
  297. data/spec/fixtures/unit/util/purgeable/managed_two/expected_2 +0 -0
  298. data/spec/fixtures/unit/util/purgeable/managed_two/unmanaged_2 +0 -0
  299. data/spec/fixtures/unit/util/subprocess/runner/no-execute.sh +3 -0
  300. data/spec/integration/git/rugged/bare_repository_spec.rb +13 -0
  301. data/spec/integration/git/rugged/cache_spec.rb +33 -0
  302. data/spec/integration/git/rugged/thin_repository_spec.rb +14 -0
  303. data/spec/integration/git/rugged/working_repository_spec.rb +48 -0
  304. data/spec/integration/git/shellgit/bare_repository_spec.rb +13 -0
  305. data/spec/integration/git/shellgit/thin_repository_spec.rb +14 -0
  306. data/spec/integration/git/shellgit/working_repository_spec.rb +13 -0
  307. data/spec/integration/git/stateful_repository_spec.rb +175 -0
  308. data/spec/integration/util/purageable_spec.rb +41 -0
  309. data/spec/matchers/exit_with.rb +28 -0
  310. data/spec/matchers/match_realpath.rb +18 -0
  311. data/spec/r10k-mocks/mock_config.rb +33 -0
  312. data/spec/r10k-mocks/mock_env.rb +18 -0
  313. data/spec/r10k-mocks/mock_source.rb +17 -0
  314. data/spec/r10k-mocks.rb +3 -0
  315. data/spec/shared-contexts/git-fixtures.rb +55 -0
  316. data/spec/shared-contexts/tarball.rb +32 -0
  317. data/spec/shared-examples/deploy-actions.rb +69 -0
  318. data/spec/shared-examples/git/bare_repository.rb +132 -0
  319. data/spec/shared-examples/git/thin_repository.rb +26 -0
  320. data/spec/shared-examples/git/working_repository.rb +207 -0
  321. data/spec/shared-examples/git-repository.rb +38 -0
  322. data/spec/shared-examples/puppetfile-action.rb +39 -0
  323. data/spec/shared-examples/settings/ancestry.rb +44 -0
  324. data/spec/shared-examples/subprocess-runner.rb +89 -0
  325. data/spec/spec_helper.rb +41 -0
  326. data/spec/unit/action/cri_runner_spec.rb +72 -0
  327. data/spec/unit/action/deploy/deploy_helpers_spec.rb +38 -0
  328. data/spec/unit/action/deploy/display_spec.rb +61 -0
  329. data/spec/unit/action/deploy/environment_spec.rb +640 -0
  330. data/spec/unit/action/deploy/module_spec.rb +476 -0
  331. data/spec/unit/action/puppetfile/check_spec.rb +53 -0
  332. data/spec/unit/action/puppetfile/cri_runner_spec.rb +47 -0
  333. data/spec/unit/action/puppetfile/install_spec.rb +112 -0
  334. data/spec/unit/action/puppetfile/purge_spec.rb +60 -0
  335. data/spec/unit/action/runner_spec.rb +407 -0
  336. data/spec/unit/action/visitor_spec.rb +39 -0
  337. data/spec/unit/cli_spec.rb +9 -0
  338. data/spec/unit/deployment/config_spec.rb +33 -0
  339. data/spec/unit/deployment_spec.rb +162 -0
  340. data/spec/unit/environment/bare_spec.rb +13 -0
  341. data/spec/unit/environment/base_spec.rb +122 -0
  342. data/spec/unit/environment/git_spec.rb +114 -0
  343. data/spec/unit/environment/name_spec.rb +181 -0
  344. data/spec/unit/environment/plain_spec.rb +8 -0
  345. data/spec/unit/environment/svn_spec.rb +146 -0
  346. data/spec/unit/environment/tarball_spec.rb +45 -0
  347. data/spec/unit/environment/with_modules_spec.rb +122 -0
  348. data/spec/unit/errors/formatting_spec.rb +84 -0
  349. data/spec/unit/feature_spec.rb +50 -0
  350. data/spec/unit/forge/module_release_spec.rb +213 -0
  351. data/spec/unit/git/alternates_spec.rb +116 -0
  352. data/spec/unit/git/cache_spec.rb +66 -0
  353. data/spec/unit/git/rugged/cache_spec.rb +48 -0
  354. data/spec/unit/git/rugged/credentials_spec.rb +215 -0
  355. data/spec/unit/git/shellgit/cache_spec.rb +27 -0
  356. data/spec/unit/git/stateful_repository_spec.rb +45 -0
  357. data/spec/unit/git_spec.rb +102 -0
  358. data/spec/unit/initializers_spec.rb +68 -0
  359. data/spec/unit/instance_cache_spec.rb +78 -0
  360. data/spec/unit/keyed_factory_spec.rb +51 -0
  361. data/spec/unit/logging/terminaloutputter_spec.rb +53 -0
  362. data/spec/unit/logging_spec.rb +68 -0
  363. data/spec/unit/module/base_spec.rb +118 -0
  364. data/spec/unit/module/forge_spec.rb +271 -0
  365. data/spec/unit/module/git_spec.rb +387 -0
  366. data/spec/unit/module/metadata_file_spec.rb +68 -0
  367. data/spec/unit/module/svn_spec.rb +208 -0
  368. data/spec/unit/module/tarball_spec.rb +70 -0
  369. data/spec/unit/module_loader/puppetfile_spec.rb +421 -0
  370. data/spec/unit/module_spec.rb +114 -0
  371. data/spec/unit/puppetfile_spec.rb +304 -0
  372. data/spec/unit/settings/collection_spec.rb +123 -0
  373. data/spec/unit/settings/container_spec.rb +92 -0
  374. data/spec/unit/settings/definition_spec.rb +79 -0
  375. data/spec/unit/settings/enum_definition_spec.rb +20 -0
  376. data/spec/unit/settings/inheritance_spec.rb +38 -0
  377. data/spec/unit/settings/list_spec.rb +88 -0
  378. data/spec/unit/settings/loader_spec.rb +110 -0
  379. data/spec/unit/settings/uri_definition_spec.rb +23 -0
  380. data/spec/unit/settings_spec.rb +303 -0
  381. data/spec/unit/source/base_spec.rb +31 -0
  382. data/spec/unit/source/exec_spec.rb +81 -0
  383. data/spec/unit/source/git_spec.rb +233 -0
  384. data/spec/unit/source/hash_spec.rb +54 -0
  385. data/spec/unit/source/svn_spec.rb +196 -0
  386. data/spec/unit/source/yaml_spec.rb +42 -0
  387. data/spec/unit/source_spec.rb +10 -0
  388. data/spec/unit/svn/remote_spec.rb +21 -0
  389. data/spec/unit/svn/working_dir_spec.rb +56 -0
  390. data/spec/unit/tarball_spec.rb +57 -0
  391. data/spec/unit/util/attempt_spec.rb +82 -0
  392. data/spec/unit/util/cacheable_spec.rb +23 -0
  393. data/spec/unit/util/commands_spec.rb +61 -0
  394. data/spec/unit/util/downloader_spec.rb +98 -0
  395. data/spec/unit/util/exec_env_spec.rb +56 -0
  396. data/spec/unit/util/purgeable_spec.rb +267 -0
  397. data/spec/unit/util/setopts_spec.rb +83 -0
  398. data/spec/unit/util/subprocess/result_spec.rb +36 -0
  399. data/spec/unit/util/subprocess/runner/posix_spec.rb +7 -0
  400. data/spec/unit/util/subprocess/runner/pump_spec.rb +79 -0
  401. data/spec/unit/util/subprocess/runner/windows_spec.rb +7 -0
  402. data/spec/unit/util/subprocess/subprocess_error_spec.rb +26 -0
  403. data/spec/unit/util/subprocess_spec.rb +65 -0
  404. data/spec/unit/util/symbolize_keys_spec.rb +67 -0
  405. metadata +637 -0
@@ -0,0 +1,850 @@
1
+ Dynamic Environment Configuration
2
+ =================================
3
+
4
+ R10k uses a configuration file to determine how dynamic environments should be
5
+ deployed.
6
+
7
+ Config file location
8
+ --------------------
9
+
10
+ ### Manual configuration
11
+
12
+ An explicit configuration file location be specified by providing the `--config`
13
+ option to `r10k deploy`, like so:
14
+
15
+ r10k deploy --config /srv/puppet/r10k.yaml [...]
16
+
17
+ ### Automatic configuration
18
+
19
+ If an explicit configuration file is not given, r10k will search the following
20
+ locations for a configuration file.
21
+
22
+ * `{current working directory}/r10k.yaml`
23
+ * `/etc/puppetlabs/r10k/r10k.yaml` (1.5.0 and later)
24
+ * `/etc/r10k.yaml` (deprecated in 1.5.0)
25
+
26
+ In 1.5.0 r10k added `/etc/puppetlabs/r10k/r10k.yaml` to the configuration search
27
+ path. The old location, `/etc/r10k.yaml` has been deprecated in favor of the new
28
+ location. If both `/etc/puppetlabs/r10k/r10k.yaml` and `/etc/r10k.yaml` exist
29
+ and explicit configuration file has not been given, r10k will log a warning and
30
+ use `/etc/puppetlabs/r10k/r10.yaml`.
31
+
32
+ General options
33
+ ---------------
34
+
35
+ ### cachedir
36
+
37
+ The 'cachedir' setting specifies where r10k should keep cached information.
38
+ Right now this is predominantly used for caching git repositories but will be
39
+ expanded as other subsystems can take advantage of caching.
40
+
41
+ For example:
42
+
43
+ ```yaml
44
+ ---
45
+ # Store all cache information in /var/cache
46
+ cachedir: '/var/cache/r10k'
47
+ ```
48
+
49
+
50
+ The cachedir setting defaults to `~/.r10k`. If the HOME environment variable is
51
+ unset r10k will assume that r10k is being run with the Puppet [`prerun_command`](https://puppet.com/docs/puppet/latest/configuration.html#preruncommand)
52
+ setting and will set the cachedir default to `/root/.r10k`.
53
+
54
+ ### proxy
55
+
56
+ The 'proxy' setting configures a proxy server to use for all operations which occur over
57
+ an HTTP(S) transport. You can override this setting for Git or Forge operations only by
58
+ setting the 'proxy' setting under the 'git' or 'forge' settings. You can also override
59
+ for a specific Git repository by setting a proxy in the 'repositories' list of the 'git'
60
+ setting. By default, r10k will look for and use the first environment variable it finds
61
+ in this list: HTTPS\_PROXY, https\_proxy, HTTP\_PROXY, http\_proxy. If no proxy setting
62
+ is found in the environment, this setting will default to use no proxy.
63
+
64
+ ```yaml
65
+ proxy: 'http://proxy.example.com:3128'
66
+ ```
67
+
68
+ r10k also supports using authenticated proxies with either Basic or Digest authentication:
69
+
70
+ ```yaml
71
+ proxy: 'http://user:password@proxy.example.com:3128'
72
+ ```
73
+
74
+ The proxy server being used will be logged at the "debug" level when r10k runs.
75
+
76
+ ### pool_size
77
+
78
+ The pool_size setting is a number to determine how many threads should be spawn
79
+ while updating modules. The default value is 4, which means modules will be updated
80
+ in parallel. If this causes issues, change this setting to 1 to cause modules to be
81
+ updated serially.
82
+
83
+ ### git
84
+
85
+ The 'git' setting is a hash that contains Git specific settings.
86
+
87
+ #### provider
88
+
89
+ The provider option determines which Git provider should be used.
90
+
91
+ ```yaml
92
+ git:
93
+ provider: rugged # one of shellgit, rugged
94
+ ```
95
+
96
+ See the [git provider documentation](../git/providers.mkd) for more information
97
+ regarding Git providers.
98
+
99
+ #### proxy
100
+
101
+ The 'proxy' setting allows you to set or override the global proxy setting specifically
102
+ for Git operations that use an HTTP(S) transport. See the global proxy setting documentation
103
+ for more information and examples.
104
+
105
+ #### username
106
+
107
+ The username setting is only used by the Rugged git provider.
108
+
109
+ The username option sets the username for SSH remotes when the SSH URL does not provide
110
+ a username. When used with a Git hosting service this is most sensibly set to 'git'.
111
+
112
+ The username defaults to the username of the currently logged in user.
113
+
114
+ ```yaml
115
+ git:
116
+ username: "git"
117
+ ```
118
+
119
+ #### private_key
120
+
121
+ The private_key setting is only used by the Rugged git provider.
122
+
123
+ The private_key option specifies the path to the default Git SSH private key for Git SSH remotes.
124
+ The private_key setting must be set if SSH remotes are used.
125
+
126
+ ```yaml
127
+ git:
128
+ private_key: "/etc/puppetlabs/r10k/ssh/id_rsa"
129
+ ```
130
+
131
+ #### oauth_token
132
+
133
+ The oauth_token setting is only used by the Rugged git provider.
134
+
135
+ The oauth_token option specifies the path to the default access token for Git HTTPS remotes.
136
+ Public git repositories can be accessed via HTTPS without authentication, but the oauth_token setting may be set if any non-public HTTPS remotes are used.
137
+
138
+ ```yaml
139
+ git:
140
+ oauth_token: "/etc/puppetlabs/r10k/token"
141
+ ```
142
+
143
+ #### repositories
144
+
145
+ The repositories option allows configuration to be set on a per-remote basis. Each entry is a map of
146
+ the repository URL and per-repository configuration for that repo.
147
+
148
+ ##### private_key
149
+
150
+ A repository specific private key to use for SSH connections for the given repository URL. This
151
+ overrides the global private_key setting.
152
+
153
+ ```yaml
154
+ git:
155
+ repositories:
156
+ - remote: "ssh://tessier-ashpool.freeside/protected-repo.git"
157
+ private_key: "/etc/puppetlabs/r10k/ssh/id_rsa-protected-repo-deploy-key"
158
+ ```
159
+
160
+ ##### oauth_token
161
+
162
+ A repository specific access token to use for HTTPS connections for the given repository URL. This
163
+ overrides the global oauth_token setting.
164
+
165
+ ```yaml
166
+ git:
167
+ repositories:
168
+ - remote: "https://tessier-ashpool.freeside/protected-repo.git"
169
+ oauth_token: "/etc/puppetlabs/r10k/protected-repo-deploy-token"
170
+ ```
171
+
172
+ ##### proxy
173
+
174
+ The 'proxy' setting allows you to set or override the global proxy setting for a single, specific
175
+ repository. See the global proxy setting documentation for more information and examples.
176
+
177
+ ### forge
178
+
179
+ The 'forge' setting is a hash that contains settings for downloading modules
180
+ from the Puppet Forge.
181
+
182
+ #### proxy
183
+
184
+ The 'proxy' setting allows you to set or override the global proxy setting for all Forge
185
+ interactions. See the global proxy setting documentation for more information and examples.
186
+
187
+ #### baseurl
188
+
189
+ The 'baseurl' setting indicates where Forge modules should be installed from.
190
+ This defaults to 'https://forgeapi.puppetlabs.com'
191
+
192
+ #### authorization_token
193
+
194
+ The 'authorization_token' setting allows you to provide a token for authenticating to a Forge server.
195
+ You will need to prepend your token with 'Bearer ' to authenticate to the Forge or when using your own Artifactory server.
196
+
197
+ ```yaml
198
+ forge:
199
+ baseurl: 'https://private-forge.mysite'
200
+ authorization_token: 'Bearer mysupersecretauthtoken'
201
+ ```
202
+
203
+ #### allow_puppetfile_override
204
+
205
+ The `allow_puppetfile_override` setting causes r10k to respect [`forge` declarations](https://github.com/puppetlabs/r10k/blob/main/doc/puppetfile.mkd#forge)
206
+ in Puppetfiles, overriding the `baseurl` setting and allowing per-environment configuration of the Forge URL.
207
+
208
+ Deployment options
209
+ ------------------
210
+
211
+ The following options configure how r10k deploys dynamic environments.
212
+
213
+ ### postrun
214
+
215
+ The `postrun` setting specifies an arbitrary command to run after deploying all
216
+ environments. The command must be an array of strings that will be used as an
217
+ argument vector. The exit code of the command is not currently used, but the
218
+ command should exit with a return code of 0 as the exit code may have semantics
219
+ in the future.
220
+
221
+ ```yaml
222
+ ---
223
+ postrun: ['/usr/bin/curl', '-F', 'deploy=done', 'http://my-app.site/endpoint']
224
+ ```
225
+
226
+ The postrun setting can only be set once.
227
+
228
+ Occurrences of the string `$modifiedenvs` in the postrun command will be
229
+ replaced with the current environment(s) being deployed.
230
+
231
+ ### sources
232
+
233
+ The `sources` setting specifies what repositories should be used for creating
234
+ dynamic environments. It is a hash where each key is the short name of a
235
+ specific repository (for instance, "qa" or "web" or "ops") and the value is a
236
+ hash of properties for that source.
237
+
238
+ ```yaml
239
+ ---
240
+ sources:
241
+ main:
242
+ # Source settings follow
243
+ ```
244
+
245
+ ### deploy
246
+
247
+ The `deploy` setting is a top level setting for controlling how r10k deploys
248
+ behave. At this point only new settings are included under this setting, but in
249
+ the long term the current top level deploy settings will be moved under
250
+ `deploy`.
251
+
252
+ #### purge\_levels
253
+
254
+ The `purge_levels` setting controls how aggressively r10k will purge unmanaged
255
+ content during a deployment. Given value must be a list of strings indicating at
256
+ what levels unmanaged content should be purged. The valid string options for the
257
+ list are 'deployment', 'environment', and 'puppetfile'.
258
+
259
+ ```yaml
260
+ ---
261
+ deploy:
262
+ purge_levels: [ 'deployment', 'environment', 'puppetfile' ]
263
+ ```
264
+
265
+ This setting currently only impacts the "deploy environment" action.
266
+
267
+ The default value is `['deployment', 'puppetfile']` to maintain parity with
268
+ existing behavior before this setting was added.
269
+
270
+ The effect of enabling the various purge levels is as follows:
271
+
272
+ ##### deployment
273
+
274
+ After each deploy, in the configured basedir, r10k will recursively remove any
275
+ content found which is not managed by one of the sources declared in the r10k.yaml
276
+ configuration. Note that disabling this level of purging may cause the number of
277
+ deployed environments to grow without bound; deleting branches from a control
278
+ repo would no longer cause the matching environment to be purged.
279
+
280
+ ##### environment
281
+
282
+ After a given environment is deployed, r10k will recursively remove any content
283
+ found which is neither committed to the control repo branch that maps to that
284
+ environment, nor declared in a Puppetfile committed to that branch.
285
+
286
+ Enabling this purge level will cause r10k to load and parse the Puppetfile for
287
+ the environment even without the `--modules` flag being set. However,
288
+ Puppetfile content will still only be deployed if the environment is new or
289
+ the `--modules` flag is set. Additionally, no environment-level content
290
+ will be purged if any errors are encountered while evaluating the Puppetfile
291
+ or deploying its contents.
292
+
293
+ Note that the .r10k-deploy.json file is exempt from this purging.
294
+
295
+ ##### puppetfile
296
+
297
+ After Puppetfile content for a given environment is deployed, r10k will
298
+ recursively remove any content found in a directory managed by the Puppetfile
299
+ which is not also declared in that Puppetfile. Directories considered to be
300
+ managed by a Puppetfile include the configured `moduledir` (which defaults to
301
+ "modules") as well as alternate directories specified as an `install_path`
302
+ option to any Puppetfile content declarations.
303
+
304
+ #### purge\_allowlist
305
+
306
+ The `purge_allowlist` setting exempts the specified filename patterns from
307
+ being purged. This setting is currently only considered during `environment`
308
+ level purging. (See above.) Given value must be a list of shell style filename
309
+ patterns in string format.
310
+
311
+ See the Ruby [documentation for the `fnmatch` method](http://ruby-doc.org/core-2.2.0/File.html#method-c-fnmatch)
312
+ for more details on valid patterns. Note that the `FNM_PATHNAME` and
313
+ `FNM_DOTMATCH` flags are in effect when r10k considers the allowlist.
314
+
315
+ Patterns are relative to the root of the environment being purged and *do
316
+ not match recursively* by default. For example, a allowlist value of
317
+ `*myfile*` would only preserve a matching file at the root of the
318
+ environment. To preserve the file throughout the deployed environment,
319
+ a recursive pattern such as `**/*myfile*` would be required.
320
+
321
+ Files matching a allowlist pattern may still be removed if they exist in
322
+ a folder that is otherwise subject to purging. In this case, an additional
323
+ allowlist rule to preserve the containing folder is required.
324
+
325
+ ```yaml
326
+ ---
327
+ deploy:
328
+ purge_allowlist: [ 'custom.json', '**/*.xpp' ]
329
+ ```
330
+
331
+
332
+ #### write\_lock
333
+
334
+ The `write_lock` setting allows administrators to temporarily disallow r10k code
335
+ deploys without having to remove the r10k configuration entirely. This can be
336
+ useful to prevent r10k deploys at certain times or prevent r10k from interfering
337
+ with a common set of code that may be touched by multiple r10k configurations.
338
+
339
+ ```yaml
340
+ ---
341
+ deploy:
342
+ write_lock: "Deploying code is disallowed until the next maintenance window (2038-01-19)"
343
+ ```
344
+
345
+ #### generate\_types
346
+
347
+ The `generate_types` setting controls whether r10k should update generated types
348
+ after a successful environment update. See [Environment isolation](https://puppet.com/docs/puppet/latest/environment\_isolation.html)
349
+ for more information on generated types. Defaults to false.
350
+
351
+ ```yaml
352
+ deploy:
353
+ generate_types: true
354
+ ```
355
+
356
+ #### puppet\_path
357
+
358
+ The path to the puppet executable used for generating types. Defaults to `/opt/puppetlabs/bin/puppet`.
359
+
360
+ ```yaml
361
+ deploy:
362
+ puppet_path: '/usr/local/bin/puppet'
363
+ ```
364
+
365
+ #### puppet\_conf
366
+
367
+ The path to the puppet.conf file used for generating types. Defaults to `/etc/puppetlabs/puppet/puppet.conf`.
368
+
369
+ ```yaml
370
+ deploy:
371
+ puppet_conf: '/opt/puppet/conf/puppet.conf'
372
+ ```
373
+
374
+ #### exclude_spec
375
+
376
+ During module deployment, r10k's default behavior is to deploy the spec directory. Setting
377
+ `exclude_spec` to true will deploy modules without their spec directory. This behavior
378
+ can be configured for all modules using the `exclude_spec` setting in the r10k config.
379
+ It can also be passed as a CLI argument for `deploy environment/module`, overriding the
380
+ r10k config. Setting this per module in a `Puppetfile` will override the default, r10k config,
381
+ and cli flag for that module. The following example sets all modules to not deploy the spec
382
+ dir via the r10k config.
383
+
384
+ ```yaml
385
+ deploy:
386
+ exclude_spec: true
387
+ ```
388
+
389
+ Source options
390
+ --------------
391
+
392
+ The following options are respected by all source implementations. Sources may
393
+ implement other options in addition to the ones listed below; see the source
394
+ specific documentation for more information.
395
+
396
+ ### remote
397
+
398
+ The 'remote' setting specifies where the source repository should be fetched
399
+ from. It may be any valid URL that the source may check out or clone. The remote
400
+ must be able to be fetched without any interactive input, eg usernames or
401
+ passwords cannot be prompted for in order to fetch the remote. We support the
402
+ `git`, `ssh`, and `https` transport protocols. An SSH private key or access
403
+ token must be provided for authentication. Only `https` may be used without
404
+ authentication. See [GitHub's blog on protocol security](https://github.blog/2021-09-01-improving-git-protocol-security-github/) for more info.
405
+
406
+ ```yaml
407
+ ---
408
+ sources:
409
+ mysource:
410
+ remote: 'https://git-server.site/my-org/main-modules'
411
+ ```
412
+
413
+ ### basedir
414
+
415
+ The 'basedir' setting specifies where environments will be created for this
416
+ source. This directory will be entirely managed by r10k and any contents that
417
+ r10k did not put there will be _removed_.
418
+
419
+ ```yaml
420
+ ---
421
+ sources:
422
+ mysource:
423
+ basedir: '/etc/puppet/environments'
424
+ ```
425
+
426
+ If two different sources have the same basedir, it's possible for them to create
427
+ two separate environments with the same name and file path. If this occurs r10k
428
+ will treat this as a fatal error and will abort. To avoid this, use prefixing on one
429
+ or both of the sources to make sure that all environment names are unique. See
430
+ also the [prefix](#prefix) setting.
431
+
432
+ ### prefix
433
+
434
+ The prefix setting allows environment names to be prefixed with the short name
435
+ of the given source. This prevents collisions when multiple sources are deployed
436
+ into the same directory.
437
+
438
+ ```yaml
439
+ ---
440
+ sources:
441
+ mysource:
442
+ basedir: '/etc/puppet/environments'
443
+ prefix: true # All environments will be prefixed with "mysource_"
444
+ ```
445
+ #### prefix behaviour
446
+ * if `true` environment folder will be prefixed with the name of the source.
447
+ * if `false` (default) environment folder will not be prefixed
448
+ * if `String` environment folder will be prefixed with the `prefix` value.
449
+
450
+ ### strip\_component
451
+
452
+ The 'strip\_component' setting allows parts of environment names from a source to have a transformation applied, removing a part of the name before turning them into Puppet environments. This is primarily useful for VCS sources (e.g. Git), because it allows branch names to use prefixes or organizing name components such as "env/production", "env/development", but deploy Puppet environments from these branches named without the leading "env/" component. E.g. "production", "development".
453
+
454
+ ```yaml
455
+ ---
456
+ sources:
457
+ mysource:
458
+ basedir: '/etc/puppet/environments'
459
+ strip_component: 'env/'
460
+ ```
461
+
462
+ #### strip\_component behaviour
463
+
464
+ * if `string` environment names will have this prefix removed, if the prefix is present. Note that when string values are used, names can only have prefix components removed.
465
+ * if `/regex/` the regex will be matched against environment names and if a match is found, the matching name component will be removed.
466
+
467
+ ### ignore_branch_prefixes
468
+
469
+ The 'ignore_branch_prefixes' setting causes environments to be ignored which match in part or whole
470
+ to any of the prefixes listed in the setting.
471
+ The setting is a list of strings. Each branch in
472
+ the 'git' repo will have its name tested against all prefixes and, if the prefix
473
+ is found, then an environment will not be deployed for this branch.
474
+ If no 'ignore_branch_prefixes' is specified, then all branches in the 'git' repo will
475
+ be deployed (default behavior).
476
+
477
+ #### ignore_branch_prefixes behaviour
478
+ * if empty, deploy environments for all branches
479
+ * for each branch in git repo
480
+ ** if `branch.name` has a prefix found in `ignore_branch_prefixes`, then do not deploy an environment for branch
481
+
482
+ Example: do not deploy branches with names starting with (or completely named) 'test' or 'dev'.
483
+ ```yaml
484
+ ---
485
+ sources:
486
+ mysource:
487
+ basedir: '/etc/puppet/environments'
488
+ ignore_branch_prefixes:
489
+ - 'test'
490
+ - 'dev'
491
+ ```
492
+
493
+ ### filter_command
494
+
495
+ You can filter out any branch based on the result of the command specified as
496
+ 'filter_command'. Currently it only works with git repository. Non zero return
497
+ status of the command results in a branch beeing removed. The command is passed
498
+ additional environment variables
499
+
500
+ * GIT_DIR – path to the cached git repository
501
+ * R10K_BRANCH – branch which is being filtered
502
+ * R10K_NAME – source name from r10k configuration
503
+
504
+ This can be used for example for filtering out the branches with invalid gpg signature of their latest commit
505
+
506
+ ```yaml
507
+ ---
508
+ sources:
509
+ mysource:
510
+ basedir: '/etc/puppet/environments'
511
+ filter_command: 'git verify-commit $R10K_BRANCH 2> /dev/null'
512
+ ```
513
+
514
+ Beware that if the production branch of manifests is filtered out, you will end up with empty environment.
515
+
516
+ Examples
517
+ --------
518
+
519
+ ### Minimal example
520
+
521
+ The majority of users will only have a single repository where all modules and
522
+ hiera data files are kept. In this case you will specify a single source:
523
+
524
+ ```yaml
525
+ ---
526
+ sources:
527
+ operations:
528
+ remote: 'https://git-server.site/my-org/org-modules'
529
+ basedir: '/etc/puppet/environments'
530
+ ```
531
+
532
+ ### Separate hiera data
533
+
534
+ For more complex cases where you want to store hiera data in a different
535
+ repository and your modules in another repository, you can specify two sources:
536
+
537
+ ```yaml
538
+ ---
539
+ sources:
540
+ operations:
541
+ remote: 'https://git-server.site/my-org/org-modules'
542
+ basedir: '/etc/puppet/environments'
543
+ hiera:
544
+ remote: 'https://git-server.site/my-org/org-hiera-data'
545
+ basedir: '/etc/puppet/hiera-data'
546
+ ```
547
+
548
+ ### Multiple tenancy
549
+
550
+ Alternately you may want to create separate environments from multiple
551
+ repositories. This is useful when you want two groups to be able to deploy
552
+ Puppet modules but they should only have write access to their own modules and
553
+ not the modules of other groups.
554
+
555
+ ```yaml
556
+ ---
557
+ sources:
558
+ main:
559
+ remote: 'https://git-server.site/my-org/main-modules'
560
+ basedir: '/etc/puppet/environments'
561
+ prefix: false # Prefix defaults to false so this is only here for clarity
562
+ qa:
563
+ remote: 'https://git-server.site/my-org/qa-puppet-modules'
564
+ basedir: '/etc/puppet/environments'
565
+ prefix: true
566
+ dev:
567
+ remote: 'https://git-server.site/my-org/dev-puppet-modules'
568
+ basedir: '/etc/puppet/environments'
569
+ prefix: true
570
+ ```
571
+
572
+ This will create the following directory structure:
573
+
574
+ ```
575
+ /etc/puppet/environments
576
+ |-- production # main-modules repository, production branch
577
+ |-- upgrade_apache # main-modules repository, upgrade_apache branch
578
+ |-- qa_production # qa repository, production branch
579
+ |-- qa_jenkins_test # qa repository, jenkins_test branch
580
+ |-- dev_production # dev repository, production branch
581
+ `-- dev_loadtest # dev repository, loadtest branch
582
+ ```
583
+
584
+ #### Multiple tenancy with external hieradata
585
+
586
+ If hiera data is in a separate repository from your control repository, you
587
+ must override the `prefix` so environment folders line up in both directories:
588
+
589
+ ```yaml
590
+ ---
591
+ sources:
592
+ app1_data:
593
+ remote: 'https://git-server.site/my-org/app1-hieradata'
594
+ basedir: '/etc/puppet/hieradata'
595
+ prefix: "app1"
596
+ app1_modules:
597
+ remote: 'https://git-server.site/my-org/app1-puppet-modules'
598
+ basedir: '/etc/puppet/environments'
599
+ prefix: "app1"
600
+ ```
601
+
602
+
603
+ This will create the following directory structure:
604
+
605
+ ```
606
+ /etc/puppet/environments
607
+ |-- app1_production # app1 modules repository, production branch
608
+ |-- app1_develop # app1 modules repository, develop branch
609
+
610
+ /etc/puppet/hieradata
611
+ |-- app1_production # app1 data repository, production branch
612
+ |-- app1_develop # app1 data repository, develop branch
613
+ ```
614
+
615
+ Experimental Features
616
+ ---------------------
617
+
618
+ ### YAML Environment Source
619
+
620
+ Dynamically deploying Puppet content based on the state of version control repositories can be powerful and efficient for development workflows. The linkage however is not advantageous when trying to build precision controls over deployment of previously-developed and tested content.
621
+
622
+ The YAML environment source type allows for a clear separation of tooling between development workflow, and deployment workflow. Development workflow creates new commits in the version control system. Deployment workflow consumes them.
623
+
624
+ To use the YAML environment source, configure r10k's sources with at least one entry using the yaml type.
625
+
626
+ ```yaml
627
+ # r10k.yaml
628
+ ---
629
+ sources:
630
+ puppet:
631
+ type: yaml
632
+ basedir: /etc/puppetlabs/code/environments
633
+ config: /etc/puppetlabs/r10k/environments.yaml # default
634
+ ```
635
+
636
+ When using the YAML source type, every environment is enumerated in a single yaml file. Each environment specifies a type, source, and version (typically a Git ref) to deploy. In the following example, two environments are defined, which are identical to each other.
637
+
638
+ ```yaml
639
+ ---
640
+ production:
641
+ type: git
642
+ source: git@github.com:puppetlabs/control-repo.git
643
+ version: 8820892
644
+
645
+ development:
646
+ type: git
647
+ source: git@github.com:puppetlabs/control-repo.git
648
+ version: 8820892
649
+ ```
650
+
651
+ ### YAMLdir Environment Source
652
+
653
+ Like the YAML environment source, but implemented as a conf.d pattern.
654
+
655
+ ```yaml
656
+ # r10k.yaml
657
+ ---
658
+ sources:
659
+ puppet:
660
+ type: yamldir
661
+ basedir: /etc/puppetlabs/code/environments
662
+ config: /etc/puppetlabs/r10k/environments.d # default
663
+ ```
664
+
665
+ Each environment is defined in a yaml file placed in the configuration directory. The filename, without the .yaml extension, will be the name of the environment.
666
+
667
+ ```
668
+ /etc/puppetlabs/r10k/environments.d
669
+ ├── production.yaml
670
+ └── development.yaml
671
+ ```
672
+
673
+ The contents of the file should be a hash specifying the enviornment type, and all other applicable environment options.
674
+
675
+ ```yaml
676
+ # production.yaml
677
+ ---
678
+ type: git
679
+ source: git@github.com:puppetlabs/control-repo.git
680
+ version: 8820892
681
+ ```
682
+
683
+ ### Exec environment Source
684
+
685
+ The exec environment source runs an external command which is expected to return on stdout content compatible with the YAML environment source data format. The command may return the data in JSON or YAML form. The exec environment source is similar in purpose to Puppet's exec node terminus, used to implement external node classifiers (ENCs). R10k's exec source type allows the the implementation of external environment sources.
686
+
687
+ ```yaml
688
+ # r10k.yaml
689
+ ---
690
+ sources:
691
+ puppet:
692
+ type: exec
693
+ basedir: /etc/puppetlabs/code/environments
694
+ command: /usr/local/bin/r10k-environments.sh
695
+ ```
696
+
697
+ ### Environment Modules
698
+
699
+ The environment modules feature allows module content to be attached to an environment at environment definition time. This happens before modules specified in a Puppetfile are attached to an environment, which does not happen until deploy time. Environment module implementation depends on the environment source type.
700
+
701
+ For the YAML environment source type, attach modules to an environment by specifying a modules key for the environment, and providing a hash of modules to attach. Each module accepts the same arguments accepted by the `mod` method in a Puppetfile. For ease of reading and consistency, however, it is perferred to use the generic type, source, and version options over implementation-specific formats and options such as "ref" and "git".
702
+
703
+ The example below includes two Forge modules and one module sourced from a Git repository. The two environments are almost identical. However, a new version of the stdlib module has been deployed in development (6.2.0), that has not yet been deployed to production.
704
+
705
+ ```yaml
706
+ ---
707
+ production:
708
+ type: git
709
+ source: git@github.com:puppetlabs/control-repo.git
710
+ version: 8820892
711
+ modules:
712
+ puppetlabs-stdlib:
713
+ type: forge
714
+ version: 6.0.0
715
+ puppetlabs-concat:
716
+ type: forge
717
+ version: 6.1.0
718
+ reidmv-xampl:
719
+ type: git
720
+ source: https://github.com/reidmv/reidmv-xampl.git
721
+ version: 62d07f2
722
+
723
+ development:
724
+ type: git
725
+ source: git@github.com:puppetlabs/control-repo.git
726
+ version: 8820892
727
+ modules:
728
+ puppetlabs-stdlib:
729
+ type: forge
730
+ version: 6.2.0
731
+ puppetlabs-concat:
732
+ type: forge
733
+ version: 6.1.0
734
+ reidmv-xampl:
735
+ type: git
736
+ source: https://github.com/reidmv/reidmv-xampl.git
737
+ version: 62d07f2
738
+ ```
739
+
740
+ An example of a single environment definition for the YAMLdir environment source type:
741
+
742
+ ```yaml
743
+ # production.yaml
744
+ ---
745
+ type: git
746
+ source: git@github.com:puppetlabs/control-repo.git
747
+ version: 8820892
748
+ modules:
749
+ puppetlabs-stdlib:
750
+ type: forge
751
+ version: 6.0.0
752
+ puppetlabs-concat:
753
+ type: forge
754
+ version: 6.1.0
755
+ reidmv-xampl:
756
+ type: git
757
+ source: https://github.com/reidmv/reidmv-xampl.git
758
+ version: 62d07f2
759
+ ```
760
+
761
+ #### Puppetfile module conflicts
762
+
763
+ When a module is defined in an environment and also in a Puppetfile, the default behavior is for the environment definition of the module to take precedence, a warning to be logged, and the Puppetfile definition to be ignored. The behavior is configurable to optionally skip the warning, or allow a hard failure instead. Use the `module_conflicts` option in an environment definition to control this.
764
+
765
+ Available `module_conflicts` options:
766
+
767
+ * `override_and_warn` (default): the version of the module defined by the environment will be used, and the version defined in the Puppetfile will be ignored. A warning will be printed.
768
+ * `override`: the version of the module defined by the environment will be used, and the version defined in the Puppetfile will be ignored.
769
+ * `error`: an error will be raised alerting the user to the conflict. The environment will not be deployed.
770
+
771
+ ```yaml
772
+ # production.yaml
773
+ ---
774
+ type: git
775
+ source: git@github.com:puppetlabs/control-repo.git
776
+ version: 8820892
777
+ module_conflicts: override_and_warn
778
+ modules:
779
+ puppetlabs-stdlib:
780
+ type: forge
781
+ version: 6.0.0
782
+ puppetlabs-concat:
783
+ type: forge
784
+ version: 6.1.0
785
+ reidmv-xampl:
786
+ type: git
787
+ source: https://github.com/reidmv/reidmv-xampl.git
788
+ version: 62d07f2
789
+ ```
790
+
791
+ ### Plain Environment Type
792
+
793
+ A "control repository" typically contains a hiera.yaml, an environment.conf, a manifests/site.pp file, and a few other things. However, none of these are strictly necessary for an environment to be functional if modules can be deployed to it.
794
+
795
+ The plain environment type allows sources that support environment modules to operate without a control repo being required. Modules can be deployed directly.
796
+
797
+ ```yaml
798
+ ---
799
+ production:
800
+ type: plain
801
+ modules:
802
+ puppetlabs-stdlib:
803
+ type: forge
804
+ version: 6.0.0
805
+ puppetlabs-concat:
806
+ type: forge
807
+ version: 6.1.0
808
+ reidmv-xampl:
809
+ type: git
810
+ source: https://github.com/reidmv/reidmv-xampl.git
811
+ version: 62d07f2
812
+
813
+ development:
814
+ type: plain
815
+ modules:
816
+ puppetlabs-stdlib:
817
+ type: forge
818
+ version: 6.0.0
819
+ puppetlabs-concat:
820
+ type: forge
821
+ version: 6.1.0
822
+ reidmv-xampl:
823
+ type: git
824
+ source: https://github.com/reidmv/reidmv-xampl.git
825
+ version: 62d07f2
826
+ ```
827
+
828
+ ### Tarball Environment Type
829
+
830
+ The tarball environment type allows an environment to be deployed from a tarball archive, rather than a Git repository. When using a tarball environment type, a source location for the tarball is required. Optionally, the tarball's sha256 checksum may be specified as the version. It is highly recommended to include a version specifier. If a version specifier is not included, r10k will never invalidate a cached copy of the tarball's source.
831
+
832
+ Tarball environment sources will be unpacked directly into the environment root.
833
+
834
+ ```yaml
835
+ ---
836
+ production:
837
+ type: tarball
838
+ source: https://repo.example.com/projects/puppet/env-2.36.1.tar.gz
839
+ version: 99a906c99c2f144de43f2ae500509a7474ed11c583fb623efa8e5b377a3157f0 # sha256digest
840
+
841
+ development:
842
+ type: tarball
843
+ source: https://repo.example.com/projects/puppet/env-6128ada.tar.gz
844
+ version: 6128ada158622cd90f8e1360fb7c2c3830a812d1ec26ddf0db7eb16d61b7293f # sha256digest
845
+ modules:
846
+ reidmv-xampl:
847
+ type: git
848
+ source: https://github.com/reidmv/reidmv-xampl.git
849
+ version: 62d07f2
850
+ ```