r10k 2.0.3 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (198) hide show
  1. checksums.yaml +8 -8
  2. data/CHANGELOG.mkd +150 -0
  3. data/README.mkd +10 -1
  4. data/doc/dynamic-environments/configuration.mkd +31 -0
  5. data/doc/dynamic-environments/quickstart.mkd +33 -79
  6. data/doc/faq.mkd +67 -0
  7. data/doc/git/providers.mkd +37 -0
  8. data/doc/puppetfile.mkd +73 -0
  9. data/integration/lib/r10k_utils.rb +47 -2
  10. data/integration/pre-suite/01_git_config.rb +9 -8
  11. data/integration/pre-suite/02_pe_r10k.rb +5 -8
  12. data/integration/scripts/setup_r10k_env_centos5.sh +1 -1
  13. data/integration/scripts/setup_r10k_env_centos6.sh +1 -1
  14. data/integration/scripts/setup_r10k_env_rhel7.sh +1 -1
  15. data/integration/scripts/setup_r10k_env_sles11.sh +1 -1
  16. data/integration/scripts/setup_r10k_env_sles12.sh +1 -1
  17. data/integration/scripts/setup_r10k_env_ubuntu1004.sh +1 -1
  18. data/integration/scripts/setup_r10k_env_ubuntu1204.sh +1 -1
  19. data/integration/scripts/setup_r10k_env_ubuntu1404.sh +1 -1
  20. data/integration/test_run_scripts/all_tests-rugged-pe-centos6.sh +1 -1
  21. data/integration/test_run_scripts/all_tests-rugged-pe-rhel7.sh +1 -1
  22. data/integration/test_run_scripts/all_tests-rugged-pe-sles11.sh +1 -1
  23. data/integration/test_run_scripts/all_tests-rugged-pe-ubuntu1204.sh +1 -1
  24. data/integration/test_run_scripts/all_tests-rugged-pe-ubuntu1404.sh +1 -1
  25. data/integration/test_run_scripts/all_tests-shellgit-pe-centos6.sh +1 -1
  26. data/integration/test_run_scripts/all_tests-shellgit-pe-rhel7.sh +1 -1
  27. data/integration/test_run_scripts/all_tests-shellgit-pe-sles11.sh +1 -1
  28. data/integration/test_run_scripts/all_tests-shellgit-pe-ubuntu1204.sh +1 -1
  29. data/integration/test_run_scripts/all_tests-shellgit-pe-ubuntu1404.sh +1 -1
  30. data/integration/test_run_scripts/basic_functionality/all_tests-pe-centos6.sh +1 -1
  31. data/integration/test_run_scripts/command_line/all_tests-pe-centos6.sh +1 -1
  32. data/integration/test_run_scripts/git_source/all_tests-pe-centos6.sh +1 -1
  33. data/integration/test_run_scripts/user_scenario/basic_workflow/all_tests-pe-centos6.sh +1 -1
  34. data/integration/test_run_scripts/user_scenario/complex_workflow/all_tests-pe-centos6.sh +1 -1
  35. data/integration/tests/basic_functionality/install_pe_only_module_with_puppetfile.rb +83 -0
  36. data/integration/tests/basic_functionality/negative/attempt_to_install_peonly_module_without_license.rb +71 -0
  37. data/integration/tests/basic_functionality/negative/neg_deploy_with_invalid_r10k_yaml.rb +7 -2
  38. data/integration/tests/basic_functionality/negative/neg_deploy_with_missing_r10k_yaml.rb +3 -2
  39. data/integration/tests/basic_functionality/negative/neg_invalid_git_provider.rb +3 -2
  40. data/integration/tests/basic_functionality/negative/negative_bad_proxy.rb +56 -0
  41. data/integration/tests/basic_functionality/proxy_specified_in_configuration.rb +103 -0
  42. data/integration/tests/basic_functionality/proxy_with_puppetfile.rb +61 -0
  43. data/integration/tests/basic_functionality/rugged_git_provider_with_ssh.rb +2 -1
  44. data/integration/tests/basic_functionality/rugged_git_provider_without_ssh.rb +2 -1
  45. data/integration/tests/command_line/deploy_env_without_mod_update.rb +3 -2
  46. data/integration/tests/command_line/negative/neg_deploy_env_with_module_update.rb +3 -2
  47. data/integration/tests/command_line/negative/neg_invalid_cli_dep_flag.rb +2 -1
  48. data/integration/tests/command_line/negative/neg_invalid_cli_env_flag.rb +2 -1
  49. data/integration/tests/command_line/negative/neg_invalid_cmd_line_arg.rb +3 -4
  50. data/integration/tests/git_source/git_source_git.rb +7 -2
  51. data/integration/tests/git_source/git_source_ssh.rb +3 -2
  52. data/integration/tests/git_source/git_source_submodule.rb +2 -1
  53. data/integration/tests/git_source/negative/neg_git_broken_remote.rb +2 -1
  54. data/integration/tests/git_source/negative/neg_git_unauthorized_https.rb +2 -1
  55. data/integration/tests/git_source/negative/neg_git_unauthorized_ssh.rb +2 -1
  56. data/integration/tests/git_source/negative/neg_git_unicode_branch.rb +2 -1
  57. data/integration/tests/user_scenario/basic_workflow/multi_env_1000_branches.rb +3 -3
  58. data/integration/tests/user_scenario/basic_workflow/multi_env_custom_forge_git_module.rb +2 -1
  59. data/integration/tests/user_scenario/basic_workflow/multi_env_custom_forge_git_module_static.rb +9 -5
  60. data/integration/tests/user_scenario/basic_workflow/multi_env_hiera.rb +9 -2
  61. data/integration/tests/user_scenario/basic_workflow/multi_env_multi_source.rb +2 -1
  62. data/integration/tests/user_scenario/basic_workflow/multi_source_custom_forge_git_module.rb +2 -1
  63. data/integration/tests/user_scenario/basic_workflow/negative/neg_bad_basedir.rb +2 -1
  64. data/integration/tests/user_scenario/basic_workflow/negative/neg_bad_forge_module.rb +7 -2
  65. data/integration/tests/user_scenario/basic_workflow/negative/neg_bad_git_module.rb +3 -4
  66. data/integration/tests/user_scenario/basic_workflow/negative/neg_bad_git_module_ref.rb +2 -1
  67. data/integration/tests/user_scenario/basic_workflow/negative/neg_bad_git_remote.rb +2 -1
  68. data/integration/tests/user_scenario/basic_workflow/negative/neg_branch_name_collision.rb +2 -1
  69. data/integration/tests/user_scenario/basic_workflow/negative/neg_disk_full.rb +2 -1
  70. data/integration/tests/user_scenario/basic_workflow/negative/neg_duplicate_module_names.rb +10 -4
  71. data/integration/tests/user_scenario/basic_workflow/negative/neg_inaccessible_forge.rb +9 -2
  72. data/integration/tests/user_scenario/basic_workflow/negative/neg_invalid_env_name.rb +2 -1
  73. data/integration/tests/user_scenario/basic_workflow/negative/neg_invalid_puppet_file.rb +2 -1
  74. data/integration/tests/user_scenario/basic_workflow/negative/neg_module_specified_at_deleted_release.rb +7 -2
  75. data/integration/tests/user_scenario/basic_workflow/negative/neg_read_only.rb +2 -1
  76. data/integration/tests/user_scenario/basic_workflow/negative/neg_specify_deleted_forge_module.rb +9 -2
  77. data/integration/tests/user_scenario/basic_workflow/single_env_10000_files.rb +2 -1
  78. data/integration/tests/user_scenario/basic_workflow/single_env_custom_forge_git_module.rb +2 -1
  79. data/integration/tests/user_scenario/basic_workflow/single_env_custom_forge_module.rb +2 -1
  80. data/integration/tests/user_scenario/basic_workflow/single_env_custom_module.rb +2 -1
  81. data/integration/tests/user_scenario/basic_workflow/single_env_large_files.rb +2 -1
  82. data/integration/tests/user_scenario/basic_workflow/single_env_module_already_installed.rb +2 -1
  83. data/integration/tests/user_scenario/basic_workflow/single_env_module_last_release_deleted.rb +2 -1
  84. data/integration/tests/user_scenario/basic_workflow/single_env_non-existent_base_dir.rb +2 -1
  85. data/integration/tests/user_scenario/basic_workflow/single_env_purge_unmanaged_modules.rb +3 -2
  86. data/integration/tests/user_scenario/basic_workflow/single_env_switch_forge_git_module.rb +3 -2
  87. data/integration/tests/user_scenario/basic_workflow/single_env_unicode_paths.rb +2 -1
  88. data/integration/tests/user_scenario/basic_workflow/single_env_upgrade_forge_mod_revert_change.rb +4 -3
  89. data/integration/tests/user_scenario/complex_workflow/multi_env_add_change_remove.rb +3 -2
  90. data/integration/tests/user_scenario/complex_workflow/multi_env_remove_re-add.rb +4 -3
  91. data/integration/tests/user_scenario/complex_workflow/multi_env_unamanaged.rb +3 -2
  92. data/integration/tests/user_scenario/complex_workflow/single_env_git_module_update.rb +3 -2
  93. data/lib/r10k/action/base.rb +31 -0
  94. data/lib/r10k/action/deploy/deploy_helpers.rb +34 -0
  95. data/lib/r10k/action/deploy/display.rb +57 -75
  96. data/lib/r10k/action/deploy/environment.rb +52 -15
  97. data/lib/r10k/action/deploy/module.rb +13 -18
  98. data/lib/r10k/action/puppetfile/check.rb +8 -18
  99. data/lib/r10k/action/puppetfile/install.rb +13 -27
  100. data/lib/r10k/action/puppetfile/purge.rb +8 -17
  101. data/lib/r10k/action/runner.rb +39 -3
  102. data/lib/r10k/cli.rb +1 -3
  103. data/lib/r10k/cli/deploy.rb +3 -1
  104. data/lib/r10k/cli/puppetfile.rb +2 -2
  105. data/lib/r10k/deployment.rb +8 -6
  106. data/lib/r10k/deployment/config.rb +18 -65
  107. data/lib/r10k/environment/base.rb +19 -0
  108. data/lib/r10k/environment/git.rb +9 -0
  109. data/lib/r10k/environment/svn.rb +9 -0
  110. data/lib/r10k/forge/module_release.rb +21 -14
  111. data/lib/r10k/git.rb +6 -0
  112. data/lib/r10k/git/alternates.rb +20 -6
  113. data/lib/r10k/git/cache.rb +1 -1
  114. data/lib/r10k/git/rugged/bare_repository.rb +5 -0
  115. data/lib/r10k/git/rugged/base_repository.rb +6 -20
  116. data/lib/r10k/git/rugged/credentials.rb +66 -0
  117. data/lib/r10k/git/rugged/thin_repository.rb +16 -11
  118. data/lib/r10k/git/rugged/working_repository.rb +15 -7
  119. data/lib/r10k/git/shellgit/bare_repository.rb +9 -4
  120. data/lib/r10k/git/shellgit/thin_repository.rb +8 -10
  121. data/lib/r10k/git/stateful_repository.rb +1 -1
  122. data/lib/r10k/initializers.rb +55 -0
  123. data/lib/r10k/module.rb +1 -0
  124. data/lib/r10k/module/base.rb +3 -2
  125. data/lib/r10k/module/forge.rb +14 -6
  126. data/lib/r10k/module/local.rb +36 -0
  127. data/lib/r10k/module/metadata_file.rb +2 -2
  128. data/lib/r10k/puppetfile.rb +1 -1
  129. data/lib/r10k/settings.rb +86 -0
  130. data/lib/r10k/settings/collection.rb +118 -0
  131. data/lib/r10k/settings/definition.rb +112 -0
  132. data/lib/r10k/settings/enum_definition.rb +22 -0
  133. data/lib/r10k/settings/loader.rb +96 -0
  134. data/lib/r10k/settings/uri_definition.rb +19 -0
  135. data/lib/r10k/util/subprocess/runner/windows.rb +4 -4
  136. data/lib/r10k/version.rb +1 -1
  137. data/r10k.gemspec +2 -3
  138. data/spec/fixtures/unit/puppetfile/argument-error/Puppetfile +1 -0
  139. data/spec/fixtures/unit/util/subprocess/{posix/runner → runner}/no-execute.sh +0 -0
  140. data/spec/integration/git/rugged/thin_repository_spec.rb +2 -2
  141. data/spec/integration/git/rugged/working_repository_spec.rb +9 -0
  142. data/spec/integration/git/shellgit/thin_repository_spec.rb +2 -2
  143. data/spec/integration/git/stateful_repository_spec.rb +1 -1
  144. data/spec/r10k-mocks/mock_config.rb +10 -13
  145. data/spec/r10k-mocks/mock_env.rb +8 -0
  146. data/spec/shared-examples/deploy-actions.rb +69 -0
  147. data/spec/shared-examples/puppetfile-action.rb +17 -0
  148. data/spec/unit/action/cri_runner_spec.rb +3 -1
  149. data/spec/unit/action/deploy/deploy_helpers_spec.rb +38 -0
  150. data/spec/unit/action/deploy/display_spec.rb +31 -0
  151. data/spec/unit/action/deploy/environment_spec.rb +56 -0
  152. data/spec/unit/action/deploy/module_spec.rb +17 -0
  153. data/spec/unit/action/puppetfile/check_spec.rb +26 -0
  154. data/spec/unit/action/puppetfile/install_spec.rb +68 -0
  155. data/spec/unit/action/puppetfile/purge_spec.rb +19 -0
  156. data/spec/unit/action/runner_spec.rb +10 -9
  157. data/spec/unit/deployment/config_spec.rb +20 -44
  158. data/spec/unit/deployment_spec.rb +1 -1
  159. data/spec/unit/environment/git_spec.rb +20 -0
  160. data/spec/unit/environment/svn_spec.rb +20 -0
  161. data/spec/unit/forge/module_release_spec.rb +6 -3
  162. data/spec/unit/git/alternates_spec.rb +38 -12
  163. data/spec/unit/git/cache_spec.rb +4 -0
  164. data/spec/unit/git/rugged/credentials_spec.rb +74 -0
  165. data/spec/unit/initializers_spec.rb +68 -0
  166. data/spec/unit/module/base_spec.rb +2 -2
  167. data/spec/unit/module/forge_spec.rb +11 -3
  168. data/spec/unit/module/metadata_file_spec.rb +0 -1
  169. data/spec/unit/puppetfile_spec.rb +11 -0
  170. data/spec/unit/settings/collection_spec.rb +122 -0
  171. data/spec/unit/settings/definition_spec.rb +78 -0
  172. data/spec/unit/settings/enum_definition_spec.rb +20 -0
  173. data/spec/unit/{deployment/config → settings}/loader_spec.rb +50 -2
  174. data/spec/unit/settings/uri_definition_spec.rb +23 -0
  175. data/spec/unit/settings_spec.rb +151 -0
  176. data/spec/unit/util/subprocess/runner/posix_spec.rb +1 -1
  177. data/spec/unit/util/subprocess/runner/windows_spec.rb +7 -0
  178. metadata +53 -90
  179. data/lib/r10k/deployment/config/loader.rb +0 -59
  180. data/lib/shared/puppet/module_tool/metadata.rb +0 -197
  181. data/lib/shared/puppet_forge/connection.rb +0 -64
  182. data/lib/shared/puppet_forge/connection/connection_failure.rb +0 -26
  183. data/lib/shared/puppet_forge/error.rb +0 -41
  184. data/lib/shared/puppet_forge/tar.rb +0 -10
  185. data/lib/shared/puppet_forge/tar/mini.rb +0 -81
  186. data/lib/shared/puppet_forge/unpacker.rb +0 -68
  187. data/lib/shared/puppet_forge/v3.rb +0 -13
  188. data/lib/shared/puppet_forge/v3/module.rb +0 -69
  189. data/lib/shared/puppet_forge/v3/module_release.rb +0 -85
  190. data/lib/shared/puppet_forge/version.rb +0 -3
  191. data/spec/unit/puppet/module_tool/metadata_spec.rb +0 -301
  192. data/spec/unit/puppet_forge/connection/connection_failure_spec.rb +0 -28
  193. data/spec/unit/puppet_forge/connection_spec.rb +0 -41
  194. data/spec/unit/puppet_forge/tar/mini_spec.rb +0 -87
  195. data/spec/unit/puppet_forge/tar_spec.rb +0 -9
  196. data/spec/unit/puppet_forge/unpacker_spec.rb +0 -59
  197. data/spec/unit/puppet_forge/v3/module_release_spec.rb +0 -83
  198. data/spec/unit/puppet_forge/v3/module_spec.rb +0 -75
@@ -1,31 +1,22 @@
1
- require 'r10k/util/setopts'
2
1
  require 'r10k/deployment'
3
2
  require 'r10k/action/visitor'
4
- require 'r10k/logging'
3
+ require 'r10k/action/base'
4
+ require 'r10k/action/deploy/deploy_helpers'
5
5
 
6
6
  module R10K
7
7
  module Action
8
8
  module Deploy
9
- class Module
9
+ class Module < R10K::Action::Base
10
10
 
11
- include R10K::Logging
12
- include R10K::Util::Setopts
13
-
14
- def initialize(opts, argv)
15
- @opts = opts
16
- @argv = argv
17
- setopts(opts, {
18
- :config => :self,
19
- :environment => nil,
20
- :trace => :self
21
- })
22
-
23
- @purge = true
24
- end
11
+ include R10K::Action::Deploy::DeployHelpers
25
12
 
26
13
  def call
27
14
  @visit_ok = true
28
- deployment = R10K::Deployment.load_config(@config)
15
+
16
+ expect_config!
17
+ deployment = R10K::Deployment.new(@settings)
18
+ check_write_lock!(@settings)
19
+
29
20
  deployment.accept(self)
30
21
  @visit_ok
31
22
  end
@@ -64,6 +55,10 @@ module R10K
64
55
  logger.debug1("Only updating modules #{@argv.inspect}, skipping module #{mod.name}")
65
56
  end
66
57
  end
58
+
59
+ def allowed_initialize_opts
60
+ super.merge(environment: true)
61
+ end
67
62
  end
68
63
  end
69
64
  end
@@ -1,30 +1,14 @@
1
1
  require 'r10k/puppetfile'
2
- require 'r10k/util/setopts'
2
+ require 'r10k/action/base'
3
3
  require 'r10k/errors/formatting'
4
- require 'r10k/logging'
5
4
 
6
5
  module R10K
7
6
  module Action
8
7
  module Puppetfile
9
- class Check
10
- include R10K::Logging
11
- include R10K::Util::Setopts
12
-
13
- def initialize(opts, argv)
14
- @opts = opts
15
- @argv = argv
16
-
17
- setopts(opts, {
18
- :root => :self,
19
- :moduledir => :self,
20
- :puppetfile => :path,
21
- :trace => :self,
22
- })
23
- end
8
+ class Check < R10K::Action::Base
24
9
 
25
10
  def call
26
11
  pf = R10K::Puppetfile.new(@root, @moduledir, @path)
27
-
28
12
  begin
29
13
  pf.load!
30
14
  $stderr.puts "Syntax OK"
@@ -34,6 +18,12 @@ module R10K
34
18
  false
35
19
  end
36
20
  end
21
+
22
+ private
23
+
24
+ def allowed_initialize_opts
25
+ super.merge(root: :self, puppetfile: :self, moduledir: :self)
26
+ end
37
27
  end
38
28
  end
39
29
  end
@@ -1,41 +1,23 @@
1
1
  require 'r10k/puppetfile'
2
- require 'r10k/util/setopts'
3
2
  require 'r10k/errors/formatting'
4
- require 'r10k/logging'
3
+ require 'r10k/action/visitor'
4
+ require 'r10k/action/base'
5
5
 
6
6
  module R10K
7
7
  module Action
8
8
  module Puppetfile
9
- class Install
10
- include R10K::Logging
11
- include R10K::Util::Setopts
12
-
13
- def initialize(opts, argv)
14
- @opts = opts
15
- @argv = argv
16
-
17
- @ok = true
18
-
19
- setopts(opts, {
20
- :root => :self,
21
- :moduledir => :self,
22
- :puppetfile => :path,
23
- :trace => :self,
24
- })
25
- end
9
+ class Install < R10K::Action::Base
26
10
 
27
11
  def call
28
- pf = R10K::Puppetfile.new(@root, @moduledir, @path)
12
+ @visit_ok = true
13
+ pf = R10K::Puppetfile.new(@root, @moduledir, @puppetfile)
29
14
  pf.accept(self)
30
- @ok
15
+ @visit_ok
31
16
  end
32
17
 
33
- def visit(type, other, &block)
34
- send("visit_#{type}", other, &block)
35
- rescue => e
36
- logger.error R10K::Errors::Formatting.format_exception(e, @trace)
37
- @ok = false
38
- end
18
+ private
19
+
20
+ include R10K::Action::Visitor
39
21
 
40
22
  def visit_puppetfile(pf)
41
23
  pf.load!
@@ -47,6 +29,10 @@ module R10K
47
29
  logger.info "Updating module #{mod.path}"
48
30
  mod.sync
49
31
  end
32
+
33
+ def allowed_initialize_opts
34
+ super.merge(root: :self, puppetfile: :self, moduledir: :self)
35
+ end
50
36
  end
51
37
  end
52
38
  end
@@ -1,26 +1,11 @@
1
1
  require 'r10k/puppetfile'
2
- require 'r10k/util/setopts'
2
+ require 'r10k/action/base'
3
3
  require 'r10k/errors/formatting'
4
- require 'r10k/logging'
5
4
 
6
5
  module R10K
7
6
  module Action
8
7
  module Puppetfile
9
- class Purge
10
- include R10K::Logging
11
- include R10K::Util::Setopts
12
-
13
- def initialize(opts, argv)
14
- @opts = opts
15
- @argv = argv
16
-
17
- setopts(opts, {
18
- :root => :self,
19
- :moduledir => :self,
20
- :puppetfile => :path,
21
- :trace => :self,
22
- })
23
- end
8
+ class Purge < R10K::Action::Base
24
9
 
25
10
  def call
26
11
  pf = R10K::Puppetfile.new(@root, @moduledir, @path)
@@ -31,6 +16,12 @@ module R10K
31
16
  logger.error R10K::Errors::Formatting.format_exception(e, @trace)
32
17
  false
33
18
  end
19
+
20
+ private
21
+
22
+ def allowed_initialize_opts
23
+ super.merge(root: :self, puppetfile: :self, moduledir: :self)
24
+ end
34
25
  end
35
26
  end
36
27
  end
@@ -1,7 +1,7 @@
1
1
  require 'r10k/logging'
2
2
  require 'r10k/errors'
3
3
  require 'r10k/util/license'
4
- require 'shared/puppet_forge/connection'
4
+ require 'puppet_forge/connection'
5
5
 
6
6
  module R10K
7
7
  module Action
@@ -12,13 +12,15 @@ module R10K
12
12
  @opts = opts
13
13
  @argv = argv
14
14
  @klass = klass
15
+
16
+ @settings = {}
15
17
  end
16
18
 
17
19
  def instance
18
20
  if @_instance.nil?
19
21
  iopts = @opts.dup
20
22
  iopts.delete(:loglevel)
21
- @_instance = @klass.new(iopts, @argv)
23
+ @_instance = @klass.new(iopts, @argv, @settings)
22
24
  end
23
25
  @_instance
24
26
  end
@@ -27,6 +29,7 @@ module R10K
27
29
  setup_logging
28
30
  setup_settings
29
31
  # @todo check arguments
32
+ setup_authorization
30
33
  instance.call
31
34
  end
32
35
 
@@ -37,7 +40,22 @@ module R10K
37
40
  end
38
41
 
39
42
  def setup_settings
40
- setup_authorization
43
+ config_settings = settings_from_config(@opts[:config])
44
+
45
+ overrides = {:cachedir => @opts[:cachedir]}
46
+ overrides.delete_if { |_, val| val.nil? }
47
+
48
+ with_overrides = config_settings.merge(overrides) do |key, oldval, newval|
49
+ logger.debug2 "Overriding config file setting '#{key}': '#{oldval}' -> '#{newval}'"
50
+ newval
51
+ end
52
+
53
+ @settings = R10K::Settings.global_settings.evaluate(with_overrides)
54
+
55
+ R10K::Initializers::GlobalInitializer.new(@settings).call
56
+ rescue R10K::Settings::Collection::ValidationError => e
57
+ logger.error e.format
58
+ exit(8)
41
59
  end
42
60
 
43
61
  def setup_authorization
@@ -51,6 +69,24 @@ module R10K
51
69
  logger.warn e.message
52
70
  end
53
71
  end
72
+
73
+ private
74
+
75
+ def settings_from_config(override_path)
76
+ loader = R10K::Settings::Loader.new
77
+ path = loader.search(override_path)
78
+ results = {}
79
+
80
+ if path
81
+ @opts[:config] = path
82
+ logger.debug2 "Reading configuration from #{path.inspect}"
83
+ results = loader.read(path)
84
+ else
85
+ logger.debug2 "No config file explicitly given and no default config file could be found, default settings will be used."
86
+ end
87
+
88
+ results
89
+ end
54
90
  end
55
91
  end
56
92
  end
@@ -35,9 +35,7 @@ module R10K::CLI
35
35
 
36
36
  flag nil, :color, 'Enable colored log messages'
37
37
 
38
- required :c, :config, 'Specify a global configuration file (deprecated, use `r10k deploy -c`)' do |value, cmd|
39
- logger.warn "Calling `r10k --config <action>` as a global option is deprecated; use r10k <action> --config"
40
- end
38
+ required :c, :config, 'Specify a global configuration file'
41
39
 
42
40
  run do |opts, args, cmd|
43
41
  puts cmd.help(:verbose => opts[:verbose])
@@ -21,7 +21,7 @@ module R10K::CLI
21
21
  (https://puppetlabs.com/blog/git-workflow-and-puppet-environments/).
22
22
  DESCRIPTION
23
23
 
24
- required :c, :config, 'Specify a configuration file'
24
+ required nil, :cachedir, 'Specify a cachedir, overriding the value in config'
25
25
 
26
26
  run do |opts, args, cmd|
27
27
  puts cmd.help(:verbose => opts[:verbose])
@@ -88,6 +88,8 @@ try to deploy the given module names in all environments.
88
88
 
89
89
  flag :p, :puppetfile, 'Display Puppetfile modules'
90
90
  flag nil, :detail, 'Display detailed information'
91
+ flag nil, :fetch, 'Update available environment lists from all remote sources'
92
+ required nil, :format, 'Display output in a specific format. Valid values: json, yaml. Default: yaml'
91
93
 
92
94
  runner R10K::Action::CriRunner.wrap(R10K::Action::Deploy::Display)
93
95
  end
@@ -31,8 +31,8 @@ Puppetfile (http://bombasticmonkey.com/librarian-puppet/).
31
31
  usage 'install'
32
32
  summary 'Install all modules from a Puppetfile'
33
33
 
34
- # @todo add --moduledir option
35
- # @todo add --puppetfile option
34
+ required nil, :moduledir, 'Path to install modules to'
35
+ required nil, :puppetfile, 'Path to puppetfile'
36
36
  # @todo add --no-purge option
37
37
  runner R10K::Action::Puppetfile::CriRunner.wrap(R10K::Action::Puppetfile::Install)
38
38
  end
@@ -15,10 +15,12 @@ module R10K
15
15
 
16
16
  # Generate a deployment object based on a config
17
17
  #
18
+ # @deprecated
19
+ #
18
20
  # @param path [String] The path to the deployment config
19
21
  # @return [R10K::Deployment] The deployment loaded with the given config
20
- def self.load_config(path)
21
- config = R10K::Deployment::Config.new(path)
22
+ def self.load_config(path, overrides={})
23
+ config = R10K::Deployment::Config.new(path, overrides)
22
24
  new(config)
23
25
  end
24
26
 
@@ -98,8 +100,8 @@ module R10K
98
100
 
99
101
  def accept(visitor)
100
102
  visitor.visit(:deployment, self) do
101
- sources.each do |env|
102
- env.accept(visitor)
103
+ sources.each do |source|
104
+ source.accept(visitor)
103
105
  end
104
106
  end
105
107
  end
@@ -107,9 +109,9 @@ module R10K
107
109
  private
108
110
 
109
111
  def load_sources
110
- sources = @config.setting(:sources)
112
+ sources = @config[:sources]
111
113
  if sources.nil? || sources.empty?
112
- raise R10K::Error, "'sources' key in #{@config.configfile} missing or empty."
114
+ raise R10K::Error, "Unable to load sources; the supplied configuration does not define the 'sources' key"
113
115
  end
114
116
  @_sources = sources.map do |(name, hash)|
115
117
  R10K::Source.from_hash(name, hash)
@@ -1,7 +1,8 @@
1
1
  require 'r10k/deployment'
2
- require 'r10k/deployment/config/loader'
2
+ require 'r10k/settings/loader'
3
3
  require 'r10k/util/symbolize_keys'
4
4
  require 'r10k/errors'
5
+ require 'r10k/initializers'
5
6
  require 'yaml'
6
7
 
7
8
  module R10K
@@ -12,88 +13,40 @@ class Config
12
13
 
13
14
  attr_accessor :configfile
14
15
 
15
- def initialize(configfile)
16
+ def initialize(configfile, overrides={})
16
17
  @configfile = configfile
18
+ @overrides = overrides
17
19
 
18
20
  load_config
19
21
  end
20
22
 
21
23
  # Perform a scan for key and check for both string and symbol keys
22
24
  def setting(key)
23
- keys = [key]
24
- case key
25
- when String
26
- keys << key.to_sym
27
- when Symbol
28
- keys << key.to_s
29
- end
25
+ @config[key]
26
+ end
30
27
 
31
- # Scan all possible keys to see if the config has a matching value
32
- keys.inject(nil) do |rv, k|
33
- v = @config[k]
34
- break v unless v.nil?
35
- end
28
+ alias [] setting
29
+
30
+ def settings
31
+ @config
36
32
  end
37
33
 
38
34
  # Load and store a config file, and set relevant options
39
35
  #
40
36
  # @param [String] configfile The path to the YAML config file
41
37
  def load_config
42
- if @configfile.nil?
43
- loader = R10K::Deployment::Config::Loader.new
44
- @configfile = loader.search
45
- if @configfile.nil?
46
- raise ConfigError, "No configuration file given, no config file found in current directory, and no global config present"
47
- end
48
- end
49
- begin
50
- @config = ::YAML.load_file(@configfile)
51
- apply_config_settings
52
- rescue => e
53
- raise ConfigError, "Couldn't load config file: #{e.message}"
54
- end
55
- end
56
-
57
- private
38
+ loader = R10K::Settings::Loader.new
39
+ hash = loader.read(@configfile)
58
40
 
59
- def with_setting(key, &block)
60
- value = setting(key)
61
- block.call(value) unless value.nil?
62
- end
63
-
64
- # Apply global configuration settings.
65
- def apply_config_settings
66
- with_setting(:purgedirs) do |purgedirs|
67
- logger.warn("The purgedirs key in r10k.yaml is deprecated. It is currently ignored.")
68
- end
69
-
70
- with_setting(:cachedir) do |cachedir|
71
- R10K::Git::Cache.settings[:cache_root] = cachedir
41
+ with_overrides = hash.merge(@overrides) do |key, oldval, newval|
42
+ logger.debug2 "Overriding config file setting '#{key}': '#{oldval}' -> '#{newval}'"
43
+ newval
72
44
  end
73
45
 
74
- with_setting(:forge) do |forge_settings|
75
- R10K::Util::SymbolizeKeys.symbolize_keys!(forge_settings)
76
- proxy = forge_settings[:proxy]
77
- if proxy
78
- R10K::Forge::ModuleRelease.settings[:proxy] = proxy
79
- end
80
- end
81
-
82
- with_setting(:git) do |git_settings|
83
- R10K::Util::SymbolizeKeys.symbolize_keys!(git_settings)
84
- provider = git_settings[:provider]
85
- if provider
86
- R10K::Git.provider = provider.to_sym
87
- end
46
+ @config = R10K::Settings.global_settings.evaluate(with_overrides)
88
47
 
89
- if git_settings[:private_key]
90
- R10K::Git.settings[:private_key] = git_settings[:private_key]
91
- end
92
-
93
- if git_settings[:username]
94
- R10K::Git.settings[:username] = git_settings[:username]
95
- end
96
- end
48
+ initializer = R10K::Initializers::GlobalInitializer.new(@config)
49
+ initializer.call
97
50
  end
98
51
 
99
52
  class ConfigError < R10K::Error