r10k 3.9.3 → 3.12.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/rspec_tests.yml +1 -1
- data/.travis.yml +0 -10
- data/CHANGELOG.mkd +33 -0
- data/README.mkd +6 -0
- data/doc/dynamic-environments/configuration.mkd +25 -0
- data/doc/dynamic-environments/usage.mkd +26 -0
- data/doc/puppetfile.mkd +18 -5
- data/integration/Rakefile +3 -1
- data/integration/tests/basic_functionality/basic_deployment.rb +176 -0
- data/integration/tests/user_scenario/basic_workflow/negative/neg_specify_deleted_forge_module.rb +3 -9
- data/integration/tests/user_scenario/basic_workflow/single_env_purge_unmanaged_modules.rb +21 -25
- data/integration/tests/user_scenario/complex_workflow/multi_env_add_change_remove.rb +3 -3
- data/integration/tests/user_scenario/complex_workflow/multi_env_remove_re-add.rb +3 -3
- data/integration/tests/user_scenario/complex_workflow/multi_env_unamanaged.rb +3 -3
- 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 +22 -9
- data/lib/r10k/action/deploy/module.rb +41 -11
- 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 +45 -10
- data/lib/r10k/action/visitor.rb +3 -0
- data/lib/r10k/cli/deploy.rb +5 -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/cache.rb +1 -1
- data/lib/r10k/git/rugged/credentials.rb +77 -0
- data/lib/r10k/git/stateful_repository.rb +8 -0
- data/lib/r10k/git.rb +3 -0
- data/lib/r10k/initializers.rb +4 -0
- data/lib/r10k/module/base.rb +42 -1
- data/lib/r10k/module/definition.rb +64 -0
- data/lib/r10k/module/forge.rb +16 -3
- data/lib/r10k/module/git.rb +23 -1
- data/lib/r10k/module/local.rb +6 -3
- data/lib/r10k/module/svn.rb +11 -0
- data/lib/r10k/module.rb +20 -2
- data/lib/r10k/module_loader/puppetfile/dsl.rb +42 -0
- data/lib/r10k/module_loader/puppetfile.rb +276 -0
- data/lib/r10k/puppetfile.rb +82 -160
- data/lib/r10k/settings/definition.rb +1 -1
- data/lib/r10k/settings.rb +58 -2
- data/lib/r10k/source/base.rb +10 -0
- data/lib/r10k/source/git.rb +5 -0
- data/lib/r10k/source/svn.rb +4 -0
- data/lib/r10k/util/purgeable.rb +74 -8
- 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 +165 -65
- data/r10k.gemspec +2 -0
- data/spec/fixtures/unit/action/r10k_forge_auth.yaml +4 -0
- data/spec/fixtures/unit/action/r10k_forge_auth_no_url.yaml +3 -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_subdir_2/ignored_1 +0 -0
- data/spec/fixtures/unit/util/purgeable/managed_two/.hidden/unmanaged_3 +0 -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 +105 -30
- data/spec/unit/action/deploy/module_spec.rb +232 -42
- 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 +122 -26
- 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/git/cache_spec.rb +14 -0
- data/spec/unit/git/rugged/credentials_spec.rb +29 -0
- data/spec/unit/git/stateful_repository_spec.rb +5 -0
- data/spec/unit/module/base_spec.rb +54 -8
- data/spec/unit/module/forge_spec.rb +59 -5
- data/spec/unit/module/git_spec.rb +67 -9
- data/spec/unit/module/svn_spec.rb +35 -5
- data/spec/unit/module_loader/puppetfile_spec.rb +405 -0
- data/spec/unit/module_spec.rb +12 -1
- data/spec/unit/puppetfile_spec.rb +125 -189
- data/spec/unit/settings_spec.rb +47 -2
- data/spec/unit/util/purgeable_spec.rb +38 -6
- metadata +29 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5500f864c81a0b1ff5f48461bca9de375450f452028a93d381ec65eac3b35865
|
4
|
+
data.tar.gz: 1d675799b9bf1df2ee328780bc90ed4e79c02bf7706a166dd40f5af952e9610a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cc75dcceceb3b368c6ee9dd1773a92530e67a59b1e35b52e3d8205d3dffb6b1b7d4b927edbe58bc828d9a1782d1052254464ca7c0556ea6099c5975811ddad1a
|
7
|
+
data.tar.gz: 12ecfa266d5c7cafc1a6656bb54d5429ecb030c2b89af8d61a2dcd6587f8bc1ff6f94221a4f185d9e463a96df652d2434adec0c59a78288bc44dda087c67ca12
|
@@ -15,7 +15,7 @@ jobs:
|
|
15
15
|
- {os: ubuntu-18.04, ruby: 2.5}
|
16
16
|
- {os: ubuntu-18.04, ruby: 2.6}
|
17
17
|
- {os: ubuntu-18.04, ruby: 2.7}
|
18
|
-
- {os: ubuntu-18.04, ruby: jruby-9.2.
|
18
|
+
- {os: ubuntu-18.04, ruby: jruby-9.2.10.0}
|
19
19
|
- {os: windows-2016, ruby: 2.5}
|
20
20
|
- {os: windows-2016, ruby: 2.6}
|
21
21
|
- {os: windows-2016, ruby: 2.7}
|
data/.travis.yml
CHANGED
@@ -10,18 +10,8 @@ jdk:
|
|
10
10
|
before_install: gem install bundler -v '< 2' --no-document
|
11
11
|
matrix:
|
12
12
|
include:
|
13
|
-
- stage: r10k tests
|
14
|
-
rvm: 2.7.0
|
15
|
-
- stage: r10k tests
|
16
|
-
rvm: 2.6.5
|
17
|
-
- stage: r10k tests
|
18
|
-
rvm: 2.5.0
|
19
|
-
- stage: r10k tests
|
20
|
-
rvm: 2.4.0
|
21
13
|
- stage: r10k tests
|
22
14
|
rvm: 2.3.0
|
23
|
-
- stage: r10k tests
|
24
|
-
rvm: jruby
|
25
15
|
- stage: r10k container tests
|
26
16
|
dist: focal
|
27
17
|
language: ruby
|
data/CHANGELOG.mkd
CHANGED
@@ -4,6 +4,39 @@ CHANGELOG
|
|
4
4
|
Unreleased
|
5
5
|
----------
|
6
6
|
|
7
|
+
3.12.1
|
8
|
+
------
|
9
|
+
|
10
|
+
- Fix requiring individual R10K::Actions without having already required 'r10k'. [#1223](https://github.com/puppetlabs/r10k/issues/1223)
|
11
|
+
- Fix evaluation of Puppetfiles that include local modules. [#1224](https://github.com/puppetlabs/r10k/pull/1224)
|
12
|
+
|
13
|
+
3.12.0
|
14
|
+
------
|
15
|
+
|
16
|
+
- (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)
|
17
|
+
- (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)
|
18
|
+
- (CODEMGMT-1454) Ensure missing repo caches are re-synced [#1210](https://github.com/puppetlabs/r10k/pull/1210)
|
19
|
+
- (PF-2437) Allow token authentication to be used with the Forge. [#1192](https://github.com/puppetlabs/r10k/pull/1192)
|
20
|
+
- Only run the module postrun command for environments in which the module was modified. [#1215](https://github.com/puppetlabs/r10k/issues/1215)
|
21
|
+
|
22
|
+
3.11.0
|
23
|
+
------
|
24
|
+
|
25
|
+
- Always sync git cache on `ref: 'HEAD'` [#1182](https://github.com/puppetlabs/r10k/pull/1182)
|
26
|
+
- (CODEMGMT-1421, CODEMGMT-1422, CODEMGMT-1457) Add setting `exclude_spec` to remove the spec dir from module deployment[#1189](https://github.com/puppetlabs/r10k/pull/1189)[#1198](https://github.com/puppetlabs/r10k/pull/1198)[#1204](https://github.com/puppetlabs/r10k/pull/1204)
|
27
|
+
- (RK-369) Make module deploys run the postrun command if any environments were updated. [#982](https://github.com/puppetlabs/r10k/issues/982)
|
28
|
+
- Add support for Github App auth token. This allows r10k to authenticate under strict SSO/2FA guidelines that cannot utilize machine users for code deployment. [#1180](https://github.com/puppetlabs/r10k/pull/1180)
|
29
|
+
- Restore the ability to load a Puppetfile from a relative `basedir`. [#1202](https://github.com/puppetlabs/r10k/pull/1202), [#1203](https://github.com/puppetlabs/r10k/pull/1203)
|
30
|
+
|
31
|
+
3.10.0
|
32
|
+
------
|
33
|
+
|
34
|
+
- Add `authorization_token` setting to allow authentication to a custom Forge server. [#1181](https://github.com/puppetlabs/r10k/pull/1181)
|
35
|
+
- (RK-135) Attempting to download the latest version for a module that has no Forge releases will now issue a meaningful error. [#1177](https://github.com/puppetlabs/r10k/pull/1177)
|
36
|
+
- Added an interface to R10K::Source::Base named `reload!` for updating the environments list for a given deployment; `reload!` is called before deployment purges to make r10k deploy pools more threadsafe. [#1172](https://github.com/puppetlabs/r10k/pull/1172)
|
37
|
+
- Remove username and password from remote url in cache directory name [#1186](https://github.com/puppetlabs/r10k/pull/1186)
|
38
|
+
- Purging efficiency is greatly improved. R10K will no longer recurse into directories that match recursive purge exclusions. This should significantly improve the deploy times for those users who enable the "environment" purge level. [#1178](https://github.com/puppetlabs/r10k/pull/1178)
|
39
|
+
|
7
40
|
3.9.3
|
8
41
|
-----
|
9
42
|
|
data/README.mkd
CHANGED
@@ -66,6 +66,12 @@ a git repository using Bundler for dependencies:
|
|
66
66
|
bundle install
|
67
67
|
bundle exec r10k help
|
68
68
|
|
69
|
+
### Arch Linux
|
70
|
+
|
71
|
+
Arch Linux provides a [system package](https://archlinux.org/packages/community/any/r10k/) for r10k.
|
72
|
+
This is built against the [system Ruby](https://archlinux.org/packages/extra/x86_64/ruby/) (which is Ruby 3.0.2 as of 2021-08-03).
|
73
|
+
This package is maintained by [Tim Meusel](https://github.com/bastelfreak).
|
74
|
+
|
69
75
|
Usage
|
70
76
|
-----
|
71
77
|
|
@@ -165,11 +165,22 @@ interactions. See the global proxy setting documentation for more information an
|
|
165
165
|
The 'baseurl' setting indicates where Forge modules should be installed from.
|
166
166
|
This defaults to 'https://forgeapi.puppetlabs.com'
|
167
167
|
|
168
|
+
#### authorization_token
|
169
|
+
|
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.
|
172
|
+
|
168
173
|
```yaml
|
169
174
|
forge:
|
170
175
|
baseurl: 'https://private-forge.mysite'
|
176
|
+
authorization_token: 'Bearer mysupersecretauthtoken'
|
171
177
|
```
|
172
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
|
+
|
173
184
|
Deployment options
|
174
185
|
------------------
|
175
186
|
|
@@ -336,6 +347,20 @@ deploy:
|
|
336
347
|
puppet_conf: '/opt/puppet/conf/puppet.conf'
|
337
348
|
```
|
338
349
|
|
350
|
+
#### exclude_spec
|
351
|
+
|
352
|
+
During module deployment, r10k's default behavior is to deploy the spec directory.
|
353
|
+
This behavior can be configured for all modules using the `exclude_spec` setting in the r10k config.
|
354
|
+
This config setting can be overridden in each module definition in the Puppetfile
|
355
|
+
or more globally via the CLI for deploys. The following example sets all modules to
|
356
|
+
not deploy the spec dir.
|
357
|
+
|
358
|
+
|
359
|
+
```yaml
|
360
|
+
deploy:
|
361
|
+
exclude_spec: true
|
362
|
+
```
|
363
|
+
|
339
364
|
Source options
|
340
365
|
--------------
|
341
366
|
|
@@ -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
|
|
@@ -130,7 +129,8 @@ with a git commit, branch reference, or a tag.
|
|
130
129
|
When a module is installed using `:tag` or `:commit`, r10k assumes that the
|
131
130
|
given object is a tag or commit and can do some optimizations around fetching
|
132
131
|
the object. If the tag or commit is already available r10k will skip network
|
133
|
-
operations when updating the repo, which can speed up install times.
|
132
|
+
operations when updating the repo, which can speed up install times. When
|
133
|
+
`:ref` is set to track `HEAD`, it will synchronize the module on each run.
|
134
134
|
|
135
135
|
Module versions can also be specified using `:branch` to track a specific
|
136
136
|
branch reference.
|
@@ -312,6 +312,19 @@ module.
|
|
312
312
|
For more information see the [FAQ entry](faq.mkd#how-do-i-prevent-r10k-from-removing-modules-in-the-modules-directory-of-my-git-repository)
|
313
313
|
on managing internal and external modules in the same directory.
|
314
314
|
|
315
|
+
### Per-Item spec dir deployment
|
316
|
+
|
317
|
+
During deployment, r10k's default behavior is to deploy the spec directory. The
|
318
|
+
Puppetfile can modify this per module, overriding settings from the default
|
319
|
+
r10k config. The following example sets the module to not deploy the spec
|
320
|
+
directory.
|
321
|
+
|
322
|
+
```
|
323
|
+
mod 'apache',
|
324
|
+
:git => 'git@github.com:puppetlabs/puppetlabs-apache.git',
|
325
|
+
:exclude_spec => true
|
326
|
+
```
|
327
|
+
|
315
328
|
### Per-Item Install Path
|
316
329
|
|
317
330
|
Git and SVN content types support installing into an alternate path without changing
|
data/integration/Rakefile
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'rototiller'
|
2
|
+
require 'fileutils'
|
2
3
|
|
3
4
|
namespace :ci do
|
4
5
|
namespace :test do
|
@@ -59,13 +60,14 @@ end
|
|
59
60
|
desc 'Generate a host configuration used by Beaker'
|
60
61
|
rototiller_task :beaker_hostgenerator do |t|
|
61
62
|
if ENV['BEAKER_HOST'].nil?
|
63
|
+
FileUtils.mkdir_p 'configs'
|
62
64
|
t.add_command do |c|
|
63
65
|
c.name = 'beaker-hostgenerator'
|
64
66
|
c.argument = '> configs/generated'
|
65
67
|
end
|
66
68
|
|
67
69
|
# This is a hack :(
|
68
|
-
t.add_flag(:name => '', :default => '
|
70
|
+
t.add_flag(:name => '', :default => 'centos7-64mdca-64.fa', :override_env => 'TEST_TARGET')
|
69
71
|
|
70
72
|
t.add_flag(:name => '--global-config', :default => '{forge_host=forge-aio01-petest.puppetlabs.com}', :override_env => 'BHG_GLOBAL_CONFIG')
|
71
73
|
end
|
@@ -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/integration/tests/user_scenario/basic_workflow/negative/neg_specify_deleted_forge_module.rb
CHANGED
@@ -10,7 +10,7 @@ last_commit = git_last_commit(master, git_environments_path)
|
|
10
10
|
r10k_fqp = get_r10k_fqp(master)
|
11
11
|
|
12
12
|
#Verification
|
13
|
-
error_notification_regex = /
|
13
|
+
error_notification_regex = /The module puppetlabs-regret does not appear to have any published releases/
|
14
14
|
|
15
15
|
#File
|
16
16
|
puppet_file = <<-PUPPETFILE
|
@@ -40,12 +40,6 @@ git_add_commit_push(master, 'production', 'Add module.', git_environments_path)
|
|
40
40
|
|
41
41
|
#Tests
|
42
42
|
step "Deploy production environment via r10k with specified module deleted"
|
43
|
-
on(master, "#{r10k_fqp} deploy environment -p -v", :acceptable_exit_codes => 1) do |result|
|
44
|
-
|
45
|
-
assert_match(error_notification_regex, result.stderr, 'Unexpected error was detected!')
|
46
|
-
else
|
47
|
-
expect_failure('expected to fail due to RK-135') do
|
48
|
-
assert_match(error_notification_regex, result.stderr, 'Unexpected error was detected!')
|
49
|
-
end
|
50
|
-
end
|
43
|
+
on(master, "#{r10k_fqp} deploy environment -p -v --trace", :acceptable_exit_codes => 1) do |result|
|
44
|
+
assert_match(error_notification_regex, result.stderr, 'Unexpected error was detected!')
|
51
45
|
end
|
@@ -1,12 +1,15 @@
|
|
1
1
|
require 'git_utils'
|
2
2
|
require 'r10k_utils'
|
3
3
|
require 'master_manipulator'
|
4
|
-
test_name 'CODEMGMT-
|
4
|
+
test_name 'CODEMGMT-78 - Puppetfile Purge --puppetfile & --moduledir flag usage'
|
5
5
|
|
6
6
|
#Init
|
7
7
|
master_certname = on(master, puppet('config', 'print', 'certname')).stdout.rstrip
|
8
|
-
|
9
|
-
|
8
|
+
environments_path = on(master, puppet('config', 'print', 'environmentpath')).stdout.strip
|
9
|
+
moduledir = File.join(environments_path, 'production', 'modules')
|
10
|
+
puppetfile_path = File.join(environments_path, 'production', 'Puppetfile')
|
11
|
+
git_remote_environments_path = '/root/environments'
|
12
|
+
last_commit = git_last_commit(master, git_remote_environments_path)
|
10
13
|
r10k_fqp = get_r10k_fqp(master)
|
11
14
|
|
12
15
|
#Verification
|
@@ -14,14 +17,12 @@ motd_path = '/etc/motd'
|
|
14
17
|
motd_contents = 'Hello!'
|
15
18
|
motd_contents_regex = /\A#{motd_contents}\z/
|
16
19
|
|
17
|
-
error_message_regex = /Blah/
|
18
|
-
|
19
20
|
#File
|
20
|
-
|
21
|
+
puppetfile = <<-PUPPETFILE
|
21
22
|
mod "puppetlabs/xinetd"
|
22
23
|
PUPPETFILE
|
23
24
|
|
24
|
-
|
25
|
+
remote_puppetfile_path = File.join(git_remote_environments_path, 'Puppetfile')
|
25
26
|
|
26
27
|
#Manifest
|
27
28
|
manifest = <<-MANIFEST
|
@@ -30,12 +31,12 @@ manifest = <<-MANIFEST
|
|
30
31
|
}
|
31
32
|
MANIFEST
|
32
33
|
|
33
|
-
|
34
|
+
remote_site_pp_path = File.join(git_remote_environments_path, 'manifests', 'site.pp')
|
34
35
|
site_pp = create_site_pp(master_certname, manifest)
|
35
36
|
|
36
37
|
#Teardown
|
37
38
|
teardown do
|
38
|
-
clean_up_r10k(master, last_commit,
|
39
|
+
clean_up_r10k(master, last_commit, git_remote_environments_path)
|
39
40
|
|
40
41
|
step 'Remove "/etc/motd" File'
|
41
42
|
on(agents, "rm -rf #{motd_path}")
|
@@ -46,27 +47,24 @@ step 'Stub Forge on Master'
|
|
46
47
|
stub_forge_on(master)
|
47
48
|
|
48
49
|
step 'Checkout "production" Branch'
|
49
|
-
git_on(master, 'checkout production',
|
50
|
-
|
51
|
-
step 'Manually Install the "motd" Module from the Forge'
|
52
|
-
on(master, puppet('module install puppetlabs-motd'))
|
50
|
+
git_on(master, 'checkout production', git_remote_environments_path)
|
53
51
|
|
54
52
|
step 'Create "Puppetfile" for the "production" Environment'
|
55
|
-
create_remote_file(master,
|
53
|
+
create_remote_file(master, remote_puppetfile_path, puppetfile)
|
56
54
|
|
57
55
|
step 'Inject New "site.pp" to the "production" Environment'
|
58
|
-
inject_site_pp(master,
|
56
|
+
inject_site_pp(master, remote_site_pp_path, site_pp)
|
59
57
|
|
60
58
|
step 'Push Changes'
|
61
|
-
git_add_commit_push(master, 'production', 'Update site.pp and add module.',
|
59
|
+
git_add_commit_push(master, 'production', 'Update site.pp and add module.', git_remote_environments_path)
|
62
60
|
|
63
|
-
#Tests
|
64
61
|
step 'Deploy Environments via r10k'
|
65
|
-
on(master, "#{r10k_fqp} deploy environment
|
62
|
+
on(master, "#{r10k_fqp} deploy environment --modules --verbose debug --trace")
|
66
63
|
|
67
|
-
step '
|
68
|
-
on(
|
64
|
+
step 'Manually Install the "motd" Module from the Forge'
|
65
|
+
on(master, puppet("module install puppetlabs-motd --modulepath #{moduledir}"))
|
69
66
|
|
67
|
+
#Tests
|
70
68
|
agents.each do |agent|
|
71
69
|
step 'Run Puppet Agent Against "production" Environment'
|
72
70
|
on(agent, puppet('agent', '--test', '--environment production'), :acceptable_exit_codes => 2) do |result|
|
@@ -80,14 +78,12 @@ agents.each do |agent|
|
|
80
78
|
end
|
81
79
|
|
82
80
|
step 'Use r10k to Purge Unmanaged Modules'
|
83
|
-
on(master, "#{r10k_fqp} puppetfile purge
|
81
|
+
on(master, "#{r10k_fqp} puppetfile purge --puppetfile #{puppetfile_path} --moduledir #{moduledir} --verbose debug --trace")
|
84
82
|
|
85
83
|
#Agent will fail because r10k will purge the "motd" module
|
86
84
|
agents.each do |agent|
|
87
85
|
step 'Attempt to Run Puppet Agent'
|
88
|
-
on(agent, puppet('agent', '--test', '--environment production'), :acceptable_exit_codes =>
|
89
|
-
|
90
|
-
assert_match(error_message_regex, result.stderr, 'Expected error was not detected!')
|
91
|
-
end
|
86
|
+
on(agent, puppet('agent', '--test', '--environment production'), :acceptable_exit_codes => 1) do |result|
|
87
|
+
assert_match(/Could not find declared class motd/, result.stderr, 'Module was not purged')
|
92
88
|
end
|
93
89
|
end
|
@@ -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
|
-
|
27
|
+
test_env_message_regex = /Environment 'test' not found on server/
|
28
28
|
|
29
29
|
#Verification for "temp" Environment
|
30
30
|
test_env_notify_message_regex = /I am in the temp environment/
|
@@ -157,7 +157,7 @@ agents.each do |agent|
|
|
157
157
|
end
|
158
158
|
|
159
159
|
step 'Attempt to Run Puppet Agent Against "test" Environment'
|
160
|
-
on(agent, puppet('agent', '--test', '--environment test'), :acceptable_exit_codes =>
|
161
|
-
assert_match(
|
160
|
+
on(agent, puppet('agent', '--test', '--environment test'), :acceptable_exit_codes => 2) do |result|
|
161
|
+
assert_match(test_env_message_regex, result.stdout, 'Expected message not found!')
|
162
162
|
end
|
163
163
|
end
|
@@ -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
|
-
|
18
|
+
stage_env_message_regex = /Environment 'stage' not found on server/
|
19
19
|
|
20
20
|
#Manifest
|
21
21
|
site_pp_path = File.join(git_environments_path, 'manifests', 'site.pp')
|
@@ -83,8 +83,8 @@ agents.each do |agent|
|
|
83
83
|
end
|
84
84
|
|
85
85
|
step 'Attempt to Run Puppet Agent Against "stage" Environment'
|
86
|
-
on(agent, puppet('agent', '--test', '--environment stage'), :acceptable_exit_codes =>
|
87
|
-
assert_match(
|
86
|
+
on(agent, puppet('agent', '--test', '--environment stage'), :acceptable_exit_codes => 2) do |result|
|
87
|
+
assert_match(stage_env_message_regex, result.stdout, 'Expected message not found!')
|
88
88
|
end
|
89
89
|
end
|
90
90
|
|
@@ -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
|
-
|
25
|
+
missing_message_regex = /Environment 'test' not found on server/
|
26
26
|
|
27
27
|
#Teardown
|
28
28
|
teardown do
|
@@ -72,7 +72,7 @@ end
|
|
72
72
|
|
73
73
|
agents.each do |agent|
|
74
74
|
step 'Run Puppet Agent Against "test" Environment'
|
75
|
-
on(agent, puppet('agent', '--test', '--environment test'), :acceptable_exit_codes =>
|
76
|
-
assert_match(
|
75
|
+
on(agent, puppet('agent', '--test', '--environment test'), :acceptable_exit_codes => 2) do |result|
|
76
|
+
assert_match(missing_message_regex, result.stdout, 'Expected message not found!')
|
77
77
|
end
|
78
78
|
end
|
data/lib/r10k/action/base.rb
CHANGED