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
data/lib/r10k/module/git.rb
CHANGED
@@ -8,7 +8,7 @@ class R10K::Module::Git < R10K::Module::Base
|
|
8
8
|
R10K::Module.register(self)
|
9
9
|
|
10
10
|
def self.implement?(name, args)
|
11
|
-
args.
|
11
|
+
args.has_key?(:git) || args[:type].to_s == 'git'
|
12
12
|
rescue
|
13
13
|
false
|
14
14
|
end
|
@@ -28,16 +28,50 @@ class R10K::Module::Git < R10K::Module::Base
|
|
28
28
|
# @return [String]
|
29
29
|
attr_reader :default_ref
|
30
30
|
|
31
|
-
|
32
|
-
|
31
|
+
# @!attribute [r] default_override_ref
|
32
|
+
# @api private
|
33
|
+
# @return [String]
|
34
|
+
attr_reader :default_override_ref
|
33
35
|
|
34
|
-
|
36
|
+
include R10K::Util::Setopts
|
37
|
+
|
38
|
+
def initialize(title, dirname, opts, environment=nil)
|
39
|
+
|
40
|
+
super
|
41
|
+
setopts(opts, {
|
42
|
+
# Standard option interface
|
43
|
+
:version => :desired_ref,
|
44
|
+
:source => :remote,
|
45
|
+
:type => ::R10K::Util::Setopts::Ignore,
|
46
|
+
|
47
|
+
# Type-specific options
|
48
|
+
:branch => :desired_ref,
|
49
|
+
:tag => :desired_ref,
|
50
|
+
:commit => :desired_ref,
|
51
|
+
:ref => :desired_ref,
|
52
|
+
:git => :remote,
|
53
|
+
:default_branch => :default_ref,
|
54
|
+
:default_branch_override => :default_override_ref,
|
55
|
+
})
|
56
|
+
|
57
|
+
force = @overrides.dig(:modules, :force)
|
58
|
+
@force = force == false ? false : true
|
59
|
+
|
60
|
+
@desired_ref ||= 'master'
|
61
|
+
|
62
|
+
if @desired_ref == :control_branch
|
63
|
+
if @environment && @environment.respond_to?(:ref)
|
64
|
+
@desired_ref = @environment.ref
|
65
|
+
else
|
66
|
+
logger.warn _("Cannot track control repo branch for content '%{name}' when not part of a git-backed environment, will use default if available." % {name: name})
|
67
|
+
end
|
68
|
+
end
|
35
69
|
|
36
70
|
@repo = R10K::Git::StatefulRepository.new(@remote, @dirname, @name)
|
37
71
|
end
|
38
72
|
|
39
73
|
def version
|
40
|
-
validate_ref(@desired_ref, @default_ref)
|
74
|
+
validate_ref(@desired_ref, @default_ref, @default_override_ref)
|
41
75
|
end
|
42
76
|
|
43
77
|
def properties
|
@@ -48,20 +82,27 @@ class R10K::Module::Git < R10K::Module::Base
|
|
48
82
|
}
|
49
83
|
end
|
50
84
|
|
85
|
+
# @param [Hash] opts Deprecated
|
51
86
|
def sync(opts={})
|
52
|
-
force = opts
|
53
|
-
@repo.sync(version, force)
|
87
|
+
force = opts[:force] || @force
|
88
|
+
@repo.sync(version, force) if should_sync?
|
54
89
|
end
|
55
90
|
|
56
91
|
def status
|
57
92
|
@repo.status(version)
|
58
93
|
end
|
59
94
|
|
95
|
+
def cachedir
|
96
|
+
@repo.cache.sanitized_dirname
|
97
|
+
end
|
98
|
+
|
60
99
|
private
|
61
100
|
|
62
|
-
def validate_ref(desired, default)
|
101
|
+
def validate_ref(desired, default, default_override)
|
63
102
|
if desired && desired != :control_branch && @repo.resolve(desired)
|
64
103
|
return desired
|
104
|
+
elsif default_override && @repo.resolve(default_override)
|
105
|
+
return default_override
|
65
106
|
elsif default && @repo.resolve(default)
|
66
107
|
return default
|
67
108
|
else
|
@@ -77,6 +118,11 @@ class R10K::Module::Git < R10K::Module::Base
|
|
77
118
|
msg << "Could not determine desired ref"
|
78
119
|
end
|
79
120
|
|
121
|
+
if default_override
|
122
|
+
msg << "or resolve the default branch override '%{default_override}',"
|
123
|
+
vars[:default_override] = default_override
|
124
|
+
end
|
125
|
+
|
80
126
|
if default
|
81
127
|
msg << "or resolve default ref '%{default}'"
|
82
128
|
vars[:default] = default
|
@@ -87,23 +133,4 @@ class R10K::Module::Git < R10K::Module::Base
|
|
87
133
|
raise ArgumentError, _(msg.join(' ')) % vars
|
88
134
|
end
|
89
135
|
end
|
90
|
-
|
91
|
-
def parse_options(options)
|
92
|
-
ref_opts = [:branch, :tag, :commit, :ref]
|
93
|
-
known_opts = [:git, :default_branch] + ref_opts
|
94
|
-
|
95
|
-
unhandled = options.keys - known_opts
|
96
|
-
unless unhandled.empty?
|
97
|
-
raise ArgumentError, _("Unhandled options %{unhandled} specified for %{class}") % {unhandled: unhandled, class: self.class}
|
98
|
-
end
|
99
|
-
|
100
|
-
@remote = options[:git]
|
101
|
-
|
102
|
-
@desired_ref = ref_opts.find { |key| break options[key] if options.has_key?(key) } || 'master'
|
103
|
-
@default_ref = options[:default_branch]
|
104
|
-
|
105
|
-
if @desired_ref == :control_branch && @environment && @environment.respond_to?(:ref)
|
106
|
-
@desired_ref = @environment.ref
|
107
|
-
end
|
108
|
-
end
|
109
136
|
end
|
data/lib/r10k/module/local.rb
CHANGED
@@ -9,7 +9,7 @@ class R10K::Module::Local < R10K::Module::Base
|
|
9
9
|
R10K::Module.register(self)
|
10
10
|
|
11
11
|
def self.implement?(name, args)
|
12
|
-
args.is_a?(Hash) && args[:local]
|
12
|
+
args.is_a?(Hash) && (args[:local] || args[:type].to_s == 'local')
|
13
13
|
end
|
14
14
|
|
15
15
|
include R10K::Logging
|
@@ -30,6 +30,7 @@ class R10K::Module::Local < R10K::Module::Base
|
|
30
30
|
:insync
|
31
31
|
end
|
32
32
|
|
33
|
+
# @param [Hash] opts Deprecated
|
33
34
|
def sync(opts={})
|
34
35
|
logger.debug1 _("Module %{title} is a local module, always indicating synced.") % {title: title}
|
35
36
|
end
|
data/lib/r10k/module/svn.rb
CHANGED
@@ -7,7 +7,7 @@ class R10K::Module::SVN < R10K::Module::Base
|
|
7
7
|
R10K::Module.register(self)
|
8
8
|
|
9
9
|
def self.implement?(name, args)
|
10
|
-
args.
|
10
|
+
args.has_key?(:svn) || args[:type].to_s == 'svn'
|
11
11
|
end
|
12
12
|
|
13
13
|
# @!attribute [r] expected_revision
|
@@ -36,18 +36,21 @@ class R10K::Module::SVN < R10K::Module::Base
|
|
36
36
|
|
37
37
|
include R10K::Util::Setopts
|
38
38
|
|
39
|
-
INITIALIZE_OPTS = {
|
40
|
-
:svn => :url,
|
41
|
-
:rev => :expected_revision,
|
42
|
-
:revision => :expected_revision,
|
43
|
-
:username => :self,
|
44
|
-
:password => :self
|
45
|
-
}
|
46
|
-
|
47
39
|
def initialize(name, dirname, opts, environment=nil)
|
48
40
|
super
|
49
|
-
|
50
|
-
|
41
|
+
setopts(opts, {
|
42
|
+
# Standard option interface
|
43
|
+
:source => :url,
|
44
|
+
:version => :expected_revision,
|
45
|
+
:type => ::R10K::Util::Setopts::Ignore,
|
46
|
+
|
47
|
+
# Type-specific options
|
48
|
+
:svn => :url,
|
49
|
+
:rev => :expected_revision,
|
50
|
+
:revision => :expected_revision,
|
51
|
+
:username => :self,
|
52
|
+
:password => :self
|
53
|
+
})
|
51
54
|
|
52
55
|
@working_dir = R10K::SVN::WorkingDir.new(@path, :username => @username, :password => @password)
|
53
56
|
end
|
@@ -66,14 +69,17 @@ class R10K::Module::SVN < R10K::Module::Base
|
|
66
69
|
end
|
67
70
|
end
|
68
71
|
|
72
|
+
# @param [Hash] opts Deprecated
|
69
73
|
def sync(opts={})
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
74
|
+
if should_sync?
|
75
|
+
case status
|
76
|
+
when :absent
|
77
|
+
install
|
78
|
+
when :mismatched
|
79
|
+
reinstall
|
80
|
+
when :outdated
|
81
|
+
update
|
82
|
+
end
|
77
83
|
end
|
78
84
|
end
|
79
85
|
|
data/lib/r10k/puppetfile.rb
CHANGED
@@ -3,6 +3,7 @@ require 'pathname'
|
|
3
3
|
require 'r10k/module'
|
4
4
|
require 'r10k/util/purgeable'
|
5
5
|
require 'r10k/errors'
|
6
|
+
require 'r10k/content_synchronizer'
|
6
7
|
|
7
8
|
module R10K
|
8
9
|
class Puppetfile
|
@@ -10,7 +11,7 @@ class Puppetfile
|
|
10
11
|
|
11
12
|
include R10K::Settings::Mixin
|
12
13
|
|
13
|
-
def_setting_attr :pool_size,
|
14
|
+
def_setting_attr :pool_size, 4
|
14
15
|
|
15
16
|
include R10K::Logging
|
16
17
|
|
@@ -42,17 +43,32 @@ class Puppetfile
|
|
42
43
|
# @return [Boolean] Overwrite any locally made changes
|
43
44
|
attr_accessor :force
|
44
45
|
|
46
|
+
# @!attribute [r] overrides
|
47
|
+
# @return [Hash] Various settings overridden from normal configs
|
48
|
+
attr_reader :overrides
|
49
|
+
|
45
50
|
# @param [String] basedir
|
46
|
-
# @param [String]
|
47
|
-
#
|
48
|
-
# @param [String]
|
49
|
-
# @param [
|
50
|
-
|
51
|
+
# @param [Hash, String, nil] options_or_moduledir The directory to install the modules or a Hash of options.
|
52
|
+
# Usage as moduledir is deprecated. Only use as options, defaults to nil
|
53
|
+
# @param [String, nil] puppetfile_path Deprecated - The path to the Puppetfile, defaults to nil
|
54
|
+
# @param [String, nil] puppetfile_name Deprecated - The name of the Puppetfile, defaults to nil
|
55
|
+
# @param [Boolean, nil] force Deprecated - Shall we overwrite locally made changes?
|
56
|
+
def initialize(basedir, options_or_moduledir = nil, deprecated_path_arg = nil, deprecated_name_arg = nil, deprecated_force_arg = nil)
|
51
57
|
@basedir = basedir
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
58
|
+
if options_or_moduledir.is_a? Hash
|
59
|
+
options = options_or_moduledir
|
60
|
+
deprecated_moduledir_arg = nil
|
61
|
+
else
|
62
|
+
options = {}
|
63
|
+
deprecated_moduledir_arg = options_or_moduledir
|
64
|
+
end
|
65
|
+
|
66
|
+
@force = deprecated_force_arg || options.delete(:force) || false
|
67
|
+
@moduledir = deprecated_moduledir_arg || options.delete(:moduledir) || File.join(basedir, 'modules')
|
68
|
+
@puppetfile_name = deprecated_name_arg || options.delete(:puppetfile_name) || 'Puppetfile'
|
69
|
+
@puppetfile_path = deprecated_path_arg || options.delete(:puppetfile_path) || File.join(basedir, @puppetfile_name)
|
70
|
+
|
71
|
+
@overrides = options.delete(:overrides) || {}
|
56
72
|
|
57
73
|
logger.info _("Using Puppetfile '%{puppetfile}'") % {puppetfile: @puppetfile_path}
|
58
74
|
|
@@ -77,7 +93,7 @@ class Puppetfile
|
|
77
93
|
|
78
94
|
dsl = R10K::Puppetfile::DSL.new(self)
|
79
95
|
dsl.instance_eval(puppetfile_contents, @puppetfile_path)
|
80
|
-
|
96
|
+
|
81
97
|
validate_no_duplicate_names(@modules)
|
82
98
|
@loaded = true
|
83
99
|
rescue SyntaxError, LoadError, ArgumentError, NameError => e
|
@@ -117,26 +133,44 @@ class Puppetfile
|
|
117
133
|
end
|
118
134
|
|
119
135
|
# @param [String] name
|
120
|
-
# @param [
|
136
|
+
# @param [Hash, String, Symbol] args Calling with anything but a Hash is
|
137
|
+
# deprecated. The DSL will now convert String and Symbol versions to
|
138
|
+
# Hashes of the shape
|
139
|
+
# { version: <String or Symbol> }
|
140
|
+
#
|
121
141
|
def add_module(name, args)
|
122
|
-
if args.is_a?(Hash)
|
142
|
+
if !args.is_a?(Hash)
|
143
|
+
args = { version: args }
|
144
|
+
end
|
145
|
+
|
146
|
+
args[:overrides] = @overrides
|
147
|
+
|
148
|
+
if install_path = args.delete(:install_path)
|
123
149
|
install_path = resolve_install_path(install_path)
|
124
150
|
validate_install_path(install_path, name)
|
125
151
|
else
|
126
152
|
install_path = @moduledir
|
127
153
|
end
|
128
154
|
|
129
|
-
if
|
130
|
-
args[:
|
155
|
+
if @default_branch_override != nil
|
156
|
+
args[:default_branch_override] = @default_branch_override
|
131
157
|
end
|
132
158
|
|
133
|
-
# Keep track of all the content this Puppetfile is managing to enable purging.
|
134
|
-
@managed_content[install_path] = Array.new unless @managed_content.has_key?(install_path)
|
135
159
|
|
136
160
|
mod = R10K::Module.new(name, install_path, args, @environment)
|
137
|
-
mod.origin =
|
161
|
+
mod.origin = :puppetfile
|
162
|
+
|
163
|
+
# Do not load modules if they would conflict with the attached
|
164
|
+
# environment
|
165
|
+
if environment && environment.module_conflicts?(mod)
|
166
|
+
mod = nil
|
167
|
+
return @modules
|
168
|
+
end
|
138
169
|
|
170
|
+
# Keep track of all the content this Puppetfile is managing to enable purging.
|
171
|
+
@managed_content[install_path] = Array.new unless @managed_content.has_key?(install_path)
|
139
172
|
@managed_content[install_path] << mod.name
|
173
|
+
|
140
174
|
@modules << mod
|
141
175
|
end
|
142
176
|
|
@@ -145,7 +179,9 @@ class Puppetfile
|
|
145
179
|
def managed_directories
|
146
180
|
self.load unless @loaded
|
147
181
|
|
148
|
-
@managed_content.keys
|
182
|
+
dirs = @managed_content.keys
|
183
|
+
dirs.delete(real_basedir)
|
184
|
+
dirs
|
149
185
|
end
|
150
186
|
|
151
187
|
# Returns an array of the full paths to all the content being managed.
|
@@ -172,63 +208,22 @@ class Puppetfile
|
|
172
208
|
def accept(visitor)
|
173
209
|
pool_size = self.settings[:pool_size]
|
174
210
|
if pool_size > 1
|
175
|
-
concurrent_accept(visitor, pool_size)
|
211
|
+
R10K::ContentSynchronizer.concurrent_accept(modules, visitor, self, pool_size, logger)
|
176
212
|
else
|
177
|
-
serial_accept(visitor)
|
178
|
-
end
|
179
|
-
end
|
180
|
-
|
181
|
-
private
|
182
|
-
|
183
|
-
def serial_accept(visitor)
|
184
|
-
visitor.visit(:puppetfile, self) do
|
185
|
-
modules.each do |mod|
|
186
|
-
mod.accept(visitor)
|
187
|
-
end
|
188
|
-
end
|
189
|
-
end
|
190
|
-
|
191
|
-
def concurrent_accept(visitor, pool_size)
|
192
|
-
logger.debug _("Updating modules with %{pool_size} threads") % {pool_size: pool_size}
|
193
|
-
mods_queue = modules_queue(visitor)
|
194
|
-
thread_pool = pool_size.times.map { visitor_thread(visitor, mods_queue) }
|
195
|
-
thread_exception = nil
|
196
|
-
|
197
|
-
# If any threads raise an exception the deployment is considered a failure.
|
198
|
-
# In that event clear the queue, wait for other threads to finish their
|
199
|
-
# current work, then re-raise the first exception caught.
|
200
|
-
begin
|
201
|
-
thread_pool.each(&:join)
|
202
|
-
rescue => e
|
203
|
-
logger.error _("Error during concurrent deploy of a module: %{message}") % {message: e.message}
|
204
|
-
mods_queue.clear
|
205
|
-
thread_exception ||= e
|
206
|
-
retry
|
207
|
-
ensure
|
208
|
-
raise thread_exception unless thread_exception.nil?
|
213
|
+
R10K::ContentSynchronizer.serial_accept(modules, visitor, self)
|
209
214
|
end
|
210
215
|
end
|
211
216
|
|
212
|
-
def
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
+
def sync
|
218
|
+
pool_size = self.settings[:pool_size]
|
219
|
+
if pool_size > 1
|
220
|
+
R10K::ContentSynchronizer.concurrent_sync(modules, pool_size, logger)
|
221
|
+
else
|
222
|
+
R10K::ContentSynchronizer.serial_sync(modules)
|
217
223
|
end
|
218
224
|
end
|
219
225
|
|
220
|
-
|
221
|
-
Thread.new do
|
222
|
-
begin
|
223
|
-
while mod = mods_queue.pop(true) do mod.accept(visitor) end
|
224
|
-
rescue ThreadError => e
|
225
|
-
logger.debug _("Module thread %{id} exiting: %{message}") % {message: e.message, id: Thread.current.object_id}
|
226
|
-
Thread.exit
|
227
|
-
rescue => e
|
228
|
-
Thread.main.raise(e)
|
229
|
-
end
|
230
|
-
end
|
231
|
-
end
|
226
|
+
private
|
232
227
|
|
233
228
|
def puppetfile_contents
|
234
229
|
File.read(@puppetfile_path)
|
@@ -248,8 +243,6 @@ class Puppetfile
|
|
248
243
|
end
|
249
244
|
|
250
245
|
def validate_install_path(path, modname)
|
251
|
-
real_basedir = Pathname.new(basedir).cleanpath.to_s
|
252
|
-
|
253
246
|
unless /^#{Regexp.escape(real_basedir)}.*/ =~ path
|
254
247
|
raise R10K::Error.new("Puppetfile cannot manage content '#{modname}' outside of containing environment: #{path} is not within #{real_basedir}")
|
255
248
|
end
|
@@ -257,6 +250,10 @@ class Puppetfile
|
|
257
250
|
true
|
258
251
|
end
|
259
252
|
|
253
|
+
def real_basedir
|
254
|
+
Pathname.new(basedir).cleanpath.to_s
|
255
|
+
end
|
256
|
+
|
260
257
|
class DSL
|
261
258
|
# A barebones implementation of the Puppetfile DSL
|
262
259
|
#
|
@@ -267,7 +264,13 @@ class Puppetfile
|
|
267
264
|
end
|
268
265
|
|
269
266
|
def mod(name, args = nil)
|
270
|
-
|
267
|
+
if args.is_a?(Hash)
|
268
|
+
opts = args
|
269
|
+
else
|
270
|
+
opts = { version: args }
|
271
|
+
end
|
272
|
+
|
273
|
+
@librarian.add_module(name, opts)
|
271
274
|
end
|
272
275
|
|
273
276
|
def forge(location)
|
data/lib/r10k/settings.rb
CHANGED
@@ -12,6 +12,8 @@ module R10K
|
|
12
12
|
class << self
|
13
13
|
# Path to puppet executable
|
14
14
|
attr_accessor :puppet_path
|
15
|
+
# Path to puppet.conf
|
16
|
+
attr_accessor :puppet_conf
|
15
17
|
end
|
16
18
|
|
17
19
|
def self.git_settings
|
@@ -35,6 +37,11 @@ module R10K
|
|
35
37
|
Only used by the 'rugged' Git provider.",
|
36
38
|
}),
|
37
39
|
|
40
|
+
Definition.new(:oauth_token, {
|
41
|
+
:desc => "The path to a token file for Git OAuth remotes.
|
42
|
+
Only used by the 'rugged' Git provider."
|
43
|
+
}),
|
44
|
+
|
38
45
|
URIDefinition.new(:proxy, {
|
39
46
|
:desc => "An optional proxy server to use when interacting with Git sources via HTTP(S).",
|
40
47
|
:default => :inherit,
|
@@ -52,11 +59,17 @@ module R10K
|
|
52
59
|
:default => :inherit,
|
53
60
|
}),
|
54
61
|
|
62
|
+
Definition.new(:oauth_token, {
|
63
|
+
:desc => "The path to a token file for Git OAuth remotes.
|
64
|
+
Only used by the 'rugged' Git provider.",
|
65
|
+
:default => :inherit
|
66
|
+
}),
|
67
|
+
|
55
68
|
URIDefinition.new(:proxy, {
|
56
69
|
:desc => "An optional proxy server to use when interacting with Git sources via HTTP(S).",
|
57
70
|
:default => :inherit,
|
58
71
|
}),
|
59
|
-
|
72
|
+
|
60
73
|
Definition.new(:ignore_branch_prefixes, {
|
61
74
|
:desc => "Array of strings used to prefix branch names that will not be deployed as environments.",
|
62
75
|
}),
|
@@ -109,11 +122,16 @@ module R10K
|
|
109
122
|
end,
|
110
123
|
}),
|
111
124
|
|
112
|
-
Definition.new(:
|
125
|
+
Definition.new(:purge_allowlist, {
|
113
126
|
:desc => "A list of filename patterns to be excluded from any purge operations. Patterns are matched relative to the root of each deployed environment, if you want a pattern to match recursively you need to use the '**' glob in your pattern. Basic shell style globs are supported.",
|
114
127
|
:default => [],
|
115
128
|
}),
|
116
129
|
|
130
|
+
Definition.new(:purge_whitelist, {
|
131
|
+
:desc => "Deprecated; please use purge_allowlist instead. This setting will be removed in a future version.",
|
132
|
+
:default => [],
|
133
|
+
}),
|
134
|
+
|
117
135
|
Definition.new(:generate_types, {
|
118
136
|
:desc => "Controls whether to generate puppet types after deploying an environment. Defaults to false.",
|
119
137
|
:default => false,
|
@@ -131,6 +149,15 @@ module R10K
|
|
131
149
|
end
|
132
150
|
end
|
133
151
|
}),
|
152
|
+
Definition.new(:puppet_conf, {
|
153
|
+
:desc => "Path to puppet.conf. Defaults to /etc/puppetlabs/puppet/puppet.conf.",
|
154
|
+
:default => '/etc/puppetlabs/puppet/puppet.conf',
|
155
|
+
:validate => lambda do |value|
|
156
|
+
unless File.readable? value
|
157
|
+
raise ArgumentError, "The specified puppet.conf #{value} is not readable"
|
158
|
+
end
|
159
|
+
end
|
160
|
+
}),
|
134
161
|
])
|
135
162
|
end
|
136
163
|
|
@@ -160,7 +187,7 @@ module R10K
|
|
160
187
|
|
161
188
|
Definition.new(:pool_size, {
|
162
189
|
:desc => "The amount of threads used to concurrently install modules. The default value is 1: install one module at a time.",
|
163
|
-
:default =>
|
190
|
+
:default => 4,
|
164
191
|
:validate => lambda do |value|
|
165
192
|
if !value.is_a?(Integer)
|
166
193
|
raise ArgumentError, "The pool_size setting should be an integer, not a #{value.class}"
|