r10k 3.9.0 → 3.10.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (65) hide show
  1. checksums.yaml +4 -4
  2. data/.github/pull_request_template.md +1 -1
  3. data/.github/workflows/rspec_tests.yml +1 -1
  4. data/.github/workflows/stale.yml +19 -0
  5. data/CHANGELOG.mkd +24 -0
  6. data/doc/dynamic-environments/configuration.mkd +13 -6
  7. data/integration/Rakefile +1 -1
  8. data/integration/tests/user_scenario/basic_workflow/negative/neg_specify_deleted_forge_module.rb +3 -9
  9. data/integration/tests/user_scenario/basic_workflow/single_env_purge_unmanaged_modules.rb +8 -14
  10. data/lib/r10k/action/base.rb +10 -0
  11. data/lib/r10k/action/deploy/display.rb +42 -9
  12. data/lib/r10k/action/deploy/environment.rb +70 -41
  13. data/lib/r10k/action/deploy/module.rb +51 -29
  14. data/lib/r10k/action/puppetfile/check.rb +3 -1
  15. data/lib/r10k/action/puppetfile/install.rb +20 -23
  16. data/lib/r10k/action/puppetfile/purge.rb +8 -2
  17. data/lib/r10k/action/runner.rb +11 -6
  18. data/lib/r10k/content_synchronizer.rb +83 -0
  19. data/lib/r10k/deployment.rb +1 -1
  20. data/lib/r10k/environment/base.rb +21 -1
  21. data/lib/r10k/environment/git.rb +0 -3
  22. data/lib/r10k/environment/svn.rb +4 -6
  23. data/lib/r10k/environment/with_modules.rb +18 -10
  24. data/lib/r10k/git/cache.rb +1 -1
  25. data/lib/r10k/initializers.rb +7 -0
  26. data/lib/r10k/module.rb +1 -1
  27. data/lib/r10k/module/base.rb +17 -1
  28. data/lib/r10k/module/forge.rb +29 -19
  29. data/lib/r10k/module/git.rb +23 -14
  30. data/lib/r10k/module/local.rb +1 -0
  31. data/lib/r10k/module/svn.rb +12 -9
  32. data/lib/r10k/module_loader/puppetfile.rb +195 -0
  33. data/lib/r10k/module_loader/puppetfile/dsl.rb +37 -0
  34. data/lib/r10k/puppetfile.rb +111 -202
  35. data/lib/r10k/settings.rb +3 -0
  36. data/lib/r10k/source/base.rb +14 -0
  37. data/lib/r10k/source/git.rb +19 -6
  38. data/lib/r10k/source/hash.rb +1 -3
  39. data/lib/r10k/source/svn.rb +4 -2
  40. data/lib/r10k/util/cleaner.rb +21 -0
  41. data/lib/r10k/util/purgeable.rb +70 -8
  42. data/lib/r10k/version.rb +1 -1
  43. data/locales/r10k.pot +67 -71
  44. data/spec/fixtures/unit/action/r10k_forge_auth.yaml +4 -0
  45. data/spec/fixtures/unit/action/r10k_forge_auth_no_url.yaml +3 -0
  46. data/spec/fixtures/unit/util/purgeable/managed_one/managed_subdir_1/managed_subdir_2/ignored_1 +0 -0
  47. data/spec/fixtures/unit/util/purgeable/managed_two/.hidden/unmanaged_3 +0 -0
  48. data/spec/r10k-mocks/mock_source.rb +1 -1
  49. data/spec/shared-examples/puppetfile-action.rb +7 -7
  50. data/spec/unit/action/deploy/display_spec.rb +32 -6
  51. data/spec/unit/action/deploy/environment_spec.rb +85 -48
  52. data/spec/unit/action/deploy/module_spec.rb +163 -31
  53. data/spec/unit/action/puppetfile/check_spec.rb +2 -2
  54. data/spec/unit/action/puppetfile/install_spec.rb +31 -10
  55. data/spec/unit/action/puppetfile/purge_spec.rb +25 -5
  56. data/spec/unit/action/runner_spec.rb +49 -25
  57. data/spec/unit/git/cache_spec.rb +14 -0
  58. data/spec/unit/module/forge_spec.rb +23 -14
  59. data/spec/unit/module/git_spec.rb +8 -8
  60. data/spec/unit/module_loader/puppetfile_spec.rb +330 -0
  61. data/spec/unit/module_spec.rb +22 -5
  62. data/spec/unit/puppetfile_spec.rb +123 -203
  63. data/spec/unit/settings_spec.rb +6 -2
  64. data/spec/unit/util/purgeable_spec.rb +40 -14
  65. metadata +12 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7e658209eb66330ab2c2cea4dd4fac0690b6700042e639e5ff11d2fffb120f1b
4
- data.tar.gz: 870249f76ef6c2b289e3255e6c752d6fc725009a8e37f8b4219f7496a7c0a439
3
+ metadata.gz: db8e1373846da121e13c6bdd3f74c7eadac79d356d65628157d1f0b6c0939f23
4
+ data.tar.gz: 7fd4694a5e33f692213339db0422fa7db58d38f84d63f2586593665f8acae8cc
5
5
  SHA512:
6
- metadata.gz: a01dfae93025bac535c4e18d5f15b800c7bc1df1aa79cf0a2ea565c034767d5c5f0b0e4b41b7954e59310090a25ca67e28e92ab416958b2f91864a3da873d93a
7
- data.tar.gz: 0631fe1846185c2808bd14be2cca3b182402991476950bae18da0fb19129eb7139fbec3b1f9a3bf1568f09931d0438c9a014380378cce71b01d7b9022364cb7c
6
+ metadata.gz: 272021e80cc4ce7ba4d11f3316bd972d7498e102a1f4d4aa9c0bcf83eeef60bd283c9fb4db74ad37e854b2ebc60f6ba28d3c251ae51cb54fb2ae03a4842d4bb8
7
+ data.tar.gz: 3689ec04b7dd2a4597199fd2fddba3e06a903b682760aacd565f96e42a604c42a6ef340f598c37ee4e1c1cfc4f4912c1132880de98bb734d86aac39475a45342
@@ -1,4 +1,4 @@
1
1
  Please add all notable changes to the "Unreleased" section of the CHANGELOG in the format:
2
2
  ```
3
- - Summary of changes. [Issue or PR #](link to issue or PR)
3
+ - (JIRA ticket) Summary of changes. [Issue or PR #](link to issue or PR)
4
4
  ```
@@ -15,7 +15,7 @@ jobs:
15
15
  - {os: ubuntu-18.04, ruby: 2.5}
16
16
  - {os: ubuntu-18.04, ruby: 2.6}
17
17
  - {os: ubuntu-18.04, ruby: 2.7}
18
- - {os: ubuntu-18.04, ruby: jruby-9.2.9.0}
18
+ - {os: ubuntu-18.04, ruby: jruby-9.2.10.0}
19
19
  - {os: windows-2016, ruby: 2.5}
20
20
  - {os: windows-2016, ruby: 2.6}
21
21
  - {os: windows-2016, ruby: 2.7}
@@ -0,0 +1,19 @@
1
+ name: Mark stale issues
2
+
3
+ on:
4
+ schedule:
5
+ - cron: "30 1 * * *"
6
+
7
+ jobs:
8
+ stale:
9
+ runs-on: ubuntu-latest
10
+ steps:
11
+ - uses: actions/stale@v3
12
+ with:
13
+ repo-token: ${{ secrets.GITHUB_TOKEN }}
14
+ days-before-stale: 60
15
+ days-before-close: 7
16
+ stale-issue-message: 'This issue has been marked stale because it has had no activity for 60 days. The Puppet Team is actively prioritizing existing bugs and new features, if this issue is still important to you please comment and we will add this to our backlog to complete. Otherwise, it will be closed in 7 days.'
17
+ stale-issue-label: 'stale'
18
+ stale-pr-message: "This PR has been marked stale because it has had no activity for 60 days. If you are still interested in getting this merged, please comment and we'll try to move it forward. Otherwise, it will be closed in 7 days."
19
+ stale-pr-label: 'stale'
data/CHANGELOG.mkd CHANGED
@@ -4,6 +4,30 @@ CHANGELOG
4
4
  Unreleased
5
5
  ----------
6
6
 
7
+ 3.10.0
8
+ ------
9
+
10
+ - Add `authorization_token` setting to allow authentication to a custom Forge server. [#1181](https://github.com/puppetlabs/r10k/pull/1181)
11
+ - (RK-135) Attempting to download the latest version for a module that has no Forge releases will now issue a meaningful error. [#1177](https://github.com/puppetlabs/r10k/pull/1177)
12
+ - Added an interface to R10K::Source::Base named `reload!` for updating the environments list for a given deployment; `reload!` is called before deployment purges to make r10k deploy pools more threadsafe. [#1172](https://github.com/puppetlabs/r10k/pull/1172)
13
+ - Remove username and password from remote url in cache directory name [#1186](https://github.com/puppetlabs/r10k/pull/1186)
14
+ - Purging efficiency is greatly improved. R10K will no longer recurse into directories that match recursive purge exclusions. This should significantly improve the deploy times for those users who enable the "environment" purge level. [#1178](https://github.com/puppetlabs/r10k/pull/1178)
15
+
16
+ 3.9.3
17
+ -----
18
+
19
+ - Fixes a regression when using `--default_branch_override` with Puppetfiles containing Forge modules. [#1173](https://github.com/puppetlabs/r10k/issues/1173)
20
+
21
+ 3.9.2
22
+ -----
23
+
24
+ - Makes the third parameter to R10K::Actions optional, restoring backwards compatability broken in 3.9.1.
25
+
26
+ 3.9.1
27
+ -----
28
+
29
+ - Invalid module specifications in a Puppetfile will cause the R10K run to abort earlier than before. Prior to this release, the R10K run would complete, sync all other modules, and return an exit code of 1. R10K will now stop syncing modules and abort immediately. [#1161](https://github.com/puppetlabs/r10k/pull/1161)
30
+
7
31
  3.9.0
8
32
  -----
9
33
 
@@ -165,9 +165,16 @@ interactions. See the global proxy setting documentation for more information an
165
165
  The 'baseurl' setting indicates where Forge modules should be installed from.
166
166
  This defaults to 'https://forgeapi.puppetlabs.com'
167
167
 
168
+ #### authorization_token
169
+
170
+ The 'authorization_token' setting allows you to provide a token for authenticating to a
171
+ custom Forge server. When set, 'baseurl' must also be set.
172
+ You will need to prepend your token with 'Bearer ' if using Artifactory as your Forge server.
173
+
168
174
  ```yaml
169
175
  forge:
170
176
  baseurl: 'https://private-forge.mysite'
177
+ authorization_token: 'Bearer mysupersecretauthtoken'
171
178
  ```
172
179
 
173
180
  Deployment options
@@ -586,13 +593,13 @@ When using the YAML source type, every environment is enumerated in a single yam
586
593
  ---
587
594
  production:
588
595
  type: git
589
- remote: git@github.com:puppetlabs/control-repo.git
590
- ref: 8820892
596
+ source: git@github.com:puppetlabs/control-repo.git
597
+ version: 8820892
591
598
 
592
599
  development:
593
600
  type: git
594
- remote: git@github.com:puppetlabs/control-repo.git
595
- ref: 8820892
601
+ source: git@github.com:puppetlabs/control-repo.git
602
+ version: 8820892
596
603
  ```
597
604
 
598
605
  ### YAMLdir Environment Source
@@ -623,8 +630,8 @@ The contents of the file should be a hash specifying the enviornment type, and a
623
630
  # production.yaml
624
631
  ---
625
632
  type: git
626
- remote: git@github.com:puppetlabs/control-repo.git
627
- ref: 8820892
633
+ source: git@github.com:puppetlabs/control-repo.git
634
+ version: 8820892
628
635
  ```
629
636
 
630
637
  ### Exec environment Source
data/integration/Rakefile CHANGED
@@ -65,7 +65,7 @@ rototiller_task :beaker_hostgenerator do |t|
65
65
  end
66
66
 
67
67
  # This is a hack :(
68
- t.add_flag(:name => '', :default => 'centos6-64mdca-64.fa', :override_env => 'TEST_TARGET')
68
+ t.add_flag(:name => '', :default => 'centos7-64mdca-64.fa', :override_env => 'TEST_TARGET')
69
69
 
70
70
  t.add_flag(:name => '--global-config', :default => '{forge_host=forge-aio01-petest.puppetlabs.com}', :override_env => 'BHG_GLOBAL_CONFIG')
71
71
  end
@@ -10,7 +10,7 @@ last_commit = git_last_commit(master, git_environments_path)
10
10
  r10k_fqp = get_r10k_fqp(master)
11
11
 
12
12
  #Verification
13
- error_notification_regex = /Does 'puppetlabs-regret' have at least one published release?/
13
+ error_notification_regex = /The module puppetlabs-regret does not appear to have any published releases/
14
14
 
15
15
  #File
16
16
  puppet_file = <<-PUPPETFILE
@@ -40,12 +40,6 @@ git_add_commit_push(master, 'production', 'Add module.', git_environments_path)
40
40
 
41
41
  #Tests
42
42
  step "Deploy production environment via r10k with specified module deleted"
43
- on(master, "#{r10k_fqp} deploy environment -p -v", :acceptable_exit_codes => 1) do |result|
44
- if get_puppet_version(master) < 4.0
45
- assert_match(error_notification_regex, result.stderr, 'Unexpected error was detected!')
46
- else
47
- expect_failure('expected to fail due to RK-135') do
48
- assert_match(error_notification_regex, result.stderr, 'Unexpected error was detected!')
49
- end
50
- end
43
+ on(master, "#{r10k_fqp} deploy environment -p -v --trace", :acceptable_exit_codes => 1) do |result|
44
+ assert_match(error_notification_regex, result.stderr, 'Unexpected error was detected!')
51
45
  end
@@ -1,10 +1,11 @@
1
1
  require 'git_utils'
2
2
  require 'r10k_utils'
3
3
  require 'master_manipulator'
4
- test_name 'CODEMGMT-73 - C63184 - Single Environment Purge Unmanaged Modules'
4
+ test_name 'CODEMGMT-78 - Puppetfile Purge --puppetfile & --moduledir flag usage'
5
5
 
6
6
  #Init
7
7
  master_certname = on(master, puppet('config', 'print', 'certname')).stdout.rstrip
8
+ moduledir = on(master, puppet('config', 'print', 'environmentpath')).stdout.strip + '/production/modules'
8
9
  git_environments_path = '/root/environments'
9
10
  last_commit = git_last_commit(master, git_environments_path)
10
11
  r10k_fqp = get_r10k_fqp(master)
@@ -14,8 +15,6 @@ motd_path = '/etc/motd'
14
15
  motd_contents = 'Hello!'
15
16
  motd_contents_regex = /\A#{motd_contents}\z/
16
17
 
17
- error_message_regex = /Blah/
18
-
19
18
  #File
20
19
  puppet_file = <<-PUPPETFILE
21
20
  mod "puppetlabs/xinetd"
@@ -48,9 +47,6 @@ stub_forge_on(master)
48
47
  step 'Checkout "production" Branch'
49
48
  git_on(master, 'checkout production', git_environments_path)
50
49
 
51
- step 'Manually Install the "motd" Module from the Forge'
52
- on(master, puppet('module install puppetlabs-motd'))
53
-
54
50
  step 'Create "Puppetfile" for the "production" Environment'
55
51
  create_remote_file(master, puppet_file_path, puppet_file)
56
52
 
@@ -60,13 +56,13 @@ inject_site_pp(master, site_pp_path, site_pp)
60
56
  step 'Push Changes'
61
57
  git_add_commit_push(master, 'production', 'Update site.pp and add module.', git_environments_path)
62
58
 
63
- #Tests
64
59
  step 'Deploy Environments via r10k'
65
60
  on(master, "#{r10k_fqp} deploy environment -v -p")
66
61
 
67
- step 'Plug-in Sync Agents'
68
- on(agents, puppet("plugin download --server #{master}"))
62
+ step 'Manually Install the "motd" Module from the Forge'
63
+ on(master, puppet("module install puppetlabs-motd --modulepath #{moduledir}"))
69
64
 
65
+ #Tests
70
66
  agents.each do |agent|
71
67
  step 'Run Puppet Agent Against "production" Environment'
72
68
  on(agent, puppet('agent', '--test', '--environment production'), :acceptable_exit_codes => 2) do |result|
@@ -80,14 +76,12 @@ agents.each do |agent|
80
76
  end
81
77
 
82
78
  step 'Use r10k to Purge Unmanaged Modules'
83
- on(master, "#{r10k_fqp} puppetfile purge -v", :acceptable_exit_codes => 1)
79
+ on(master, "#{r10k_fqp} puppetfile purge -v --puppetfile #{puppet_file_path} --moduledir #{moduledir}")
84
80
 
85
81
  #Agent will fail because r10k will purge the "motd" module
86
82
  agents.each do |agent|
87
83
  step 'Attempt to Run Puppet Agent'
88
- on(agent, puppet('agent', '--test', '--environment production'), :acceptable_exit_codes => 0) do |result|
89
- expect_failure('Expected to fail due to CODEMGMT-78') do
90
- assert_match(error_message_regex, result.stderr, 'Expected error was not detected!')
91
- end
84
+ on(agent, puppet('agent', '--test', '--environment production'), :acceptable_exit_codes => 1) do |result|
85
+ assert_match(/Could not find declared class motd/, result.stderr, 'Module was not purged')
92
86
  end
93
87
  end
@@ -10,6 +10,16 @@ module R10K
10
10
 
11
11
  attr_accessor :settings
12
12
 
13
+ # @param opts [Hash] A hash of options defined in #allowed_initialized_opts
14
+ # and managed by the SetOps mixin within the Action::Base class.
15
+ # Corresponds to the CLI flags and options.
16
+ # @param argv [Enumerable] Typically CRI::ArgumentList or Array. A list-like
17
+ # collection of the remaining arguments to the CLI invocation (after
18
+ # removing flags and options).
19
+ # @param settings [Hash] A hash of configuration loaded from the relevant
20
+ # config (r10k.yaml).
21
+ #
22
+ # @note All arguments will be required in the next major version
13
23
  def initialize(opts, argv, settings = {})
14
24
  @opts = opts
15
25
  @argv = argv
@@ -9,17 +9,48 @@ module R10K
9
9
 
10
10
  include R10K::Action::Deploy::DeployHelpers
11
11
 
12
+ # @param opts [Hash] A hash of options defined in #allowed_initialized_opts
13
+ # and managed by the SetOps mixin within the Action::Base class.
14
+ # Corresponds to the CLI flags and options.
15
+ # @param argv [Enumerable] Typically CRI::ArgumentList or Array. A list-like
16
+ # collection of the remaining arguments to the CLI invocation (after
17
+ # removing flags and options).
18
+ # @param settings [Hash] A hash of configuration loaded from the relevant
19
+ # config (r10k.yaml).
20
+ #
21
+ # @note All arguments will be required in the next major version
22
+ def initialize(opts, argv, settings = {})
23
+ super
24
+
25
+ @settings = @settings.merge({
26
+ overrides: {
27
+ environments: {
28
+ preload_environments: @fetch,
29
+ requested_environments: @argv.map { |arg| arg.gsub(/\W/, '_') }
30
+ },
31
+ modules: {},
32
+ output: {
33
+ format: @format,
34
+ trace: @trace,
35
+ detail: @detail
36
+ },
37
+ purging: {}
38
+ }
39
+ })
40
+ end
41
+
12
42
  def call
13
43
  expect_config!
14
44
  deployment = R10K::Deployment.new(@settings)
15
45
 
16
- if @fetch
46
+ if @settings.dig(:overrides, :environments, :preload_environments)
17
47
  deployment.preload!
48
+ deployment.validate!
18
49
  end
19
50
 
20
- output = { :sources => deployment.sources.map { |source| source_info(source, @argv) } }
51
+ output = { :sources => deployment.sources.map { |source| source_info(source, @settings.dig(:overrides, :environments, :requested_environments)) } }
21
52
 
22
- case @format
53
+ case @settings.dig(:overrides, :output, :format)
23
54
  when 'json' then json_format(output)
24
55
  else yaml_format(output)
25
56
  end
@@ -27,7 +58,7 @@ module R10K
27
58
  # exit 0
28
59
  true
29
60
  rescue => e
30
- logger.error R10K::Errors::Formatting.format_exception(e, @trace)
61
+ logger.error R10K::Errors::Formatting.format_exception(e, @settings.dig(:overrides, :output, :trace))
31
62
  false
32
63
  end
33
64
 
@@ -43,7 +74,7 @@ module R10K
43
74
  puts output.to_yaml
44
75
  end
45
76
 
46
- def source_info(source, argv=[])
77
+ def source_info(source, requested_environments = [])
47
78
  source_info = {
48
79
  :name => source.name,
49
80
  :basedir => source.basedir,
@@ -52,28 +83,30 @@ module R10K
52
83
  source_info[:prefix] = source.prefix if source.prefix
53
84
  source_info[:remote] = source.remote if source.respond_to?(:remote)
54
85
 
55
- env_list = source.environments.select { |env| argv.empty? || argv.include?(env.name) }
86
+ select_all_envs = requested_environments.empty?
87
+ env_list = source.environments.select { |env| select_all_envs || requested_environments.include?(env.name) }
56
88
  source_info[:environments] = env_list.map { |env| environment_info(env) }
57
89
 
58
90
  source_info
59
91
  end
60
92
 
61
93
  def environment_info(env)
62
- if !@modules && !@detail
94
+ modules = @settings.dig(:overrides, :environments, :deploy_modules)
95
+ if !modules && !@settings.dig(:overrides, :output, :detail)
63
96
  env.dirname
64
97
  else
65
98
  env_info = env.info.merge({
66
99
  :status => (env.status rescue nil),
67
100
  })
68
101
 
69
- env_info[:modules] = env.modules.map { |mod| module_info(mod) } if @modules
102
+ env_info[:modules] = env.modules.map { |mod| module_info(mod) } if modules
70
103
 
71
104
  env_info
72
105
  end
73
106
  end
74
107
 
75
108
  def module_info(mod)
76
- if @detail
109
+ if @settings.dig(:overrides, :output, :detail)
77
110
  { :name => mod.title, :properties => mod.properties }
78
111
  else
79
112
  mod.title
@@ -1,4 +1,5 @@
1
1
  require 'r10k/util/setopts'
2
+ require 'r10k/util/cleaner'
2
3
  require 'r10k/deployment'
3
4
  require 'r10k/logging'
4
5
  require 'r10k/action/visitor'
@@ -13,30 +14,64 @@ module R10K
13
14
 
14
15
  include R10K::Action::Deploy::DeployHelpers
15
16
 
17
+ # Deprecated
16
18
  attr_reader :force
17
19
 
18
- def initialize(opts, argv, settings = nil)
19
- settings ||= {}
20
- @purge_levels = settings.fetch(:deploy, {}).fetch(:purge_levels, [])
21
- @user_purge_allowlist = read_purge_allowlist(settings.fetch(:deploy, {}).fetch(:purge_whitelist, []),
22
- settings.fetch(:deploy, {}).fetch(:purge_allowlist, []))
23
- @generate_types = settings.fetch(:deploy, {}).fetch(:generate_types, false)
24
-
20
+ attr_reader :settings
21
+
22
+ # @param opts [Hash] A hash of options defined in #allowed_initialized_opts
23
+ # and managed by the SetOps mixin within the Action::Base class.
24
+ # Corresponds to the CLI flags and options.
25
+ # @param argv [Enumerable] Typically CRI::ArgumentList or Array. A list-like
26
+ # collection of the remaining arguments to the CLI invocation (after
27
+ # removing flags and options).
28
+ # @param settings [Hash] A hash of configuration loaded from the relevant
29
+ # config (r10k.yaml).
30
+ #
31
+ # @note All arguments will be required in the next major version
32
+ def initialize(opts, argv, settings = {})
25
33
  super
26
34
 
27
- # @force here is used to make it easier to reason about
28
- @force = !@no_force
29
- @argv = @argv.map { |arg| arg.gsub(/\W/,'_') }
35
+ # instance variables below are set by the super class based on the
36
+ # spec of #allowed_initialize_opts and any command line flags. This
37
+ # gives a preference order of cli flags > config files > defaults.
38
+ @settings = @settings.merge({
39
+ overrides: {
40
+ environments: {
41
+ requested_environments: @argv.map { |arg| arg.gsub(/\W/,'_') },
42
+ default_branch_override: @default_branch_override,
43
+ generate_types: @generate_types || settings.dig(:deploy, :generate_types) || false,
44
+ preload_environments: true
45
+ },
46
+ modules: {
47
+ requested_modules: [],
48
+ deploy_modules: @modules,
49
+ force: !@no_force, # force here is used to make it easier to reason about
50
+ },
51
+ purging: {
52
+ purge_levels: settings.dig(:deploy, :purge_levels) || [],
53
+ purge_allowlist: read_purge_allowlist(settings.dig(:deploy, :purge_whitelist) || [],
54
+ settings.dig(:deploy, :purge_allowlist) || [])
55
+ },
56
+ output: {}
57
+ }
58
+ })
30
59
  end
31
60
 
32
61
  def call
33
62
  @visit_ok = true
34
63
 
35
- expect_config!
36
- deployment = R10K::Deployment.new(@settings)
37
- check_write_lock!(@settings)
64
+ begin
65
+ expect_config!
66
+ deployment = R10K::Deployment.new(@settings)
67
+ check_write_lock!(@settings)
68
+
69
+ deployment.accept(self)
70
+ rescue => e
71
+ @visit_ok = false
72
+ logger.error R10K::Errors::Formatting.format_exception(e, @trace)
73
+ end
38
74
 
39
- deployment.accept(self)
40
75
  @visit_ok
41
76
  end
42
77
 
@@ -66,10 +101,12 @@ module R10K
66
101
  # sources then we can't fully enumerate all environments which
67
102
  # could be dangerous. If this fails then an exception will be raised
68
103
  # and execution will be halted.
69
- deployment.preload!
70
- deployment.validate!
104
+ if @settings.dig(:overrides, :environments, :preload_environments)
105
+ deployment.preload!
106
+ deployment.validate!
107
+ end
71
108
 
72
- undeployable = undeployable_environment_names(deployment.environments, @argv)
109
+ undeployable = undeployable_environment_names(deployment.environments, @settings.dig(:overrides, :environments, :requested_environments))
73
110
  if !undeployable.empty?
74
111
  @visit_ok = false
75
112
  logger.error _("Environment(s) \'%{environments}\' cannot be found in any source and will not be deployed.") % {environments: undeployable.join(", ")}
@@ -77,15 +114,19 @@ module R10K
77
114
 
78
115
  yield
79
116
 
80
- if @purge_levels.include?(:deployment)
117
+ if @settings.dig(:overrides, :purging, :purge_levels).include?(:deployment)
81
118
  logger.debug("Purging unmanaged environments for deployment...")
119
+ deployment.sources.each do |source|
120
+ source.reload!
121
+ end
82
122
  deployment.purge!
83
123
  end
84
124
  ensure
85
125
  if (postcmd = @settings[:postrun])
86
126
  if postcmd.grep('$modifiedenvs').any?
87
127
  envs = deployment.environments.map { |e| e.dirname }
88
- envs.reject! { |e| !@argv.include?(e) } if @argv.any?
128
+ requested_envs = @settings.dig(:overrides, :environments, :requested_environments)
129
+ envs.reject! { |e| !requested_envs.include?(e) } if requested_envs.any?
89
130
  postcmd = postcmd.map { |e| e.gsub('$modifiedenvs', envs.join(' ')) }
90
131
  end
91
132
  subproc = R10K::Util::Subprocess.new(postcmd)
@@ -99,7 +140,8 @@ module R10K
99
140
  end
100
141
 
101
142
  def visit_environment(environment)
102
- if !(@argv.empty? || @argv.any? { |name| environment.dirname == name })
143
+ requested_envs = @settings.dig(:overrides, :environments, :requested_environments)
144
+ if !(requested_envs.empty? || requested_envs.any? { |name| environment.dirname == name })
103
145
  logger.debug1(_("Environment %{env_dir} does not match environment name filter, skipping") % {env_dir: environment.dirname})
104
146
  return
105
147
  end
@@ -113,28 +155,31 @@ module R10K
113
155
  environment.sync
114
156
  logger.info _("Environment %{env_dir} is now at %{env_signature}") % {env_dir: environment.dirname, env_signature: environment.signature}
115
157
 
116
- if status == :absent || @modules
158
+ if status == :absent || @settings.dig(:overrides, :modules, :deploy_modules)
117
159
  if status == :absent
118
160
  logger.debug(_("Environment %{env_dir} is new, updating all modules") % {env_dir: environment.dirname})
119
161
  end
120
162
 
121
163
  previous_ok = @visit_ok
122
164
  @visit_ok = true
123
- yield
165
+
166
+ environment.deploy
167
+
124
168
  @environment_ok = @visit_ok
125
169
  @visit_ok &&= previous_ok
126
170
  end
127
171
 
128
- if @purge_levels.include?(:environment)
172
+
173
+ if @settings.dig(:overrides, :purging, :purge_levels).include?(:environment)
129
174
  if @visit_ok
130
175
  logger.debug("Purging unmanaged content for environment '#{environment.dirname}'...")
131
- environment.purge!(:recurse => true, :whitelist => environment.whitelist(@user_purge_allowlist))
176
+ environment.purge!(:recurse => true, :whitelist => environment.whitelist(@settings.dig(:overrides, :purging, :purge_allowlist)))
132
177
  else
133
178
  logger.debug("Not purging unmanaged content for environment '#{environment.dirname}' due to prior deploy failures.")
134
179
  end
135
180
  end
136
181
 
137
- if @generate_types
182
+ if @settings.dig(:overrides, :environments, :generate_types)
138
183
  if @environment_ok
139
184
  logger.debug("Generating puppet types for environment '#{environment.dirname}'...")
140
185
  environment.generate_types!
@@ -146,22 +191,6 @@ module R10K
146
191
  write_environment_info!(environment, started_at, @visit_ok)
147
192
  end
148
193
 
149
- def visit_puppetfile(puppetfile)
150
- puppetfile.load(@opts[:'default-branch-override'])
151
-
152
- yield
153
-
154
- if @purge_levels.include?(:puppetfile)
155
- logger.debug("Purging unmanaged Puppetfile content for environment '#{puppetfile.environment.dirname}'...")
156
- puppetfile.purge!
157
- end
158
- end
159
-
160
- def visit_module(mod)
161
- logger.info _("Deploying %{origin} content %{path}") % {origin: mod.origin, path: mod.path}
162
- mod.sync(force: @force)
163
- end
164
-
165
194
  def write_environment_info!(environment, started_at, success)
166
195
  module_deploys =
167
196
  begin