r10k 3.11.0 → 3.14.0
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 +1 -1
- data/.github/workflows/rspec_tests.yml +2 -2
- data/.travis.yml +1 -1
- data/CHANGELOG.mkd +34 -0
- data/doc/dynamic-environments/configuration.mkd +35 -7
- data/doc/dynamic-environments/usage.mkd +26 -0
- data/doc/puppetfile.mkd +16 -4
- data/integration/tests/basic_functionality/basic_deployment.rb +176 -0
- data/lib/r10k/action/base.rb +1 -1
- data/lib/r10k/action/deploy/deploy_helpers.rb +4 -0
- data/lib/r10k/action/deploy/display.rb +1 -1
- data/lib/r10k/action/deploy/environment.rb +13 -8
- data/lib/r10k/action/deploy/module.rb +14 -10
- 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/action/runner.rb +6 -0
- data/lib/r10k/action/visitor.rb +3 -0
- 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/bare.rb +4 -7
- data/lib/r10k/environment/base.rb +64 -11
- data/lib/r10k/environment/name.rb +14 -9
- data/lib/r10k/environment/plain.rb +16 -0
- data/lib/r10k/environment/tarball.rb +78 -0
- data/lib/r10k/environment/with_modules.rb +6 -10
- data/lib/r10k/environment.rb +2 -0
- data/lib/r10k/errors.rb +5 -0
- data/lib/r10k/forge/module_release.rb +2 -1
- data/lib/r10k/git/cache.rb +4 -13
- data/lib/r10k/git/rugged/base_repository.rb +12 -1
- data/lib/r10k/git/rugged/cache.rb +8 -0
- data/lib/r10k/git/stateful_repository.rb +9 -0
- data/lib/r10k/initializers.rb +21 -7
- data/lib/r10k/logging.rb +78 -1
- 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 +6 -3
- data/lib/r10k/module/svn.rb +10 -0
- data/lib/r10k/module/tarball.rb +101 -0
- data/lib/r10k/module.rb +21 -2
- data/lib/r10k/module_loader/puppetfile/dsl.rb +8 -3
- data/lib/r10k/module_loader/puppetfile.rb +109 -30
- data/lib/r10k/puppetfile.rb +1 -2
- data/lib/r10k/settings.rb +46 -0
- data/lib/r10k/source/git.rb +18 -18
- data/lib/r10k/source/yaml.rb +1 -1
- data/lib/r10k/tarball.rb +183 -0
- data/lib/r10k/util/cacheable.rb +31 -0
- data/lib/r10k/util/downloader.rb +134 -0
- data/lib/r10k/util/purgeable.rb +6 -2
- data/lib/r10k/util/setopts.rb +2 -0
- data/lib/r10k/util/subprocess.rb +1 -0
- data/lib/r10k/version.rb +1 -1
- data/locales/r10k.pot +119 -71
- data/r10k.gemspec +2 -2
- data/r10k.yaml.example +28 -0
- data/spec/fixtures/tarball/tarball.tar.gz +0 -0
- data/spec/fixtures/unit/action/r10k_logging.yaml +12 -0
- data/spec/fixtures/unit/puppetfile/forge-override/Puppetfile +8 -0
- data/spec/fixtures/unit/puppetfile/various-modules/Puppetfile +10 -0
- data/spec/fixtures/unit/puppetfile/various-modules/Puppetfile.new +10 -0
- data/spec/fixtures/unit/util/purgeable/managed_one/managed_subdir_1/managed_symlink_file +1 -0
- data/spec/fixtures/unit/util/purgeable/managed_one/managed_subdir_1/{managed_subdir_2 → subdir_allowlisted_2}/ignored_1 +0 -0
- data/spec/fixtures/unit/util/purgeable/managed_one/managed_subdir_1/unmanaged_symlink_dir +1 -0
- data/spec/fixtures/unit/util/purgeable/managed_one/managed_symlink_dir +1 -0
- data/spec/fixtures/unit/util/purgeable/managed_one/unmanaged_symlink_file +1 -0
- data/spec/integration/git/rugged/cache_spec.rb +33 -0
- data/spec/integration/util/purageable_spec.rb +41 -0
- data/spec/r10k-mocks/mock_env.rb +3 -0
- data/spec/r10k-mocks/mock_source.rb +7 -3
- data/spec/shared-contexts/tarball.rb +32 -0
- data/spec/spec_helper.rb +1 -0
- data/spec/unit/action/deploy/environment_spec.rb +80 -30
- data/spec/unit/action/deploy/module_spec.rb +52 -64
- 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 +52 -9
- data/spec/unit/environment/bare_spec.rb +13 -0
- data/spec/unit/environment/base_spec.rb +30 -17
- data/spec/unit/environment/git_spec.rb +2 -2
- data/spec/unit/environment/name_spec.rb +18 -0
- data/spec/unit/environment/plain_spec.rb +8 -0
- data/spec/unit/environment/svn_spec.rb +4 -3
- data/spec/unit/environment/tarball_spec.rb +45 -0
- data/spec/unit/environment/with_modules_spec.rb +3 -2
- data/spec/unit/git/cache_spec.rb +2 -15
- data/spec/unit/git/rugged/cache_spec.rb +19 -0
- 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/tarball_spec.rb +70 -0
- data/spec/unit/module_loader/puppetfile_spec.rb +96 -31
- data/spec/unit/puppetfile_spec.rb +2 -2
- data/spec/unit/settings_spec.rb +25 -2
- data/spec/unit/tarball_spec.rb +57 -0
- data/spec/unit/util/cacheable_spec.rb +23 -0
- data/spec/unit/util/downloader_spec.rb +98 -0
- data/spec/unit/util/purgeable_spec.rb +22 -11
- metadata +44 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: da22a28bcd5de19a996ff2c869ba074c402e393d7a3caa2528bb342c75192234
|
4
|
+
data.tar.gz: 9bf7067d8412b9d158f2d47ad96499f90183c5dcade26b97fede2a344b06dca0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a2a529ce1b781f858253f1d929e4cf521806a8f11ce9733a4f2dc92dcfd4792d4afcbad9290a814d10a14be645eb0ada9551c542def43f6acc48d28931783bc2
|
7
|
+
data.tar.gz: 31d2a9e5d85f29da1c6f62d77d7bbd83c7ed8c4687bb5035f7185c8b37042e2707e59b623d6603af5d533ee79c44380d4a3a4a1a2a28ddd06af9c723c6f1c1bb
|
@@ -59,7 +59,7 @@ jobs:
|
|
59
59
|
bundle --version
|
60
60
|
|
61
61
|
# Run tests
|
62
|
-
bundle exec rspec --color --format documentation spec
|
62
|
+
bundle exec rspec --color --format documentation spec
|
63
63
|
|
64
64
|
- name: Run tests on Linux
|
65
65
|
if: runner.os == 'Linux'
|
@@ -78,4 +78,4 @@ jobs:
|
|
78
78
|
fi
|
79
79
|
|
80
80
|
# Run tests
|
81
|
-
bundle exec rspec --color --format documentation spec
|
81
|
+
bundle exec rspec --color --format documentation spec
|
data/.travis.yml
CHANGED
data/CHANGELOG.mkd
CHANGED
@@ -4,6 +4,40 @@ CHANGELOG
|
|
4
4
|
Unreleased
|
5
5
|
----------
|
6
6
|
|
7
|
+
3.14.0
|
8
|
+
------
|
9
|
+
|
10
|
+
- Record unprocessed environment name, so that `strip_component` does not cause truncated environment names to be used as git branches, resulting in errors or incorrect deploys. [#1240](https://github.com/puppetlabs/r10k/pull/1240)
|
11
|
+
- (CODEMGMT-1294) Resync repos with unresolvable refs [#1239](https://github.com/puppetlabs/r10k/pull/1239)
|
12
|
+
- (RK-378) Restore access to the environment name from the Puppetfile [#1241](https://github.com/puppetlabs/r10k/pull/1241)
|
13
|
+
- (CODEMGMT-1300) Ensure the remote url in rugged cache directories is current [#1245](https://github.com/puppetlabs/r10k/pull/1245)
|
14
|
+
- Add support for tarball module type, allowing module content to be packaged and sourced from generic fileservers [#1244](https://github.com/puppetlabs/r10k/pull/1244)
|
15
|
+
- Add experimental support for tarball environment type, allowing whole environments to be packaged and sourced from generic fileservers [#1244](https://github.com/puppetlabs/r10k/pull/1244)
|
16
|
+
|
17
|
+
3.13.0
|
18
|
+
------
|
19
|
+
|
20
|
+
- Restore Ruby 3 compatibility [#1234](https://github.com/puppetlabs/r10k/pull/1234)
|
21
|
+
- (RK-381) Do not recurse into symlinked dirs when finding files to purge. [#1233](https://github.com/puppetlabs/r10k/pull/1233)
|
22
|
+
- Purge should remove unmanaged directories, in addition to unmanaged files. [#1222](https://github.com/puppetlabs/r10k/pull/1222)
|
23
|
+
- Rename experimental environment type "bare" to "plain". [#1228](https://github.com/puppetlabs/r10k/pull/1228)
|
24
|
+
- Add support for specifying additional logging ouputs. [#1230](https://github.com/puppetlabs/r10k/issues/1230)
|
25
|
+
|
26
|
+
3.12.1
|
27
|
+
------
|
28
|
+
|
29
|
+
- Fix requiring individual R10K::Actions without having already required 'r10k'. [#1223](https://github.com/puppetlabs/r10k/issues/1223)
|
30
|
+
- Fix evaluation of Puppetfiles that include local modules. [#1224](https://github.com/puppetlabs/r10k/pull/1224)
|
31
|
+
|
32
|
+
3.12.0
|
33
|
+
------
|
34
|
+
|
35
|
+
- (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)
|
36
|
+
- (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)
|
37
|
+
- (CODEMGMT-1454) Ensure missing repo caches are re-synced [#1210](https://github.com/puppetlabs/r10k/pull/1210)
|
38
|
+
- (PF-2437) Allow token authentication to be used with the Forge. [#1192](https://github.com/puppetlabs/r10k/pull/1192)
|
39
|
+
- Only run the module postrun command for environments in which the module was modified. [#1215](https://github.com/puppetlabs/r10k/issues/1215)
|
40
|
+
|
7
41
|
3.11.0
|
8
42
|
------
|
9
43
|
|
@@ -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
|
|
@@ -756,16 +760,16 @@ modules:
|
|
756
760
|
version: 62d07f2
|
757
761
|
```
|
758
762
|
|
759
|
-
###
|
763
|
+
### Plain Environment Type
|
760
764
|
|
761
765
|
A "control repository" typically contains a hiera.yaml, an environment.conf, a manifests/site.pp file, and a few other things. However, none of these are strictly necessary for an environment to be functional if modules can be deployed to it.
|
762
766
|
|
763
|
-
The
|
767
|
+
The plain environment type allows sources that support environment modules to operate without a control repo being required. Modules can be deployed directly.
|
764
768
|
|
765
769
|
```yaml
|
766
770
|
---
|
767
771
|
production:
|
768
|
-
type:
|
772
|
+
type: plain
|
769
773
|
modules:
|
770
774
|
puppetlabs-stdlib:
|
771
775
|
type: forge
|
@@ -779,7 +783,7 @@ production:
|
|
779
783
|
version: 62d07f2
|
780
784
|
|
781
785
|
development:
|
782
|
-
type:
|
786
|
+
type: plain
|
783
787
|
modules:
|
784
788
|
puppetlabs-stdlib:
|
785
789
|
type: forge
|
@@ -792,3 +796,27 @@ development:
|
|
792
796
|
source: https://github.com/reidmv/reidmv-xampl.git
|
793
797
|
version: 62d07f2
|
794
798
|
```
|
799
|
+
|
800
|
+
### Tarball Environment Type
|
801
|
+
|
802
|
+
The tarball environment type allows an environment to be deployed from a tarball archive, rather than a Git repository. When using a tarball environment type, a source location for the tarball is required. Optionally, the tarball's sha256 checksum may be specified as the version. It is highly recommended to include a version specifier. If a version specifier is not included, r10k will never invalidate a cached copy of the tarball's source.
|
803
|
+
|
804
|
+
Tarball environment sources will be unpacked directly into the environment root.
|
805
|
+
|
806
|
+
```yaml
|
807
|
+
---
|
808
|
+
production:
|
809
|
+
type: tarball
|
810
|
+
source: https://repo.example.com/projects/puppet/env-2.36.1.tar.gz
|
811
|
+
version: 99a906c99c2f144de43f2ae500509a7474ed11c583fb623efa8e5b377a3157f0 # sha256digest
|
812
|
+
|
813
|
+
development:
|
814
|
+
type: tarball
|
815
|
+
source: https://repo.example.com/projects/puppet/env-6128ada.tar.gz
|
816
|
+
version: 6128ada158622cd90f8e1360fb7c2c3830a812d1ec26ddf0db7eb16d61b7293f # sha256digest
|
817
|
+
modules:
|
818
|
+
reidmv-xampl:
|
819
|
+
type: git
|
820
|
+
source: https://github.com/reidmv/reidmv-xampl.git
|
821
|
+
version: 62d07f2
|
822
|
+
```
|
@@ -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
|
|
@@ -240,6 +239,19 @@ credentials may be visible in the process table when r10k is running. If you
|
|
240
239
|
choose to supply SVN credentials make sure that the system running r10k is
|
241
240
|
appropriately secured.
|
242
241
|
|
242
|
+
### Tarball
|
243
|
+
|
244
|
+
Modules can be installed from tarball archives. A tarball module must specify a source URL to retreive the tarball content from. A tarball module may optionally specify a sha256 checksum as the module version.
|
245
|
+
|
246
|
+
mod 'puppetlabs-apache',
|
247
|
+
type: 'tarball',
|
248
|
+
source: 'https://repo.example.com/puppet/modules/puppetlabs-apache-7.0.0.tar.gz',
|
249
|
+
version: 'aedd6dc1a5136c6a1a1ec2f285df2a70b0fe4c9effb254b5a1f58116e4c1659e' # sha256 digest
|
250
|
+
|
251
|
+
If no version is specified, a tarball will be downloaded from the given source and cached. The cache will not be invalidated until the source URL is changed, or a sha256 checksum version is provided.
|
252
|
+
|
253
|
+
Tarball module content will be unpacked directly into an appropriately named module directory. For example, the puppetlabs-apache-7.0.0.tar.gz archive in the example above will be unpacked into `<environment-dir>/modules/apache/`.
|
254
|
+
|
243
255
|
### Local
|
244
256
|
|
245
257
|
In the event you want to store locally written modules in your r10k-managed
|
@@ -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
|
+
|
data/lib/r10k/action/base.rb
CHANGED
@@ -1,10 +1,9 @@
|
|
1
|
-
require 'r10k/util/setopts'
|
2
|
-
require 'r10k/util/cleaner'
|
3
|
-
require 'r10k/deployment'
|
4
|
-
require 'r10k/logging'
|
5
|
-
require 'r10k/action/visitor'
|
6
1
|
require 'r10k/action/base'
|
7
2
|
require 'r10k/action/deploy/deploy_helpers'
|
3
|
+
require 'r10k/action/visitor'
|
4
|
+
require 'r10k/deployment'
|
5
|
+
require 'r10k/util/setopts'
|
6
|
+
|
8
7
|
require 'json'
|
9
8
|
|
10
9
|
module R10K
|
@@ -13,6 +12,7 @@ module R10K
|
|
13
12
|
class Environment < R10K::Action::Base
|
14
13
|
|
15
14
|
include R10K::Action::Deploy::DeployHelpers
|
15
|
+
include R10K::Action::Visitor
|
16
16
|
|
17
17
|
# Deprecated
|
18
18
|
attr_reader :force
|
@@ -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
|
})
|
@@ -76,8 +81,6 @@ module R10K
|
|
76
81
|
@visit_ok
|
77
82
|
end
|
78
83
|
|
79
|
-
include R10K::Action::Visitor
|
80
|
-
|
81
84
|
private
|
82
85
|
|
83
86
|
def read_purge_allowlist (whitelist, allowlist)
|
@@ -130,6 +133,7 @@ module R10K
|
|
130
133
|
envs.reject! { |e| !requested_envs.include?(e) } if requested_envs.any?
|
131
134
|
postcmd = postcmd.map { |e| e.gsub('$modifiedenvs', envs.join(' ')) }
|
132
135
|
end
|
136
|
+
logger.debug _("Executing postrun command.")
|
133
137
|
subproc = R10K::Util::Subprocess.new(postcmd)
|
134
138
|
subproc.logger = logger
|
135
139
|
subproc.execute
|
@@ -237,6 +241,7 @@ module R10K
|
|
237
241
|
super.merge(puppetfile: :modules,
|
238
242
|
modules: :self,
|
239
243
|
cachedir: :self,
|
244
|
+
incremental: :self,
|
240
245
|
'no-force': :self,
|
241
246
|
'exclude-spec': :self,
|
242
247
|
'generate-types': :self,
|
@@ -1,7 +1,7 @@
|
|
1
|
-
require 'r10k/deployment'
|
2
|
-
require 'r10k/action/visitor'
|
3
1
|
require 'r10k/action/base'
|
4
2
|
require 'r10k/action/deploy/deploy_helpers'
|
3
|
+
require 'r10k/action/visitor'
|
4
|
+
require 'r10k/deployment'
|
5
5
|
|
6
6
|
module R10K
|
7
7
|
module Action
|
@@ -9,6 +9,7 @@ module R10K
|
|
9
9
|
class Module < R10K::Action::Base
|
10
10
|
|
11
11
|
include R10K::Action::Deploy::DeployHelpers
|
12
|
+
include R10K::Action::Visitor
|
12
13
|
|
13
14
|
# Deprecated
|
14
15
|
attr_reader :force
|
@@ -39,10 +40,14 @@ module R10K
|
|
39
40
|
},
|
40
41
|
modules: {
|
41
42
|
exclude_spec: settings.dig(:deploy, :exclude_spec),
|
43
|
+
pool_size: @settings[:pool_size] || 4,
|
42
44
|
requested_modules: @argv.map.to_a,
|
43
45
|
# force here is used to make it easier to reason about
|
44
46
|
force: !@no_force
|
45
47
|
},
|
48
|
+
forge: {
|
49
|
+
allow_puppetfile_override: settings.dig(:forge, :allow_puppetfile_override) || false
|
50
|
+
},
|
46
51
|
purging: {},
|
47
52
|
output: {}
|
48
53
|
}
|
@@ -65,8 +70,6 @@ module R10K
|
|
65
70
|
@visit_ok
|
66
71
|
end
|
67
72
|
|
68
|
-
include R10K::Action::Visitor
|
69
|
-
|
70
73
|
private
|
71
74
|
|
72
75
|
def visit_deployment(deployment)
|
@@ -74,16 +77,18 @@ module R10K
|
|
74
77
|
ensure
|
75
78
|
if (postcmd = @settings[:postrun])
|
76
79
|
if @modified_envs.any?
|
80
|
+
envs_to_run = @modified_envs.join(' ')
|
81
|
+
logger.debug _("Running postrun command for environments: %{envs_to_run}.") % { envs_to_run: envs_to_run }
|
82
|
+
|
77
83
|
if postcmd.grep('$modifiedenvs').any?
|
78
|
-
envs_to_run = @modified_envs.join(' ')
|
79
|
-
logger.debug "Running postrun command for environments #{envs_to_run}."
|
80
84
|
postcmd = postcmd.map { |e| e.gsub('$modifiedenvs', envs_to_run) }
|
81
85
|
end
|
86
|
+
|
82
87
|
subproc = R10K::Util::Subprocess.new(postcmd)
|
83
88
|
subproc.logger = logger
|
84
89
|
subproc.execute
|
85
90
|
else
|
86
|
-
logger.debug "No environments were modified, not executing postrun command."
|
91
|
+
logger.debug _("No environments were modified, not executing postrun command.")
|
87
92
|
end
|
88
93
|
end
|
89
94
|
end
|
@@ -99,11 +104,10 @@ module R10K
|
|
99
104
|
else
|
100
105
|
logger.debug1(_("Updating modules %{modules} in environment %{env_path}") % {modules: @settings.dig(:overrides, :modules, :requested_modules).inspect, env_path: environment.path})
|
101
106
|
|
102
|
-
environment.deploy
|
107
|
+
updated_modules = environment.deploy
|
103
108
|
|
104
|
-
requested_mods = @settings.dig(:overrides, :modules, :requested_modules) || []
|
105
109
|
# We actually synced a module in this env
|
106
|
-
if !
|
110
|
+
if !updated_modules.nil? && !updated_modules.empty?
|
107
111
|
# Record modified environment for postrun command
|
108
112
|
@modified_envs << environment.dirname
|
109
113
|
|
@@ -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
|