r10k 3.5.2 → 3.9.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/pull_request_template.md +4 -1
- data/.github/workflows/docker.yml +4 -1
- data/.github/workflows/release.yml +3 -2
- data/.github/workflows/rspec_tests.yml +81 -0
- data/.github/workflows/stale.yml +19 -0
- data/.travis.yml +8 -1
- data/CHANGELOG.mkd +43 -1
- data/CODEOWNERS +2 -2
- data/README.mkd +13 -4
- data/doc/common-patterns.mkd +1 -0
- data/doc/dynamic-environments/configuration.mkd +149 -45
- data/doc/dynamic-environments/usage.mkd +12 -11
- data/doc/puppetfile.mkd +23 -3
- data/docker/Gemfile +1 -1
- data/docker/Makefile +7 -4
- data/docker/docker-compose.yml +18 -0
- data/docker/r10k/Dockerfile +4 -3
- data/docker/r10k/docker-entrypoint.sh +0 -1
- data/docker/r10k/release.Dockerfile +3 -2
- data/docker/spec/dockerfile_spec.rb +26 -32
- data/integration/tests/git_source/git_source_repeated_remote.rb +68 -0
- data/integration/tests/user_scenario/basic_workflow/multi_env_custom_forge_git_module.rb +2 -1
- data/integration/tests/user_scenario/basic_workflow/multi_env_custom_forge_git_module_static.rb +2 -1
- data/integration/tests/user_scenario/basic_workflow/multi_source_custom_forge_git_module.rb +1 -1
- data/integration/tests/user_scenario/basic_workflow/single_env_custom_forge_git_module.rb +2 -1
- data/integration/tests/user_scenario/complex_workflow/multi_env_add_change_remove.rb +1 -1
- data/integration/tests/user_scenario/complex_workflow/multi_env_remove_re-add.rb +1 -1
- data/integration/tests/user_scenario/complex_workflow/multi_env_unamanaged.rb +1 -1
- data/lib/r10k/action/base.rb +8 -1
- data/lib/r10k/action/deploy/display.rb +46 -10
- data/lib/r10k/action/deploy/environment.rb +98 -50
- data/lib/r10k/action/deploy/module.rb +51 -29
- data/lib/r10k/action/puppetfile/check.rb +3 -1
- data/lib/r10k/action/puppetfile/install.rb +20 -23
- data/lib/r10k/action/puppetfile/purge.rb +8 -2
- data/lib/r10k/action/runner.rb +34 -0
- data/lib/r10k/cli/deploy.rb +14 -7
- data/lib/r10k/cli/puppetfile.rb +5 -5
- data/lib/r10k/content_synchronizer.rb +83 -0
- data/lib/r10k/deployment.rb +1 -1
- data/lib/r10k/environment/base.rb +30 -3
- data/lib/r10k/environment/git.rb +17 -5
- data/lib/r10k/environment/name.rb +22 -4
- data/lib/r10k/environment/svn.rb +11 -4
- data/lib/r10k/environment/with_modules.rb +46 -30
- data/lib/r10k/git.rb +1 -0
- data/lib/r10k/git/cache.rb +12 -4
- data/lib/r10k/git/rugged/credentials.rb +39 -2
- data/lib/r10k/git/stateful_repository.rb +4 -0
- data/lib/r10k/initializers.rb +2 -0
- data/lib/r10k/module.rb +1 -1
- data/lib/r10k/module/base.rb +25 -1
- data/lib/r10k/module/forge.rb +29 -11
- data/lib/r10k/module/git.rb +54 -27
- data/lib/r10k/module/local.rb +2 -1
- data/lib/r10k/module/svn.rb +24 -18
- data/lib/r10k/puppetfile.rb +75 -72
- data/lib/r10k/settings.rb +30 -3
- data/lib/r10k/source/base.rb +9 -0
- data/lib/r10k/source/git.rb +40 -9
- data/lib/r10k/source/hash.rb +5 -5
- data/lib/r10k/source/svn.rb +5 -3
- data/lib/r10k/util/cleaner.rb +21 -0
- data/lib/r10k/util/setopts.rb +33 -12
- data/lib/r10k/version.rb +1 -1
- data/locales/r10k.pot +103 -83
- data/r10k.gemspec +1 -1
- data/spec/fixtures/unit/action/r10k_creds.yaml +9 -0
- data/spec/r10k-mocks/mock_source.rb +1 -1
- data/spec/shared-examples/puppetfile-action.rb +7 -7
- data/spec/shared-examples/subprocess-runner.rb +11 -5
- data/spec/unit/action/deploy/display_spec.rb +35 -5
- data/spec/unit/action/deploy/environment_spec.rb +207 -37
- data/spec/unit/action/deploy/module_spec.rb +173 -26
- data/spec/unit/action/puppetfile/check_spec.rb +2 -2
- data/spec/unit/action/puppetfile/install_spec.rb +32 -10
- data/spec/unit/action/puppetfile/purge_spec.rb +25 -5
- data/spec/unit/action/runner_spec.rb +48 -1
- data/spec/unit/environment/git_spec.rb +19 -2
- data/spec/unit/environment/name_spec.rb +28 -0
- data/spec/unit/environment/svn_spec.rb +12 -0
- data/spec/unit/environment/with_modules_spec.rb +74 -0
- data/spec/unit/git/cache_spec.rb +10 -0
- data/spec/unit/git/rugged/credentials_spec.rb +79 -2
- data/spec/unit/git_spec.rb +3 -3
- data/spec/unit/module/forge_spec.rb +21 -13
- data/spec/unit/module/git_spec.rb +64 -1
- data/spec/unit/module_spec.rb +60 -10
- data/spec/unit/puppetfile_spec.rb +98 -30
- data/spec/unit/settings_spec.rb +12 -0
- data/spec/unit/source/git_spec.rb +49 -1
- data/spec/unit/util/purgeable_spec.rb +2 -8
- data/spec/unit/util/setopts_spec.rb +25 -1
- metadata +12 -11
- data/azure-pipelines.yml +0 -86
@@ -9,17 +9,45 @@ 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 [CRI::ArgumentList] A list-like collection of the remaining
|
16
|
+
# arguments to the CLI invocation (after removing flags and options).
|
17
|
+
# @param settings [Hash] A hash of configuration loaded from the relevant
|
18
|
+
# config (r10k.yaml).
|
19
|
+
def initialize(opts, argv, settings)
|
20
|
+
super
|
21
|
+
|
22
|
+
@settings = @settings.merge({
|
23
|
+
overrides: {
|
24
|
+
environments: {
|
25
|
+
preload_environments: @fetch,
|
26
|
+
requested_environments: @argv.map { |arg| arg.gsub(/\W/, '_') }
|
27
|
+
},
|
28
|
+
modules: {},
|
29
|
+
output: {
|
30
|
+
format: @format,
|
31
|
+
trace: @trace,
|
32
|
+
detail: @detail
|
33
|
+
},
|
34
|
+
purging: {}
|
35
|
+
}
|
36
|
+
})
|
37
|
+
end
|
38
|
+
|
12
39
|
def call
|
13
40
|
expect_config!
|
14
41
|
deployment = R10K::Deployment.new(@settings)
|
15
42
|
|
16
|
-
if @
|
43
|
+
if @settings.dig(:overrides, :environments, :preload_environments)
|
17
44
|
deployment.preload!
|
45
|
+
deployment.validate!
|
18
46
|
end
|
19
47
|
|
20
|
-
output = { :sources => deployment.sources.map { |source| source_info(source, @
|
48
|
+
output = { :sources => deployment.sources.map { |source| source_info(source, @settings.dig(:overrides, :environments, :requested_environments)) } }
|
21
49
|
|
22
|
-
case @format
|
50
|
+
case @settings.dig(:overrides, :output, :format)
|
23
51
|
when 'json' then json_format(output)
|
24
52
|
else yaml_format(output)
|
25
53
|
end
|
@@ -27,7 +55,7 @@ module R10K
|
|
27
55
|
# exit 0
|
28
56
|
true
|
29
57
|
rescue => e
|
30
|
-
logger.error R10K::Errors::Formatting.format_exception(e, @trace)
|
58
|
+
logger.error R10K::Errors::Formatting.format_exception(e, @settings.dig(:overrides, :output, :trace))
|
31
59
|
false
|
32
60
|
end
|
33
61
|
|
@@ -43,7 +71,7 @@ module R10K
|
|
43
71
|
puts output.to_yaml
|
44
72
|
end
|
45
73
|
|
46
|
-
def source_info(source,
|
74
|
+
def source_info(source, requested_environments = [])
|
47
75
|
source_info = {
|
48
76
|
:name => source.name,
|
49
77
|
:basedir => source.basedir,
|
@@ -52,28 +80,30 @@ module R10K
|
|
52
80
|
source_info[:prefix] = source.prefix if source.prefix
|
53
81
|
source_info[:remote] = source.remote if source.respond_to?(:remote)
|
54
82
|
|
55
|
-
|
83
|
+
select_all_envs = requested_environments.empty?
|
84
|
+
env_list = source.environments.select { |env| select_all_envs || requested_environments.include?(env.name) }
|
56
85
|
source_info[:environments] = env_list.map { |env| environment_info(env) }
|
57
86
|
|
58
87
|
source_info
|
59
88
|
end
|
60
89
|
|
61
90
|
def environment_info(env)
|
62
|
-
|
91
|
+
modules = @settings.dig(:overrides, :environments, :deploy_modules)
|
92
|
+
if !modules && !@settings.dig(:overrides, :output, :detail)
|
63
93
|
env.dirname
|
64
94
|
else
|
65
95
|
env_info = env.info.merge({
|
66
96
|
:status => (env.status rescue nil),
|
67
97
|
})
|
68
98
|
|
69
|
-
env_info[:modules] = env.modules.map { |mod| module_info(mod) } if
|
99
|
+
env_info[:modules] = env.modules.map { |mod| module_info(mod) } if modules
|
70
100
|
|
71
101
|
env_info
|
72
102
|
end
|
73
103
|
end
|
74
104
|
|
75
105
|
def module_info(mod)
|
76
|
-
if @detail
|
106
|
+
if @settings.dig(:overrides, :output, :detail)
|
77
107
|
{ :name => mod.title, :properties => mod.properties }
|
78
108
|
else
|
79
109
|
mod.title
|
@@ -81,7 +111,13 @@ module R10K
|
|
81
111
|
end
|
82
112
|
|
83
113
|
def allowed_initialize_opts
|
84
|
-
super.merge(
|
114
|
+
super.merge({
|
115
|
+
puppetfile: :modules,
|
116
|
+
modules: :self,
|
117
|
+
detail: :self,
|
118
|
+
format: :self,
|
119
|
+
fetch: :self
|
120
|
+
})
|
85
121
|
end
|
86
122
|
end
|
87
123
|
end
|
@@ -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,29 +14,61 @@ module R10K
|
|
13
14
|
|
14
15
|
include R10K::Action::Deploy::DeployHelpers
|
15
16
|
|
17
|
+
# Deprecated
|
16
18
|
attr_reader :force
|
17
19
|
|
18
|
-
|
19
|
-
settings ||= {}
|
20
|
-
@purge_levels = settings.fetch(:deploy, {}).fetch(:purge_levels, [])
|
21
|
-
@user_purge_whitelist = settings.fetch(:deploy, {}).fetch(:purge_whitelist, [])
|
22
|
-
@generate_types = settings.fetch(:deploy, {}).fetch(:generate_types, false)
|
20
|
+
attr_reader :settings
|
23
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 [CRI::ArgumentList] A list-like collection of the remaining
|
26
|
+
# arguments to the CLI invocation (after removing flags and options).
|
27
|
+
# @param settings [Hash] A hash of configuration loaded from the relevant
|
28
|
+
# config (r10k.yaml).
|
29
|
+
def initialize(opts, argv, settings)
|
24
30
|
super
|
25
31
|
|
26
|
-
#
|
27
|
-
|
28
|
-
|
32
|
+
# instance variables below are set by the super class based on the
|
33
|
+
# spec of #allowed_initialize_opts and any command line flags. This
|
34
|
+
# gives a preference order of cli flags > config files > defaults.
|
35
|
+
@settings = @settings.merge({
|
36
|
+
overrides: {
|
37
|
+
environments: {
|
38
|
+
requested_environments: @argv.map { |arg| arg.gsub(/\W/,'_') },
|
39
|
+
default_branch_override: @default_branch_override,
|
40
|
+
generate_types: @generate_types || settings.dig(:deploy, :generate_types) || false,
|
41
|
+
preload_environments: true
|
42
|
+
},
|
43
|
+
modules: {
|
44
|
+
requested_modules: [],
|
45
|
+
deploy_modules: @modules,
|
46
|
+
force: !@no_force, # force here is used to make it easier to reason about
|
47
|
+
},
|
48
|
+
purging: {
|
49
|
+
purge_levels: settings.dig(:deploy, :purge_levels) || [],
|
50
|
+
purge_allowlist: read_purge_allowlist(settings.dig(:deploy, :purge_whitelist) || [],
|
51
|
+
settings.dig(:deploy, :purge_allowlist) || [])
|
52
|
+
},
|
53
|
+
output: {}
|
54
|
+
}
|
55
|
+
})
|
29
56
|
end
|
30
57
|
|
31
58
|
def call
|
32
59
|
@visit_ok = true
|
33
60
|
|
34
|
-
|
35
|
-
|
36
|
-
|
61
|
+
begin
|
62
|
+
expect_config!
|
63
|
+
deployment = R10K::Deployment.new(@settings)
|
64
|
+
check_write_lock!(@settings)
|
65
|
+
|
66
|
+
deployment.accept(self)
|
67
|
+
rescue => e
|
68
|
+
@visit_ok = false
|
69
|
+
logger.error R10K::Errors::Formatting.format_exception(e, @trace)
|
70
|
+
end
|
37
71
|
|
38
|
-
deployment.accept(self)
|
39
72
|
@visit_ok
|
40
73
|
end
|
41
74
|
|
@@ -43,15 +76,34 @@ module R10K
|
|
43
76
|
|
44
77
|
private
|
45
78
|
|
79
|
+
def read_purge_allowlist (whitelist, allowlist)
|
80
|
+
whitelist_has_content = !whitelist.empty?
|
81
|
+
allowlist_has_content = !allowlist.empty?
|
82
|
+
case
|
83
|
+
when whitelist_has_content == false && allowlist_has_content == false
|
84
|
+
[]
|
85
|
+
when whitelist_has_content && allowlist_has_content
|
86
|
+
raise R10K::Error.new "Values found for both purge_whitelist and purge_allowlist. Setting " <<
|
87
|
+
"purge_whitelist is deprecated, please only use purge_allowlist."
|
88
|
+
when allowlist_has_content
|
89
|
+
allowlist
|
90
|
+
else
|
91
|
+
logger.warn "Setting purge_whitelist is deprecated; please use purge_allowlist instead."
|
92
|
+
whitelist
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
46
96
|
def visit_deployment(deployment)
|
47
97
|
# Ensure that everything can be preloaded. If we cannot preload all
|
48
98
|
# sources then we can't fully enumerate all environments which
|
49
99
|
# could be dangerous. If this fails then an exception will be raised
|
50
100
|
# and execution will be halted.
|
51
|
-
|
52
|
-
|
101
|
+
if @settings.dig(:overrides, :environments, :preload_environments)
|
102
|
+
deployment.preload!
|
103
|
+
deployment.validate!
|
104
|
+
end
|
53
105
|
|
54
|
-
undeployable = undeployable_environment_names(deployment.environments, @
|
106
|
+
undeployable = undeployable_environment_names(deployment.environments, @settings.dig(:overrides, :environments, :requested_environments))
|
55
107
|
if !undeployable.empty?
|
56
108
|
@visit_ok = false
|
57
109
|
logger.error _("Environment(s) \'%{environments}\' cannot be found in any source and will not be deployed.") % {environments: undeployable.join(", ")}
|
@@ -59,7 +111,7 @@ module R10K
|
|
59
111
|
|
60
112
|
yield
|
61
113
|
|
62
|
-
if @purge_levels.include?(:deployment)
|
114
|
+
if @settings.dig(:overrides, :purging, :purge_levels).include?(:deployment)
|
63
115
|
logger.debug("Purging unmanaged environments for deployment...")
|
64
116
|
deployment.purge!
|
65
117
|
end
|
@@ -67,7 +119,8 @@ module R10K
|
|
67
119
|
if (postcmd = @settings[:postrun])
|
68
120
|
if postcmd.grep('$modifiedenvs').any?
|
69
121
|
envs = deployment.environments.map { |e| e.dirname }
|
70
|
-
|
122
|
+
requested_envs = @settings.dig(:overrides, :environments, :requested_environments)
|
123
|
+
envs.reject! { |e| !requested_envs.include?(e) } if requested_envs.any?
|
71
124
|
postcmd = postcmd.map { |e| e.gsub('$modifiedenvs', envs.join(' ')) }
|
72
125
|
end
|
73
126
|
subproc = R10K::Util::Subprocess.new(postcmd)
|
@@ -81,7 +134,8 @@ module R10K
|
|
81
134
|
end
|
82
135
|
|
83
136
|
def visit_environment(environment)
|
84
|
-
|
137
|
+
requested_envs = @settings.dig(:overrides, :environments, :requested_environments)
|
138
|
+
if !(requested_envs.empty? || requested_envs.any? { |name| environment.dirname == name })
|
85
139
|
logger.debug1(_("Environment %{env_dir} does not match environment name filter, skipping") % {env_dir: environment.dirname})
|
86
140
|
return
|
87
141
|
end
|
@@ -95,28 +149,31 @@ module R10K
|
|
95
149
|
environment.sync
|
96
150
|
logger.info _("Environment %{env_dir} is now at %{env_signature}") % {env_dir: environment.dirname, env_signature: environment.signature}
|
97
151
|
|
98
|
-
if status == :absent || @
|
152
|
+
if status == :absent || @settings.dig(:overrides, :modules, :deploy_modules)
|
99
153
|
if status == :absent
|
100
154
|
logger.debug(_("Environment %{env_dir} is new, updating all modules") % {env_dir: environment.dirname})
|
101
155
|
end
|
102
156
|
|
103
157
|
previous_ok = @visit_ok
|
104
158
|
@visit_ok = true
|
105
|
-
|
159
|
+
|
160
|
+
environment.deploy
|
161
|
+
|
106
162
|
@environment_ok = @visit_ok
|
107
163
|
@visit_ok &&= previous_ok
|
108
164
|
end
|
109
165
|
|
110
|
-
|
166
|
+
|
167
|
+
if @settings.dig(:overrides, :purging, :purge_levels).include?(:environment)
|
111
168
|
if @visit_ok
|
112
169
|
logger.debug("Purging unmanaged content for environment '#{environment.dirname}'...")
|
113
|
-
environment.purge!(:recurse => true, :whitelist => environment.whitelist(@
|
170
|
+
environment.purge!(:recurse => true, :whitelist => environment.whitelist(@settings.dig(:overrides, :purging, :purge_allowlist)))
|
114
171
|
else
|
115
172
|
logger.debug("Not purging unmanaged content for environment '#{environment.dirname}' due to prior deploy failures.")
|
116
173
|
end
|
117
174
|
end
|
118
175
|
|
119
|
-
if @generate_types
|
176
|
+
if @settings.dig(:overrides, :environments, :generate_types)
|
120
177
|
if @environment_ok
|
121
178
|
logger.debug("Generating puppet types for environment '#{environment.dirname}'...")
|
122
179
|
environment.generate_types!
|
@@ -128,34 +185,21 @@ module R10K
|
|
128
185
|
write_environment_info!(environment, started_at, @visit_ok)
|
129
186
|
end
|
130
187
|
|
131
|
-
def visit_puppetfile(puppetfile)
|
132
|
-
puppetfile.load(@opts[:'default-branch-override'])
|
133
|
-
|
134
|
-
yield
|
135
|
-
|
136
|
-
if @purge_levels.include?(:puppetfile)
|
137
|
-
logger.debug("Purging unmanaged Puppetfile content for environment '#{puppetfile.environment.dirname}'...")
|
138
|
-
puppetfile.purge!
|
139
|
-
end
|
140
|
-
end
|
141
|
-
|
142
|
-
def visit_module(mod)
|
143
|
-
logger.info _("Deploying %{origin} content %{path}") % {origin: mod.origin, path: mod.path}
|
144
|
-
mod.sync(force: @force)
|
145
|
-
end
|
146
|
-
|
147
188
|
def write_environment_info!(environment, started_at, success)
|
148
|
-
module_deploys =
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
189
|
+
module_deploys =
|
190
|
+
begin
|
191
|
+
environment.modules.map do |mod|
|
192
|
+
props = mod.properties
|
193
|
+
{
|
194
|
+
name: mod.name,
|
195
|
+
version: props[:expected],
|
196
|
+
sha: props[:type] == :git ? props[:actual] : nil
|
197
|
+
}
|
198
|
+
end
|
199
|
+
rescue
|
200
|
+
logger.debug("Unable to get environment module deploy data for .r10k-deploy.json at #{environment.path}")
|
201
|
+
[]
|
155
202
|
end
|
156
|
-
rescue
|
157
|
-
logger.debug("Unable to get environment module deploy data for .r10k-deploy.json at #{environment.path}")
|
158
|
-
end
|
159
203
|
|
160
204
|
# make this file write as atomic as possible in pure ruby
|
161
205
|
final = "#{environment.path}/.r10k-deploy.json"
|
@@ -183,11 +227,15 @@ module R10K
|
|
183
227
|
end
|
184
228
|
|
185
229
|
def allowed_initialize_opts
|
186
|
-
super.merge(puppetfile: :
|
230
|
+
super.merge(puppetfile: :modules,
|
231
|
+
modules: :self,
|
187
232
|
cachedir: :self,
|
188
233
|
'no-force': :self,
|
189
234
|
'generate-types': :self,
|
190
235
|
'puppet-path': :self,
|
236
|
+
'puppet-conf': :self,
|
237
|
+
'private-key': :self,
|
238
|
+
'oauth-token': :self,
|
191
239
|
'default-branch-override': :self)
|
192
240
|
end
|
193
241
|
end
|
@@ -10,25 +10,53 @@ module R10K
|
|
10
10
|
|
11
11
|
include R10K::Action::Deploy::DeployHelpers
|
12
12
|
|
13
|
+
# Deprecated
|
13
14
|
attr_reader :force
|
14
15
|
|
15
|
-
|
16
|
-
settings ||= {}
|
16
|
+
attr_reader :settings
|
17
17
|
|
18
|
+
# @param opts [Hash] A hash of options defined in #allowed_initialized_opts
|
19
|
+
# and managed by the SetOps mixin within the Action::Base class.
|
20
|
+
# Corresponds to the CLI flags and options.
|
21
|
+
# @param argv [CRI::ArgumentList] A list-like collection of the remaining
|
22
|
+
# arguments to the CLI invocation (after removing flags and options).
|
23
|
+
# @param settings [Hash] A hash of configuration loaded from the relevant
|
24
|
+
# config (r10k.yaml).
|
25
|
+
def initialize(opts, argv, settings)
|
18
26
|
super
|
19
27
|
|
20
|
-
|
21
|
-
|
28
|
+
requested_env = @opts[:environment] ? [@opts[:environment].gsub(/\W/, '_')] : []
|
29
|
+
|
30
|
+
@settings = @settings.merge({
|
31
|
+
overrides: {
|
32
|
+
environments: {
|
33
|
+
requested_environments: requested_env,
|
34
|
+
generate_types: @generate_types
|
35
|
+
},
|
36
|
+
modules: {
|
37
|
+
requested_modules: @argv.map.to_a,
|
38
|
+
# force here is used to make it easier to reason about
|
39
|
+
force: !@no_force
|
40
|
+
},
|
41
|
+
purging: {},
|
42
|
+
output: {}
|
43
|
+
}
|
44
|
+
})
|
22
45
|
end
|
23
46
|
|
24
47
|
def call
|
25
48
|
@visit_ok = true
|
49
|
+
begin
|
50
|
+
expect_config!
|
51
|
+
deployment = R10K::Deployment.new(@settings)
|
52
|
+
check_write_lock!(@settings)
|
53
|
+
|
54
|
+
deployment.accept(self)
|
55
|
+
rescue => e
|
56
|
+
@visit_ok = false
|
57
|
+
logger.error R10K::Errors::Formatting.format_exception(e, @trace)
|
58
|
+
end
|
26
59
|
|
27
|
-
expect_config!
|
28
|
-
deployment = R10K::Deployment.new(@settings)
|
29
|
-
check_write_lock!(@settings)
|
30
|
-
|
31
|
-
deployment.accept(self)
|
32
60
|
@visit_ok
|
33
61
|
end
|
34
62
|
|
@@ -45,29 +73,20 @@ module R10K
|
|
45
73
|
end
|
46
74
|
|
47
75
|
def visit_environment(environment)
|
48
|
-
|
49
|
-
|
76
|
+
requested_envs = @settings.dig(:overrides, :environments, :requested_environments)
|
77
|
+
if !requested_envs.empty? && !requested_envs.include?(environment.dirname)
|
78
|
+
logger.debug1(_("Only updating modules in environment(s) %{opt_env} skipping environment %{env_path}") % {opt_env: requested_envs.inspect, env_path: environment.path})
|
50
79
|
else
|
51
|
-
logger.debug1(_("Updating modules %{modules} in environment %{env_path}") % {modules: @
|
52
|
-
yield
|
53
|
-
end
|
54
|
-
end
|
80
|
+
logger.debug1(_("Updating modules %{modules} in environment %{env_path}") % {modules: @settings.dig(:overrides, :modules, :requested_modules).inspect, env_path: environment.path})
|
55
81
|
|
56
|
-
|
57
|
-
puppetfile.load
|
58
|
-
yield
|
59
|
-
end
|
82
|
+
environment.deploy
|
60
83
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
logger.debug("Generating puppet types for environment '#{mod.environment.dirname}'...")
|
67
|
-
mod.environment.generate_types!
|
84
|
+
requested_mods = @settings.dig(:overrides, :modules, :requested_modules) || []
|
85
|
+
generate_types = @settings.dig(:overrides, :environments, :generate_types)
|
86
|
+
if generate_types && !((environment.modules.map(&:name) & requested_mods).empty?)
|
87
|
+
logger.debug("Generating puppet types for environment '#{environment.dirname}'...")
|
88
|
+
environment.generate_types!
|
68
89
|
end
|
69
|
-
else
|
70
|
-
logger.debug1(_("Only updating modules %{modules}, skipping module %{mod_name}") % {modules: @argv.inspect, mod_name: mod.name})
|
71
90
|
end
|
72
91
|
end
|
73
92
|
|
@@ -76,7 +95,10 @@ module R10K
|
|
76
95
|
cachedir: :self,
|
77
96
|
'no-force': :self,
|
78
97
|
'generate-types': :self,
|
79
|
-
'puppet-path': :self
|
98
|
+
'puppet-path': :self,
|
99
|
+
'puppet-conf': :self,
|
100
|
+
'private-key': :self,
|
101
|
+
'oauth-token': :self)
|
80
102
|
end
|
81
103
|
end
|
82
104
|
end
|