r10k 1.4.2 → 1.5.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (244) hide show
  1. data/.travis.yml +2 -0
  2. data/CHANGELOG.mkd +192 -0
  3. data/CONTRIBUTING.mkd +3 -3
  4. data/Gemfile +4 -0
  5. data/README.mkd +13 -6
  6. data/doc/dynamic-environments/configuration.mkd +77 -8
  7. data/doc/dynamic-environments/git-environments.mkd +12 -2
  8. data/doc/dynamic-environments/quickstart.mkd +6 -0
  9. data/doc/faq.mkd +6 -6
  10. data/doc/git/cloning-and-mirroring.mkd +60 -0
  11. data/doc/git/providers.mkd +68 -0
  12. data/integration/Gemfile +3 -0
  13. data/integration/README.mkd +29 -0
  14. data/integration/configs/README.mkd +7 -0
  15. data/integration/configs/pe/centos-6-64mda +25 -0
  16. data/integration/configs/pe/centos-7-64mda +25 -0
  17. data/integration/configs/pe/debian-6-64mda +25 -0
  18. data/integration/configs/pe/debian-7-64mda +25 -0
  19. data/integration/configs/pe/redhat-6-64mda +25 -0
  20. data/integration/configs/pe/redhat-7-64mda +25 -0
  21. data/integration/configs/pe/sles-11-64mda +25 -0
  22. data/integration/configs/pe/ubuntu-1004-64mda +25 -0
  23. data/integration/configs/pe/ubuntu-1204-64mda +25 -0
  24. data/integration/configs/pe/ubuntu-1404-64mda +25 -0
  25. data/integration/files/README.mkd +4 -0
  26. data/integration/files/hiera.yaml +8 -0
  27. data/integration/files/modules/helloworld/manifests/init.pp +3 -0
  28. data/integration/files/modules/hieratest/manifests/init.pp +3 -0
  29. data/integration/files/modules/unicode/files/pretend_unicode +1 -0
  30. data/integration/files/modules/unicode/manifests/init.pp +6 -0
  31. data/integration/files/pre-suite/prod_env.config +3 -0
  32. data/integration/files/r10k_conf.yaml.erb +9 -0
  33. data/integration/lib/README.mkd +4 -0
  34. data/integration/lib/git_utils.rb +205 -0
  35. data/integration/lib/master_manipulator.rb +205 -0
  36. data/integration/lib/r10k_utils.rb +166 -0
  37. data/integration/manifests/README.mkd +4 -0
  38. data/integration/pre-suite/00_pe_install.rb +4 -0
  39. data/integration/pre-suite/01_git_config.rb +59 -0
  40. data/integration/pre-suite/02_pe_r10k.rb +60 -0
  41. data/integration/pre-suite/03_test_utils.rb +17 -0
  42. data/integration/pre-suite/README.mkd +5 -0
  43. data/integration/test_run_scripts/README.mkd +5 -0
  44. data/integration/test_run_scripts/all_tests-rugged-pe-centos6.sh +20 -0
  45. data/integration/test_run_scripts/all_tests-rugged-pe-rhel7.sh +20 -0
  46. data/integration/test_run_scripts/all_tests-rugged-pe-sles11.sh +20 -0
  47. data/integration/test_run_scripts/all_tests-rugged-pe-ubuntu1204.sh +20 -0
  48. data/integration/test_run_scripts/all_tests-rugged-pe-ubuntu1404.sh +20 -0
  49. data/integration/test_run_scripts/all_tests-shellgit-pe-centos6.sh +20 -0
  50. data/integration/test_run_scripts/all_tests-shellgit-pe-rhel7.sh +20 -0
  51. data/integration/test_run_scripts/all_tests-shellgit-pe-sles11.sh +20 -0
  52. data/integration/test_run_scripts/all_tests-shellgit-pe-ubuntu1204.sh +20 -0
  53. data/integration/test_run_scripts/all_tests-shellgit-pe-ubuntu1404.sh +20 -0
  54. data/integration/test_run_scripts/basic_functionality/all_tests-pe-centos6.sh +20 -0
  55. data/integration/test_run_scripts/command_line/all_tests-pe-centos6.sh +20 -0
  56. data/integration/test_run_scripts/git_source/all_tests-pe-centos6.sh +20 -0
  57. data/integration/test_run_scripts/user_scenario/basic_workflow/all_tests-pe-centos6.sh +20 -0
  58. data/integration/test_run_scripts/user_scenario/complex_workflow/all_tests-pe-centos6.sh +20 -0
  59. data/integration/tests/README.mkd +4 -0
  60. data/integration/tests/basic_functionality/negative/neg_deploy_with_invalid_r10k_yaml.rb +46 -0
  61. data/integration/tests/basic_functionality/negative/neg_deploy_with_missing_r10k_yaml.rb +27 -0
  62. data/integration/tests/command_line/deploy_env_without_mod_update.rb +75 -0
  63. data/integration/tests/command_line/negative/neg_deploy_env_with_module_update.rb +76 -0
  64. data/integration/tests/command_line/negative/neg_invalid_cli_dep_flag.rb +22 -0
  65. data/integration/tests/command_line/negative/neg_invalid_cli_env_flag.rb +22 -0
  66. data/integration/tests/command_line/negative/neg_invalid_cmd_line_arg.rb +24 -0
  67. data/integration/tests/git_source/git_source_git.rb +123 -0
  68. data/integration/tests/git_source/git_source_ssh.rb +84 -0
  69. data/integration/tests/git_source/git_source_submodule.rb +69 -0
  70. data/integration/tests/git_source/negative/neg_git_broken_remote.rb +37 -0
  71. data/integration/tests/git_source/negative/neg_git_unauthorized_https.rb +45 -0
  72. data/integration/tests/git_source/negative/neg_git_unauthorized_ssh.rb +72 -0
  73. data/integration/tests/git_source/negative/neg_git_unicode_branch.rb +34 -0
  74. data/integration/tests/user_scenario/basic_workflow/multi_env_1000_branches.rb +66 -0
  75. data/integration/tests/user_scenario/basic_workflow/multi_env_custom_forge_git_module.rb +110 -0
  76. data/integration/tests/user_scenario/basic_workflow/multi_env_custom_forge_git_module_static.rb +113 -0
  77. data/integration/tests/user_scenario/basic_workflow/multi_env_hiera.rb +93 -0
  78. data/integration/tests/user_scenario/basic_workflow/multi_env_multi_source.rb +132 -0
  79. data/integration/tests/user_scenario/basic_workflow/multi_source_custom_forge_git_module.rb +160 -0
  80. data/integration/tests/user_scenario/basic_workflow/negative/neg_bad_basedir.rb +45 -0
  81. data/integration/tests/user_scenario/basic_workflow/negative/neg_bad_forge_module.rb +43 -0
  82. data/integration/tests/user_scenario/basic_workflow/negative/neg_bad_git_module.rb +40 -0
  83. data/integration/tests/user_scenario/basic_workflow/negative/neg_bad_git_module_ref.rb +42 -0
  84. data/integration/tests/user_scenario/basic_workflow/negative/neg_bad_git_remote.rb +44 -0
  85. data/integration/tests/user_scenario/basic_workflow/negative/neg_branch_name_collision.rb +63 -0
  86. data/integration/tests/user_scenario/basic_workflow/negative/neg_disk_full.rb +73 -0
  87. data/integration/tests/user_scenario/basic_workflow/negative/neg_duplicate_module_names.rb +45 -0
  88. data/integration/tests/user_scenario/basic_workflow/negative/neg_inaccessible_forge.rb +51 -0
  89. data/integration/tests/user_scenario/basic_workflow/negative/neg_invalid_env_name.rb +33 -0
  90. data/integration/tests/user_scenario/basic_workflow/negative/neg_invalid_puppet_file.rb +35 -0
  91. data/integration/tests/user_scenario/basic_workflow/negative/neg_module_specified_at_deleted_release.rb +44 -0
  92. data/integration/tests/user_scenario/basic_workflow/negative/neg_read_only.rb +57 -0
  93. data/integration/tests/user_scenario/basic_workflow/negative/neg_specify_deleted_forge_module.rb +44 -0
  94. data/integration/tests/user_scenario/basic_workflow/single_env_10000_files.rb +73 -0
  95. data/integration/tests/user_scenario/basic_workflow/single_env_custom_forge_git_module.rb +103 -0
  96. data/integration/tests/user_scenario/basic_workflow/single_env_custom_forge_module.rb +80 -0
  97. data/integration/tests/user_scenario/basic_workflow/single_env_custom_module.rb +48 -0
  98. data/integration/tests/user_scenario/basic_workflow/single_env_large_files.rb +73 -0
  99. data/integration/tests/user_scenario/basic_workflow/single_env_module_already_installed.rb +81 -0
  100. data/integration/tests/user_scenario/basic_workflow/single_env_module_last_release_deleted.rb +67 -0
  101. data/integration/tests/user_scenario/basic_workflow/single_env_non-existent_base_dir.rb +93 -0
  102. data/integration/tests/user_scenario/basic_workflow/single_env_purge_unmanaged_modules.rb +92 -0
  103. data/integration/tests/user_scenario/basic_workflow/single_env_switch_forge_git_module.rb +116 -0
  104. data/integration/tests/user_scenario/basic_workflow/single_env_unicode_paths.rb +59 -0
  105. data/integration/tests/user_scenario/basic_workflow/single_env_upgrade_forge_mod_revert_change.rb +165 -0
  106. data/integration/tests/user_scenario/complex_workflow/multi_env_add_change_remove.rb +162 -0
  107. data/integration/tests/user_scenario/complex_workflow/multi_env_remove_re-add.rb +110 -0
  108. data/lib/r10k/action/cri_runner.rb +10 -13
  109. data/lib/r10k/cli.rb +3 -8
  110. data/lib/r10k/cli/version.rb +10 -1
  111. data/lib/r10k/deployment/config.rb +26 -6
  112. data/lib/r10k/deployment/config/loader.rb +38 -29
  113. data/lib/r10k/deployment/source.rb +2 -4
  114. data/lib/r10k/environment/git.rb +10 -19
  115. data/lib/r10k/environment/name.rb +86 -0
  116. data/lib/r10k/errors.rb +8 -5
  117. data/lib/r10k/feature.rb +35 -0
  118. data/lib/r10k/feature/collection.rb +23 -0
  119. data/lib/r10k/features.rb +18 -0
  120. data/lib/r10k/git.rb +106 -12
  121. data/lib/r10k/git/alternates.rb +2 -2
  122. data/lib/r10k/git/cache.rb +43 -26
  123. data/lib/r10k/git/errors.rb +12 -6
  124. data/lib/r10k/git/head.rb +3 -0
  125. data/lib/r10k/git/ref.rb +3 -0
  126. data/lib/r10k/git/remote_head.rb +6 -0
  127. data/lib/r10k/git/repository.rb +6 -0
  128. data/lib/r10k/git/rugged.rb +17 -0
  129. data/lib/r10k/git/rugged/bare_repository.rb +86 -0
  130. data/lib/r10k/git/rugged/base_repository.rb +90 -0
  131. data/lib/r10k/git/rugged/cache.rb +11 -0
  132. data/lib/r10k/git/rugged/thin_repository.rb +72 -0
  133. data/lib/r10k/git/rugged/working_repository.rb +99 -0
  134. data/lib/r10k/git/shellgit.rb +9 -0
  135. data/lib/r10k/git/shellgit/bare_repository.rb +29 -0
  136. data/lib/r10k/git/shellgit/base_repository.rb +102 -0
  137. data/lib/r10k/git/shellgit/cache.rb +11 -0
  138. data/lib/r10k/git/shellgit/thin_repository.rb +56 -0
  139. data/lib/r10k/git/shellgit/working_repository.rb +73 -0
  140. data/lib/r10k/git/stateful_repository.rb +80 -0
  141. data/lib/r10k/git/tag.rb +3 -0
  142. data/lib/r10k/git/working_dir.rb +15 -2
  143. data/lib/r10k/logging.rb +73 -36
  144. data/lib/r10k/logging/terminaloutputter.rb +36 -0
  145. data/lib/r10k/module/forge.rb +10 -9
  146. data/lib/r10k/module/git.rb +14 -44
  147. data/lib/r10k/module/metadata_file.rb +31 -0
  148. data/lib/r10k/module/svn.rb +0 -1
  149. data/lib/r10k/module_repository/forge.rb +20 -7
  150. data/lib/r10k/puppetfile.rb +1 -1
  151. data/lib/r10k/settings/container.rb +6 -0
  152. data/lib/r10k/settings/mixin.rb +9 -0
  153. data/lib/r10k/source.rb +2 -3
  154. data/lib/r10k/source/base.rb +5 -5
  155. data/lib/r10k/source/git.rb +11 -86
  156. data/lib/r10k/source/svn.rb +8 -52
  157. data/lib/r10k/util/basedir.rb +4 -4
  158. data/lib/r10k/util/commands.rb +31 -0
  159. data/lib/r10k/util/exec_env.rb +36 -0
  160. data/lib/r10k/util/platform.rb +4 -0
  161. data/lib/r10k/util/purgeable.rb +2 -2
  162. data/lib/r10k/util/subprocess.rb +3 -7
  163. data/lib/r10k/util/subprocess/runner.rb +3 -28
  164. data/lib/r10k/util/subprocess/runner/posix.rb +103 -0
  165. data/lib/r10k/util/subprocess/runner/pump.rb +59 -0
  166. data/lib/r10k/util/subprocess/{windows/runner.rb → runner/windows.rb} +2 -11
  167. data/lib/r10k/util/symbolize_keys.rb +31 -0
  168. data/lib/r10k/version.rb +1 -1
  169. data/lib/shared/puppet/module_tool/metadata.rb +197 -0
  170. data/r10k.gemspec +7 -5
  171. data/spec/fixtures/integration/git/puppet-boolean-bare.tar +0 -0
  172. data/spec/fixtures/module/forge/bad_module/metadata.json +1 -0
  173. data/spec/fixtures/unit/util/subprocess/posix/runner/no-execute.sh +3 -0
  174. data/spec/fixtures/vcr/cassettes/R10K_ModuleRepository_Forge/and_the_expected_version_is_latest/can_fetch_all_versions_of_a_given_module.yml +171 -26
  175. data/spec/fixtures/vcr/cassettes/R10K_ModuleRepository_Forge/and_the_expected_version_is_latest/can_fetch_the_latest_version_of_a_given_module.yml +171 -26
  176. data/spec/fixtures/vcr/cassettes/R10K_ModuleRepository_Forge/and_the_expected_version_is_latest/ignores_deleted_releases.yml +190 -0
  177. data/spec/fixtures/vcr/cassettes/R10K_ModuleRepository_Forge/it_handles_errors_from_forgeapi_puppetlabs_com/raises_an_error_for_a_non-existant_module.yml +34 -0
  178. data/spec/fixtures/vcr/cassettes/R10K_Module_Forge/and_the_expected_version_is_latest/sets_the_expected_version_based_on_the_latest_forge_version.yml +87 -26
  179. data/spec/integration/git/rugged/bare_repository_spec.rb +13 -0
  180. data/spec/integration/git/rugged/thin_repository_spec.rb +14 -0
  181. data/spec/integration/git/rugged/working_repository_spec.rb +13 -0
  182. data/spec/integration/git/shellgit/bare_repository_spec.rb +13 -0
  183. data/spec/integration/git/shellgit/thin_repository_spec.rb +14 -0
  184. data/spec/integration/git/shellgit/working_repository_spec.rb +13 -0
  185. data/spec/integration/git/stateful_repository_spec.rb +104 -0
  186. data/spec/matchers/match_realpath.rb +18 -0
  187. data/spec/shared-contexts/git-fixtures.rb +55 -0
  188. data/spec/shared-examples/git-repository.rb +38 -0
  189. data/spec/shared-examples/git/bare_repository.rb +70 -0
  190. data/spec/shared-examples/git/thin_repository.rb +26 -0
  191. data/spec/shared-examples/git/working_repository.rb +115 -0
  192. data/spec/shared-examples/subprocess-runner.rb +83 -0
  193. data/spec/spec_helper.rb +13 -9
  194. data/spec/unit/action/cri_runner_spec.rb +0 -6
  195. data/spec/unit/action/puppetfile/{cri_action_spec.rb → cri_runner_spec.rb} +0 -0
  196. data/spec/unit/deployment/config/loader_spec.rb +48 -0
  197. data/spec/unit/deployment/config_spec.rb +49 -0
  198. data/spec/unit/environment/git_spec.rb +5 -39
  199. data/spec/unit/environment/name_spec.rb +135 -0
  200. data/spec/unit/feature_spec.rb +50 -0
  201. data/spec/unit/git/alternates_spec.rb +1 -1
  202. data/spec/unit/git/cache_spec.rb +32 -19
  203. data/spec/unit/git/commit_spec.rb +1 -0
  204. data/spec/unit/git/head_spec.rb +1 -6
  205. data/spec/unit/git/ref_spec.rb +0 -23
  206. data/spec/unit/git/rugged/cache_spec.rb +26 -0
  207. data/spec/unit/git/shellgit/cache_spec.rb +27 -0
  208. data/spec/unit/git/stateful_repository_spec.rb +43 -0
  209. data/spec/unit/git/tag_spec.rb +1 -0
  210. data/spec/unit/git/working_dir_spec.rb +1 -0
  211. data/spec/unit/git_spec.rb +74 -0
  212. data/spec/unit/logging/terminaloutputter_spec.rb +53 -0
  213. data/spec/unit/logging_spec.rb +68 -0
  214. data/spec/unit/module/forge_spec.rb +7 -38
  215. data/spec/unit/module/git_spec.rb +7 -38
  216. data/spec/unit/module/metadata_file_spec.rb +69 -0
  217. data/spec/unit/module/svn_spec.rb +0 -4
  218. data/spec/unit/module_repository/forge_spec.rb +22 -1
  219. data/spec/unit/puppet/module_tool/metadata_spec.rb +301 -0
  220. data/spec/unit/settings/container_spec.rb +17 -0
  221. data/spec/unit/source/git_spec.rb +0 -123
  222. data/spec/unit/source/svn_spec.rb +66 -0
  223. data/spec/unit/util/commands_spec.rb +61 -0
  224. data/spec/unit/util/exec_env_spec.rb +56 -0
  225. data/spec/unit/util/subprocess/runner/posix_spec.rb +7 -0
  226. data/spec/unit/util/subprocess/runner/pump_spec.rb +79 -0
  227. data/spec/unit/util/subprocess_spec.rb +3 -2
  228. data/spec/unit/util/symbolize_keys_spec.rb +51 -0
  229. metadata +226 -45
  230. data/lib/r10k/execution.rb +0 -47
  231. data/lib/r10k/module/metadata.rb +0 -47
  232. data/lib/r10k/util/core_ext/hash_ext.rb +0 -19
  233. data/lib/r10k/util/subprocess/io.rb +0 -7
  234. data/lib/r10k/util/subprocess/posix.rb +0 -4
  235. data/lib/r10k/util/subprocess/posix/io.rb +0 -7
  236. data/lib/r10k/util/subprocess/posix/runner.rb +0 -140
  237. data/lib/r10k/util/subprocess/windows.rb +0 -4
  238. data/lib/r10k/util/subprocess/windows/io.rb +0 -6
  239. data/spec/fixtures/vcr/cassettes/R10K_ModuleRepository_Forge/looking_up_versions.yml +0 -42
  240. data/spec/fixtures/vcr/cassettes/R10K_ModuleRepository_Forge/looking_up_versions/can_fetch_all_versions_of_a_given_module.yml +0 -42
  241. data/spec/fixtures/vcr/cassettes/R10K_ModuleRepository_Forge/looking_up_versions/can_fetch_the_latest_version_of_a_given_module.yml +0 -42
  242. data/spec/unit/deployment/source_spec.rb +0 -24
  243. data/spec/unit/module/metadata_spec.rb +0 -68
  244. data/spec/unit/util/core_ext/hash_ext_spec.rb +0 -63
@@ -0,0 +1,92 @@
1
+ require 'git_utils'
2
+ require 'r10k_utils'
3
+ require 'master_manipulator'
4
+ test_name 'CODEMGMT-73 - C63184 - Single Environment Purge Unmanaged Modules'
5
+
6
+ #Init
7
+ master_certname = on(master, puppet('config', 'print', 'certname')).stdout.rstrip
8
+ git_environments_path = '/root/environments'
9
+ last_commit = git_last_commit(master, git_environments_path)
10
+
11
+ #Verification
12
+ motd_path = '/etc/motd'
13
+ motd_contents = 'Hello!'
14
+ motd_contents_regex = /\A#{motd_contents}\z/
15
+
16
+ error_message_regex = /Blah/
17
+
18
+ #File
19
+ puppet_file = <<-PUPPETFILE
20
+ mod "puppetlabs/xinetd"
21
+ PUPPETFILE
22
+
23
+ puppet_file_path = File.join(git_environments_path, 'Puppetfile')
24
+
25
+ #Manifest
26
+ manifest = <<-MANIFEST
27
+ class { 'motd':
28
+ content => '#{motd_contents}',
29
+ }
30
+ MANIFEST
31
+
32
+ site_pp_path = File.join(git_environments_path, 'manifests', 'site.pp')
33
+ site_pp = create_site_pp(master_certname, manifest)
34
+
35
+ #Teardown
36
+ teardown do
37
+ clean_up_r10k(master, last_commit, git_environments_path)
38
+
39
+ step 'Remove "/etc/motd" File'
40
+ on(agents, "rm -rf #{motd_path}")
41
+ end
42
+
43
+ #Setup
44
+ step 'Stub Forge on Master'
45
+ stub_forge_on(master)
46
+
47
+ step 'Checkout "production" Branch'
48
+ git_on(master, 'checkout production', git_environments_path)
49
+
50
+ step 'Manually Install the "motd" Module from the Forge'
51
+ on(master, puppet('module install puppetlabs-motd'))
52
+
53
+ step 'Create "Puppetfile" for the "production" Environment'
54
+ create_remote_file(master, puppet_file_path, puppet_file)
55
+
56
+ step 'Inject New "site.pp" to the "production" Environment'
57
+ inject_site_pp(master, site_pp_path, site_pp)
58
+
59
+ step 'Push Changes'
60
+ git_add_commit_push(master, 'production', 'Update site.pp and add module.', git_environments_path)
61
+
62
+ #Tests
63
+ step 'Deploy Environments via r10k'
64
+ on(master, 'r10k deploy environment -v -p')
65
+
66
+ step 'Plug-in Sync Agents'
67
+ on(agents, puppet("plugin download --server #{master}"))
68
+
69
+ agents.each do |agent|
70
+ step 'Run Puppet Agent Against "production" Environment'
71
+ on(agent, puppet('agent', '--test', '--environment production'), :acceptable_exit_codes => 2) do |result|
72
+ assert_no_match(/Error:/, result.stderr, 'Unexpected error was detected!')
73
+ end
74
+
75
+ step "Verify MOTD Contents"
76
+ on(agent, "cat #{motd_path}") do |result|
77
+ assert_match(motd_contents_regex, result.stdout, 'File content is invalid!')
78
+ end
79
+ end
80
+
81
+ step 'Use r10k to Purge Unmanaged Modules'
82
+ on(master, 'r10k puppetfile purge -v', :acceptable_exit_codes => 1)
83
+
84
+ #Agent will fail because r10k will purge the "motd" module
85
+ agents.each do |agent|
86
+ step 'Attempt to Run Puppet Agent'
87
+ on(agent, puppet('agent', '--test', '--environment production'), :acceptable_exit_codes => 0) do |result|
88
+ expect_failure('Expected to fail due to CODEMGMT-78') do
89
+ assert_match(error_message_regex, result.stderr, 'Expected error was not detected!')
90
+ end
91
+ end
92
+ end
@@ -0,0 +1,116 @@
1
+ require 'git_utils'
2
+ require 'r10k_utils'
3
+ require 'master_manipulator'
4
+ test_name 'CODEMGMT-111 - C63600 - Single Environment Switch Between Forge and Git for Puppetfile Module'
5
+
6
+ #Init
7
+ master_certname = on(master, puppet('config', 'print', 'certname')).stdout.rstrip
8
+ env_path = on(master, puppet('config print environmentpath')).stdout.rstrip
9
+ prod_env_modules_path = File.join(env_path, 'production', 'modules')
10
+
11
+ git_environments_path = '/root/environments'
12
+ last_commit = git_last_commit(master, git_environments_path)
13
+
14
+ #Verification
15
+ motd_path = '/etc/motd'
16
+ motd_template_path = File.join(prod_env_modules_path, 'motd', 'templates', 'motd.erb')
17
+ motd_template_contents_forge = 'Hello!'
18
+ motd_contents_git = 'Bonjour!'
19
+ motd_contents_forge_regex = /\A#{motd_template_contents_forge}\n\z/
20
+ motd_contents_git_regex = /\A#{motd_contents_git}\z/
21
+
22
+ #File
23
+ puppet_file_forge = <<-PUPPETFILE
24
+ mod "puppetlabs/motd", '1.1.1'
25
+ PUPPETFILE
26
+
27
+ puppet_file_git = <<-PUPPETFILE
28
+ mod "puppetlabs/motd",
29
+ :git => 'https://github.com/puppetlabs/puppetlabs-motd',
30
+ :tag => '1.2.0'
31
+ PUPPETFILE
32
+
33
+ puppet_file_path = File.join(git_environments_path, 'Puppetfile')
34
+
35
+ #Manifest
36
+ manifest_forge = <<-MANIFEST
37
+ include motd
38
+ MANIFEST
39
+
40
+ manifest_git = <<-MANIFEST
41
+ class { 'motd':
42
+ content => '#{motd_contents_git}',
43
+ }
44
+ MANIFEST
45
+
46
+ site_pp_path = File.join(git_environments_path, 'manifests', 'site.pp')
47
+ site_pp_forge = create_site_pp(master_certname, manifest_forge)
48
+ site_pp_git = create_site_pp(master_certname, manifest_git)
49
+
50
+ #Teardown
51
+ teardown do
52
+ clean_up_r10k(master, last_commit, git_environments_path)
53
+
54
+ step 'Remove "/etc/motd" File'
55
+ on(agents, "rm -rf #{motd_path}")
56
+ end
57
+
58
+ #Setup
59
+ step 'Stub Forge on Master'
60
+ stub_forge_on(master)
61
+
62
+ step 'Checkout "production" Branch'
63
+ git_on(master, 'checkout production', git_environments_path)
64
+
65
+ step 'Inject New "site.pp" to the "production" Environment'
66
+ inject_site_pp(master, site_pp_path, site_pp_forge)
67
+
68
+ step 'Create "Puppetfile" for the "production" Environment'
69
+ create_remote_file(master, puppet_file_path, puppet_file_forge)
70
+
71
+ step 'Push Changes'
72
+ git_add_commit_push(master, 'production', 'Update site.pp and add modules.', git_environments_path)
73
+
74
+ #Tests
75
+ step 'Deploy "production" Environment via r10k'
76
+ on(master, 'r10k deploy environment -v -p')
77
+
78
+ step 'Update MOTD Template'
79
+ create_remote_file(master, motd_template_path, motd_template_contents_forge)
80
+ on(master, "chmod 644 #{motd_template_path}")
81
+
82
+ agents.each do |agent|
83
+ step 'Run Puppet Agent'
84
+ on(agent, puppet('agent', '--test', '--environment production'), :acceptable_exit_codes => [0,2]) do |result|
85
+ assert_no_match(/Error:/, result.stderr, 'Unexpected error was detected!')
86
+ end
87
+
88
+ step 'Verify MOTD Contents for Forge Version of Module'
89
+ on(agent, "cat #{motd_path}") do |result|
90
+ assert_match(motd_contents_forge_regex, result.stdout, 'File content is invalid!')
91
+ end
92
+ end
93
+
94
+ step 'Update "Puppetfile" to use Git for MOTD Module'
95
+ create_remote_file(master, puppet_file_path, puppet_file_git)
96
+
97
+ step 'Update "site.pp" in the "production" Environment'
98
+ inject_site_pp(master, site_pp_path, site_pp_git)
99
+
100
+ step 'Push Changes'
101
+ git_add_commit_push(master, 'production', 'Update site.pp and Puppetfile.', git_environments_path)
102
+
103
+ step 'Deploy "production" Environment Again via r10k'
104
+ on(master, 'r10k deploy environment -v -p')
105
+
106
+ agents.each do |agent|
107
+ step 'Run Puppet Agent'
108
+ on(agent, puppet('agent', '--test', '--environment production'), :acceptable_exit_codes => [0,2]) do |result|
109
+ assert_no_match(/Error:/, result.stderr, 'Unexpected error was detected!')
110
+ end
111
+
112
+ step 'Verify MOTD Contents for Git Version of Module'
113
+ on(agent, "cat #{motd_path}") do |result|
114
+ assert_match(motd_contents_git_regex, result.stdout, 'File content is invalid!')
115
+ end
116
+ end
@@ -0,0 +1,59 @@
1
+ require 'git_utils'
2
+ require 'r10k_utils'
3
+ require 'master_manipulator'
4
+ test_name 'CODEMGMT-62 - C59260 - Single Environment with Unicode File Paths'
5
+
6
+ #Init
7
+ master_certname = on(master, puppet('config', 'print', 'certname')).stdout.rstrip
8
+ environment_path = on(master, puppet('config', 'print', 'environmentpath')).stdout.rstrip
9
+ prod_env_modules_path = File.join(environment_path, 'production', 'modules')
10
+
11
+ git_environments_path = '/root/environments'
12
+ last_commit = git_last_commit(master, git_environments_path)
13
+ local_files_root_path = ENV['FILES'] || 'files'
14
+
15
+ unicode_module_path = File.join(local_files_root_path, 'modules', 'unicode')
16
+ unicode_remote_original_file_path = File.join(git_environments_path, 'modules', 'unicode', 'files', 'pretend_unicode')
17
+ unicode_remote_rename_file_path = File.join(git_environments_path, 'modules', 'unicode', 'files', "\uAD62\uCC63\uC0C3\uBEE7\uBE23\uB7E9\uC715\uCEFE\uBF90\uAE69")
18
+
19
+ #Verification
20
+ unicode_file_contents_regex = /\AHa ha ha! I am in Korean!\n\z/
21
+
22
+ #Manifest
23
+ site_pp_path = File.join(git_environments_path, 'manifests', 'site.pp')
24
+ site_pp = create_site_pp(master_certname, ' include unicode')
25
+
26
+ #Teardown
27
+ teardown do
28
+ clean_up_r10k(master, last_commit, git_environments_path)
29
+ end
30
+
31
+ #Setup
32
+ step 'Checkout "production" Branch'
33
+ git_on(master, 'checkout production', git_environments_path)
34
+
35
+ step 'Copy "unicode" Module to "production" Environment Git Repo'
36
+ scp_to(master, unicode_module_path, File.join(git_environments_path, 'modules'))
37
+
38
+ #Required because of CODEMGMT-87
39
+ step 'Rename File to Actual Unicode'
40
+ on(master, "mv #{unicode_remote_original_file_path} #{unicode_remote_rename_file_path}".force_encoding('BINARY'))
41
+
42
+ step 'Inject New "site.pp" to the "production" Environment'
43
+ inject_site_pp(master, site_pp_path, site_pp)
44
+
45
+ step 'Push Changes'
46
+ git_add_commit_push(master, 'production', 'Update site.pp and add modules.', git_environments_path)
47
+
48
+ #Tests
49
+ step 'Deploy "production" Environment via r10k'
50
+ on(master, 'r10k deploy environment -v')
51
+
52
+ #Note: Usually a full Puppet Run would be performed for verification.
53
+ #Since Puppet has problems with Unicode, this test will verify the file
54
+ #directly in the r10k environment.
55
+
56
+ step 'Verify Unicode File'
57
+ on(master, "cat #{unicode_remote_rename_file_path}") do |result|
58
+ assert_match(unicode_file_contents_regex, result.stdout, 'File content is invalid!')
59
+ end
@@ -0,0 +1,165 @@
1
+ require 'git_utils'
2
+ require 'r10k_utils'
3
+ require 'master_manipulator'
4
+ test_name 'CODEMGMT-117 - C63602- Single Environment Upgrade Forge Module then Revert Change'
5
+
6
+ #Init
7
+ master_certname = on(master, puppet('config', 'print', 'certname')).stdout.rstrip
8
+ env_path = on(master, puppet('config print environmentpath')).stdout.rstrip
9
+ prod_env_modules_path = File.join(env_path, 'production', 'modules')
10
+
11
+ git_environments_path = '/root/environments'
12
+ last_commit = git_last_commit(master, git_environments_path)
13
+
14
+ #Verification
15
+ motd_path = '/etc/motd'
16
+ motd_template_path = File.join(prod_env_modules_path, 'motd', 'templates', 'motd.erb')
17
+ motd_template_contents = 'Hello!'
18
+ motd_new_contents = 'Yolo!'
19
+ motd_contents_old_regex = /\A#{motd_template_contents}\n\z/
20
+ motd_contents_new_regex = /\A#{motd_new_contents}\z/
21
+
22
+ motd_old_version = /"*1.1.1*"/
23
+ motd_new_version = /"*1.2.0*"/
24
+ motd_version_file_path = File.join(prod_env_modules_path, 'motd', 'metadata.json')
25
+
26
+ #File
27
+ puppet_file_old_motd = <<-PUPPETFILE
28
+ mod "puppetlabs/motd", '1.1.1'
29
+ PUPPETFILE
30
+
31
+ puppet_file_new_motd = <<-PUPPETFILE
32
+ mod "puppetlabs/motd", '1.2.0'
33
+ PUPPETFILE
34
+
35
+ puppet_file_path = File.join(git_environments_path, 'Puppetfile')
36
+ puppet_file_path_bak = "#{puppet_file_path}.bak"
37
+
38
+ #Manifest
39
+ manifest_old = <<-MANIFEST
40
+ include motd
41
+ MANIFEST
42
+
43
+ manifest_new = <<-MANIFEST
44
+ class { 'motd':
45
+ content => '#{motd_new_contents}',
46
+ }
47
+ MANIFEST
48
+
49
+ site_pp_path = File.join(git_environments_path, 'manifests', 'site.pp')
50
+ site_pp_old = create_site_pp(master_certname, manifest_old)
51
+ site_pp_new = create_site_pp(master_certname, manifest_new)
52
+
53
+ #Teardown
54
+ teardown do
55
+ clean_up_r10k(master, last_commit, git_environments_path)
56
+
57
+ step 'Remove "/etc/motd" File'
58
+ on(agents, "rm -rf #{motd_path}")
59
+ end
60
+
61
+ #Setup
62
+ step 'Stub Forge on Master'
63
+ stub_forge_on(master)
64
+
65
+ step 'Checkout "production" Branch'
66
+ git_on(master, 'checkout production', git_environments_path)
67
+
68
+ step 'Inject New "site.pp" to the "production" Environment'
69
+ inject_site_pp(master, site_pp_path, site_pp_old)
70
+
71
+ step 'Create "Puppetfile" for the "production" Environment'
72
+ create_remote_file(master, puppet_file_path, puppet_file_old_motd)
73
+
74
+ step 'Push Changes'
75
+ git_add_commit_push(master, 'production', 'Update site.pp and add modules.', git_environments_path)
76
+
77
+ #Tests
78
+ step 'Deploy "production" Environment via r10k'
79
+ on(master, 'r10k deploy environment -v -p')
80
+
81
+ step 'Update MOTD Template'
82
+ create_remote_file(master, motd_template_path, motd_template_contents)
83
+ on(master, "chmod 644 #{motd_template_path}")
84
+
85
+ agents.each do |agent|
86
+ step 'Run Puppet Agent'
87
+ on(agent, puppet('agent', '--test', '--environment production'), :acceptable_exit_codes => [0,2]) do |result|
88
+ assert_no_match(/Error:/, result.stderr, 'Unexpected error was detected!')
89
+ end
90
+
91
+ step 'Verify MOTD Contents for Forge Version of Module'
92
+ on(agent, "cat #{motd_path}") do |result|
93
+ assert_match(motd_contents_old_regex, result.stdout, 'File content is invalid!')
94
+ end
95
+
96
+ step 'Verify Version 1.1.1 of the MOTD Module'
97
+ on(master, "grep version #{motd_version_file_path}") do |result|
98
+ assert_match(motd_old_version, result.stdout, 'File content is invalid!')
99
+ end
100
+ end
101
+
102
+ step 'Backup Old MOTD "Puppetfile" to allow for creation of New MOTD "Puppetfile"'
103
+ on(master, "mv #{puppet_file_path} #{puppet_file_path_bak}")
104
+
105
+ step 'Update "Puppetfile" to use New Module Version 1.2.0'
106
+ create_remote_file(master, puppet_file_path, puppet_file_new_motd)
107
+
108
+ step 'Update "site.pp" in the "production" Environment to New Style Manifest'
109
+ inject_site_pp(master, site_pp_path, site_pp_new)
110
+
111
+ step 'Push Changes'
112
+ git_add_commit_push(master, 'production', 'Update site.pp and Puppetfile.', git_environments_path)
113
+
114
+ step 'Deploy "production" Environment Again via r10k'
115
+ on(master, 'r10k deploy environment -v -p')
116
+
117
+ agents.each do |agent|
118
+ step 'Run Puppet Agent'
119
+ on(agent, puppet('agent', '--test', '--environment production'), :acceptable_exit_codes => [0,2]) do |result|
120
+ assert_no_match(/Error:/, result.stderr, 'Unexpected error was detected!')
121
+ end
122
+
123
+ step 'Verify MOTD Contents for New Version of Module'
124
+ on(agent, "cat #{motd_path}") do |result|
125
+ assert_match(motd_contents_new_regex, result.stdout, 'File content is invalid!')
126
+ end
127
+
128
+ step 'Verify Version 1.2.0 of the MOTD Module'
129
+ on(master, "grep version #{motd_version_file_path}") do |result|
130
+ assert_match(motd_new_version, result.stdout, 'File content is invalid!')
131
+ end
132
+ end
133
+
134
+ step 'Restore Old MOTD "Puppetfile"'
135
+ on(master, "mv #{puppet_file_path_bak} #{puppet_file_path}")
136
+
137
+ step 'Revert "site.pp" in the "production" Environment to Old Style Manifest'
138
+ inject_site_pp(master, site_pp_path, site_pp_old)
139
+
140
+ step 'Push Changes'
141
+ git_add_commit_push(master, 'production', 'Update site.pp and add modules.', git_environments_path)
142
+
143
+ step 'Deploy "production" Environment Again via r10k'
144
+ on(master, 'r10k deploy environment -v -p')
145
+
146
+ step 'Update MOTD Template'
147
+ create_remote_file(master, motd_template_path, motd_template_contents)
148
+ on(master, "chmod 644 #{motd_template_path}")
149
+
150
+ agents.each do |agent|
151
+ step 'Run Puppet Agent'
152
+ on(agent, puppet('agent', '--test', '--environment production'), :acceptable_exit_codes => [0,2]) do |result|
153
+ assert_no_match(/Error:/, result.stderr, 'Unexpected error was detected!')
154
+ end
155
+
156
+ step 'Verify MOTD Contents for Old Version of Module'
157
+ on(agent, "cat #{motd_path}") do |result|
158
+ assert_match(motd_contents_old_regex, result.stdout, 'File content is invalid!')
159
+ end
160
+
161
+ step 'Verify Version 1.1.1 of the MOTD Module'
162
+ on(master, "grep version #{motd_version_file_path}") do |result|
163
+ assert_match(motd_old_version, result.stdout, 'File content is invalid!')
164
+ end
165
+ end
@@ -0,0 +1,162 @@
1
+ require 'git_utils'
2
+ require 'r10k_utils'
3
+ require 'master_manipulator'
4
+ test_name 'CODEMGMT-48 - C59262 - Multiple Environments with Additions, Changes and Removal of Branches'
5
+
6
+ #Init
7
+ master_certname = on(master, puppet('config', 'print', 'certname')).stdout.rstrip
8
+ git_environments_path = '/root/environments'
9
+ last_commit = git_last_commit(master, git_environments_path)
10
+ local_files_root_path = ENV['FILES'] || 'files'
11
+ helloworld_module_path = File.join(local_files_root_path, 'modules', 'helloworld')
12
+
13
+ initial_env_names = ['production', 'stage', 'test']
14
+
15
+ #Verification for "production" Environment
16
+ motd_path = '/etc/motd'
17
+ motd_contents = 'Hello!'
18
+ motd_contents_regex = /\A#{motd_contents}\z/
19
+ prod_env_notify_message_regex = /I am in the production environment/
20
+
21
+ #Verification for "stage" Environment
22
+ stage_env_notify_message = 'This is a different message'
23
+ stage_env_notify_message_regex = /#{stage_env_notify_message}/
24
+
25
+ #Verification for "test" Environment
26
+ test_env_error_message_regex = /Error:.*Could not find environment 'test'/
27
+
28
+ #Verification for "temp" Environment
29
+ test_env_notify_message_regex = /I am in the temp environment/
30
+
31
+ #Manifest
32
+ prod_env_motd_manifest = <<-MANIFEST
33
+ class { 'helloworld': }
34
+ class { 'motd':
35
+ content => '#{motd_contents}',
36
+ }
37
+ MANIFEST
38
+
39
+ stage_env_custom_mod_manifest = <<-MANIFEST
40
+ class helloworld {
41
+ notify { "Hello world!":
42
+ message => "#{stage_env_notify_message}"
43
+ }
44
+ }
45
+ MANIFEST
46
+
47
+ site_pp_path = File.join(git_environments_path, 'manifests', 'site.pp')
48
+ original_site_pp = create_site_pp(master_certname, ' include helloworld')
49
+ prod_env_motd_site_pp = create_site_pp(master_certname, prod_env_motd_manifest)
50
+
51
+ #File
52
+ puppet_file = <<-PUPPETFILE
53
+ mod "puppetlabs/motd"
54
+ PUPPETFILE
55
+
56
+ puppet_file_path = File.join(git_environments_path, 'Puppetfile')
57
+
58
+ #Teardown
59
+ teardown do
60
+ clean_up_r10k(master, last_commit, git_environments_path)
61
+
62
+ step 'Remove "/etc/motd" File'
63
+ on(agents, "rm -rf #{motd_path}")
64
+ end
65
+
66
+ #Setup
67
+ step 'Stub Forge on Master'
68
+ stub_forge_on(master)
69
+
70
+ initial_env_names.each do |env|
71
+ if env == 'production'
72
+ step "Checkout \"#{env}\" Branch"
73
+ git_on(master, "checkout #{env}", git_environments_path)
74
+
75
+ step "Copy \"helloworld\" Module to \"#{env}\" Environment Git Repo"
76
+ scp_to(master, helloworld_module_path, File.join(git_environments_path, "site", 'helloworld'))
77
+
78
+ step "Inject New \"site.pp\" to the \"#{env}\" Environment"
79
+ inject_site_pp(master, site_pp_path, original_site_pp)
80
+
81
+ step "Push Changes to \"#{env}\" Environment"
82
+ git_add_commit_push(master, env, 'Update site.pp and add module.', git_environments_path)
83
+ else
84
+ step "Create \"#{env}\" Branch from \"production\""
85
+ git_on(master, 'checkout production', git_environments_path)
86
+ git_on(master, "checkout -b #{env}", git_environments_path)
87
+
88
+ step "Push Changes to \"#{env}\" Environment"
89
+ git_push(master, env, git_environments_path)
90
+ end
91
+ end
92
+
93
+ #Tests
94
+ step 'Deploy Environments via r10k'
95
+ on(master, 'r10k deploy environment -v')
96
+
97
+ #Initial Verification
98
+ initial_env_names.each do |env|
99
+ agents.each do |agent|
100
+ step "Run Puppet Agent Against \"#{env}\" Environment"
101
+ on(agent, puppet('agent', '--test', "--environment #{env}"), :acceptable_exit_codes => 2) do |result|
102
+ assert_no_match(/Error:/, result.stderr, 'Unexpected error was detected!')
103
+ assert_match(/I am in the #{env} environment/, result.stdout, 'Expected message not found!')
104
+ end
105
+ end
106
+ end
107
+
108
+ #Add, Change, Remove Environments
109
+ step 'Create "temp" Branch from "production"'
110
+ git_on(master, 'checkout production', git_environments_path)
111
+ git_on(master, 'checkout -b temp', git_environments_path)
112
+ git_push(master, 'temp', git_environments_path)
113
+
114
+ step 'Add "puppetlabs-motd" Module to the "production" Environment'
115
+ git_on(master, 'checkout production', git_environments_path)
116
+ inject_site_pp(master, site_pp_path, prod_env_motd_site_pp)
117
+ create_remote_file(master, puppet_file_path, puppet_file)
118
+ git_add_commit_push(master, 'production', 'Add motd module.', git_environments_path)
119
+
120
+ step 'Update Custom Module in the "stage" Environment'
121
+ hw_init_pp_path = File.join(git_environments_path, 'site', 'helloworld', 'manifests', 'init.pp')
122
+ git_on(master, 'checkout stage', git_environments_path)
123
+ create_remote_file(master, hw_init_pp_path, stage_env_custom_mod_manifest)
124
+ git_add_commit_push(master, 'stage', 'Update custom module.', git_environments_path)
125
+
126
+ step 'Delete the "test" Environment'
127
+ git_on(master, 'branch -D test', git_environments_path)
128
+ git_on(master, 'push origin --delete test', git_environments_path)
129
+
130
+ step 'Re-deploy Environments via r10k'
131
+ on(master, 'r10k deploy environment -v -p')
132
+
133
+ #Second Pass Verification
134
+ agents.each do |agent|
135
+ step 'Run Puppet Agent Against "production" Environment'
136
+ on(agent, puppet('agent', '--test', '--environment production'), :acceptable_exit_codes => 2) do |result|
137
+ assert_no_match(/Error:/, result.stderr, 'Unexpected error was detected!')
138
+ assert_match(prod_env_notify_message_regex, result.stdout, 'Expected message not found!')
139
+ end
140
+
141
+ step 'Run Puppet Agent Against "temp" Environment'
142
+ on(agent, puppet('agent', '--test', '--environment temp'), :acceptable_exit_codes => 2) do |result|
143
+ assert_no_match(/Error:/, result.stderr, 'Unexpected error was detected!')
144
+ assert_match(test_env_notify_message_regex, result.stdout, 'Expected message not found!')
145
+ end
146
+
147
+ step "Verify MOTD Contents"
148
+ on(agent, "cat #{motd_path}") do |result|
149
+ assert_match(motd_contents_regex, result.stdout, 'File content is invalid!')
150
+ end
151
+
152
+ step 'Run Puppet Agent Against "stage" Environment'
153
+ on(agent, puppet('agent', '--test', '--environment stage'), :acceptable_exit_codes => 2) do |result|
154
+ assert_no_match(/Error:/, result.stderr, 'Unexpected error was detected!')
155
+ assert_match(stage_env_notify_message_regex, result.stdout, 'Expected message not found!')
156
+ end
157
+
158
+ step 'Attempt to Run Puppet Agent Against "test" Environment'
159
+ on(agent, puppet('agent', '--test', '--environment test'), :acceptable_exit_codes => 1) do |result|
160
+ assert_match(test_env_error_message_regex, result.stderr, 'Expected error was not detected!')
161
+ end
162
+ end