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
@@ -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)
|
data/lib/r10k/action/runner.rb
CHANGED
@@ -46,6 +46,7 @@ module R10K
|
|
46
46
|
overrides[:cachedir] = @opts[:cachedir] if @opts.key?(:cachedir)
|
47
47
|
overrides[:deploy] = {} if @opts.key?(:'puppet-path') || @opts.key?(:'generate-types')
|
48
48
|
overrides[:deploy][:puppet_path] = @opts[:'puppet-path'] if @opts.key?(:'puppet-path')
|
49
|
+
overrides[:deploy][:puppet_conf] = @opts[:'puppet-conf'] unless @opts[:'puppet-conf'].nil?
|
49
50
|
overrides[:deploy][:generate_types] = @opts[:'generate-types'] if @opts.key?(:'generate-types')
|
50
51
|
|
51
52
|
with_overrides = config_settings.merge(overrides) do |key, oldval, newval|
|
@@ -54,6 +55,10 @@ module R10K
|
|
54
55
|
newval
|
55
56
|
end
|
56
57
|
|
58
|
+
# Credentials from the CLI override both the global and per-repo
|
59
|
+
# credentials from the config, and so need to be handled specially
|
60
|
+
with_overrides = add_credential_overrides(with_overrides)
|
61
|
+
|
57
62
|
@settings = R10K::Settings.global_settings.evaluate(with_overrides)
|
58
63
|
|
59
64
|
R10K::Initializers::GlobalInitializer.new(@settings).call
|
@@ -91,6 +96,35 @@ module R10K
|
|
91
96
|
|
92
97
|
results
|
93
98
|
end
|
99
|
+
|
100
|
+
def add_credential_overrides(overrides)
|
101
|
+
sshkey_path = @opts[:'private-key']
|
102
|
+
token_path = @opts[:'oauth-token']
|
103
|
+
|
104
|
+
if sshkey_path && token_path
|
105
|
+
raise R10K::Error, "Cannot specify both an SSH key and a token to use with this deploy."
|
106
|
+
end
|
107
|
+
|
108
|
+
if sshkey_path
|
109
|
+
overrides[:git] ||= {}
|
110
|
+
overrides[:git][:private_key] = sshkey_path
|
111
|
+
if repo_settings = overrides[:git][:repositories]
|
112
|
+
repo_settings.each do |repo|
|
113
|
+
repo[:private_key] = sshkey_path
|
114
|
+
end
|
115
|
+
end
|
116
|
+
elsif token_path
|
117
|
+
overrides[:git] ||= {}
|
118
|
+
overrides[:git][:oauth_token] = token_path
|
119
|
+
if repo_settings = overrides[:git][:repositories]
|
120
|
+
repo_settings.each do |repo|
|
121
|
+
repo[:oauth_token] = token_path
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
overrides
|
127
|
+
end
|
94
128
|
end
|
95
129
|
end
|
96
130
|
end
|
data/lib/r10k/cli/deploy.rb
CHANGED
@@ -21,7 +21,7 @@ module R10K::CLI
|
|
21
21
|
(https://puppet.com/docs/puppet/latest/environments_about.html).
|
22
22
|
DESCRIPTION
|
23
23
|
|
24
|
-
|
24
|
+
option nil, :cachedir, 'Specify a cachedir, overriding the value in config', argument: :required
|
25
25
|
flag nil, :'no-force', 'Prevent the overwriting of local module modifications'
|
26
26
|
flag nil, :'generate-types', 'Run `puppet generate types` after updating an environment'
|
27
27
|
option nil, :'puppet-path', 'Path to puppet executable', argument: :required do |value, cmd|
|
@@ -31,6 +31,9 @@ module R10K::CLI
|
|
31
31
|
exit 1
|
32
32
|
end
|
33
33
|
end
|
34
|
+
option nil, :'puppet-conf', 'Path to puppet.conf', argument: :required
|
35
|
+
option nil, :'private-key', 'Path to SSH key to use when cloning. Only valid with rugged provider', argument: :required
|
36
|
+
option nil, :'oauth-token', 'Path to OAuth token to use when cloning. Only valid with rugged provider', argument: :required
|
34
37
|
|
35
38
|
run do |opts, args, cmd|
|
36
39
|
puts cmd.help(:verbose => opts[:verbose])
|
@@ -52,7 +55,7 @@ branches.
|
|
52
55
|
|
53
56
|
Environments can provide a Puppetfile at the root of the directory to deploy
|
54
57
|
independent Puppet modules. To recursively deploy an environment, pass the
|
55
|
-
`--
|
58
|
+
`--modules` flag to the command.
|
56
59
|
|
57
60
|
**NOTE**: If an environment has a Puppetfile when it is instantiated a
|
58
61
|
recursive update will be forced. It is assumed that environments are dependent
|
@@ -60,8 +63,10 @@ on modules specified in the Puppetfile and an update will be automatically
|
|
60
63
|
scheduled. On subsequent deployments, Puppetfile deployment will default to off.
|
61
64
|
DESCRIPTION
|
62
65
|
|
63
|
-
flag :p, :puppetfile, 'Deploy modules
|
64
|
-
|
66
|
+
flag :p, :puppetfile, 'Deploy modules (deprecated, use -m)'
|
67
|
+
flag :m, :modules, 'Deploy modules'
|
68
|
+
option nil, :'default-branch-override', 'Specify a branchname to override the default branch in the puppetfile',
|
69
|
+
argument: :required
|
65
70
|
|
66
71
|
runner R10K::Action::CriRunner.wrap(R10K::Action::Deploy::Environment)
|
67
72
|
end
|
@@ -81,7 +86,7 @@ It will load the Puppetfile configurations out of all environments, and will
|
|
81
86
|
try to deploy the given module names in all environments.
|
82
87
|
DESCRIPTION
|
83
88
|
|
84
|
-
|
89
|
+
option :e, :environment, 'Update the modules in the given environment', argument: :required
|
85
90
|
|
86
91
|
runner R10K::Action::CriRunner.wrap(R10K::Action::Deploy::Module)
|
87
92
|
end
|
@@ -96,10 +101,12 @@ try to deploy the given module names in all environments.
|
|
96
101
|
usage 'display'
|
97
102
|
summary 'Display environments and modules in the deployment'
|
98
103
|
|
99
|
-
flag :p, :puppetfile, 'Display
|
104
|
+
flag :p, :puppetfile, 'Display modules (deprecated, use -m)'
|
105
|
+
flag :m, :modules, 'Display modules'
|
100
106
|
flag nil, :detail, 'Display detailed information'
|
101
107
|
flag nil, :fetch, 'Update available environment lists from all remote sources'
|
102
|
-
|
108
|
+
option nil, :format, 'Display output in a specific format. Valid values: json, yaml. Default: yaml',
|
109
|
+
argument: :required
|
103
110
|
|
104
111
|
runner R10K::Action::CriRunner.wrap(R10K::Action::Deploy::Display)
|
105
112
|
end
|
data/lib/r10k/cli/puppetfile.rb
CHANGED
@@ -30,8 +30,8 @@ Puppetfile (http://bombasticmonkey.com/librarian-puppet/).
|
|
30
30
|
name 'install'
|
31
31
|
usage 'install'
|
32
32
|
summary 'Install all modules from a Puppetfile'
|
33
|
-
|
34
|
-
|
33
|
+
option nil, :moduledir, 'Path to install modules to', argument: :required
|
34
|
+
option nil, :puppetfile, 'Path to puppetfile', argument: :required
|
35
35
|
flag nil, :force, 'Force locally changed files to be overwritten'
|
36
36
|
runner R10K::Action::Puppetfile::CriRunner.wrap(R10K::Action::Puppetfile::Install)
|
37
37
|
end
|
@@ -45,7 +45,7 @@ Puppetfile (http://bombasticmonkey.com/librarian-puppet/).
|
|
45
45
|
usage 'check'
|
46
46
|
summary 'Try and load the Puppetfile to verify the syntax is correct.'
|
47
47
|
|
48
|
-
|
48
|
+
option nil, :puppetfile, 'Path to Puppetfile', argument: :required
|
49
49
|
runner R10K::Action::Puppetfile::CriRunner.wrap(R10K::Action::Puppetfile::Check)
|
50
50
|
end
|
51
51
|
end
|
@@ -58,8 +58,8 @@ Puppetfile (http://bombasticmonkey.com/librarian-puppet/).
|
|
58
58
|
usage 'purge'
|
59
59
|
summary 'Purge unmanaged modules from a Puppetfile managed directory'
|
60
60
|
|
61
|
-
|
62
|
-
|
61
|
+
option nil, :moduledir, 'Path to install modules to', argument: :required
|
62
|
+
option nil, :puppetfile, 'Path to Puppetfile', argument: :required
|
63
63
|
runner R10K::Action::Puppetfile::CriRunner.wrap(R10K::Action::Puppetfile::Purge)
|
64
64
|
end
|
65
65
|
end
|
@@ -0,0 +1,83 @@
|
|
1
|
+
module R10K
|
2
|
+
module ContentSynchronizer
|
3
|
+
|
4
|
+
def self.serial_accept(modules, visitor, loader)
|
5
|
+
visitor.visit(:puppetfile, loader) do
|
6
|
+
serial_sync(modules)
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.serial_sync(modules)
|
11
|
+
modules.each do |mod|
|
12
|
+
mod.sync
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.concurrent_accept(modules, visitor, loader, pool_size, logger)
|
17
|
+
mods_queue = modules_visit_queue(modules, visitor, loader)
|
18
|
+
sync_queue(mods_queue, pool_size, logger)
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.concurrent_sync(modules, pool_size, logger)
|
22
|
+
mods_queue = modules_sync_queue(modules)
|
23
|
+
sync_queue(mods_queue, pool_size, logger)
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.sync_queue(mods_queue, pool_size, logger)
|
27
|
+
logger.debug _("Updating modules with %{pool_size} threads") % {pool_size: pool_size}
|
28
|
+
thread_pool = pool_size.times.map { sync_thread(mods_queue, logger) }
|
29
|
+
thread_exception = nil
|
30
|
+
|
31
|
+
# If any threads raise an exception the deployment is considered a failure.
|
32
|
+
# In that event clear the queue, wait for other threads to finish their
|
33
|
+
# current work, then re-raise the first exception caught.
|
34
|
+
begin
|
35
|
+
thread_pool.each(&:join)
|
36
|
+
rescue => e
|
37
|
+
logger.error _("Error during concurrent deploy of a module: %{message}") % {message: e.message}
|
38
|
+
mods_queue.clear
|
39
|
+
thread_exception ||= e
|
40
|
+
retry
|
41
|
+
ensure
|
42
|
+
raise thread_exception unless thread_exception.nil?
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def self.modules_visit_queue(modules, visitor, loader)
|
47
|
+
Queue.new.tap do |queue|
|
48
|
+
visitor.visit(:puppetfile, loader) do
|
49
|
+
enqueue_modules(queue, modules)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def self.modules_sync_queue(modules)
|
55
|
+
Queue.new.tap do |queue|
|
56
|
+
enqueue_modules(queue, modules)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def self.enqueue_modules(queue, modules)
|
61
|
+
modules_by_cachedir = modules.group_by { |mod| mod.cachedir }
|
62
|
+
modules_without_vcs_cachedir = modules_by_cachedir.delete(:none) || []
|
63
|
+
|
64
|
+
modules_without_vcs_cachedir.each {|mod| queue << Array(mod) }
|
65
|
+
modules_by_cachedir.values.each {|mods| queue << mods }
|
66
|
+
end
|
67
|
+
|
68
|
+
def self.sync_thread(mods_queue, logger)
|
69
|
+
Thread.new do
|
70
|
+
begin
|
71
|
+
while mods = mods_queue.pop(true) do
|
72
|
+
mods.each { |mod| mod.sync }
|
73
|
+
end
|
74
|
+
rescue ThreadError => e
|
75
|
+
logger.debug _("Module thread %{id} exiting: %{message}") % {message: e.message, id: Thread.current.object_id}
|
76
|
+
Thread.exit
|
77
|
+
rescue => e
|
78
|
+
Thread.main.raise(e)
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
data/lib/r10k/deployment.rb
CHANGED
@@ -118,7 +118,7 @@ module R10K
|
|
118
118
|
raise R10K::Error, _("Unable to load sources; the supplied configuration does not define the 'sources' key")
|
119
119
|
end
|
120
120
|
@_sources = sources.map do |(name, hash)|
|
121
|
-
R10K::Source.from_hash(name, hash)
|
121
|
+
R10K::Source.from_hash(name, hash.merge({overrides: @config[:overrides]}))
|
122
122
|
end
|
123
123
|
end
|
124
124
|
|
@@ -1,10 +1,13 @@
|
|
1
1
|
require 'r10k/util/subprocess'
|
2
|
+
require 'r10k/logging'
|
2
3
|
|
3
4
|
# This class defines a common interface for environment implementations.
|
4
5
|
#
|
5
6
|
# @since 1.3.0
|
6
7
|
class R10K::Environment::Base
|
7
8
|
|
9
|
+
include R10K::Logging
|
10
|
+
|
8
11
|
# @!attribute [r] name
|
9
12
|
# @return [String] A name for this environment that is unique to the given source
|
10
13
|
attr_reader :name
|
@@ -43,12 +46,16 @@ class R10K::Environment::Base
|
|
43
46
|
@basedir = basedir
|
44
47
|
@dirname = dirname
|
45
48
|
@options = options
|
46
|
-
@puppetfile_name = options
|
49
|
+
@puppetfile_name = options.delete(:puppetfile_name)
|
50
|
+
@overrides = options.delete(:overrides) || {}
|
47
51
|
|
48
52
|
@full_path = File.join(@basedir, @dirname)
|
49
53
|
@path = Pathname.new(File.join(@basedir, @dirname))
|
50
54
|
|
51
|
-
@puppetfile = R10K::Puppetfile.new(@full_path,
|
55
|
+
@puppetfile = R10K::Puppetfile.new(@full_path,
|
56
|
+
{overrides: @overrides,
|
57
|
+
force: @overrides.dig(:modules, :force),
|
58
|
+
puppetfile_name: @puppetfile_name})
|
52
59
|
@puppetfile.environment = self
|
53
60
|
end
|
54
61
|
|
@@ -103,12 +110,32 @@ class R10K::Environment::Base
|
|
103
110
|
@puppetfile.modules
|
104
111
|
end
|
105
112
|
|
113
|
+
# @return [Array<R10K::Module::Base>] Whether or not the given module
|
114
|
+
# conflicts with any modules already defined in the r10k environment
|
115
|
+
# object.
|
116
|
+
def module_conflicts?(mod)
|
117
|
+
false
|
118
|
+
end
|
119
|
+
|
106
120
|
def accept(visitor)
|
107
121
|
visitor.visit(:environment, self) do
|
108
122
|
puppetfile.accept(visitor)
|
109
123
|
end
|
110
124
|
end
|
111
125
|
|
126
|
+
def deploy
|
127
|
+
puppetfile.load(@overrides.dig(:environments, :default_branch_override))
|
128
|
+
|
129
|
+
puppetfile.sync
|
130
|
+
|
131
|
+
if (@overrides.dig(:purging, :purge_levels) || []).include?(:puppetfile)
|
132
|
+
logger.debug("Purging unmanaged Puppetfile content for environment '#{dirname}'...")
|
133
|
+
R10K::Util::Cleaner.new(puppetfile.managed_directories,
|
134
|
+
puppetfile.desired_contents,
|
135
|
+
puppetfile.purge_exclusions).purge!
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
112
139
|
def whitelist(user_whitelist=[])
|
113
140
|
user_whitelist.collect { |pattern| File.join(@full_path, pattern) }
|
114
141
|
end
|
@@ -137,7 +164,7 @@ class R10K::Environment::Base
|
|
137
164
|
end
|
138
165
|
|
139
166
|
def generate_types!
|
140
|
-
argv = [R10K::Settings.puppet_path, 'generate', 'types', '--environment', dirname, '--environmentpath', basedir]
|
167
|
+
argv = [R10K::Settings.puppet_path, 'generate', 'types', '--environment', dirname, '--environmentpath', basedir, '--config', R10K::Settings.puppet_conf]
|
141
168
|
subproc = R10K::Util::Subprocess.new(argv)
|
142
169
|
subproc.raise_on_fail = true
|
143
170
|
subproc.logger = logger
|
data/lib/r10k/environment/git.rb
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
require 'r10k/logging'
|
2
1
|
require 'r10k/puppetfile'
|
3
2
|
require 'r10k/git/stateful_repository'
|
4
3
|
require 'forwardable'
|
@@ -8,8 +7,6 @@ require 'forwardable'
|
|
8
7
|
# @since 1.3.0
|
9
8
|
class R10K::Environment::Git < R10K::Environment::WithModules
|
10
9
|
|
11
|
-
include R10K::Logging
|
12
|
-
|
13
10
|
R10K::Environment.register(:git, self)
|
14
11
|
# Register git as the default environment type
|
15
12
|
R10K::Environment.register(nil, self)
|
@@ -27,6 +24,8 @@ class R10K::Environment::Git < R10K::Environment::WithModules
|
|
27
24
|
# @return [R10K::Git::StatefulRepository] The git repo backing this environment
|
28
25
|
attr_reader :repo
|
29
26
|
|
27
|
+
include R10K::Util::Setopts
|
28
|
+
|
30
29
|
# Initialize the given Git environment.
|
31
30
|
#
|
32
31
|
# @param name [String] The unique name describing this environment.
|
@@ -38,8 +37,21 @@ class R10K::Environment::Git < R10K::Environment::WithModules
|
|
38
37
|
# @param options [String] :ref The git reference to use for this environment
|
39
38
|
def initialize(name, basedir, dirname, options = {})
|
40
39
|
super
|
41
|
-
|
42
|
-
|
40
|
+
setopts(options, {
|
41
|
+
# Standard option interface
|
42
|
+
:version => :ref,
|
43
|
+
:source => :remote,
|
44
|
+
:type => ::R10K::Util::Setopts::Ignore,
|
45
|
+
|
46
|
+
# Type-specific options
|
47
|
+
:ref => :self,
|
48
|
+
:remote => :self,
|
49
|
+
|
50
|
+
}, raise_on_unhandled: false)
|
51
|
+
# TODO: in r10k 4.0.0, a major version bump, stop allowing garbage options.
|
52
|
+
# We only allow them now, here, on this object, because prior to adopting
|
53
|
+
# setopts in the constructor, this object type didn't do any validation
|
54
|
+
# checking of options passed, and would permit garbage parameters.
|
43
55
|
|
44
56
|
@repo = R10K::Git::StatefulRepository.new(@remote, @basedir, @dirname)
|
45
57
|
end
|