r10k 1.5.1 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (139) hide show
  1. checksums.yaml +15 -0
  2. data/.travis.yml +0 -1
  3. data/CHANGELOG.mkd +63 -0
  4. data/Gemfile +2 -2
  5. data/README.mkd +1 -10
  6. data/doc/dynamic-environments/configuration.mkd +24 -6
  7. data/doc/dynamic-environments/quickstart.mkd +1 -1
  8. data/integration/Gemfile +1 -1
  9. data/integration/configs/pe/centos-5-64mda +25 -0
  10. data/integration/configs/pe/centos-6-64mda +1 -1
  11. data/integration/configs/pe/centos-7-64mda +1 -1
  12. data/integration/configs/pe/debian-6-64mda +1 -1
  13. data/integration/configs/pe/debian-7-64mda +1 -1
  14. data/integration/configs/pe/redhat-6-64mda +1 -1
  15. data/integration/configs/pe/redhat-7-64mda +1 -1
  16. data/integration/configs/pe/sles-11-64mda +1 -1
  17. data/integration/configs/pe/sles-12-64mda +25 -0
  18. data/integration/configs/pe/ubuntu-1004-64mda +1 -1
  19. data/integration/configs/pe/ubuntu-1204-64mda +1 -1
  20. data/integration/configs/pe/ubuntu-1404-64mda +1 -1
  21. data/integration/files/pre-suite/git_config.pp.erb +19 -0
  22. data/integration/pre-suite/01_git_config.rb +5 -17
  23. data/integration/pre-suite/02_pe_r10k.rb +0 -2
  24. data/integration/scripts/README.mkd +86 -0
  25. data/integration/scripts/setup_r10k_env_centos5.sh +23 -0
  26. data/integration/scripts/setup_r10k_env_centos6.sh +23 -0
  27. data/integration/scripts/setup_r10k_env_rhel7.sh +23 -0
  28. data/integration/scripts/setup_r10k_env_sles11.sh +23 -0
  29. data/integration/scripts/setup_r10k_env_sles12.sh +23 -0
  30. data/integration/scripts/setup_r10k_env_ubuntu1004.sh +23 -0
  31. data/integration/scripts/setup_r10k_env_ubuntu1204.sh +23 -0
  32. data/integration/scripts/setup_r10k_env_ubuntu1404.sh +23 -0
  33. data/integration/tests/basic_functionality/negative/neg_invalid_git_provider.rb +44 -0
  34. data/integration/tests/basic_functionality/rugged_git_provider_with_ssh.rb +106 -0
  35. data/integration/tests/basic_functionality/rugged_git_provider_without_ssh.rb +107 -0
  36. data/integration/tests/git_source/git_source_git.rb +1 -1
  37. data/integration/tests/git_source/git_source_ssh.rb +1 -1
  38. data/integration/tests/git_source/negative/neg_git_unauthorized_https.rb +1 -1
  39. data/integration/tests/git_source/negative/neg_git_unauthorized_ssh.rb +1 -1
  40. data/integration/tests/user_scenario/basic_workflow/negative/neg_bad_basedir.rb +1 -1
  41. data/integration/tests/user_scenario/basic_workflow/negative/neg_bad_git_module.rb +8 -2
  42. data/integration/tests/user_scenario/basic_workflow/negative/neg_bad_git_module_ref.rb +1 -1
  43. data/integration/tests/user_scenario/basic_workflow/negative/neg_bad_git_remote.rb +1 -1
  44. data/integration/tests/user_scenario/basic_workflow/negative/neg_branch_name_collision.rb +1 -1
  45. data/integration/tests/user_scenario/basic_workflow/negative/neg_disk_full.rb +5 -1
  46. data/integration/tests/user_scenario/basic_workflow/negative/neg_duplicate_module_names.rb +3 -3
  47. data/integration/tests/user_scenario/basic_workflow/negative/neg_invalid_puppet_file.rb +1 -1
  48. data/integration/tests/user_scenario/basic_workflow/negative/neg_read_only.rb +1 -1
  49. data/integration/tests/user_scenario/basic_workflow/single_env_10000_files.rb +4 -0
  50. data/integration/tests/user_scenario/basic_workflow/single_env_large_files.rb +4 -0
  51. data/integration/tests/user_scenario/complex_workflow/multi_env_unamanaged.rb +77 -0
  52. data/integration/tests/user_scenario/complex_workflow/single_env_git_module_update.rb +99 -0
  53. data/lib/r10k/action/deploy/display.rb +0 -1
  54. data/lib/r10k/action/runner.rb +20 -0
  55. data/lib/r10k/cli.rb +0 -3
  56. data/lib/r10k/cli/deploy.rb +0 -3
  57. data/lib/r10k/deployment.rb +1 -7
  58. data/lib/r10k/deployment/config.rb +15 -1
  59. data/lib/r10k/deployment/config/loader.rb +0 -11
  60. data/lib/r10k/environment/git.rb +0 -9
  61. data/lib/r10k/environment/svn.rb +0 -9
  62. data/lib/r10k/errors.rb +0 -3
  63. data/lib/r10k/feature.rb +24 -3
  64. data/lib/r10k/forge/module_release.rb +142 -0
  65. data/lib/r10k/git.rb +32 -11
  66. data/lib/r10k/module/forge.rb +25 -54
  67. data/lib/r10k/module_repository/forge.rb +2 -5
  68. data/lib/r10k/puppetfile.rb +1 -1
  69. data/lib/r10k/util/license.rb +20 -0
  70. data/lib/r10k/version.rb +1 -1
  71. data/lib/shared/puppet_forge/connection.rb +62 -0
  72. data/lib/shared/puppet_forge/error.rb +28 -0
  73. data/lib/shared/puppet_forge/tar.rb +10 -0
  74. data/lib/shared/puppet_forge/tar/mini.rb +81 -0
  75. data/lib/shared/puppet_forge/unpacker.rb +68 -0
  76. data/lib/shared/puppet_forge/v3.rb +13 -0
  77. data/lib/shared/puppet_forge/v3/module.rb +66 -0
  78. data/lib/shared/puppet_forge/v3/module_release.rb +73 -0
  79. data/lib/shared/puppet_forge/version.rb +3 -0
  80. data/r10k.gemspec +2 -2
  81. data/r10k.yaml.example +80 -5
  82. data/spec/spec_helper.rb +0 -12
  83. data/spec/unit/action/runner_spec.rb +53 -0
  84. data/spec/unit/deployment/config/loader_spec.rb +5 -19
  85. data/spec/unit/deployment/config_spec.rb +8 -0
  86. data/spec/unit/deployment_spec.rb +1 -1
  87. data/spec/unit/forge/module_release_spec.rb +130 -0
  88. data/spec/unit/git_spec.rb +5 -5
  89. data/spec/unit/module/forge_spec.rb +66 -116
  90. data/spec/unit/module_repository/forge_spec.rb +35 -5
  91. data/spec/unit/module_spec.rb +10 -10
  92. data/spec/unit/puppet_forge/connection_spec.rb +41 -0
  93. data/spec/unit/puppet_forge/tar/mini_spec.rb +87 -0
  94. data/spec/unit/puppet_forge/tar_spec.rb +9 -0
  95. data/spec/unit/puppet_forge/unpacker_spec.rb +59 -0
  96. data/spec/unit/puppet_forge/v3/module_release_spec.rb +68 -0
  97. data/spec/unit/puppet_forge/v3/module_spec.rb +67 -0
  98. metadata +48 -112
  99. data/lib/r10k/cli/environment.rb +0 -28
  100. data/lib/r10k/cli/environment/deploy.rb +0 -26
  101. data/lib/r10k/cli/environment/list.rb +0 -23
  102. data/lib/r10k/cli/environment/stale.rb +0 -24
  103. data/lib/r10k/cli/module.rb +0 -29
  104. data/lib/r10k/cli/module/deploy.rb +0 -27
  105. data/lib/r10k/cli/module/list.rb +0 -24
  106. data/lib/r10k/cli/synchronize.rb +0 -27
  107. data/lib/r10k/deployment/basedir.rb +0 -4
  108. data/lib/r10k/deployment/environment.rb +0 -20
  109. data/lib/r10k/deployment/source.rb +0 -37
  110. data/lib/r10k/git/commit.rb +0 -22
  111. data/lib/r10k/git/head.rb +0 -36
  112. data/lib/r10k/git/ref.rb +0 -66
  113. data/lib/r10k/git/remote_head.rb +0 -19
  114. data/lib/r10k/git/repository.rb +0 -158
  115. data/lib/r10k/git/tag.rb +0 -29
  116. data/lib/r10k/git/working_dir.rb +0 -186
  117. data/lib/r10k/registry.rb +0 -4
  118. data/lib/r10k/semver.rb +0 -128
  119. data/lib/r10k/task.rb +0 -12
  120. data/lib/r10k/task/deployment.rb +0 -164
  121. data/lib/r10k/task/environment.rb +0 -31
  122. data/lib/r10k/task/module.rb +0 -19
  123. data/lib/r10k/task/puppetfile.rb +0 -102
  124. data/lib/r10k/task_runner.rb +0 -72
  125. data/lib/r10k/util/monkey_patches.rb +0 -11
  126. data/spec/fixtures/vcr/cassettes/R10K_ModuleRepository_Forge/and_the_expected_version_is_latest/can_fetch_all_versions_of_a_given_module.yml +0 -187
  127. data/spec/fixtures/vcr/cassettes/R10K_ModuleRepository_Forge/and_the_expected_version_is_latest/can_fetch_the_latest_version_of_a_given_module.yml +0 -187
  128. data/spec/fixtures/vcr/cassettes/R10K_ModuleRepository_Forge/and_the_expected_version_is_latest/ignores_deleted_releases.yml +0 -190
  129. data/spec/fixtures/vcr/cassettes/R10K_ModuleRepository_Forge/it_handles_errors_from_forgeapi_puppetlabs_com/raises_an_error_for_a_non-existant_module.yml +0 -34
  130. 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 +0 -103
  131. data/spec/shared-examples/git-ref.rb +0 -49
  132. data/spec/unit/deployment/environment_spec.rb +0 -25
  133. data/spec/unit/git/commit_spec.rb +0 -34
  134. data/spec/unit/git/head_spec.rb +0 -22
  135. data/spec/unit/git/ref_spec.rb +0 -45
  136. data/spec/unit/git/repository_spec.rb +0 -34
  137. data/spec/unit/git/tag_spec.rb +0 -32
  138. data/spec/unit/git/working_dir_spec.rb +0 -122
  139. data/spec/unit/util/monkey_patches_spec.rb +0 -20
@@ -0,0 +1,23 @@
1
+ #!/bin/bash
2
+ SCRIPT_PATH=$(pwd)
3
+ BASENAME_CMD="basename ${SCRIPT_PATH}"
4
+ SCRIPT_BASE_PATH=`eval ${BASENAME_CMD}`
5
+
6
+ if [ $SCRIPT_BASE_PATH = "scripts" ]; then
7
+ cd ../
8
+ fi
9
+
10
+ export pe_dist_dir=http://neptune.puppetlabs.lan/3.8/ci-ready/
11
+ export GIT_PROVIDER=shellgit
12
+
13
+ bundle install --path .bundle/gems
14
+
15
+ bundle exec beaker \
16
+ --preserve-hosts always \
17
+ --config configs/pe/centos-5-64mda \
18
+ --debug \
19
+ --keyfile ~/.ssh/id_rsa-acceptance \
20
+ --pre-suite pre-suite \
21
+ --load-path lib
22
+
23
+ rm -rf .bundle
@@ -0,0 +1,23 @@
1
+ #!/bin/bash
2
+ SCRIPT_PATH=$(pwd)
3
+ BASENAME_CMD="basename ${SCRIPT_PATH}"
4
+ SCRIPT_BASE_PATH=`eval ${BASENAME_CMD}`
5
+
6
+ if [ $SCRIPT_BASE_PATH = "scripts" ]; then
7
+ cd ../
8
+ fi
9
+
10
+ export pe_dist_dir=http://neptune.puppetlabs.lan/3.8/ci-ready/
11
+ export GIT_PROVIDER=shellgit
12
+
13
+ bundle install --path .bundle/gems
14
+
15
+ bundle exec beaker \
16
+ --preserve-hosts always \
17
+ --config configs/pe/centos-6-64mda \
18
+ --debug \
19
+ --keyfile ~/.ssh/id_rsa-acceptance \
20
+ --pre-suite pre-suite \
21
+ --load-path lib
22
+
23
+ rm -rf .bundle
@@ -0,0 +1,23 @@
1
+ #!/bin/bash
2
+ SCRIPT_PATH=$(pwd)
3
+ BASENAME_CMD="basename ${SCRIPT_PATH}"
4
+ SCRIPT_BASE_PATH=`eval ${BASENAME_CMD}`
5
+
6
+ if [ $SCRIPT_BASE_PATH = "scripts" ]; then
7
+ cd ../
8
+ fi
9
+
10
+ export pe_dist_dir=http://neptune.puppetlabs.lan/3.8/ci-ready/
11
+ export GIT_PROVIDER=shellgit
12
+
13
+ bundle install --path .bundle/gems
14
+
15
+ bundle exec beaker \
16
+ --preserve-hosts always \
17
+ --config configs/pe/redhat-7-64mda \
18
+ --debug \
19
+ --keyfile ~/.ssh/id_rsa-acceptance \
20
+ --pre-suite pre-suite \
21
+ --load-path lib
22
+
23
+ rm -rf .bundle
@@ -0,0 +1,23 @@
1
+ #!/bin/bash
2
+ SCRIPT_PATH=$(pwd)
3
+ BASENAME_CMD="basename ${SCRIPT_PATH}"
4
+ SCRIPT_BASE_PATH=`eval ${BASENAME_CMD}`
5
+
6
+ if [ $SCRIPT_BASE_PATH = "scripts" ]; then
7
+ cd ../
8
+ fi
9
+
10
+ export pe_dist_dir=http://neptune.puppetlabs.lan/3.8/ci-ready/
11
+ export GIT_PROVIDER=shellgit
12
+
13
+ bundle install --path .bundle/gems
14
+
15
+ bundle exec beaker \
16
+ --preserve-hosts always \
17
+ --config configs/pe/sles-11-64mda \
18
+ --debug \
19
+ --keyfile ~/.ssh/id_rsa-acceptance \
20
+ --pre-suite pre-suite \
21
+ --load-path lib
22
+
23
+ rm -rf .bundle
@@ -0,0 +1,23 @@
1
+ #!/bin/bash
2
+ SCRIPT_PATH=$(pwd)
3
+ BASENAME_CMD="basename ${SCRIPT_PATH}"
4
+ SCRIPT_BASE_PATH=`eval ${BASENAME_CMD}`
5
+
6
+ if [ $SCRIPT_BASE_PATH = "scripts" ]; then
7
+ cd ../
8
+ fi
9
+
10
+ export pe_dist_dir=http://neptune.puppetlabs.lan/3.8/ci-ready/
11
+ export GIT_PROVIDER=shellgit
12
+
13
+ bundle install --path .bundle/gems
14
+
15
+ bundle exec beaker \
16
+ --preserve-hosts always \
17
+ --config configs/pe/sles-12-64mda \
18
+ --debug \
19
+ --keyfile ~/.ssh/id_rsa-acceptance \
20
+ --pre-suite pre-suite \
21
+ --load-path lib
22
+
23
+ rm -rf .bundle
@@ -0,0 +1,23 @@
1
+ #!/bin/bash
2
+ SCRIPT_PATH=$(pwd)
3
+ BASENAME_CMD="basename ${SCRIPT_PATH}"
4
+ SCRIPT_BASE_PATH=`eval ${BASENAME_CMD}`
5
+
6
+ if [ $SCRIPT_BASE_PATH = "scripts" ]; then
7
+ cd ../
8
+ fi
9
+
10
+ export pe_dist_dir=http://neptune.puppetlabs.lan/3.8/ci-ready/
11
+ export GIT_PROVIDER=shellgit
12
+
13
+ bundle install --path .bundle/gems
14
+
15
+ bundle exec beaker \
16
+ --preserve-hosts always \
17
+ --config configs/pe/ubuntu-1004-64mda \
18
+ --debug \
19
+ --keyfile ~/.ssh/id_rsa-acceptance \
20
+ --pre-suite pre-suite \
21
+ --load-path lib
22
+
23
+ rm -rf .bundle
@@ -0,0 +1,23 @@
1
+ #!/bin/bash
2
+ SCRIPT_PATH=$(pwd)
3
+ BASENAME_CMD="basename ${SCRIPT_PATH}"
4
+ SCRIPT_BASE_PATH=`eval ${BASENAME_CMD}`
5
+
6
+ if [ $SCRIPT_BASE_PATH = "scripts" ]; then
7
+ cd ../
8
+ fi
9
+
10
+ export pe_dist_dir=http://neptune.puppetlabs.lan/3.8/ci-ready/
11
+ export GIT_PROVIDER=shellgit
12
+
13
+ bundle install --path .bundle/gems
14
+
15
+ bundle exec beaker \
16
+ --preserve-hosts always \
17
+ --config configs/pe/ubuntu-1204-64mda \
18
+ --debug \
19
+ --keyfile ~/.ssh/id_rsa-acceptance \
20
+ --pre-suite pre-suite \
21
+ --load-path lib
22
+
23
+ rm -rf .bundle
@@ -0,0 +1,23 @@
1
+ #!/bin/bash
2
+ SCRIPT_PATH=$(pwd)
3
+ BASENAME_CMD="basename ${SCRIPT_PATH}"
4
+ SCRIPT_BASE_PATH=`eval ${BASENAME_CMD}`
5
+
6
+ if [ $SCRIPT_BASE_PATH = "scripts" ]; then
7
+ cd ../
8
+ fi
9
+
10
+ export pe_dist_dir=http://neptune.puppetlabs.lan/3.8/ci-ready/
11
+ export GIT_PROVIDER=shellgit
12
+
13
+ bundle install --path .bundle/gems
14
+
15
+ bundle exec beaker \
16
+ --preserve-hosts always \
17
+ --config configs/pe/ubuntu-1404-64mda \
18
+ --debug \
19
+ --keyfile ~/.ssh/id_rsa-acceptance \
20
+ --pre-suite pre-suite \
21
+ --load-path lib
22
+
23
+ rm -rf .bundle
@@ -0,0 +1,44 @@
1
+ test_name 'CODEMGMT-137 - C64161 - Specify Invalid Value for Git Provider'
2
+
3
+ #Init
4
+ env_path = on(master, puppet('config print environmentpath')).stdout.rstrip
5
+
6
+ git_repo_path = '/git_repos'
7
+ git_control_remote = File.join(git_repo_path, 'environments.git')
8
+ git_provider = 'invalid'
9
+
10
+ r10k_config_path = get_r10k_config_file_path(master)
11
+ r10k_config_bak_path = "#{r10k_config_path}.bak"
12
+
13
+ #In-line files
14
+ r10k_conf = <<-CONF
15
+ cachedir: '/var/cache/r10k'
16
+ git:
17
+ provider: '#{git_provider}'
18
+ sources:
19
+ control:
20
+ basedir: "#{env_path}"
21
+ remote: "#{git_control_remote}"
22
+ CONF
23
+
24
+ #Verification
25
+ error_message_regex = /ConfigError:.*Couldn't load config file/
26
+
27
+ #Teardown
28
+ teardown do
29
+ step 'Restore Original "r10k" Config'
30
+ on(master, "mv #{r10k_config_bak_path} #{r10k_config_path}")
31
+ end
32
+
33
+ #Setup
34
+ step 'Backup a Valid "r10k" Config'
35
+ on(master, "mv #{r10k_config_path} #{r10k_config_bak_path}")
36
+
37
+ step 'Update the "r10k" Config'
38
+ create_remote_file(master, r10k_config_path, r10k_conf)
39
+
40
+ #Tests
41
+ step 'Attempt to Deploy via r10k'
42
+ on(master, 'r10k deploy environment -v', :acceptable_exit_codes => 1) do |result|
43
+ assert_match(error_message_regex, result.stderr, 'Expected message not found!')
44
+ end
@@ -0,0 +1,106 @@
1
+ require 'erb'
2
+ require 'git_utils'
3
+ require 'r10k_utils'
4
+ require 'master_manipulator'
5
+ test_name 'CODEMGMT-137 - C64160 - Use "rugged" Git Provider with Authentication'
6
+
7
+ confine(:to, :platform => ['el', 'ubuntu', 'sles'])
8
+
9
+ if ENV['GIT_PROVIDER'] == 'shellgit'
10
+ skip_test('Skipping test because removing Git from the system affects other "shellgit" tests.')
11
+ elsif fact_on(master, 'osfamily') == 'RedHat' and fact_on(master, "operatingsystemmajrelease").to_i < 6
12
+ skip_test('This version of EL is not supported by this test case!')
13
+ end
14
+
15
+ #Init
16
+ master_platform = fact_on(master, 'osfamily')
17
+ master_certname = on(master, puppet('config', 'print', 'certname')).stdout.rstrip
18
+ env_path = on(master, puppet('config print environmentpath')).stdout.rstrip
19
+
20
+ git_repo_path = '/git_repos'
21
+ git_control_remote = 'git@github.com:puppetlabs/codemgmt-92.git'
22
+ git_environments_path = '/root/environments'
23
+ last_commit = git_last_commit(master, git_environments_path)
24
+ git_provider = 'rugged'
25
+
26
+ jenkins_key_path = File.file?("#{ENV['HOME']}/.ssh/id_rsa") ? "#{ENV['HOME']}/.ssh/id_rsa" : File.expand_path('~/.ssh/id_rsa-jenkins')
27
+ ssh_private_key_path = '/root/.ssh/id_rsa-jenkins'
28
+
29
+ local_files_root_path = ENV['FILES'] || 'files'
30
+ helloworld_module_path = File.join(local_files_root_path, 'modules', 'helloworld')
31
+
32
+ git_manifest_template_path = File.join(local_files_root_path, 'pre-suite', 'git_config.pp.erb')
33
+ git_manifest = ERB.new(File.read(git_manifest_template_path)).result(binding)
34
+
35
+ r10k_config_path = get_r10k_config_file_path(master)
36
+ r10k_config_bak_path = "#{r10k_config_path}.bak"
37
+
38
+ #In-line files
39
+ r10k_conf = <<-CONF
40
+ cachedir: '/var/cache/r10k'
41
+ git:
42
+ provider: '#{git_provider}'
43
+ private_key: '#{ssh_private_key_path}'
44
+ sources:
45
+ control:
46
+ basedir: "#{env_path}"
47
+ remote: "#{git_control_remote}"
48
+ CONF
49
+
50
+ #Manifest
51
+ site_pp_path = File.join(git_environments_path, 'manifests', 'site.pp')
52
+ site_pp = create_site_pp(master_certname, ' include helloworld')
53
+
54
+ #Verification
55
+ notify_message_regex = /I am in the production environment/
56
+
57
+ #Teardown
58
+ teardown do
59
+ step 'Restore "git" Package'
60
+ on(master, puppet('apply'), :stdin => git_manifest, :acceptable_exit_codes => [0,2])
61
+
62
+ step 'Restore Original "r10k" Config'
63
+ on(master, "mv #{r10k_config_bak_path} #{r10k_config_path}")
64
+
65
+ clean_up_r10k(master, last_commit, git_environments_path)
66
+ end
67
+
68
+ #Setup
69
+ step 'Backup Current "r10k" Config'
70
+ on(master, "mv #{r10k_config_path} #{r10k_config_bak_path}")
71
+
72
+ if File.file?(jenkins_key_path) == false
73
+ skip_test('Skipping test because necessary SSH key is not present!')
74
+ end
75
+
76
+ step 'Update the "r10k" Config'
77
+ create_remote_file(master, r10k_config_path, r10k_conf)
78
+
79
+ step 'Copy SSH Key to Master'
80
+ scp_to(master, jenkins_key_path, ssh_private_key_path)
81
+ on(master, "chmod 600 #{ssh_private_key_path}")
82
+
83
+ step 'Remove "git" Package from System'
84
+ if master_platform == 'RedHat'
85
+ on(master, 'yum remove -y git')
86
+ elsif master_platform == 'Debian'
87
+ if fact_on(master, "operatingsystemmajrelease") == '10.04'
88
+ on(master, 'apt-get remove -y git-core')
89
+ else
90
+ on(master, 'apt-get remove -y git')
91
+ end
92
+ elsif master_platform == 'SLES'
93
+ on(master, 'zypper remove -y git-core git')
94
+ end
95
+
96
+ #Tests
97
+ step 'Deploy "production" Environment via r10k'
98
+ on(master, 'r10k deploy environment -v')
99
+
100
+ agents.each do |agent|
101
+ step "Run Puppet Agent"
102
+ on(agent, puppet('agent', '--test', '--environment production'), :acceptable_exit_codes => 2) do |result|
103
+ assert_no_match(/Error:/, result.stderr, 'Unexpected error was detected!')
104
+ assert_match(notify_message_regex, result.stdout, 'Expected message not found!')
105
+ end
106
+ end
@@ -0,0 +1,107 @@
1
+ require 'erb'
2
+ require 'git_utils'
3
+ require 'r10k_utils'
4
+ require 'master_manipulator'
5
+ test_name 'CODEMGMT-137 - C64159 - Use "rugged" Git Provider without Authentication'
6
+
7
+ confine(:to, :platform => ['el', 'ubuntu', 'sles'])
8
+
9
+ if ENV['GIT_PROVIDER'] == 'shellgit'
10
+ skip_test('Skipping test because removing Git from the system affects other "shellgit" tests.')
11
+ elsif fact_on(master, 'osfamily') == 'RedHat' and fact_on(master, "operatingsystemmajrelease").to_i < 6
12
+ skip_test('This version of EL is not supported by this test case!')
13
+ end
14
+
15
+ #Init
16
+ master_platform = fact_on(master, 'osfamily')
17
+ master_certname = on(master, puppet('config', 'print', 'certname')).stdout.rstrip
18
+ env_path = on(master, puppet('config print environmentpath')).stdout.rstrip
19
+
20
+ git_repo_path = '/git_repos'
21
+ git_repo_name = 'environments'
22
+ git_control_remote = File.join(git_repo_path, "#{git_repo_name}.git")
23
+ git_environments_path = '/root/environments'
24
+ last_commit = git_last_commit(master, git_environments_path)
25
+ git_provider = 'rugged'
26
+
27
+ local_files_root_path = ENV['FILES'] || 'files'
28
+ helloworld_module_path = File.join(local_files_root_path, 'modules', 'helloworld')
29
+
30
+ git_manifest_template_path = File.join(local_files_root_path, 'pre-suite', 'git_config.pp.erb')
31
+ git_manifest = ERB.new(File.read(git_manifest_template_path)).result(binding)
32
+
33
+ r10k_config_path = get_r10k_config_file_path(master)
34
+ r10k_config_bak_path = "#{r10k_config_path}.bak"
35
+
36
+ #In-line files
37
+ r10k_conf = <<-CONF
38
+ cachedir: '/var/cache/r10k'
39
+ git:
40
+ provider: '#{git_provider}'
41
+ sources:
42
+ control:
43
+ basedir: "#{env_path}"
44
+ remote: "#{git_control_remote}"
45
+ CONF
46
+
47
+ #Manifest
48
+ site_pp_path = File.join(git_environments_path, 'manifests', 'site.pp')
49
+ site_pp = create_site_pp(master_certname, ' include helloworld')
50
+
51
+ #Verification
52
+ notify_message_regex = /I am in the production environment/
53
+
54
+ #Teardown
55
+ teardown do
56
+ step 'Restore "git" Package'
57
+ on(master, puppet('apply'), :stdin => git_manifest, :acceptable_exit_codes => [0,2])
58
+
59
+ step 'Restore Original "r10k" Config'
60
+ on(master, "mv #{r10k_config_bak_path} #{r10k_config_path}")
61
+
62
+ clean_up_r10k(master, last_commit, git_environments_path)
63
+ end
64
+
65
+ #Setup
66
+ step 'Backup Current "r10k" Config'
67
+ on(master, "mv #{r10k_config_path} #{r10k_config_bak_path}")
68
+
69
+ step 'Update the "r10k" Config'
70
+ create_remote_file(master, r10k_config_path, r10k_conf)
71
+
72
+ step 'Checkout "production" Branch'
73
+ git_on(master, 'checkout production', git_environments_path)
74
+
75
+ step 'Copy "helloworld" Module to "production" 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 "production" Environment'
79
+ inject_site_pp(master, site_pp_path, site_pp)
80
+
81
+ step 'Push Changes'
82
+ git_add_commit_push(master, 'production', 'Update site.pp and add module.', git_environments_path)
83
+
84
+ step 'Remove "git" Package from System'
85
+ if master_platform == 'RedHat'
86
+ on(master, 'yum remove -y git')
87
+ elsif master_platform == 'Debian'
88
+ if fact_on(master, "operatingsystemmajrelease") == '10.04'
89
+ on(master, 'apt-get remove -y git-core')
90
+ else
91
+ on(master, 'apt-get remove -y git')
92
+ end
93
+ elsif master_platform == 'SLES'
94
+ on(master, 'zypper remove -y git-core git')
95
+ end
96
+
97
+ #Tests
98
+ step 'Deploy "production" Environment via r10k'
99
+ on(master, 'r10k deploy environment -v')
100
+
101
+ agents.each do |agent|
102
+ step "Run Puppet Agent"
103
+ on(agent, puppet('agent', '--test', '--environment production'), :acceptable_exit_codes => 2) do |result|
104
+ assert_no_match(/Error:/, result.stderr, 'Unexpected error was detected!')
105
+ assert_match(notify_message_regex, result.stdout, 'Expected message not found!')
106
+ end
107
+ end