r10k 3.6.0 → 3.9.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- 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 +33 -0
- data/CODEOWNERS +2 -2
- data/README.mkd +2 -2
- data/doc/common-patterns.mkd +1 -0
- data/doc/dynamic-environments/configuration.mkd +123 -42
- data/doc/dynamic-environments/usage.mkd +12 -11
- data/doc/puppetfile.mkd +23 -3
- data/docker/Gemfile +1 -1
- data/docker/Makefile +4 -3
- data/docker/docker-compose.yml +18 -0
- data/docker/r10k/Dockerfile +1 -1
- data/docker/r10k/docker-entrypoint.sh +0 -1
- data/docker/r10k/release.Dockerfile +1 -1
- data/docker/spec/dockerfile_spec.rb +26 -32
- data/integration/tests/git_source/git_source_repeated_remote.rb +2 -2
- 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 +10 -0
- data/lib/r10k/action/deploy/display.rb +49 -10
- data/lib/r10k/action/deploy/environment.rb +102 -51
- data/lib/r10k/action/deploy/module.rb +55 -30
- 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 +11 -1
- data/lib/r10k/git/rugged/credentials.rb +39 -2
- data/lib/r10k/initializers.rb +2 -0
- data/lib/r10k/module.rb +1 -1
- data/lib/r10k/module/base.rb +17 -1
- data/lib/r10k/module/forge.rb +29 -11
- data/lib/r10k/module/git.rb +50 -27
- data/lib/r10k/module/local.rb +2 -1
- data/lib/r10k/module/svn.rb +24 -18
- data/lib/r10k/puppetfile.rb +66 -83
- data/lib/r10k/settings.rb +29 -2
- data/lib/r10k/source/base.rb +9 -0
- data/lib/r10k/source/git.rb +18 -7
- 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 +98 -82
- 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 +31 -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 +63 -60
- data/spec/unit/settings_spec.rb +12 -0
- data/spec/unit/source/git_spec.rb +15 -3
- data/spec/unit/util/purgeable_spec.rb +2 -8
- data/spec/unit/util/setopts_spec.rb +25 -1
- metadata +11 -11
- data/azure-pipelines.yml +0 -87
@@ -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,64 @@ module R10K
|
|
13
14
|
|
14
15
|
include R10K::Action::Deploy::DeployHelpers
|
15
16
|
|
17
|
+
# Deprecated
|
16
18
|
attr_reader :force
|
17
19
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
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 = {})
|
24
33
|
super
|
25
34
|
|
26
|
-
#
|
27
|
-
|
28
|
-
|
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
|
+
})
|
29
59
|
end
|
30
60
|
|
31
61
|
def call
|
32
62
|
@visit_ok = true
|
33
63
|
|
34
|
-
|
35
|
-
|
36
|
-
|
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
|
37
74
|
|
38
|
-
deployment.accept(self)
|
39
75
|
@visit_ok
|
40
76
|
end
|
41
77
|
|
@@ -43,15 +79,34 @@ module R10K
|
|
43
79
|
|
44
80
|
private
|
45
81
|
|
82
|
+
def read_purge_allowlist (whitelist, allowlist)
|
83
|
+
whitelist_has_content = !whitelist.empty?
|
84
|
+
allowlist_has_content = !allowlist.empty?
|
85
|
+
case
|
86
|
+
when whitelist_has_content == false && allowlist_has_content == false
|
87
|
+
[]
|
88
|
+
when whitelist_has_content && allowlist_has_content
|
89
|
+
raise R10K::Error.new "Values found for both purge_whitelist and purge_allowlist. Setting " <<
|
90
|
+
"purge_whitelist is deprecated, please only use purge_allowlist."
|
91
|
+
when allowlist_has_content
|
92
|
+
allowlist
|
93
|
+
else
|
94
|
+
logger.warn "Setting purge_whitelist is deprecated; please use purge_allowlist instead."
|
95
|
+
whitelist
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
46
99
|
def visit_deployment(deployment)
|
47
100
|
# Ensure that everything can be preloaded. If we cannot preload all
|
48
101
|
# sources then we can't fully enumerate all environments which
|
49
102
|
# could be dangerous. If this fails then an exception will be raised
|
50
103
|
# and execution will be halted.
|
51
|
-
|
52
|
-
|
104
|
+
if @settings.dig(:overrides, :environments, :preload_environments)
|
105
|
+
deployment.preload!
|
106
|
+
deployment.validate!
|
107
|
+
end
|
53
108
|
|
54
|
-
undeployable = undeployable_environment_names(deployment.environments, @
|
109
|
+
undeployable = undeployable_environment_names(deployment.environments, @settings.dig(:overrides, :environments, :requested_environments))
|
55
110
|
if !undeployable.empty?
|
56
111
|
@visit_ok = false
|
57
112
|
logger.error _("Environment(s) \'%{environments}\' cannot be found in any source and will not be deployed.") % {environments: undeployable.join(", ")}
|
@@ -59,7 +114,7 @@ module R10K
|
|
59
114
|
|
60
115
|
yield
|
61
116
|
|
62
|
-
if @purge_levels.include?(:deployment)
|
117
|
+
if @settings.dig(:overrides, :purging, :purge_levels).include?(:deployment)
|
63
118
|
logger.debug("Purging unmanaged environments for deployment...")
|
64
119
|
deployment.purge!
|
65
120
|
end
|
@@ -67,7 +122,8 @@ module R10K
|
|
67
122
|
if (postcmd = @settings[:postrun])
|
68
123
|
if postcmd.grep('$modifiedenvs').any?
|
69
124
|
envs = deployment.environments.map { |e| e.dirname }
|
70
|
-
|
125
|
+
requested_envs = @settings.dig(:overrides, :environments, :requested_environments)
|
126
|
+
envs.reject! { |e| !requested_envs.include?(e) } if requested_envs.any?
|
71
127
|
postcmd = postcmd.map { |e| e.gsub('$modifiedenvs', envs.join(' ')) }
|
72
128
|
end
|
73
129
|
subproc = R10K::Util::Subprocess.new(postcmd)
|
@@ -81,7 +137,8 @@ module R10K
|
|
81
137
|
end
|
82
138
|
|
83
139
|
def visit_environment(environment)
|
84
|
-
|
140
|
+
requested_envs = @settings.dig(:overrides, :environments, :requested_environments)
|
141
|
+
if !(requested_envs.empty? || requested_envs.any? { |name| environment.dirname == name })
|
85
142
|
logger.debug1(_("Environment %{env_dir} does not match environment name filter, skipping") % {env_dir: environment.dirname})
|
86
143
|
return
|
87
144
|
end
|
@@ -95,28 +152,31 @@ module R10K
|
|
95
152
|
environment.sync
|
96
153
|
logger.info _("Environment %{env_dir} is now at %{env_signature}") % {env_dir: environment.dirname, env_signature: environment.signature}
|
97
154
|
|
98
|
-
if status == :absent || @
|
155
|
+
if status == :absent || @settings.dig(:overrides, :modules, :deploy_modules)
|
99
156
|
if status == :absent
|
100
157
|
logger.debug(_("Environment %{env_dir} is new, updating all modules") % {env_dir: environment.dirname})
|
101
158
|
end
|
102
159
|
|
103
160
|
previous_ok = @visit_ok
|
104
161
|
@visit_ok = true
|
105
|
-
|
162
|
+
|
163
|
+
environment.deploy
|
164
|
+
|
106
165
|
@environment_ok = @visit_ok
|
107
166
|
@visit_ok &&= previous_ok
|
108
167
|
end
|
109
168
|
|
110
|
-
|
169
|
+
|
170
|
+
if @settings.dig(:overrides, :purging, :purge_levels).include?(:environment)
|
111
171
|
if @visit_ok
|
112
172
|
logger.debug("Purging unmanaged content for environment '#{environment.dirname}'...")
|
113
|
-
environment.purge!(:recurse => true, :whitelist => environment.whitelist(@
|
173
|
+
environment.purge!(:recurse => true, :whitelist => environment.whitelist(@settings.dig(:overrides, :purging, :purge_allowlist)))
|
114
174
|
else
|
115
175
|
logger.debug("Not purging unmanaged content for environment '#{environment.dirname}' due to prior deploy failures.")
|
116
176
|
end
|
117
177
|
end
|
118
178
|
|
119
|
-
if @generate_types
|
179
|
+
if @settings.dig(:overrides, :environments, :generate_types)
|
120
180
|
if @environment_ok
|
121
181
|
logger.debug("Generating puppet types for environment '#{environment.dirname}'...")
|
122
182
|
environment.generate_types!
|
@@ -128,34 +188,21 @@ module R10K
|
|
128
188
|
write_environment_info!(environment, started_at, @visit_ok)
|
129
189
|
end
|
130
190
|
|
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
191
|
def write_environment_info!(environment, started_at, success)
|
148
|
-
module_deploys =
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
192
|
+
module_deploys =
|
193
|
+
begin
|
194
|
+
environment.modules.map do |mod|
|
195
|
+
props = mod.properties
|
196
|
+
{
|
197
|
+
name: mod.name,
|
198
|
+
version: props[:expected],
|
199
|
+
sha: props[:type] == :git ? props[:actual] : nil
|
200
|
+
}
|
201
|
+
end
|
202
|
+
rescue
|
203
|
+
logger.debug("Unable to get environment module deploy data for .r10k-deploy.json at #{environment.path}")
|
204
|
+
[]
|
155
205
|
end
|
156
|
-
rescue
|
157
|
-
logger.debug("Unable to get environment module deploy data for .r10k-deploy.json at #{environment.path}")
|
158
|
-
end
|
159
206
|
|
160
207
|
# make this file write as atomic as possible in pure ruby
|
161
208
|
final = "#{environment.path}/.r10k-deploy.json"
|
@@ -183,11 +230,15 @@ module R10K
|
|
183
230
|
end
|
184
231
|
|
185
232
|
def allowed_initialize_opts
|
186
|
-
super.merge(puppetfile: :
|
233
|
+
super.merge(puppetfile: :modules,
|
234
|
+
modules: :self,
|
187
235
|
cachedir: :self,
|
188
236
|
'no-force': :self,
|
189
237
|
'generate-types': :self,
|
190
238
|
'puppet-path': :self,
|
239
|
+
'puppet-conf': :self,
|
240
|
+
'private-key': :self,
|
241
|
+
'oauth-token': :self,
|
191
242
|
'default-branch-override': :self)
|
192
243
|
end
|
193
244
|
end
|
@@ -10,25 +10,56 @@ module R10K
|
|
10
10
|
|
11
11
|
include R10K::Action::Deploy::DeployHelpers
|
12
12
|
|
13
|
+
# Deprecated
|
13
14
|
attr_reader :force
|
14
15
|
|
15
|
-
|
16
|
-
|
17
|
-
|
16
|
+
attr_reader :settings
|
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 [Enumerable] Typically CRI::ArgumentList or Array. A list-like
|
22
|
+
# collection of the remaining arguments to the CLI invocation (after
|
23
|
+
# removing flags and options).
|
24
|
+
# @param settings [Hash] A hash of configuration loaded from the relevant
|
25
|
+
# config (r10k.yaml).
|
26
|
+
#
|
27
|
+
# @note All arguments will be required in the next major version
|
28
|
+
def initialize(opts, argv, settings = {})
|
18
29
|
super
|
19
30
|
|
20
|
-
|
21
|
-
|
31
|
+
requested_env = @opts[:environment] ? [@opts[:environment].gsub(/\W/, '_')] : []
|
32
|
+
|
33
|
+
@settings = @settings.merge({
|
34
|
+
overrides: {
|
35
|
+
environments: {
|
36
|
+
requested_environments: requested_env,
|
37
|
+
generate_types: @generate_types
|
38
|
+
},
|
39
|
+
modules: {
|
40
|
+
requested_modules: @argv.map.to_a,
|
41
|
+
# force here is used to make it easier to reason about
|
42
|
+
force: !@no_force
|
43
|
+
},
|
44
|
+
purging: {},
|
45
|
+
output: {}
|
46
|
+
}
|
47
|
+
})
|
22
48
|
end
|
23
49
|
|
24
50
|
def call
|
25
51
|
@visit_ok = true
|
52
|
+
begin
|
53
|
+
expect_config!
|
54
|
+
deployment = R10K::Deployment.new(@settings)
|
55
|
+
check_write_lock!(@settings)
|
56
|
+
|
57
|
+
deployment.accept(self)
|
58
|
+
rescue => e
|
59
|
+
@visit_ok = false
|
60
|
+
logger.error R10K::Errors::Formatting.format_exception(e, @trace)
|
61
|
+
end
|
26
62
|
|
27
|
-
expect_config!
|
28
|
-
deployment = R10K::Deployment.new(@settings)
|
29
|
-
check_write_lock!(@settings)
|
30
|
-
|
31
|
-
deployment.accept(self)
|
32
63
|
@visit_ok
|
33
64
|
end
|
34
65
|
|
@@ -45,29 +76,20 @@ module R10K
|
|
45
76
|
end
|
46
77
|
|
47
78
|
def visit_environment(environment)
|
48
|
-
|
49
|
-
|
79
|
+
requested_envs = @settings.dig(:overrides, :environments, :requested_environments)
|
80
|
+
if !requested_envs.empty? && !requested_envs.include?(environment.dirname)
|
81
|
+
logger.debug1(_("Only updating modules in environment(s) %{opt_env} skipping environment %{env_path}") % {opt_env: requested_envs.inspect, env_path: environment.path})
|
50
82
|
else
|
51
|
-
logger.debug1(_("Updating modules %{modules} in environment %{env_path}") % {modules: @
|
52
|
-
yield
|
53
|
-
end
|
54
|
-
end
|
83
|
+
logger.debug1(_("Updating modules %{modules} in environment %{env_path}") % {modules: @settings.dig(:overrides, :modules, :requested_modules).inspect, env_path: environment.path})
|
55
84
|
|
56
|
-
|
57
|
-
puppetfile.load
|
58
|
-
yield
|
59
|
-
end
|
85
|
+
environment.deploy
|
60
86
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
logger.debug("Generating puppet types for environment '#{mod.environment.dirname}'...")
|
67
|
-
mod.environment.generate_types!
|
87
|
+
requested_mods = @settings.dig(:overrides, :modules, :requested_modules) || []
|
88
|
+
generate_types = @settings.dig(:overrides, :environments, :generate_types)
|
89
|
+
if generate_types && !((environment.modules.map(&:name) & requested_mods).empty?)
|
90
|
+
logger.debug("Generating puppet types for environment '#{environment.dirname}'...")
|
91
|
+
environment.generate_types!
|
68
92
|
end
|
69
|
-
else
|
70
|
-
logger.debug1(_("Only updating modules %{modules}, skipping module %{mod_name}") % {modules: @argv.inspect, mod_name: mod.name})
|
71
93
|
end
|
72
94
|
end
|
73
95
|
|
@@ -76,7 +98,10 @@ module R10K
|
|
76
98
|
cachedir: :self,
|
77
99
|
'no-force': :self,
|
78
100
|
'generate-types': :self,
|
79
|
-
'puppet-path': :self
|
101
|
+
'puppet-path': :self,
|
102
|
+
'puppet-conf': :self,
|
103
|
+
'private-key': :self,
|
104
|
+
'oauth-token': :self)
|
80
105
|
end
|
81
106
|
end
|
82
107
|
end
|
@@ -8,7 +8,9 @@ module R10K
|
|
8
8
|
class Check < R10K::Action::Base
|
9
9
|
|
10
10
|
def call
|
11
|
-
pf = R10K::Puppetfile.new(@root,
|
11
|
+
pf = R10K::Puppetfile.new(@root,
|
12
|
+
{moduledir: @moduledir,
|
13
|
+
puppetfile_path: @puppetfile})
|
12
14
|
begin
|
13
15
|
pf.load!
|
14
16
|
$stderr.puts _("Syntax OK")
|
@@ -2,6 +2,7 @@ require 'r10k/puppetfile'
|
|
2
2
|
require 'r10k/errors/formatting'
|
3
3
|
require 'r10k/action/visitor'
|
4
4
|
require 'r10k/action/base'
|
5
|
+
require 'r10k/util/cleaner'
|
5
6
|
|
6
7
|
module R10K
|
7
8
|
module Action
|
@@ -9,33 +10,29 @@ module R10K
|
|
9
10
|
class Install < R10K::Action::Base
|
10
11
|
|
11
12
|
def call
|
12
|
-
@
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
def visit_module(mod)
|
29
|
-
@force ||= false
|
30
|
-
logger.info _("Updating module %{mod_path}") % {mod_path: mod.path}
|
31
|
-
|
32
|
-
if mod.respond_to?(:desired_ref) && mod.desired_ref == :control_branch
|
33
|
-
logger.warn _("Cannot track control repo branch for content '%{name}' when not part of a 'deploy' action, will use default if available." % {name: mod.name})
|
13
|
+
@ok = true
|
14
|
+
begin
|
15
|
+
pf = R10K::Puppetfile.new(@root,
|
16
|
+
{moduledir: @moduledir,
|
17
|
+
puppetfile_path: @puppetfile,
|
18
|
+
force: @force || false})
|
19
|
+
pf.load!
|
20
|
+
pf.sync
|
21
|
+
|
22
|
+
R10K::Util::Cleaner.new(pf.managed_directories,
|
23
|
+
pf.desired_contents,
|
24
|
+
pf.purge_exclusions).purge!
|
25
|
+
|
26
|
+
rescue => e
|
27
|
+
@ok = false
|
28
|
+
logger.error R10K::Errors::Formatting.format_exception(e, @trace)
|
34
29
|
end
|
35
30
|
|
36
|
-
|
31
|
+
@ok
|
37
32
|
end
|
38
33
|
|
34
|
+
private
|
35
|
+
|
39
36
|
def allowed_initialize_opts
|
40
37
|
super.merge(root: :self, puppetfile: :self, moduledir: :self, force: :self )
|
41
38
|
end
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'r10k/puppetfile'
|
2
|
+
require 'r10k/util/cleaner'
|
2
3
|
require 'r10k/action/base'
|
3
4
|
require 'r10k/errors/formatting'
|
4
5
|
|
@@ -8,9 +9,14 @@ module R10K
|
|
8
9
|
class Purge < R10K::Action::Base
|
9
10
|
|
10
11
|
def call
|
11
|
-
pf = R10K::Puppetfile.new(@root,
|
12
|
+
pf = R10K::Puppetfile.new(@root,
|
13
|
+
{moduledir: @moduledir,
|
14
|
+
puppetfile_path: @puppetfile})
|
12
15
|
pf.load!
|
13
|
-
pf.
|
16
|
+
R10K::Util::Cleaner.new(pf.managed_directories,
|
17
|
+
pf.desired_contents,
|
18
|
+
pf.purge_exclusions).purge!
|
19
|
+
|
14
20
|
true
|
15
21
|
rescue => e
|
16
22
|
logger.error R10K::Errors::Formatting.format_exception(e, @trace)
|