r10k 3.11.0 → 3.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.mkd +9 -0
- data/doc/dynamic-environments/configuration.mkd +7 -3
- data/doc/dynamic-environments/usage.mkd +26 -0
- data/doc/puppetfile.mkd +3 -4
- data/integration/tests/basic_functionality/basic_deployment.rb +176 -0
- data/lib/r10k/action/deploy/environment.rb +8 -1
- data/lib/r10k/action/deploy/module.rb +11 -6
- data/lib/r10k/action/puppetfile/check.rb +7 -5
- data/lib/r10k/action/puppetfile/install.rb +22 -16
- data/lib/r10k/action/puppetfile/purge.rb +12 -9
- data/lib/r10k/cli/deploy.rb +1 -0
- data/lib/r10k/cli/puppetfile.rb +0 -1
- data/lib/r10k/content_synchronizer.rb +16 -4
- data/lib/r10k/environment/base.rb +64 -11
- data/lib/r10k/environment/with_modules.rb +6 -10
- data/lib/r10k/git/stateful_repository.rb +7 -0
- data/lib/r10k/initializers.rb +1 -7
- data/lib/r10k/module/base.rb +5 -1
- data/lib/r10k/module/definition.rb +64 -0
- data/lib/r10k/module/forge.rb +10 -2
- data/lib/r10k/module/git.rb +22 -1
- data/lib/r10k/module/local.rb +2 -3
- data/lib/r10k/module/svn.rb +10 -0
- data/lib/r10k/module.rb +20 -2
- data/lib/r10k/module_loader/puppetfile/dsl.rb +8 -3
- data/lib/r10k/module_loader/puppetfile.rb +95 -29
- data/lib/r10k/puppetfile.rb +1 -2
- data/lib/r10k/settings.rb +11 -0
- data/lib/r10k/version.rb +1 -1
- data/locales/r10k.pot +75 -47
- data/spec/fixtures/unit/puppetfile/forge-override/Puppetfile +8 -0
- data/spec/fixtures/unit/puppetfile/various-modules/Puppetfile +9 -0
- data/spec/fixtures/unit/puppetfile/various-modules/Puppetfile.new +9 -0
- data/spec/r10k-mocks/mock_env.rb +3 -0
- data/spec/r10k-mocks/mock_source.rb +7 -3
- data/spec/unit/action/deploy/environment_spec.rb +80 -30
- data/spec/unit/action/deploy/module_spec.rb +50 -62
- data/spec/unit/action/puppetfile/check_spec.rb +17 -5
- data/spec/unit/action/puppetfile/install_spec.rb +42 -36
- data/spec/unit/action/puppetfile/purge_spec.rb +15 -17
- data/spec/unit/action/runner_spec.rb +0 -8
- data/spec/unit/environment/base_spec.rb +30 -17
- data/spec/unit/environment/git_spec.rb +2 -2
- data/spec/unit/environment/svn_spec.rb +4 -3
- data/spec/unit/environment/with_modules_spec.rb +2 -1
- data/spec/unit/module/base_spec.rb +8 -8
- data/spec/unit/module/forge_spec.rb +32 -4
- data/spec/unit/module/git_spec.rb +51 -10
- data/spec/unit/module/svn_spec.rb +18 -6
- data/spec/unit/module_loader/puppetfile_spec.rb +90 -30
- data/spec/unit/puppetfile_spec.rb +2 -2
- data/spec/unit/settings_spec.rb +25 -2
- metadata +7 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f378346234a9e8a8d92b3acb64735f88ca6b8e8edd60aa33adad9a09d7efd537
|
4
|
+
data.tar.gz: 1b94403eb2e5cb420939d85b73ec299c709418afabb45705f70b1cfb8606a1f5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a3eda38f3fc6e79ea62082c7c71bd65383089dce82e87dc6473c1f278f1560239f3e2189df28ef23a9ce8e47f3446cdd63e8794344ee62895914353bdcdec6ee
|
7
|
+
data.tar.gz: 0dc89955ede8226bf59c7cd4f8e03d9a89688700f5767d0578884fce97643c937f3363dd0d965404fd2b900128b181874dfb129952d64891a3700516239a2af6
|
data/CHANGELOG.mkd
CHANGED
@@ -4,6 +4,15 @@ CHANGELOG
|
|
4
4
|
Unreleased
|
5
5
|
----------
|
6
6
|
|
7
|
+
3.12.0
|
8
|
+
------
|
9
|
+
|
10
|
+
- (RK-308) Provide a `forge.allow_puppetfile_override` setting that, when true, causes a `forge` declaration in the Puppetfile to override `forge.baseurl`. [#1214](https://github.com/puppetlabs/r10k/pull/1214)
|
11
|
+
- (CODEMGMT-1415) Provide an `--incremental` flag to only sync those modules in a Puppetfile whose definitions have changed since last sync, or those whose versions could change. [#1200](https://github.com/puppetlabs/r10k/pull/1200)
|
12
|
+
- (CODEMGMT-1454) Ensure missing repo caches are re-synced [#1210](https://github.com/puppetlabs/r10k/pull/1210)
|
13
|
+
- (PF-2437) Allow token authentication to be used with the Forge. [#1192](https://github.com/puppetlabs/r10k/pull/1192)
|
14
|
+
- Only run the module postrun command for environments in which the module was modified. [#1215](https://github.com/puppetlabs/r10k/issues/1215)
|
15
|
+
|
7
16
|
3.11.0
|
8
17
|
------
|
9
18
|
|
@@ -167,9 +167,8 @@ This defaults to 'https://forgeapi.puppetlabs.com'
|
|
167
167
|
|
168
168
|
#### authorization_token
|
169
169
|
|
170
|
-
The 'authorization_token' setting allows you to provide a token for authenticating to a
|
171
|
-
|
172
|
-
You will need to prepend your token with 'Bearer ' if using Artifactory as your Forge server.
|
170
|
+
The 'authorization_token' setting allows you to provide a token for authenticating to a Forge server.
|
171
|
+
You will need to prepend your token with 'Bearer ' to authenticate to the Forge or when using your own Artifactory server.
|
173
172
|
|
174
173
|
```yaml
|
175
174
|
forge:
|
@@ -177,6 +176,11 @@ forge:
|
|
177
176
|
authorization_token: 'Bearer mysupersecretauthtoken'
|
178
177
|
```
|
179
178
|
|
179
|
+
#### allow_puppetfile_override
|
180
|
+
|
181
|
+
The `allow_puppetfile_override` setting causes r10k to respect [`forge` declarations](https://github.com/puppetlabs/r10k/blob/main/doc/puppetfile.mkd#forge)
|
182
|
+
in Puppetfiles, overriding the `baseurl` setting and allowing per-environment configuration of the Forge URL.
|
183
|
+
|
180
184
|
Deployment options
|
181
185
|
------------------
|
182
186
|
|
@@ -62,6 +62,32 @@ useful if you want to make sure that a given environment is fully up to date.
|
|
62
62
|
|
63
63
|
- - -
|
64
64
|
|
65
|
+
There is also a middle ground between updating all modules and updating no modules.
|
66
|
+
It is often desirable to update the environment and then update only those modules
|
67
|
+
whose definitions have changed in the Puppetfile, or whose content _could_ have
|
68
|
+
changed since the last deployment (eg, Forge modules with their version set to
|
69
|
+
`:latest` or Git modules who point to a `branch` ref).
|
70
|
+
|
71
|
+
This can be achieved by assuming content is unchanged locally on disk. This is the
|
72
|
+
opposite of what one would assume during a module development cycle, when a user
|
73
|
+
might be making local edits to test code changes. However, in production, access
|
74
|
+
to puppet code is usually locked down, and updates are deployed through automated
|
75
|
+
invocations of R10K.
|
76
|
+
|
77
|
+
In these cases, deploys where most modules are unchanged and reference exact
|
78
|
+
versions (ie, not `:latest` or a branch as mentioned above), this invocation
|
79
|
+
may shorten deployment times dozens of seconds if not minutes depending on how
|
80
|
+
many modules meet the above criteria (approximately 1 minute for every 400 modules).
|
81
|
+
|
82
|
+
To take advantage of this, set as many modules as possible in the Puppetfile to
|
83
|
+
explicit, static version. These are released Forge versions, or Git modules using
|
84
|
+
the `:tag`, or `:commit` keys. Git `:ref`s containing only the full 40 character
|
85
|
+
commit SHA will also be treated as static versions. Then invoke a deploy with:
|
86
|
+
|
87
|
+
r10k deploy environment production --modules --incremental
|
88
|
+
|
89
|
+
- - -
|
90
|
+
|
65
91
|
Update a single environment and specify a default branch override:
|
66
92
|
|
67
93
|
r10k deploy environment my_working_environment --modules --default-branch-override default_branch_override
|
data/doc/puppetfile.mkd
CHANGED
@@ -51,10 +51,9 @@ handles modules.
|
|
51
51
|
### forge
|
52
52
|
|
53
53
|
The `forge` setting specifies which server that Forge based modules are fetched
|
54
|
-
from. This
|
55
|
-
|
56
|
-
|
57
|
-
R10k supports setting the Forge to use _globally_ in `r10k.yaml`. see [Configuration](/doc/dynamic-environments/configuration.mkd#baseurl) for details.
|
54
|
+
from. This declaration is only respected if [`forge.allow_puppetfile_override`](/dynamic-environments/configuration.mkd#allow_puppetfile_override)
|
55
|
+
is set to true in the main `r10k.yaml`. Otherwise, use [`forge.baseurl`](/doc/dynamic-environments/configuration.mkd#baseurl)
|
56
|
+
to globally configure where modules should be downloaded from.
|
58
57
|
|
59
58
|
### moduledir
|
60
59
|
|
@@ -0,0 +1,176 @@
|
|
1
|
+
require 'git_utils'
|
2
|
+
require 'r10k_utils'
|
3
|
+
require 'master_manipulator'
|
4
|
+
|
5
|
+
|
6
|
+
test_name 'Basic Environment Deployment Workflows'
|
7
|
+
|
8
|
+
# This isn't a block because we want to use the local variables throughout the file
|
9
|
+
step 'init'
|
10
|
+
@env_path = on(master, puppet('config print environmentpath')).stdout.rstrip
|
11
|
+
r10k_fqp = get_r10k_fqp(master)
|
12
|
+
|
13
|
+
control_repo_gitdir = '/git_repos/environments.git'
|
14
|
+
control_repo_worktree = '/root/environments'
|
15
|
+
last_commit = git_last_commit(master, control_repo_worktree)
|
16
|
+
git_provider = ENV['GIT_PROVIDER']
|
17
|
+
|
18
|
+
config_path = get_r10k_config_file_path(master)
|
19
|
+
config_backup_path = "#{config_path}.bak"
|
20
|
+
|
21
|
+
puppetfile1 =<<-EOS
|
22
|
+
mod 'puppetlabs/apache', '0.10.0'
|
23
|
+
mod 'puppetlabs/stdlib', '8.0.0'
|
24
|
+
EOS
|
25
|
+
|
26
|
+
r10k_conf = <<-CONF
|
27
|
+
cachedir: '/var/cache/r10k'
|
28
|
+
git:
|
29
|
+
provider: '#{git_provider}'
|
30
|
+
sources:
|
31
|
+
control:
|
32
|
+
basedir: "#{@env_path}"
|
33
|
+
remote: "#{control_repo_gitdir}"
|
34
|
+
deploy:
|
35
|
+
purge_levels: ['deployment','environment','puppetfile']
|
36
|
+
|
37
|
+
CONF
|
38
|
+
|
39
|
+
|
40
|
+
def and_stdlib_is_correct
|
41
|
+
metadata_path = "#{@env_path}/production/modules/stdlib/metadata.json"
|
42
|
+
on(master, "test -f #{metadata_path}", accept_all_exit_codes: true) do |result|
|
43
|
+
assert(result.exit_code == 0, 'stdlib content has been inappropriately purged')
|
44
|
+
end
|
45
|
+
metadata_info = JSON.parse(on(master, "cat #{metadata_path}").stdout)
|
46
|
+
assert(metadata_info['version'] == '8.0.0', 'stdlib deployed to wrong version')
|
47
|
+
end
|
48
|
+
|
49
|
+
teardown do
|
50
|
+
on(master, "mv #{config_backup_path} #{config_path}")
|
51
|
+
clean_up_r10k(master, last_commit, control_repo_worktree)
|
52
|
+
end
|
53
|
+
|
54
|
+
step 'Set up r10k and control repo' do
|
55
|
+
|
56
|
+
# Backup and replace r10k config
|
57
|
+
on(master, "mv #{config_path} #{config_backup_path}")
|
58
|
+
create_remote_file(master, config_path, r10k_conf)
|
59
|
+
|
60
|
+
# Place our Puppetfile in the control repo's production branch
|
61
|
+
git_on(master, 'checkout production', control_repo_worktree)
|
62
|
+
create_remote_file(master, "#{control_repo_worktree}/Puppetfile", puppetfile1)
|
63
|
+
git_add_commit_push(master, 'production', 'add Puppetfile for Basic Deployment test', control_repo_worktree)
|
64
|
+
|
65
|
+
# Ensure the production environment will be deployed anew
|
66
|
+
on(master, "rm -rf #{@env_path}/production")
|
67
|
+
end
|
68
|
+
|
69
|
+
test_path = "#{@env_path}/production/modules/apache/metadata.json"
|
70
|
+
step 'Test initial environment deploy works' do
|
71
|
+
on(master, "#{r10k_fqp} deploy environment production --verbose=info") do |result|
|
72
|
+
assert(result.output =~ /.*Deploying module to .*apache.*/, 'Did not log apache deployment')
|
73
|
+
assert(result.output =~ /.*Deploying module to .*stdlib.*/, 'Did not log stdlib deployment')
|
74
|
+
end
|
75
|
+
on(master, "test -f #{test_path}", accept_all_exit_codes: true) do |result|
|
76
|
+
assert(result.exit_code == 0, 'Expected module in Puppetfile was not installed')
|
77
|
+
end
|
78
|
+
|
79
|
+
and_stdlib_is_correct
|
80
|
+
end
|
81
|
+
|
82
|
+
original_apache_info = JSON.parse(on(master, "cat #{test_path}").stdout)
|
83
|
+
|
84
|
+
step 'Test second run of deploy updates control repo, but leaves moduledir untouched' do
|
85
|
+
puppetfile2 =<<-EOS
|
86
|
+
# Current latest of apache is 6.5.1 as of writing this test
|
87
|
+
mod 'puppetlabs/apache', :latest
|
88
|
+
mod 'puppetlabs/stdlib', '8.0.0'
|
89
|
+
mod 'puppetlabs/concat', '7.0.0'
|
90
|
+
EOS
|
91
|
+
|
92
|
+
git_on(master, 'checkout production', control_repo_worktree)
|
93
|
+
create_remote_file(master, "#{control_repo_worktree}/Puppetfile", puppetfile2)
|
94
|
+
git_add_commit_push(master, 'production', 'add Puppetfile for Basic Deployment test', control_repo_worktree)
|
95
|
+
|
96
|
+
on(master, "#{r10k_fqp} deploy environment production --verbose=info") do |result|
|
97
|
+
refute(result.output =~ /.*Deploying module to .*apache.*/, 'Inappropriately updated apache')
|
98
|
+
refute(result.output =~ /.*Deploying module to .*stdlib.*/, 'Inappropriately updated stdlib')
|
99
|
+
end
|
100
|
+
|
101
|
+
on(master, "test -f #{test_path}", accept_all_exit_codes: true) do |result|
|
102
|
+
assert(result.exit_code == 0, 'Expected module content in Puppetfile was inappropriately purged')
|
103
|
+
end
|
104
|
+
|
105
|
+
new_apache_info = JSON.parse(on(master, "cat #{test_path}").stdout)
|
106
|
+
on(master, "cat #{@env_path}/production/Puppetfile | grep ':latest'", accept_all_exit_codes: true) do |result|
|
107
|
+
assert(result.exit_code == 0, 'Puppetfile not updated on subsequent r10k deploys')
|
108
|
+
end
|
109
|
+
|
110
|
+
assert(original_apache_info['version'] == new_apache_info['version'] &&
|
111
|
+
new_apache_info['version'] == '0.10.0',
|
112
|
+
'Module content updated on subsequent r10k invocations w/o providing --modules')
|
113
|
+
|
114
|
+
on(master, "test -f #{@env_path}/production/modules/concat/metadata.json", accept_all_exit_codes: true) do |result|
|
115
|
+
assert(result.exit_code == 1, 'Module content deployed on subsequent r10k invocation w/o providing --modules')
|
116
|
+
end
|
117
|
+
|
118
|
+
and_stdlib_is_correct
|
119
|
+
end
|
120
|
+
|
121
|
+
step 'Test --modules updates modules' do
|
122
|
+
on(master, "#{r10k_fqp} deploy environment production --modules --verbose=info") do |result|
|
123
|
+
assert(result.output =~ /.*Deploying module to .*apache.*/, 'Did not log apache deployment')
|
124
|
+
assert(result.output =~ /.*Deploying module to .*stdlib.*/, 'Did not log stdlib deployment')
|
125
|
+
assert(result.output =~ /.*Deploying module to .*concat.*/, 'Did not log concat deployment')
|
126
|
+
end
|
127
|
+
|
128
|
+
on(master, "test -f #{test_path}", accept_all_exit_codes: true) do |result|
|
129
|
+
assert(result.exit_code == 0, 'Expected module content in Puppetfile was inappropriately purged')
|
130
|
+
end
|
131
|
+
|
132
|
+
on(master, "test -f #{@env_path}/production/modules/concat/metadata.json", accept_all_exit_codes: true) do |result|
|
133
|
+
assert(result.exit_code == 0, 'New module content was not deployed when providing --modules')
|
134
|
+
end
|
135
|
+
|
136
|
+
new_apache_info = JSON.parse(on(master, "cat #{test_path}").stdout)
|
137
|
+
apache_major_version = new_apache_info['version'].split('.').first.to_i
|
138
|
+
assert(apache_major_version > 5, 'Module not updated correctly using --modules')
|
139
|
+
|
140
|
+
and_stdlib_is_correct
|
141
|
+
end
|
142
|
+
|
143
|
+
step 'Test --modules --incremental deploys changed & dynamic modules, but not unchanged, static modules' do
|
144
|
+
puppetfile3 =<<-EOS
|
145
|
+
# Current latest of apache is 6.5.1 as of writing this test
|
146
|
+
mod 'puppetlabs/apache', :latest
|
147
|
+
mod 'puppetlabs/stdlib', '8.0.0'
|
148
|
+
mod 'puppetlabs/concat', '7.1.0'
|
149
|
+
EOS
|
150
|
+
|
151
|
+
git_on(master, 'checkout production', control_repo_worktree)
|
152
|
+
create_remote_file(master, "#{control_repo_worktree}/Puppetfile", puppetfile3)
|
153
|
+
git_add_commit_push(master, 'production', 'add Puppetfile for Basic Deployment test', control_repo_worktree)
|
154
|
+
|
155
|
+
on(master, "#{r10k_fqp} deploy environment production --modules --incremental --verbose=debug1") do |result|
|
156
|
+
assert(result.output =~ /.*Deploying module to .*apache.*/, 'Did not log apache deployment')
|
157
|
+
assert(result.output =~ /.*Deploying module to .*concat.*/, 'Did not log concat deployment')
|
158
|
+
assert(result.output =~ /.*Not updating module stdlib, assuming content unchanged.*/, 'Did not log notice of skipping stdlib')
|
159
|
+
end
|
160
|
+
|
161
|
+
on(master, "test -f #{test_path}", accept_all_exit_codes: true) do |result|
|
162
|
+
assert(result.exit_code == 0, 'Expected module content in Puppetfile was inappropriately purged')
|
163
|
+
end
|
164
|
+
|
165
|
+
new_apache_info = JSON.parse(on(master, "cat #{test_path}").stdout)
|
166
|
+
apache_major_version = new_apache_info['version'].split('.').first.to_i
|
167
|
+
assert(apache_major_version > 5, 'Module not updated correctly using --modules & --incremental')
|
168
|
+
|
169
|
+
concat_info = JSON.parse(on(master, "cat #{@env_path}/production/modules/concat/metadata.json").stdout)
|
170
|
+
concat_minor_version = concat_info['version'].split('.')[1].to_i
|
171
|
+
assert(concat_minor_version == 1, 'Module not updated correctly using --modules & --incremental')
|
172
|
+
|
173
|
+
and_stdlib_is_correct
|
174
|
+
end
|
175
|
+
|
176
|
+
|
@@ -41,12 +41,14 @@ module R10K
|
|
41
41
|
requested_environments: @argv.map { |arg| arg.gsub(/\W/,'_') },
|
42
42
|
default_branch_override: @default_branch_override,
|
43
43
|
generate_types: @generate_types || settings.dig(:deploy, :generate_types) || false,
|
44
|
-
preload_environments: true
|
44
|
+
preload_environments: true,
|
45
|
+
incremental: @incremental
|
45
46
|
},
|
46
47
|
modules: {
|
47
48
|
exclude_spec: settings.dig(:deploy, :exclude_spec),
|
48
49
|
requested_modules: [],
|
49
50
|
deploy_modules: @modules,
|
51
|
+
pool_size: @settings[:pool_size] || 4,
|
50
52
|
force: !@no_force, # force here is used to make it easier to reason about
|
51
53
|
},
|
52
54
|
purging: {
|
@@ -54,6 +56,9 @@ module R10K
|
|
54
56
|
purge_allowlist: read_purge_allowlist(settings.dig(:deploy, :purge_whitelist) || [],
|
55
57
|
settings.dig(:deploy, :purge_allowlist) || [])
|
56
58
|
},
|
59
|
+
forge: {
|
60
|
+
allow_puppetfile_override: settings.dig(:forge, :allow_puppetfile_override) || false
|
61
|
+
},
|
57
62
|
output: {}
|
58
63
|
}
|
59
64
|
})
|
@@ -130,6 +135,7 @@ module R10K
|
|
130
135
|
envs.reject! { |e| !requested_envs.include?(e) } if requested_envs.any?
|
131
136
|
postcmd = postcmd.map { |e| e.gsub('$modifiedenvs', envs.join(' ')) }
|
132
137
|
end
|
138
|
+
logger.debug _("Executing postrun command.")
|
133
139
|
subproc = R10K::Util::Subprocess.new(postcmd)
|
134
140
|
subproc.logger = logger
|
135
141
|
subproc.execute
|
@@ -237,6 +243,7 @@ module R10K
|
|
237
243
|
super.merge(puppetfile: :modules,
|
238
244
|
modules: :self,
|
239
245
|
cachedir: :self,
|
246
|
+
incremental: :self,
|
240
247
|
'no-force': :self,
|
241
248
|
'exclude-spec': :self,
|
242
249
|
'generate-types': :self,
|
@@ -39,10 +39,14 @@ module R10K
|
|
39
39
|
},
|
40
40
|
modules: {
|
41
41
|
exclude_spec: settings.dig(:deploy, :exclude_spec),
|
42
|
+
pool_size: @settings[:pool_size] || 4,
|
42
43
|
requested_modules: @argv.map.to_a,
|
43
44
|
# force here is used to make it easier to reason about
|
44
45
|
force: !@no_force
|
45
46
|
},
|
47
|
+
forge: {
|
48
|
+
allow_puppetfile_override: settings.dig(:forge, :allow_puppetfile_override) || false
|
49
|
+
},
|
46
50
|
purging: {},
|
47
51
|
output: {}
|
48
52
|
}
|
@@ -74,16 +78,18 @@ module R10K
|
|
74
78
|
ensure
|
75
79
|
if (postcmd = @settings[:postrun])
|
76
80
|
if @modified_envs.any?
|
81
|
+
envs_to_run = @modified_envs.join(' ')
|
82
|
+
logger.debug _("Running postrun command for environments: %{envs_to_run}.") % { envs_to_run: envs_to_run }
|
83
|
+
|
77
84
|
if postcmd.grep('$modifiedenvs').any?
|
78
|
-
envs_to_run = @modified_envs.join(' ')
|
79
|
-
logger.debug "Running postrun command for environments #{envs_to_run}."
|
80
85
|
postcmd = postcmd.map { |e| e.gsub('$modifiedenvs', envs_to_run) }
|
81
86
|
end
|
87
|
+
|
82
88
|
subproc = R10K::Util::Subprocess.new(postcmd)
|
83
89
|
subproc.logger = logger
|
84
90
|
subproc.execute
|
85
91
|
else
|
86
|
-
logger.debug "No environments were modified, not executing postrun command."
|
92
|
+
logger.debug _("No environments were modified, not executing postrun command.")
|
87
93
|
end
|
88
94
|
end
|
89
95
|
end
|
@@ -99,11 +105,10 @@ module R10K
|
|
99
105
|
else
|
100
106
|
logger.debug1(_("Updating modules %{modules} in environment %{env_path}") % {modules: @settings.dig(:overrides, :modules, :requested_modules).inspect, env_path: environment.path})
|
101
107
|
|
102
|
-
environment.deploy
|
108
|
+
updated_modules = environment.deploy
|
103
109
|
|
104
|
-
requested_mods = @settings.dig(:overrides, :modules, :requested_modules) || []
|
105
110
|
# We actually synced a module in this env
|
106
|
-
if !
|
111
|
+
if !updated_modules.nil? && !updated_modules.empty?
|
107
112
|
# Record modified environment for postrun command
|
108
113
|
@modified_envs << environment.dirname
|
109
114
|
|
@@ -1,6 +1,6 @@
|
|
1
|
-
require 'r10k/puppetfile'
|
2
1
|
require 'r10k/action/base'
|
3
2
|
require 'r10k/errors/formatting'
|
3
|
+
require 'r10k/module_loader/puppetfile'
|
4
4
|
|
5
5
|
module R10K
|
6
6
|
module Action
|
@@ -8,11 +8,13 @@ module R10K
|
|
8
8
|
class Check < R10K::Action::Base
|
9
9
|
|
10
10
|
def call
|
11
|
-
|
12
|
-
|
13
|
-
|
11
|
+
options = { basedir: @root }
|
12
|
+
options[:moduledir] = @moduledir if @moduledir
|
13
|
+
options[:puppetfile] = @puppetfile if @puppetfile
|
14
|
+
|
15
|
+
loader = R10K::ModuleLoader::Puppetfile.new(**options)
|
14
16
|
begin
|
15
|
-
|
17
|
+
loader.load!
|
16
18
|
$stderr.puts _("Syntax OK")
|
17
19
|
true
|
18
20
|
rescue => e
|
@@ -1,7 +1,7 @@
|
|
1
|
-
require 'r10k/puppetfile'
|
2
|
-
require 'r10k/errors/formatting'
|
3
|
-
require 'r10k/action/visitor'
|
4
1
|
require 'r10k/action/base'
|
2
|
+
require 'r10k/content_synchronizer'
|
3
|
+
require 'r10k/errors/formatting'
|
4
|
+
require 'r10k/module_loader/puppetfile'
|
5
5
|
require 'r10k/util/cleaner'
|
6
6
|
|
7
7
|
module R10K
|
@@ -10,25 +10,31 @@ module R10K
|
|
10
10
|
class Install < R10K::Action::Base
|
11
11
|
|
12
12
|
def call
|
13
|
-
@ok = true
|
14
13
|
begin
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
14
|
+
options = { basedir: @root, overrides: { force: @force || false } }
|
15
|
+
options[:moduledir] = @moduledir if @moduledir
|
16
|
+
options[:puppetfile] = @puppetfile if @puppetfile
|
17
|
+
|
18
|
+
loader = R10K::ModuleLoader::Puppetfile.new(**options)
|
19
|
+
loaded_content = loader.load!
|
21
20
|
|
22
|
-
|
23
|
-
|
24
|
-
|
21
|
+
pool_size = @settings[:pool_size] || 4
|
22
|
+
modules = loaded_content[:modules]
|
23
|
+
if pool_size > 1
|
24
|
+
R10K::ContentSynchronizer.concurrent_sync(modules, pool_size, logger)
|
25
|
+
else
|
26
|
+
R10K::ContentSynchronizer.serial_sync(modules, logger)
|
27
|
+
end
|
25
28
|
|
29
|
+
R10K::Util::Cleaner.new(loaded_content[:managed_directories],
|
30
|
+
loaded_content[:desired_contents],
|
31
|
+
loaded_content[:purge_exclusions]).purge!
|
32
|
+
|
33
|
+
true
|
26
34
|
rescue => e
|
27
|
-
@ok = false
|
28
35
|
logger.error R10K::Errors::Formatting.format_exception(e, @trace)
|
36
|
+
false
|
29
37
|
end
|
30
|
-
|
31
|
-
@ok
|
32
38
|
end
|
33
39
|
|
34
40
|
private
|