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
@@ -18,16 +18,16 @@ Command line invocation
|
|
18
18
|
|
19
19
|
Recursively update all environments:
|
20
20
|
|
21
|
-
r10k deploy environment --
|
21
|
+
r10k deploy environment --modules
|
22
22
|
|
23
23
|
The simplest way to use r10k is by simply updating all environments and modules
|
24
24
|
and takes the brute force approach of "update everything, ever." When this
|
25
25
|
command is run r10k will update all sources, create new environments and delete
|
26
26
|
old environments, and recursively update all environment modules specified in
|
27
|
-
environment Puppetfiles. While this is the simplest method for
|
28
|
-
is also the slowest by a very large degree because it does the
|
29
|
-
work. This should not be something you run interactively, or
|
30
|
-
basis.
|
27
|
+
environment Puppetfiles, yamldirs, etc. While this is the simplest method for
|
28
|
+
running r10k, it is also the slowest by a very large degree because it does the
|
29
|
+
maximum possible work. This should not be something you run interactively, or
|
30
|
+
use on a regular basis.
|
31
31
|
|
32
32
|
- - -
|
33
33
|
|
@@ -55,7 +55,7 @@ only the environment itself will be updated.
|
|
55
55
|
|
56
56
|
Update a single environment and force an update of modules:
|
57
57
|
|
58
|
-
r10k deploy environment my_working_environment --
|
58
|
+
r10k deploy environment my_working_environment --modules
|
59
59
|
|
60
60
|
This will update the given environment and update all contained modules. This is
|
61
61
|
useful if you want to make sure that a given environment is fully up to date.
|
@@ -64,13 +64,14 @@ useful if you want to make sure that a given environment is fully up to date.
|
|
64
64
|
|
65
65
|
Update a single environment and specify a default branch override:
|
66
66
|
|
67
|
-
r10k deploy environment my_working_environment --
|
67
|
+
r10k deploy environment my_working_environment --modules --default-branch-override default_branch_override
|
68
68
|
|
69
|
-
This will update the given environment and update all contained modules,
|
70
|
-
the :default_branch entry in the Puppetfile of each module.
|
69
|
+
This will update the given environment and update all contained modules, overriding
|
70
|
+
the :default_branch entry in the Puppetfile of each module. If the specified override branch is not
|
71
|
+
found, it will fall back to the normal default branch and attempt to use that. This is used primarily to allow
|
71
72
|
automated r10k solutions using the control_branch pattern with a temporary branch deployment to
|
72
|
-
ensure the deployment is pushed to the correct module repository branch. Note that the :default_branch
|
73
|
-
|
73
|
+
ensure the deployment is pushed to the correct module repository branch. Note that the :default_branch and its
|
74
|
+
override are only ever used if the specific desired ref cannot be located.
|
74
75
|
|
75
76
|
### Deploying modules
|
76
77
|
|
data/doc/puppetfile.mkd
CHANGED
@@ -109,11 +109,19 @@ latest version available.
|
|
109
109
|
|
110
110
|
mod 'puppetlabs/apache', :latest
|
111
111
|
|
112
|
+
An explicit type and/or version can be specified using the standard interface,
|
113
|
+
`:type` and `:version`. The `:source` parameter is not supported for individual
|
114
|
+
forge modules and will be ignored.
|
115
|
+
|
116
|
+
mod 'puppetlabs/apache',
|
117
|
+
type: 'forge',
|
118
|
+
version: '6.0.0'
|
119
|
+
|
112
120
|
### Git
|
113
121
|
|
114
122
|
Git repositories that contain a Puppet module can be cloned and used as modules.
|
115
123
|
When Git is used, the module version can be specified by using `:ref`, `:tag`,
|
116
|
-
`:commit`,
|
124
|
+
`:commit`, `:branch`, or the standard interface parameter `:version`.
|
117
125
|
|
118
126
|
When a module is installed using `:ref`, r10k uses some simple heuristics to
|
119
127
|
determine the type of Git object that should be checked out. This can be used
|
@@ -153,6 +161,13 @@ mod 'apache',
|
|
153
161
|
mod 'apache',
|
154
162
|
:git => 'https://github.com/puppetlabs/puppetlabs-apache',
|
155
163
|
:branch => 'docs_experiment'
|
164
|
+
|
165
|
+
# Install puppetlabs/apache and use standard interface parameters pinned to the
|
166
|
+
# '2098a17' commit.
|
167
|
+
mod 'puppetlabs-apache',
|
168
|
+
type: 'git',
|
169
|
+
source: 'https://github.com/puppetlabs/puppetlabs-apache',
|
170
|
+
version: '2098a17'
|
156
171
|
```
|
157
172
|
|
158
173
|
#### Control Repo Branch Tracking
|
@@ -195,8 +210,8 @@ the latest version available in the main SVN repository.
|
|
195
210
|
mod 'apache',
|
196
211
|
:svn => 'https://github.com/puppetlabs/puppetlabs-apache/trunk'
|
197
212
|
|
198
|
-
If an SVN revision number is specified with `:rev
|
199
|
-
SVN revision will be kept checked out.
|
213
|
+
If an SVN revision number is specified with `:rev`, `:revision`, or `:version`,
|
214
|
+
that SVN revision will be kept checked out.
|
200
215
|
|
201
216
|
mod 'apache',
|
202
217
|
:svn => 'https://github.com/puppetlabs/puppetlabs-apache/trunk',
|
@@ -206,6 +221,11 @@ SVN revision will be kept checked out.
|
|
206
221
|
:svn => 'https://github.com/puppetlabs/puppetlabs-apache/trunk',
|
207
222
|
:revision => '154'
|
208
223
|
|
224
|
+
mod 'apache',
|
225
|
+
type: 'svn',
|
226
|
+
source: 'https://github.com/puppetlabs/puppetlabs-apache/trunk',
|
227
|
+
version: '154'
|
228
|
+
|
209
229
|
If the SVN repository requires credentials, you can supply the `:username` and
|
210
230
|
`:password` options.
|
211
231
|
|
data/docker/Gemfile
CHANGED
data/docker/Makefile
CHANGED
@@ -5,12 +5,12 @@ vcs_ref := $(shell git rev-parse HEAD)
|
|
5
5
|
build_date := $(shell date -u +%FT%T)
|
6
6
|
hadolint_available := $(shell hadolint --help > /dev/null 2>&1; echo $$?)
|
7
7
|
hadolint_command := hadolint
|
8
|
-
hadolint_container := hadolint/hadolint:latest
|
8
|
+
hadolint_container := ghcr.io/hadolint/hadolint:latest
|
9
9
|
alpine_version := 3.9
|
10
10
|
export BUNDLE_PATH = $(PWD)/.bundle/gems
|
11
11
|
export BUNDLE_BIN = $(PWD)/.bundle/bin
|
12
12
|
export GEMFILE = $(PWD)/Gemfile
|
13
|
-
export DOCKER_BUILDKIT
|
13
|
+
export DOCKER_BUILDKIT ?= 1
|
14
14
|
|
15
15
|
ifeq ($(IS_RELEASE),true)
|
16
16
|
VERSION ?= $(shell echo $(git_describe) | sed 's/-.*//')
|
@@ -50,8 +50,9 @@ endif
|
|
50
50
|
|
51
51
|
build: prep
|
52
52
|
docker pull alpine:$(alpine_version)
|
53
|
-
docker build \
|
53
|
+
docker buildx build \
|
54
54
|
${DOCKER_BUILD_FLAGS} \
|
55
|
+
--load \
|
55
56
|
--build-arg alpine_version=$(alpine_version) \
|
56
57
|
--build-arg vcs_ref=$(vcs_ref) \
|
57
58
|
--build-arg build_date=$(build_date) \
|
@@ -0,0 +1,18 @@
|
|
1
|
+
version: '3.7'
|
2
|
+
|
3
|
+
services:
|
4
|
+
r10k_check:
|
5
|
+
image: ${R10K_IMAGE:-puppet/r10k}
|
6
|
+
environment:
|
7
|
+
- PUPPERWARE_ANALYTICS_ENABLED=${PUPPERWARE_ANALYTICS_ENABLED:-false}
|
8
|
+
command: 'puppetfile check --verbose --trace --puppetfile test/Puppetfile'
|
9
|
+
volumes:
|
10
|
+
- ${SPEC_DIRECTORY}/fixtures:/home/puppet/test
|
11
|
+
|
12
|
+
r10k_install:
|
13
|
+
image: ${R10K_IMAGE:-puppet/r10k}
|
14
|
+
environment:
|
15
|
+
- PUPPERWARE_ANALYTICS_ENABLED=${PUPPERWARE_ANALYTICS_ENABLED:-false}
|
16
|
+
command: 'puppetfile install --verbose --trace --puppetfile test/Puppetfile'
|
17
|
+
volumes:
|
18
|
+
- ${SPEC_DIRECTORY}/fixtures:/home/puppet/test
|
data/docker/r10k/Dockerfile
CHANGED
@@ -49,7 +49,7 @@ COPY --from=build /workspace/r10k.gem /
|
|
49
49
|
SHELL ["/bin/ash", "-eo", "pipefail", "-c"]
|
50
50
|
# ignore apk and gem pinning
|
51
51
|
# hadolint ignore=DL3018,DL3028
|
52
|
-
RUN chmod a+x /adduser.sh /docker-entrypoint.sh && \
|
52
|
+
RUN chmod a+x /adduser.sh /docker-entrypoint.sh /docker-entrypoint.d/*.sh && \
|
53
53
|
# Add a puppet user to run r10k as for consistency with puppetserver
|
54
54
|
/adduser.sh && \
|
55
55
|
chown -R puppet: /docker-entrypoint.d /docker-entrypoint.sh && \
|
@@ -38,7 +38,7 @@ LABEL org.label-schema.version="$version" \
|
|
38
38
|
SHELL ["/bin/ash", "-eo", "pipefail", "-c"]
|
39
39
|
# ignore apk and gem pinning
|
40
40
|
# hadolint ignore=DL3018,DL3028
|
41
|
-
RUN chmod a+x /adduser.sh /docker-entrypoint.sh && \
|
41
|
+
RUN chmod a+x /adduser.sh /docker-entrypoint.sh /docker-entrypoint.d/*.sh && \
|
42
42
|
/adduser.sh && \
|
43
43
|
chown -R puppet: /docker-entrypoint.d /docker-entrypoint.sh && \
|
44
44
|
apk add --no-cache ruby openssh-client git ruby-rugged curl ruby-dev make gcc musl-dev && \
|
@@ -1,43 +1,37 @@
|
|
1
1
|
require 'rspec/core'
|
2
2
|
require 'fileutils'
|
3
3
|
require 'open3'
|
4
|
+
include Pupperware::SpecHelpers
|
4
5
|
|
5
|
-
SPEC_DIRECTORY = File.dirname(__FILE__)
|
6
|
+
ENV['SPEC_DIRECTORY'] = File.dirname(__FILE__)
|
7
|
+
# unifies volume naming
|
8
|
+
ENV['COMPOSE_PROJECT_NAME'] ||= 'r10k'
|
6
9
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
--trace \
|
15
|
-
--puppetfile test/Puppetfile")
|
16
|
-
end
|
17
|
-
|
18
|
-
before(:all) do
|
19
|
-
@image = require_test_image
|
10
|
+
RSpec.configure do |c|
|
11
|
+
c.before(:suite) do
|
12
|
+
ENV['R10K_IMAGE'] = require_test_image
|
13
|
+
pull_images(['r10k_check','r10k_install'])
|
14
|
+
teardown_cluster()
|
15
|
+
# no certs to preload, but if the suite adds puppetserver, be explicit
|
16
|
+
docker_compose_up(preload_certs: true)
|
20
17
|
end
|
21
18
|
|
22
|
-
after(:
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
it 'should validate the Puppetfile' do
|
27
|
-
result = run_r10k('puppetfile check')
|
28
|
-
container = result[:stdout].chomp
|
29
|
-
wait_on_container_exit(container)
|
30
|
-
expect(get_container_exit_code(container)).to eq(0)
|
31
|
-
emit_log(container)
|
32
|
-
teardown_container(container)
|
19
|
+
c.after(:suite) do
|
20
|
+
teardown_cluster()
|
21
|
+
FileUtils.rm_rf(File.join(ENV['SPEC_DIRECTORY'], 'fixtures', 'modules'))
|
33
22
|
end
|
23
|
+
end
|
34
24
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
25
|
+
describe 'r10k container' do
|
26
|
+
{
|
27
|
+
'r10k_check': 'validate',
|
28
|
+
'r10k_install': 'install',
|
29
|
+
}.each do |container, op|
|
30
|
+
it "should #{op} the Puppetfile" do
|
31
|
+
container = get_service_container(container)
|
32
|
+
wait_on_container_exit(container)
|
33
|
+
expect(get_container_exit_code(container)).to eq(0)
|
34
|
+
emit_log(container)
|
35
|
+
end
|
42
36
|
end
|
43
37
|
end
|
@@ -30,11 +30,11 @@ CONF
|
|
30
30
|
puppetfile = <<-EOS
|
31
31
|
mod 'prod_apache',
|
32
32
|
:git => 'git://github.com/puppetlabs/puppetlabs-apache.git',
|
33
|
-
:
|
33
|
+
:tag => 'v6.0.0'
|
34
34
|
|
35
35
|
mod 'test_apache',
|
36
36
|
:git => 'git://github.com/puppetlabs/puppetlabs-apache.git',
|
37
|
-
:
|
37
|
+
:tag => 'v6.0.0'
|
38
38
|
EOS
|
39
39
|
|
40
40
|
teardown do
|
@@ -27,7 +27,8 @@ stdlib_notify_message_regex = /The test message is:.*one.*=>.*1.*two.*=>.*bats.*
|
|
27
27
|
puppet_file = <<-PUPPETFILE
|
28
28
|
mod "puppetlabs/motd"
|
29
29
|
mod 'puppetlabs/stdlib',
|
30
|
-
:git => 'git://github.com/puppetlabs/puppetlabs-stdlib.git'
|
30
|
+
:git => 'git://github.com/puppetlabs/puppetlabs-stdlib.git',
|
31
|
+
:tag => 'v7.0.1'
|
31
32
|
PUPPETFILE
|
32
33
|
|
33
34
|
puppet_file_path = File.join(git_environments_path, 'Puppetfile')
|
data/integration/tests/user_scenario/basic_workflow/multi_env_custom_forge_git_module_static.rb
CHANGED
@@ -31,7 +31,8 @@ puppet_file = <<-PUPPETFILE
|
|
31
31
|
moduledir '#{@module_path}'
|
32
32
|
mod "puppetlabs/motd"
|
33
33
|
mod 'puppetlabs/stdlib',
|
34
|
-
:git => 'git://github.com/puppetlabs/puppetlabs-stdlib.git'
|
34
|
+
:git => 'git://github.com/puppetlabs/puppetlabs-stdlib.git',
|
35
|
+
:tag => 'v7.0.1'
|
35
36
|
PUPPETFILE
|
36
37
|
|
37
38
|
puppet_file_path = File.join(git_environments_path, 'Puppetfile')
|
@@ -65,7 +65,7 @@ env_structs = {:production => GitEnv.new('/git_repos',
|
|
65
65
|
'/git_repos_alt/environments_alt.git',
|
66
66
|
'/root/environments_alt',
|
67
67
|
'/root/environments_alt/Puppetfile',
|
68
|
-
'mod "puppetlabs/stdlib", :git => "git://github.com/puppetlabs/puppetlabs-stdlib.git"',
|
68
|
+
'mod "puppetlabs/stdlib", :git => "git://github.com/puppetlabs/puppetlabs-stdlib.git", :tag => "v7.0.1"',
|
69
69
|
'/root/environments_alt/manifests/site.pp',
|
70
70
|
create_site_pp(master_certname, stage_env_manifest)
|
71
71
|
),
|
@@ -28,7 +28,8 @@ notify_message_regex = /I am in the production environment/
|
|
28
28
|
puppet_file = <<-PUPPETFILE
|
29
29
|
mod "puppetlabs/motd"
|
30
30
|
mod 'puppetlabs/inifile',
|
31
|
-
:git => 'git://github.com/puppetlabs/puppetlabs-inifile'
|
31
|
+
:git => 'git://github.com/puppetlabs/puppetlabs-inifile',
|
32
|
+
:tag => 'v5.0.1'
|
32
33
|
PUPPETFILE
|
33
34
|
|
34
35
|
puppet_file_path = File.join(git_environments_path, 'Puppetfile')
|
@@ -24,7 +24,7 @@ stage_env_notify_message = 'This is a different message'
|
|
24
24
|
stage_env_notify_message_regex = /#{stage_env_notify_message}/
|
25
25
|
|
26
26
|
#Verification for "test" Environment
|
27
|
-
test_env_error_message_regex = /Error:.*Could not
|
27
|
+
test_env_error_message_regex = /Error:.*Could not.*environment '?test'?/
|
28
28
|
|
29
29
|
#Verification for "temp" Environment
|
30
30
|
test_env_notify_message_regex = /I am in the temp environment/
|
@@ -15,7 +15,7 @@ initial_env_names = ['production', 'stage']
|
|
15
15
|
|
16
16
|
#Verification
|
17
17
|
notify_message_regex = /I am in the production environment/
|
18
|
-
stage_env_error_message_regex = /Error:.*Could not
|
18
|
+
stage_env_error_message_regex = /Error:.*Could not.*environment '?stage'?/
|
19
19
|
|
20
20
|
#Manifest
|
21
21
|
site_pp_path = File.join(git_environments_path, 'manifests', 'site.pp')
|
@@ -22,7 +22,7 @@ site_pp = create_site_pp(master_certname, ' include helloworld')
|
|
22
22
|
notify_message_prod_env_regex = /I am in the production environment/
|
23
23
|
notify_message_test_env_regex = /I am in the test environment/
|
24
24
|
removal_message_test_env_regex = /Removing unmanaged path.*test/
|
25
|
-
error_message_regex = /Could not retrieve catalog from remote server/
|
25
|
+
error_message_regex = /Could not retrieve (catalog from remote server|information from environment test)/
|
26
26
|
|
27
27
|
#Teardown
|
28
28
|
teardown do
|
data/lib/r10k/action/base.rb
CHANGED
@@ -10,6 +10,16 @@ module R10K
|
|
10
10
|
|
11
11
|
attr_accessor :settings
|
12
12
|
|
13
|
+
# @param opts [Hash] A hash of options defined in #allowed_initialized_opts
|
14
|
+
# and managed by the SetOps mixin within the Action::Base class.
|
15
|
+
# Corresponds to the CLI flags and options.
|
16
|
+
# @param argv [Enumerable] Typically CRI::ArgumentList or Array. A list-like
|
17
|
+
# collection of the remaining arguments to the CLI invocation (after
|
18
|
+
# removing flags and options).
|
19
|
+
# @param settings [Hash] A hash of configuration loaded from the relevant
|
20
|
+
# config (r10k.yaml).
|
21
|
+
#
|
22
|
+
# @note All arguments will be required in the next major version
|
13
23
|
def initialize(opts, argv, settings = {})
|
14
24
|
@opts = opts
|
15
25
|
@argv = argv
|
@@ -9,17 +9,48 @@ 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 [Enumerable] Typically CRI::ArgumentList or Array. A list-like
|
16
|
+
# collection of the remaining arguments to the CLI invocation (after
|
17
|
+
# removing flags and options).
|
18
|
+
# @param settings [Hash] A hash of configuration loaded from the relevant
|
19
|
+
# config (r10k.yaml).
|
20
|
+
#
|
21
|
+
# @note All arguments will be required in the next major version
|
22
|
+
def initialize(opts, argv, settings = {})
|
23
|
+
super
|
24
|
+
|
25
|
+
@settings = @settings.merge({
|
26
|
+
overrides: {
|
27
|
+
environments: {
|
28
|
+
preload_environments: @fetch,
|
29
|
+
requested_environments: @argv.map { |arg| arg.gsub(/\W/, '_') }
|
30
|
+
},
|
31
|
+
modules: {},
|
32
|
+
output: {
|
33
|
+
format: @format,
|
34
|
+
trace: @trace,
|
35
|
+
detail: @detail
|
36
|
+
},
|
37
|
+
purging: {}
|
38
|
+
}
|
39
|
+
})
|
40
|
+
end
|
41
|
+
|
12
42
|
def call
|
13
43
|
expect_config!
|
14
44
|
deployment = R10K::Deployment.new(@settings)
|
15
45
|
|
16
|
-
if @
|
46
|
+
if @settings.dig(:overrides, :environments, :preload_environments)
|
17
47
|
deployment.preload!
|
48
|
+
deployment.validate!
|
18
49
|
end
|
19
50
|
|
20
|
-
output = { :sources => deployment.sources.map { |source| source_info(source, @
|
51
|
+
output = { :sources => deployment.sources.map { |source| source_info(source, @settings.dig(:overrides, :environments, :requested_environments)) } }
|
21
52
|
|
22
|
-
case @format
|
53
|
+
case @settings.dig(:overrides, :output, :format)
|
23
54
|
when 'json' then json_format(output)
|
24
55
|
else yaml_format(output)
|
25
56
|
end
|
@@ -27,7 +58,7 @@ module R10K
|
|
27
58
|
# exit 0
|
28
59
|
true
|
29
60
|
rescue => e
|
30
|
-
logger.error R10K::Errors::Formatting.format_exception(e, @trace)
|
61
|
+
logger.error R10K::Errors::Formatting.format_exception(e, @settings.dig(:overrides, :output, :trace))
|
31
62
|
false
|
32
63
|
end
|
33
64
|
|
@@ -43,7 +74,7 @@ module R10K
|
|
43
74
|
puts output.to_yaml
|
44
75
|
end
|
45
76
|
|
46
|
-
def source_info(source,
|
77
|
+
def source_info(source, requested_environments = [])
|
47
78
|
source_info = {
|
48
79
|
:name => source.name,
|
49
80
|
:basedir => source.basedir,
|
@@ -52,28 +83,30 @@ module R10K
|
|
52
83
|
source_info[:prefix] = source.prefix if source.prefix
|
53
84
|
source_info[:remote] = source.remote if source.respond_to?(:remote)
|
54
85
|
|
55
|
-
|
86
|
+
select_all_envs = requested_environments.empty?
|
87
|
+
env_list = source.environments.select { |env| select_all_envs || requested_environments.include?(env.name) }
|
56
88
|
source_info[:environments] = env_list.map { |env| environment_info(env) }
|
57
89
|
|
58
90
|
source_info
|
59
91
|
end
|
60
92
|
|
61
93
|
def environment_info(env)
|
62
|
-
|
94
|
+
modules = @settings.dig(:overrides, :environments, :deploy_modules)
|
95
|
+
if !modules && !@settings.dig(:overrides, :output, :detail)
|
63
96
|
env.dirname
|
64
97
|
else
|
65
98
|
env_info = env.info.merge({
|
66
99
|
:status => (env.status rescue nil),
|
67
100
|
})
|
68
101
|
|
69
|
-
env_info[:modules] = env.modules.map { |mod| module_info(mod) } if
|
102
|
+
env_info[:modules] = env.modules.map { |mod| module_info(mod) } if modules
|
70
103
|
|
71
104
|
env_info
|
72
105
|
end
|
73
106
|
end
|
74
107
|
|
75
108
|
def module_info(mod)
|
76
|
-
if @detail
|
109
|
+
if @settings.dig(:overrides, :output, :detail)
|
77
110
|
{ :name => mod.title, :properties => mod.properties }
|
78
111
|
else
|
79
112
|
mod.title
|
@@ -81,7 +114,13 @@ module R10K
|
|
81
114
|
end
|
82
115
|
|
83
116
|
def allowed_initialize_opts
|
84
|
-
super.merge(
|
117
|
+
super.merge({
|
118
|
+
puppetfile: :modules,
|
119
|
+
modules: :self,
|
120
|
+
detail: :self,
|
121
|
+
format: :self,
|
122
|
+
fetch: :self
|
123
|
+
})
|
85
124
|
end
|
86
125
|
end
|
87
126
|
end
|