r10k 3.5.1 → 3.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (84) hide show
  1. checksums.yaml +4 -4
  2. data/.github/pull_request_template.md +4 -1
  3. data/.github/workflows/docker.yml +4 -1
  4. data/.github/workflows/release.yml +3 -2
  5. data/.github/workflows/rspec_tests.yml +81 -0
  6. data/.travis.yml +8 -1
  7. data/CHANGELOG.mkd +43 -2
  8. data/CODEOWNERS +2 -2
  9. data/README.mkd +13 -4
  10. data/doc/common-patterns.mkd +1 -0
  11. data/doc/dynamic-environments/configuration.mkd +143 -39
  12. data/doc/dynamic-environments/usage.mkd +12 -11
  13. data/doc/puppetfile.mkd +23 -3
  14. data/docker/Gemfile +1 -1
  15. data/docker/Makefile +7 -4
  16. data/docker/docker-compose.yml +18 -0
  17. data/docker/r10k/Dockerfile +4 -3
  18. data/docker/r10k/docker-entrypoint.sh +0 -1
  19. data/docker/r10k/release.Dockerfile +3 -2
  20. data/docker/spec/dockerfile_spec.rb +26 -32
  21. data/integration/tests/git_source/git_source_repeated_remote.rb +68 -0
  22. data/integration/tests/user_scenario/basic_workflow/multi_env_custom_forge_git_module.rb +2 -1
  23. data/integration/tests/user_scenario/basic_workflow/multi_env_custom_forge_git_module_static.rb +2 -1
  24. data/integration/tests/user_scenario/basic_workflow/multi_source_custom_forge_git_module.rb +1 -1
  25. data/integration/tests/user_scenario/basic_workflow/single_env_custom_forge_git_module.rb +2 -1
  26. data/integration/tests/user_scenario/complex_workflow/multi_env_add_change_remove.rb +1 -1
  27. data/integration/tests/user_scenario/complex_workflow/multi_env_remove_re-add.rb +1 -1
  28. data/integration/tests/user_scenario/complex_workflow/multi_env_unamanaged.rb +1 -1
  29. data/lib/r10k/action/deploy/display.rb +9 -3
  30. data/lib/r10k/action/deploy/environment.rb +39 -14
  31. data/lib/r10k/action/deploy/module.rb +4 -1
  32. data/lib/r10k/action/runner.rb +34 -0
  33. data/lib/r10k/cli/deploy.rb +14 -7
  34. data/lib/r10k/cli/puppetfile.rb +5 -5
  35. data/lib/r10k/environment/base.rb +9 -2
  36. data/lib/r10k/environment/git.rb +17 -2
  37. data/lib/r10k/environment/name.rb +22 -4
  38. data/lib/r10k/environment/svn.rb +11 -2
  39. data/lib/r10k/environment/with_modules.rb +28 -20
  40. data/lib/r10k/forge/module_release.rb +2 -2
  41. data/lib/r10k/git.rb +1 -0
  42. data/lib/r10k/git/cache.rb +12 -4
  43. data/lib/r10k/git/rugged/credentials.rb +39 -2
  44. data/lib/r10k/git/stateful_repository.rb +4 -0
  45. data/lib/r10k/initializers.rb +2 -0
  46. data/lib/r10k/module/base.rb +8 -0
  47. data/lib/r10k/module/forge.rb +16 -4
  48. data/lib/r10k/module/git.rb +42 -24
  49. data/lib/r10k/module/local.rb +1 -1
  50. data/lib/r10k/module/svn.rb +14 -11
  51. data/lib/r10k/puppetfile.rb +30 -12
  52. data/lib/r10k/settings.rb +30 -3
  53. data/lib/r10k/source/base.rb +5 -0
  54. data/lib/r10k/source/git.rb +26 -3
  55. data/lib/r10k/source/hash.rb +4 -2
  56. data/lib/r10k/source/svn.rb +5 -1
  57. data/lib/r10k/util/setopts.rb +33 -12
  58. data/lib/r10k/version.rb +1 -1
  59. data/locales/r10k.pot +71 -43
  60. data/r10k.gemspec +1 -1
  61. data/spec/fixtures/unit/action/r10k_creds.yaml +9 -0
  62. data/spec/shared-examples/subprocess-runner.rb +11 -5
  63. data/spec/unit/action/deploy/display_spec.rb +4 -0
  64. data/spec/unit/action/deploy/environment_spec.rb +154 -12
  65. data/spec/unit/action/deploy/module_spec.rb +40 -1
  66. data/spec/unit/action/puppetfile/install_spec.rb +1 -0
  67. data/spec/unit/action/runner_spec.rb +48 -1
  68. data/spec/unit/environment/git_spec.rb +19 -2
  69. data/spec/unit/environment/name_spec.rb +28 -0
  70. data/spec/unit/environment/svn_spec.rb +12 -0
  71. data/spec/unit/environment/with_modules_spec.rb +74 -0
  72. data/spec/unit/forge/module_release_spec.rb +14 -10
  73. data/spec/unit/git/cache_spec.rb +10 -0
  74. data/spec/unit/git/rugged/credentials_spec.rb +79 -2
  75. data/spec/unit/git_spec.rb +3 -3
  76. data/spec/unit/module/forge_spec.rb +6 -0
  77. data/spec/unit/module/git_spec.rb +56 -1
  78. data/spec/unit/module_spec.rb +59 -9
  79. data/spec/unit/puppetfile_spec.rb +61 -7
  80. data/spec/unit/settings_spec.rb +12 -0
  81. data/spec/unit/source/git_spec.rb +49 -1
  82. data/spec/unit/util/setopts_spec.rb +25 -1
  83. metadata +9 -11
  84. data/azure-pipelines.yml +0 -86
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2f2418e73622a4149507cc7e2dde74b68a448689da2a7287b19107fbef0e184e
4
- data.tar.gz: 95acaeb5cb7ad0969ec3f2a3545ab82490bafb9d0fca5da444125bbe780b9836
3
+ metadata.gz: 7e658209eb66330ab2c2cea4dd4fac0690b6700042e639e5ff11d2fffb120f1b
4
+ data.tar.gz: 870249f76ef6c2b289e3255e6c752d6fc725009a8e37f8b4219f7496a7c0a439
5
5
  SHA512:
6
- metadata.gz: dd666a18fe5df938ab5a151cf411ac335e0f3f151428fe8589010ff699b832609fc58e189c46f52894d9d6b9d8e63156ed928bd14d2ed02d5d9a113fc0c5feb0
7
- data.tar.gz: 40307661c96a21d00595271fa21836175c993dc937504b82b449218e39cd3804000a7c24c32a52aa570098b450fd35417573190dd9d603ac087e217f391aacb4
6
+ metadata.gz: a01dfae93025bac535c4e18d5f15b800c7bc1df1aa79cf0a2ea565c034767d5c5f0b0e4b41b7954e59310090a25ca67e28e92ab416958b2f91864a3da873d93a
7
+ data.tar.gz: 0631fe1846185c2808bd14be2cca3b182402991476950bae18da0fb19129eb7139fbec3b1f9a3bf1568f09931d0438c9a014380378cce71b01d7b9022364cb7c
@@ -1 +1,4 @@
1
- Please add all notable changes to the "Unreleased" section of the CHANGELOG.
1
+ Please add all notable changes to the "Unreleased" section of the CHANGELOG in the format:
2
+ ```
3
+ - Summary of changes. [Issue or PR #](link to issue or PR)
4
+ ```
@@ -29,7 +29,10 @@ jobs:
29
29
  - run: gem install bundler
30
30
  - name: Build container
31
31
  working-directory: docker
32
- run: make lint build test
32
+ run: |
33
+ docker system prune --all --force --volumes
34
+ docker builder prune --force --keep-storage=10GB
35
+ make lint build test
33
36
  - name: Publish container
34
37
  working-directory: docker
35
38
  run: |
@@ -3,7 +3,7 @@ name: Tag and release
3
3
  on:
4
4
  push:
5
5
  branches:
6
- - master
6
+ - main
7
7
  paths:
8
8
  - 'lib/r10k/version.rb'
9
9
 
@@ -15,10 +15,11 @@ jobs:
15
15
  with:
16
16
  fetch-depth: '0'
17
17
  - name: Bump version and push tag
18
- uses: anothrNick/github-tag-action@1.17.2
18
+ uses: anothrNick/github-tag-action@1.35.0
19
19
  env:
20
20
  GITHUB_TOKEN: ${{ secrets.PUPPET_RELEASE_GH_TOKEN }}
21
21
  DEFAULT_BUMP: patch
22
+ TAG_CONTEXT: branch
22
23
  WITH_V: false
23
24
  # Uncomment this if the tag and version file become out-of-sync and
24
25
  # you need to tag at a specific version.
@@ -0,0 +1,81 @@
1
+ name: Rspec tests
2
+
3
+ on:
4
+ pull_request:
5
+ branches:
6
+ - main
7
+
8
+ jobs:
9
+ rspec_tests:
10
+ name: ${{ matrix.cfg.os }}(ruby ${{ matrix.cfg.ruby }})
11
+ strategy:
12
+ matrix:
13
+ cfg:
14
+ - {os: ubuntu-18.04, ruby: 2.4}
15
+ - {os: ubuntu-18.04, ruby: 2.5}
16
+ - {os: ubuntu-18.04, ruby: 2.6}
17
+ - {os: ubuntu-18.04, ruby: 2.7}
18
+ - {os: ubuntu-18.04, ruby: jruby-9.2.9.0}
19
+ - {os: windows-2016, ruby: 2.5}
20
+ - {os: windows-2016, ruby: 2.6}
21
+ - {os: windows-2016, ruby: 2.7}
22
+
23
+ runs-on: ${{ matrix.cfg.os }}
24
+ steps:
25
+ - name: Checkout current PR
26
+ uses: actions/checkout@v2
27
+
28
+ - name: Install ruby version ${{ matrix.cfg.ruby }}
29
+ uses: ruby/setup-ruby@v1
30
+ with:
31
+ ruby-version: ${{ matrix.cfg.ruby }}
32
+
33
+ - name: Install bundler and gems
34
+ run: |
35
+ gem install bundler
36
+ bundle config set without packaging documentation
37
+ bundle install --jobs 4 --retry 3
38
+
39
+ - name: Run tests on Windows
40
+ if: runner.os == 'Windows'
41
+ run: |
42
+ # https://github.com/ruby/ruby/pull/2791/files#diff-ff5ff976e81bebd977f0834e60416abbR97-R100
43
+ # Actions uses UTF8, causes test failures, similar to normal OS setup
44
+ $PSDefaultParameterValues['*:Encoding'] = 'utf8'
45
+ [Console]::OutputEncoding = [System.Text.Encoding]::GetEncoding("IBM437")
46
+ [Console]::InputEncoding = [System.Text.Encoding]::GetEncoding("IBM437")
47
+ $Env:LOG_SPEC_ORDER = 'true'
48
+
49
+ # debug information
50
+ chcp
51
+ Get-WinSystemLocale
52
+ Get-ChildItem Env: | % { Write-Output "$($_.Key): $($_.Value)" }
53
+ # list current OpenSSL install
54
+ gem list openssl
55
+ ruby -ropenssl -e 'puts \"OpenSSL Version - #{OpenSSL::OPENSSL_VERSION}\"; puts \"OpenSSL Library Version - #{OpenSSL::OPENSSL_LIBRARY_VERSION}\"'
56
+ Get-Content Gemfile.lock
57
+ ruby -v
58
+ gem --version
59
+ bundle --version
60
+
61
+ # Run tests
62
+ bundle exec rspec --color --format documentation spec/unit
63
+
64
+ - name: Run tests on Linux
65
+ if: runner.os == 'Linux'
66
+ run: |
67
+ # debug information
68
+ cat Gemfile.lock
69
+ ruby -v
70
+ gem --version
71
+ bundle --version
72
+
73
+ if [[ ${{ matrix.cfg.ruby }} =~ "jruby" ]]; then
74
+ export _JAVA_OPTIONS='-Xmx1024m -Xms512m'
75
+
76
+ # workaround for PUP-10683
77
+ sudo apt remove rpm
78
+ fi
79
+
80
+ # Run tests
81
+ bundle exec rspec --color --format documentation spec/unit
data/.travis.yml CHANGED
@@ -29,7 +29,8 @@ matrix:
29
29
  - docker
30
30
  rvm: 2.6.6
31
31
  env:
32
- - DOCKER_COMPOSE_VERSION=1.25.5
32
+ - DOCKER_COMPOSE_VERSION=1.28.6
33
+ - DOCKER_BUILDX_VERSION=0.5.1
33
34
  # necessary to prevent overwhelming TravisCI build output limits
34
35
  - DOCKER_BUILD_FLAGS="--progress plain"
35
36
  before_install:
@@ -37,9 +38,15 @@ matrix:
37
38
  - curl --location https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE_VERSION}/docker-compose-`uname --kernel-name`-`uname --machine` > docker-compose
38
39
  - chmod +x docker-compose
39
40
  - sudo mv docker-compose /usr/local/bin
41
+ - mkdir -vp ~/.docker/cli-plugins
42
+ - curl --location https://github.com/docker/buildx/releases/download/v${DOCKER_BUILDX_VERSION}/buildx-v${DOCKER_BUILDX_VERSION}.linux-amd64 > ~/.docker/cli-plugins/docker-buildx
43
+ - chmod +x ~/.docker/cli-plugins/docker-buildx
44
+ - docker buildx create --name travis_builder --use
40
45
  script:
41
46
  - set -e
42
47
  - cd docker
43
48
  - make lint
44
49
  - make build
45
50
  - make test
51
+ after_script:
52
+ - docker buildx rm travis_builder
data/CHANGELOG.mkd CHANGED
@@ -2,14 +2,50 @@ CHANGELOG
2
2
  =========
3
3
 
4
4
  Unreleased
5
- ----
5
+ ----------
6
+
7
+ 3.9.0
8
+ -----
9
+
10
+ - Add '--modules' flag to `deploy` subcommand as a replacement to '--puppetfile', deprecate '--puppetfile'. [#1147](https://github.com/puppetlabs/r10k/pull/1147)
11
+ - Deprecate 'purge_whitelist' and favor usage of 'purge_allowlist'. [#1144](https://github.com/puppetlabs/r10k/pull/1144)
12
+ - Add 'strip\_component' environment source configuration setting, to allow deploying Git branches named like "env/production" as Puppet environments named like "production". [#1128](https://github.com/puppetlabs/r10k/pull/1128)
13
+ - A warning will be emitted when the user supplies conflicting arguments to module definitions in a Puppetfile, such as when specifying both :commit and :branch [#1130](https://github.com/puppetlabs/r10k/pull/1130)
14
+ - Add optional standard module and environment specification interface: name, type, source, version. These options can be used when specifying environments and/or modules in a yaml/exec source, as well as when specifying modules in a Puppetfile. Providing the standard interface simplifies integrations with external services [#1131](https://github.com/puppetlabs/r10k/pull/1131)
15
+ - Pin cri to 2.15.10 to maintain support for Ruby 2.3 and 2.4 [#1121](https://github.com/puppetlabs/r10k/issues/1121)
16
+
17
+ 3.8.0
18
+ -----
19
+
20
+ - When a forge module fails name validation the offending name will now be printed in the error message. [#1126](https://github.com/puppetlabs/r10k/pull/1126)
21
+ - Module ref resolution will now fall back to the normal default branch if the default branch override cannot be resolved. [#1122](https://github.com/puppetlabs/r10k/pull/1122)
22
+ - Experimental feature change: conflicts between environment-defined modules and Puppetfile-defined modules now default to logging a warning and deploying the environment module version, overriding the Puppetfile. Previously, conflicts would result in an error. The behavior is now configurable via the `module_conflicts` environment setting [#1107](https://github.com/puppetlabs/r10k/pull/1107)
23
+
24
+ 3.7.0
25
+ -----
26
+
27
+ - Use %LOCALAPPDATA% for Windows cachedir [#1049](https://github.com/puppetlabs/r10k/issues/1049)
28
+ - Add support for defining custom puppet.conf when generating types [#993](https://github.com/puppetlabs/r10k/pull/993)
29
+ - Update test cases to account for error message changes in Puppet 7
30
+
31
+ 3.6.0
32
+ -----
33
+
34
+ - Add filter_command configuration option for git repositories. (Thanks to [mhumpula](https://github.com/mhumpula) for the feature.) [#823](https://github.com/puppetlabs/r10k/pull/823)
35
+ - Increase default pool_size to 4, allowing modules to be downloaded on 4 threads concurrently. [#1038](https://github.com/puppetlabs/r10k/issues/1038)
36
+ - Ensure that modules that share a cachedir download serially, to avoid cache corruption. [#1058](https://github.com/puppetlabs/r10k/issues/1058)
37
+ - Don't purge root when using `puppetfile install`. [#1084](https://github.com/puppetlabs/r10k/issues/1084)
38
+
39
+ 3.5.2
40
+ -----
41
+
42
+ - (RK-319) Clean up tmp directories used for downloading modules
6
43
 
7
44
  3.5.1
8
45
  -----
9
46
 
10
47
  - Upgrade Rugged Gemfile dependency for local development to ~> 1.0
11
48
 
12
-
13
49
  3.5.0
14
50
  -----
15
51
 
@@ -171,6 +207,11 @@ Ruby >= 2.3 official and documented.
171
207
  - Unable to parse Puppetfile
172
208
  - Various perfomance improvements
173
209
 
210
+ 2.6.9
211
+ ----
212
+
213
+ - Don't purge root when using `puppetfile install`. [#1084](https://github.com/puppetlabs/r10k/issues/1084)
214
+
174
215
  2.6.8
175
216
  ----
176
217
 
data/CODEOWNERS CHANGED
@@ -1,2 +1,2 @@
1
- * @puppetlabs/puppetserver-maintainers @adrienthebo @dhollinger
2
- /docker/ @puppetlabs/pupperware
1
+ * @puppetlabs/puppetserver-maintainers
2
+ /docker/ @puppetlabs/platform-services
data/README.mkd CHANGED
@@ -17,8 +17,8 @@ implementation of Puppet [environments][workflow].
17
17
  Requirements
18
18
  ------------
19
19
 
20
- R10k supports the Ruby versions `>= 2.3.0`. It's tested on Ruby 2.3.0 up to
21
- Ruby 2.6.0 + Jruby.
20
+ R10k supports the Ruby versions `>= 2.4.0`. It's tested on Ruby 2.4.0 up to
21
+ Ruby 2.7.0 + Jruby.
22
22
 
23
23
  R10k requires additional components, depending on how you plan on managing
24
24
  environments and modules.
@@ -98,6 +98,14 @@ When localizing the strings found in R10k, follow the prescribed
98
98
  The workflow describes the rake tasks provided to generate the .po files for
99
99
  each locale.
100
100
 
101
+ Releasing
102
+ ---------
103
+ To release a new version of the r10k gem, ensure the [changelog](CHANGELOG.mkd) is up to date and open a pull request updating the [version file](lib/r10k/version.rb). When the PR is merged, a new release of the gem will be triggered.
104
+
105
+ By default, a patch (Z) release will be triggered. To release a new major (X) or minor (Y) version, include `#major` or `#minor` (respectively) in your commit message to trigger the appropriate release.
106
+
107
+ NOTE: This currently only works for the default branch. If you would like to release from a different branch, please contact the [CODEOWNERS](CODEOWNERS).
108
+
101
109
  Getting help
102
110
  ------------
103
111
 
@@ -113,6 +121,7 @@ Please see the CHANGELOG for a listing of the (very awesome) contributors.
113
121
 
114
122
  ## Maintenance
115
123
 
116
- See [MAINTAINERS](MAINTAINERS) (json file)
124
+ See [CODEOWNERS](CODEOWNERS) for active repo maintainers.
125
+
126
+ Open [issues](https://github.com/puppetlabs/r10k/issues) directly in the r10k repo.
117
127
 
118
- Tickets: File at https://tickets.puppet.com/browse/RK
@@ -42,3 +42,4 @@ publicly available hook. These include:
42
42
  * [Reaktor](https://github.com/pzim/reaktor)
43
43
  * [zack/r10k's Webhooks](https://forge.puppetlabs.com/zack/r10k#webhook-support)
44
44
  (Puppet Enterprise only)
45
+ * [Simple Puppet Provisioner](https://github.com/mbaynton/SimplePuppetProvisioner)
@@ -76,9 +76,9 @@ The proxy server being used will be logged at the "debug" level when r10k runs.
76
76
  ### pool_size
77
77
 
78
78
  The pool_size setting is a number to determine how many threads should be spawn
79
- while updating modules. The default value is 1, which means the default behaviour
80
- is to update modules in a serial manner. Increasing this number should bring
81
- some performance gains.
79
+ while updating modules. The default value is 4, which means modules will be updated
80
+ in parallel. If this causes issues, change this setting to 1 to cause modules to be
81
+ updated serially.
82
82
 
83
83
  ### git
84
84
 
@@ -249,9 +249,9 @@ found which is neither committed to the control repo branch that maps to that
249
249
  environment, nor declared in a Puppetfile committed to that branch.
250
250
 
251
251
  Enabling this purge level will cause r10k to load and parse the Puppetfile for
252
- the environment even without the `--puppetfile` flag being set. However,
252
+ the environment even without the `--modules` flag being set. However,
253
253
  Puppetfile content will still only be deployed if the environment is new or
254
- the `--puppetfile` flag is set. Additionally, no environment-level content
254
+ the `--modules` flag is set. Additionally, no environment-level content
255
255
  will be purged if any errors are encountered while evaluating the Puppetfile
256
256
  or deploying its contents.
257
257
 
@@ -266,31 +266,31 @@ managed by a Puppetfile include the configured `moduledir` (which defaults to
266
266
  "modules") as well as alternate directories specified as an `install_path`
267
267
  option to any Puppetfile content declarations.
268
268
 
269
- #### purge\_whitelist
269
+ #### purge\_allowlist
270
270
 
271
- The `purge_whitelist` setting exempts the specified filename patterns from
271
+ The `purge_allowlist` setting exempts the specified filename patterns from
272
272
  being purged. This setting is currently only considered during `environment`
273
273
  level purging. (See above.) Given value must be a list of shell style filename
274
274
  patterns in string format.
275
275
 
276
276
  See the Ruby [documentation for the `fnmatch` method](http://ruby-doc.org/core-2.2.0/File.html#method-c-fnmatch)
277
277
  for more details on valid patterns. Note that the `FNM_PATHNAME` and
278
- `FNM_DOTMATCH` flags are in effect when r10k considers the whitelist.
278
+ `FNM_DOTMATCH` flags are in effect when r10k considers the allowlist.
279
279
 
280
280
  Patterns are relative to the root of the environment being purged and *do
281
- not match recursively* by default. For example, a whitelist value of
281
+ not match recursively* by default. For example, a allowlist value of
282
282
  `*myfile*` would only preserve a matching file at the root of the
283
283
  environment. To preserve the file throughout the deployed environment,
284
284
  a recursive pattern such as `**/*myfile*` would be required.
285
285
 
286
- Files matching a whitelist pattern may still be removed if they exist in
286
+ Files matching a allowlist pattern may still be removed if they exist in
287
287
  a folder that is otherwise subject to purging. In this case, an additional
288
- whitelist rule to preserve the containing folder is required.
288
+ allowlist rule to preserve the containing folder is required.
289
289
 
290
290
  ```yaml
291
291
  ---
292
292
  deploy:
293
- purge_whitelist: [ 'custom.json', '**/*.xpp' ]
293
+ purge_allowlist: [ 'custom.json', '**/*.xpp' ]
294
294
  ```
295
295
 
296
296
 
@@ -327,6 +327,15 @@ deploy:
327
327
  puppet_path: '/usr/local/bin/puppet'
328
328
  ```
329
329
 
330
+ #### puppet\_conf
331
+
332
+ The path to the puppet.conf file used for generating types. Defaults to `/etc/puppetlabs/puppet/puppet.conf`.
333
+
334
+ ```yaml
335
+ deploy:
336
+ puppet_conf: '/opt/puppet/conf/puppet.conf'
337
+ ```
338
+
330
339
  Source options
331
340
  --------------
332
341
 
@@ -385,6 +394,23 @@ sources:
385
394
  * if `false` (default) environment folder will not be prefixed
386
395
  * if `String` environment folder will be prefixed with the `prefix` value.
387
396
 
397
+ ### strip\_component
398
+
399
+ The 'strip\_component' setting allows parts of environment names from a source to have a transformation applied, removing a part of the name before turning them into Puppet environments. This is primarily useful for VCS sources (e.g. Git), because it allows branch names to use prefixes or organizing name components such as "env/production", "env/development", but deploy Puppet environments from these branches named without the leading "env/" component. E.g. "production", "development".
400
+
401
+ ```yaml
402
+ ---
403
+ sources:
404
+ mysource:
405
+ basedir: '/etc/puppet/environments'
406
+ strip_component: 'env/'
407
+ ```
408
+
409
+ #### strip\_component behaviour
410
+
411
+ * if `string` environment names will have this prefix removed, if the prefix is present. Note that when string values are used, names can only have prefix components removed.
412
+ * if `/regex/` the regex will be matched against environment names and if a match is found, the matching name component will be removed.
413
+
388
414
  ### ignore_branch_prefixes
389
415
 
390
416
  The 'ignore_branch_prefixes' setting causes environments to be ignored which match in part or whole
@@ -411,6 +437,29 @@ sources:
411
437
  - 'dev'
412
438
  ```
413
439
 
440
+ ### filter_command
441
+
442
+ You can filter out any branch based on the result of the command specified as
443
+ 'filter_command'. Currently it only works with git repository. Non zero return
444
+ status of the command results in a branch beeing removed. The command is passed
445
+ additional environment variables
446
+
447
+ * GIT_DIR – path to the cached git repository
448
+ * R10K_BRANCH – branch which is being filtered
449
+ * R10K_NAME – source name from r10k configuration
450
+
451
+ This can be used for example for filtering out the branches with invalid gpg signature of their latest commit
452
+
453
+ ```yaml
454
+ ---
455
+ sources:
456
+ mysource:
457
+ basedir: '/etc/puppet/environments'
458
+ filter_command: 'git verify-commit $R10K_BRANCH 2> /dev/null'
459
+ ```
460
+
461
+ Beware that if the production branch of manifests is filtered out, you will end up with empty environment.
462
+
414
463
  Examples
415
464
  --------
416
465
 
@@ -596,7 +645,7 @@ sources:
596
645
 
597
646
  The environment modules feature allows module content to be attached to an environment at environment definition time. This happens before modules specified in a Puppetfile are attached to an environment, which does not happen until deploy time. Environment module implementation depends on the environment source type.
598
647
 
599
- For the YAML environment source type, attach modules to an environment by specifying a modules key for the environment, and providing a hash of modules to attach. Each module accepts the same arguments accepted by the `mod` method in a Puppetfile.
648
+ For the YAML environment source type, attach modules to an environment by specifying a modules key for the environment, and providing a hash of modules to attach. Each module accepts the same arguments accepted by the `mod` method in a Puppetfile. For ease of reading and consistency, however, it is perferred to use the generic type, source, and version options over implementation-specific formats and options such as "ref" and "git".
600
649
 
601
650
  The example below includes two Forge modules and one module sourced from a Git repository. The two environments are almost identical. However, a new version of the stdlib module has been deployed in development (6.2.0), that has not yet been deployed to production.
602
651
 
@@ -604,25 +653,35 @@ The example below includes two Forge modules and one module sourced from a Git r
604
653
  ---
605
654
  production:
606
655
  type: git
607
- remote: git@github.com:puppetlabs/control-repo.git
608
- ref: 8820892
656
+ source: git@github.com:puppetlabs/control-repo.git
657
+ version: 8820892
609
658
  modules:
610
- puppetlabs-stdlib: 6.0.0
611
- puppetlabs-concat: 6.1.0
659
+ puppetlabs-stdlib:
660
+ type: forge
661
+ version: 6.0.0
662
+ puppetlabs-concat:
663
+ type: forge
664
+ version: 6.1.0
612
665
  reidmv-xampl:
613
- git: https://github.com/reidmv/reidmv-xampl.git
614
- ref: 62d07f2
666
+ type: git
667
+ source: https://github.com/reidmv/reidmv-xampl.git
668
+ version: 62d07f2
615
669
 
616
670
  development:
617
671
  type: git
618
- remote: git@github.com:puppetlabs/control-repo.git
619
- ref: 8820892
672
+ source: git@github.com:puppetlabs/control-repo.git
673
+ version: 8820892
620
674
  modules:
621
- puppetlabs-stdlib: 6.2.0
622
- puppetlabs-concat: 6.1.0
675
+ puppetlabs-stdlib:
676
+ type: forge
677
+ version: 6.2.0
678
+ puppetlabs-concat:
679
+ type: forge
680
+ version: 6.1.0
623
681
  reidmv-xampl:
624
- git: https://github.com/reidmv/reidmv-xampl.git
625
- ref: 62d07f2
682
+ type: git
683
+ source: https://github.com/reidmv/reidmv-xampl.git
684
+ version: 62d07f2
626
685
  ```
627
686
 
628
687
  An example of a single environment definition for the YAMLdir environment source type:
@@ -631,14 +690,49 @@ An example of a single environment definition for the YAMLdir environment source
631
690
  # production.yaml
632
691
  ---
633
692
  type: git
634
- remote: git@github.com:puppetlabs/control-repo.git
635
- ref: 8820892
693
+ source: git@github.com:puppetlabs/control-repo.git
694
+ version: 8820892
695
+ modules:
696
+ puppetlabs-stdlib:
697
+ type: forge
698
+ version: 6.0.0
699
+ puppetlabs-concat:
700
+ type: forge
701
+ version: 6.1.0
702
+ reidmv-xampl:
703
+ type: git
704
+ source: https://github.com/reidmv/reidmv-xampl.git
705
+ version: 62d07f2
706
+ ```
707
+
708
+ #### Puppetfile module conflicts
709
+
710
+ When a module is defined in an environment and also in a Puppetfile, the default behavior is for the environment definition of the module to take precedence, a warning to be logged, and the Puppetfile definition to be ignored. The behavior is configurable to optionally skip the warning, or allow a hard failure instead. Use the `module_conflicts` option in an environment definition to control this.
711
+
712
+ Available `module_conflicts` options:
713
+
714
+ * `override_and_warn` (default): the version of the module defined by the environment will be used, and the version defined in the Puppetfile will be ignored. A warning will be printed.
715
+ * `override`: the version of the module defined by the environment will be used, and the version defined in the Puppetfile will be ignored.
716
+ * `error`: an error will be raised alerting the user to the conflict. The environment will not be deployed.
717
+
718
+ ```yaml
719
+ # production.yaml
720
+ ---
721
+ type: git
722
+ source: git@github.com:puppetlabs/control-repo.git
723
+ version: 8820892
724
+ module_conflicts: override_and_warn
636
725
  modules:
637
- puppetlabs-stdlib: 6.0.0
638
- puppetlabs-concat: 6.1.0
726
+ puppetlabs-stdlib:
727
+ type: forge
728
+ version: 6.0.0
729
+ puppetlabs-concat:
730
+ type: forge
731
+ version: 6.1.0
639
732
  reidmv-xampl:
640
- git: https://github.com/reidmv/reidmv-xampl.git
641
- ref: 62d07f2
733
+ type: git
734
+ source: https://github.com/reidmv/reidmv-xampl.git
735
+ version: 62d07f2
642
736
  ```
643
737
 
644
738
  ### Bare Environment Type
@@ -652,18 +746,28 @@ The bare environment type allows sources that support environment modules to ope
652
746
  production:
653
747
  type: bare
654
748
  modules:
655
- puppetlabs-stdlib: 6.0.0
656
- puppetlabs-concat: 6.1.0
749
+ puppetlabs-stdlib:
750
+ type: forge
751
+ version: 6.0.0
752
+ puppetlabs-concat:
753
+ type: forge
754
+ version: 6.1.0
657
755
  reidmv-xampl:
658
- git: https://github.com/reidmv/reidmv-xampl.git
659
- ref: 62d07f2
756
+ type: git
757
+ source: https://github.com/reidmv/reidmv-xampl.git
758
+ version: 62d07f2
660
759
 
661
760
  development:
662
761
  type: bare
663
762
  modules:
664
- puppetlabs-stdlib: 6.0.0
665
- puppetlabs-concat: 6.1.0
763
+ puppetlabs-stdlib:
764
+ type: forge
765
+ version: 6.0.0
766
+ puppetlabs-concat:
767
+ type: forge
768
+ version: 6.1.0
666
769
  reidmv-xampl:
667
- git: https://github.com/reidmv/reidmv-xampl.git
668
- ref: 62d07f2
770
+ type: git
771
+ source: https://github.com/reidmv/reidmv-xampl.git
772
+ version: 62d07f2
669
773
  ```