onceover 3.22.0 → 4.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (65) hide show
  1. checksums.yaml +4 -4
  2. data/.github/dependabot.yml +17 -0
  3. data/.github/workflows/release.yaml +25 -17
  4. data/.github/workflows/tests.yaml +30 -4
  5. data/.gitignore +2 -1
  6. data/.rubocop.yml +4 -704
  7. data/.rubocop_todo.yml +828 -0
  8. data/CHANGELOG.md +1036 -0
  9. data/Gemfile +7 -1
  10. data/LICENSE +202 -0
  11. data/README.md +81 -35
  12. data/Rakefile +23 -14
  13. data/features/auto_vendored.feature +27 -0
  14. data/features/step_definitions/common.rb +5 -5
  15. data/features/support/cache_helper.rb +0 -1
  16. data/features/support/command_helper.rb +0 -2
  17. data/features/support/controlrepo_helper.rb +0 -2
  18. data/lib/onceover/beaker/spec_helper.rb +7 -7
  19. data/lib/onceover/beaker.rb +9 -12
  20. data/lib/onceover/cli/run.rb +1 -0
  21. data/lib/onceover/controlrepo.rb +19 -24
  22. data/lib/onceover/deploy.rb +29 -2
  23. data/lib/onceover/group.rb +1 -3
  24. data/lib/onceover/logger.rb +3 -3
  25. data/lib/onceover/node.rb +0 -2
  26. data/lib/onceover/rake_tasks.rb +9 -4
  27. data/lib/onceover/rspec/formatters.rb +3 -4
  28. data/lib/onceover/test.rb +1 -2
  29. data/lib/onceover/testconfig.rb +2 -2
  30. data/lib/onceover/vendored_modules.rb +186 -0
  31. data/onceover.gemspec +24 -21
  32. data/spec/fixtures/controlrepos/caching/spec/factsets/README.md +1 -1
  33. data/spec/fixtures/controlrepos/caching/spec/pre_conditions/README.md +1 -1
  34. data/spec/fixtures/controlrepos/factsets/spec/factsets/README.md +1 -1
  35. data/spec/fixtures/controlrepos/puppet_controlrepo/Gemfile +1 -1
  36. data/spec/fixtures/controlrepos/vendored/Puppetfile +3 -0
  37. data/spec/fixtures/controlrepos/vendored/Puppetfile.cron +5 -0
  38. data/spec/fixtures/controlrepos/vendored/environment.conf +1 -0
  39. data/spec/fixtures/controlrepos/vendored/site-modules/role/manifests/cron.pp +9 -0
  40. data/spec/fixtures/controlrepos/vendored/spec/vendored_modules/augeas_core-puppet_agent-7.30.0.json +1 -0
  41. data/spec/fixtures/controlrepos/vendored/spec/vendored_modules/augeas_core-puppet_agent-8.6.0.json +1 -0
  42. data/spec/fixtures/controlrepos/vendored/spec/vendored_modules/cron_core-puppet_agent-7.30.0.json +1 -0
  43. data/spec/fixtures/controlrepos/vendored/spec/vendored_modules/cron_core-puppet_agent-8.6.0.json +1 -0
  44. data/spec/fixtures/controlrepos/vendored/spec/vendored_modules/host_core-puppet_agent-7.30.0.json +1 -0
  45. data/spec/fixtures/controlrepos/vendored/spec/vendored_modules/host_core-puppet_agent-8.6.0.json +1 -0
  46. data/spec/fixtures/controlrepos/vendored/spec/vendored_modules/mount_core-puppet_agent-7.30.0.json +1 -0
  47. data/spec/fixtures/controlrepos/vendored/spec/vendored_modules/mount_core-puppet_agent-8.6.0.json +1 -0
  48. data/spec/fixtures/controlrepos/vendored/spec/vendored_modules/repo_tree-puppet_agent-7.30.0.json +1 -0
  49. data/spec/fixtures/controlrepos/vendored/spec/vendored_modules/repo_tree-puppet_agent-8.6.0.json +1 -0
  50. data/spec/fixtures/controlrepos/vendored/spec/vendored_modules/scheduled_task-puppet_agent-7.30.0.json +1 -0
  51. data/spec/fixtures/controlrepos/vendored/spec/vendored_modules/scheduled_task-puppet_agent-8.6.0.json +1 -0
  52. data/spec/fixtures/controlrepos/vendored/spec/vendored_modules/selinux_core-puppet_agent-7.30.0.json +1 -0
  53. data/spec/fixtures/controlrepos/vendored/spec/vendored_modules/selinux_core-puppet_agent-8.6.0.json +1 -0
  54. data/spec/fixtures/controlrepos/vendored/spec/vendored_modules/sshkeys_core-puppet_agent-7.30.0.json +1 -0
  55. data/spec/fixtures/controlrepos/vendored/spec/vendored_modules/sshkeys_core-puppet_agent-8.6.0.json +1 -0
  56. data/spec/fixtures/controlrepos/vendored/spec/vendored_modules/yumrepo_core-puppet_agent-7.30.0.json +1 -0
  57. data/spec/fixtures/controlrepos/vendored/spec/vendored_modules/yumrepo_core-puppet_agent-8.6.0.json +1 -0
  58. data/spec/fixtures/controlrepos/vendored/spec/vendored_modules/zfs_core-puppet_agent-7.30.0.json +1 -0
  59. data/spec/fixtures/controlrepos/vendored/spec/vendored_modules/zfs_core-puppet_agent-8.6.0.json +1 -0
  60. data/spec/fixtures/controlrepos/vendored/spec/vendored_modules/zone_core-puppet_agent-7.30.0.json +1 -0
  61. data/spec/fixtures/controlrepos/vendored/spec/vendored_modules/zone_core-puppet_agent-8.6.0.json +1 -0
  62. data/spec/onceover/controlrepo_spec.rb +1 -1
  63. data/templates/factsets_README.md.erb +1 -1
  64. data/templates/pre_conditions_README.md.erb +1 -1
  65. metadata +56 -9
data/Gemfile CHANGED
@@ -10,12 +10,13 @@ end
10
10
 
11
11
  group :test do
12
12
  # Required for the final controlrepo tests
13
+ gem 'rexml', '~> 3.3', '>= 3.3.9'
13
14
  gem 'toml-rb'
14
15
  end
15
16
 
16
17
  group :development do
17
- gem 'pry'
18
18
  gem 'cucumber'
19
+ gem 'pry'
19
20
  gem 'rubocop'
20
21
  gem 'rubygems-tasks'
21
22
  end
@@ -29,3 +30,8 @@ end
29
30
  if File.exist?(File.join(Dir.home, '.gemfile'))
30
31
  eval(File.read(File.join(Dir.home, '.gemfile')), binding)
31
32
  end
33
+
34
+ group :release do
35
+ gem 'faraday-retry', require: false
36
+ gem 'github_changelog_generator', require: false
37
+ end
data/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
data/README.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Onceover
2
2
 
3
+ [![License](https://img.shields.io/github/license/voxpupuli/onceover.svg)](https://github.com/voxpupuli/onceover/blob/master/LICENSE)
4
+ [![Donated by dylanratcliffe](https://img.shields.io/badge/donated%20by-dylanratcliffe-fb7047.svg)](#transfer-notice)
5
+ [![RubyGem Version](https://img.shields.io/gem/v/onceover.svg)](https://rubygems.org/gems/onceover)
6
+ [![RubyGem Downloads](https://img.shields.io/gem/dt/onceover.svg)](https://rubygems.org/gems/onceover)
7
+
3
8
  *The gateway drug to automated infrastructure testing with Puppet*
4
9
 
5
10
  Onceover is a tool to automatically run basic tests on an entire Puppet control repository.
@@ -8,8 +13,6 @@ It includes automatic parsing of the `Puppetfile`, `environment.conf` and others
8
13
 
9
14
  **New in v3.19.1: I've reversed the decision to have onceover use `site.pp` in the same way Puppet does. From now on your `manifest` setting in `environment.conf` will be ignored and your `site.pp` will only be used if you explicitly set the `manifest` option in the CLI or config file.**
10
15
 
11
- [![Build Status](https://travis-ci.com/dylanratcliffe/onceover.svg?branch=master)](https://travis-ci.com/dylanratcliffe/onceover) [![Build status](https://ci.appveyor.com/api/projects/status/2ys2ggkgln69hmyf/branch/master?svg=true)](https://ci.appveyor.com/project/dylanratcliffe/onceover/branch/master)
12
-
13
16
  ## Table of Contents
14
17
 
15
18
  - [Overview](#overview)
@@ -21,6 +24,7 @@ It includes automatic parsing of the `Puppetfile`, `environment.conf` and others
21
24
  - [Puppetfile](#puppetfile)
22
25
  - [Spec testing](#spec-testing)
23
26
  - [Adding your own spec tests](#adding-your-own-spec-tests)
27
+ - [Vendored Modules](#vendored-modules)
24
28
  - [Using Workarounds](#using-workarounds)
25
29
  - [Extra tooling](#extra-tooling)
26
30
  - [Plugins](#plugins)
@@ -33,6 +37,7 @@ It includes automatic parsing of the `Puppetfile`, `environment.conf` and others
33
37
  - [Ruby Warnings](#ruby-warnings)
34
38
  - [Rake tasks](#rake-tasks)
35
39
  - [generate_fixtures](#generate_fixtures)
40
+ - [generate_vendor_cache](#generate_vendor_cache)
36
41
 
37
42
  ## Overview
38
43
 
@@ -65,6 +70,7 @@ This toolset requires some [configuration](#configuration) before it can be used
65
70
  ```shell
66
71
  bundle exec onceover init
67
72
  ```
73
+
68
74
  1. Run your spec tests!
69
75
 
70
76
  ```shell
@@ -179,6 +185,7 @@ Hopefully this config file will be fairly self explanatory once you see it, but
179
185
  **Note**: The facts are available through the `node_facts` hash and the trusted facts as `trusted_facts`.
180
186
 
181
187
  Exmaple:
188
+
182
189
  ```yaml
183
190
  after:
184
191
  - "puts 'Test finished running'"
@@ -200,6 +207,7 @@ Hopefully this config file will be fairly self explanatory once you see it, but
200
207
  This setting overrides defaults for the `Onceover::Controlrepo` class' `opts` hash.
201
208
 
202
209
  Example:
210
+
203
211
  ```yaml
204
212
  opts:
205
213
  :facts_dirs: # Remember: `opts` keys are symbols!
@@ -385,9 +393,10 @@ In this case, you're all set and onceover will auto-magically pick those up for
385
393
  **Note**: The top level `trusted` hash takes precidence over the `trusted[extensions]` hash nested under `values`. Meaning that if you have any specified at the top level, any nested ones will not be considered. So pick **ONE** method and stick with that.
386
394
 
387
395
  #### Trusted Certname
388
- **Note:** When testing with Puppet >= 4.3 the trusted facts hash will have the standard trusted fact keys (certname, domain, and hostname) populated based on the node name (as set with :node).
389
396
 
390
- To support the resolution of the trusted fact `certname` in auto-generated spec tests, onceover will set `:node` to the value of `trusted[certname]` where present in the source factset.
397
+ **Note:** When testing with Puppet >= 4.3 the trusted facts hash will have the standard trusted fact keys (certname, domain, and hostname) populated based on the node name (as set with :node).
398
+
399
+ To support the resolution of the trusted fact `certname` in auto-generated spec tests, onceover will set `:node` to the value of `trusted[certname]` where present in the source factset.
391
400
 
392
401
  For example: A spec test generated by the factset below would result in `:node` == `node.puppetlabs.net`.
393
402
 
@@ -425,8 +434,9 @@ If `trusted[certname]` is absent, the value of `:node` will default to the FQDN
425
434
  ```
426
435
 
427
436
  See the following rspec-puppet links for more information:
428
- - [Specifying the FQDN of the test node](https://github.com/puppetlabs/rspec-puppet#specifying-the-fqdn-of-the-test-node)
429
- - [Specifying trusted facts](https://github.com/puppetlabs/rspec-puppet#specifying-trusted-facts)
437
+
438
+ - [Specifying the FQDN of the test node](https://github.com/puppetlabs/rspec-puppet#specifying-the-fqdn-of-the-test-node)
439
+ - [Specifying trusted facts](https://github.com/puppetlabs/rspec-puppet#specifying-trusted-facts)
430
440
 
431
441
  #### Trusted External Data
432
442
 
@@ -488,7 +498,7 @@ In these instances it may be worth creating a hierarchy level that simply includ
488
498
 
489
499
  Organisations often reference modules from their own git servers in the `Puppetfile`, like this:
490
500
 
491
- ```
501
+ ```ruby
492
502
  mod "puppetlabs-apache",
493
503
  :git => "https://git.megacorp.com/pup/puppetlabs-apache.git",
494
504
  :tag => "v5.4.0"
@@ -498,7 +508,7 @@ Under the hood, `onceover` uses `r10k` to download the modules in your `Puppetfi
498
508
  If you get errors downloading modules from `git`, its because `r10k`'s call to your underlying `git` command has failed.
499
509
  `onceover` tells you the command that `r10k` tried to run, so if you get an error like this:
500
510
 
501
- ```
511
+ ```text
502
512
  INFO -> Updating module /Users/dylan/control-repo/.onceover/etc/puppetlabs/code/environments
503
513
  /production/modules/apache
504
514
  ERROR -> Command exited with non-zero exit code:
@@ -516,14 +526,17 @@ Exit code: 128
516
526
 
517
527
  Then the approach to debug it would be to run the command that Onceover suggested:
518
528
 
519
- ```
529
+ ```shell
520
530
  git --git-dir /Users/dylan/.r10k/git/ssh---git.megacorp.com-pup-puppetlabs_apache.git fetch origin --prune
521
531
  ```
522
532
 
523
533
  In this case, running the command interactively gives us a prompt to add the server to our `~/.ssh/known_hosts` file, which fixes the problem permanently:
524
534
 
525
- ```
535
+ ```shell
526
536
  $ git --git-dir /Users/dylan/.r10k/git/ssh---git.megacorp.com-pup-puppetlabs_apache.git fetch origin --prune
537
+ ```
538
+
539
+ ```text
527
540
  The authenticity of host 'git.megacorp.com (123.456.789.101)' can't be established.
528
541
  ...
529
542
  Warning: Permanently added 'git.megacorp.com,123.456.789.101' (RSA) to the list of known hosts.
@@ -605,13 +618,37 @@ If you want to see Puppet's output, you can set the `SHOW_PUPPET_OUTPUT` environ
605
618
 
606
619
  `SHOW_PUPPET_OUTPUT=true onceover run spec`
607
620
 
621
+ ### Vendored Modules
622
+
623
+ As of Puppet 6.0 some resource types were removed from Puppet and repackaged as individual modules. These supported type modules are still included in the `puppet-agent` package, so you don't have to download them from the Forge. However, this does not apply to the `puppet` gem used when spec testing. This frequently results in users wondering why their Puppet manifests apply just fine on a node, but their tests fail with messages like `Unknown resource type: cron_core` for example. A common workaround for this problem was to add said modules into your Puppetfile, thus requiring manual management.
624
+
625
+ Onceover now has the ability to remove that manual process for you by querying Github's API to determine which versions are in use by the version of the [puppet-agent package](https://github.com/puppetlabs/puppet-agent/tree/main/configs/components) you are testing against.
626
+
627
+ This functionality is opt in, so to use it configure the following:
628
+
629
+ ```yaml
630
+ # onceover.yaml
631
+ opts:
632
+ auto_vendored: true
633
+ ```
634
+
635
+ or on the cli:
636
+
637
+ ```shell
638
+ bundle exec onceover run spec --auto_vendored=true
639
+ ```
640
+
641
+ Essentially what this is doing is resolving any of these [supported type modules](https://www.puppet.com/docs/puppet/8/type#supported-type-modules-in-puppet-agent) that are not already specified in your Puppetfile, and adding them to the copy Onceover uses to deploy into its working directory structure.
642
+
643
+ CI/CD pipeline users are encouraged to provide Onceover with a cache of the module versions to test against in order to avoid hitting Githubs API ratelimit. To do so, the [generate_vendor_cache](#generate_vendor_cache) rake task can be used to populate the cache into your `spec/vendored_modules` directory.
644
+
608
645
  ## Using workarounds
609
646
 
610
647
  There may be situations where you cannot test everything that is in your puppet code, some common reasons for this include:
611
648
 
612
- - Code is destined for a Puppet Master but the VM image is not a Puppet Master which means we can't restart certain services etc.
613
- - A file is being pulled from somewhere that is only accessible in production
614
- - Something is trying to connect to something else that does not exist
649
+ - Code is destined for a Puppet Master but the VM image is not a Puppet Master which means we can't restart certain services etc.
650
+ - A file is being pulled from somewhere that is only accessible in production
651
+ - Something is trying to connect to something else that does not exist
615
652
 
616
653
  Fear not! There is a solution for this, it's also a good way to practice writing *nasty* puppet code. For this exact purpose I have added the ability for onceover to include extra bits of code in the tests to fix things like this. All you need to do is put a file/s containing puppet code here:
617
654
 
@@ -673,8 +710,8 @@ Onceover now allows for plugins. To use a plugin simply install a gem with a nam
673
710
 
674
711
  Useful plugins:
675
712
 
676
- - [onceover-codequality](https://github.com/declarativesystems/onceover-codequality) _Check lint and syntax_
677
- - [onceover-octocatalog-diff](https://github.com/dylanratcliffe/onceover-octocatalog-diff) _See the differences between two versions of a catalog_
713
+ - [onceover-codequality](https://github.com/declarativesystems/onceover-codequality) _Check lint and syntax_
714
+ - [onceover-octocatalog-diff](https://github.com/voxpupuli/onceover-octocatalog-diff) _See the differences between two versions of a catalog_
678
715
 
679
716
  If you want to write your own plugin, take a look at [onceover-helloworld](https://github.com/declarativesystems/onceover-helloworld) to help you get started.
680
717
 
@@ -879,6 +916,12 @@ fixtures:
879
916
 
880
917
  Notice that the symlinks are not the ones that we provided in `environment.conf`? This is because the rake task will go into each of directories, find the modules and create a symlink for each of them (This is what rspec expects).
881
918
 
919
+ #### generate_vendor_cache
920
+
921
+ `bundle exec rake generate_vendor_cache`
922
+
923
+ This task will query Github's API to determine the versions of the vendored modules in use by the version of the puppet agent you are testing against, and cache that information in `control-repo/spec/vendored_modules`. This way your pipelines won't need to reach out for this information each time Onceover is ran with `auto_vendored` enabled.
924
+
882
925
  ## Developing Onceover
883
926
 
884
927
  Install gem dependencies:
@@ -897,23 +940,26 @@ Execute tests
897
940
 
898
941
  Cheers to all of those who helped out:
899
942
 
900
- - @jessereynolds
901
- - @op-ct
902
- - @GeoffWilliams
903
- - @beergeek
904
- - @jairojunior
905
- - @natemccurdy
906
- - @aardvark
907
- - @Mandos
908
- - @Nekototori
909
- - @LMacchi
910
- - @tabakhase
911
- - @binford2k
912
- - @raphink
913
- - @tequeter
914
- - @alexjfisher
915
- - @smortex
916
- - @16c7x
917
- - @neomilium
918
- - @chlawren
919
-
943
+ - @jessereynolds
944
+ - @op-ct
945
+ - @GeoffWilliams
946
+ - @beergeek
947
+ - @jairojunior
948
+ - @natemccurdy
949
+ - @aardvark
950
+ - @Mandos
951
+ - @Nekototori
952
+ - @LMacchi
953
+ - @tabakhase
954
+ - @binford2k
955
+ - @raphink
956
+ - @tequeter
957
+ - @alexjfisher
958
+ - @smortex
959
+ - @16c7x
960
+ - @neomilium
961
+ - @chlawren
962
+
963
+ ## Transfer Notice
964
+
965
+ This project was originally authored by dylanratcliffe. The maintainer preferred that Vox Pupuli take ownership of the project for future improvement and maintenance. Existing pull requests and issues were transferred over, please fork and continue to contribute here instead of voxpupuli-onceover.
data/Rakefile CHANGED
@@ -1,7 +1,6 @@
1
1
  require 'rubygems/tasks'
2
2
  require 'rspec/core/rake_task'
3
3
  require 'cucumber/rake/task'
4
- require 'rubocop/rake_task'
5
4
  require 'puppet/version'
6
5
  Gem::Tasks.new
7
6
 
@@ -33,15 +32,13 @@ Cucumber::Rake::Task.new(:cucumber) do |t|
33
32
  t.cucumber_opts = "--tags \"#{skip_string}\"" # Any valid command line option can go here.
34
33
  end
35
34
 
36
-
37
35
  task default: :full_tests
38
36
 
39
-
40
37
  desc "Run unit tests"
41
- task rspec_unit_tests: [:syntax, :rubocop, :spec]
38
+ task rspec_unit_tests: [:syntax, :spec]
42
39
 
43
40
  desc "Run acceptance cucumber tests"
44
- task cucumber_acceptance_tests: [:syntax, :rubocop, :fixtures, :cucumber]
41
+ task cucumber_acceptance_tests: [:syntax, :fixtures, :cucumber]
45
42
 
46
43
  desc "Run full set of tests"
47
44
  task full_tests: [:rspec_unit_tests, :cucumber_acceptance_tests]
@@ -60,16 +57,28 @@ task :syntax do
60
57
  end
61
58
  end
62
59
 
63
- RuboCop::RakeTask.new(:rubocop) do |task|
64
- task.options << '--display-cop-names'
65
- task.formatters = ['simple']
66
- task.patterns = [
67
- "lib/**/*.rb",
68
- "ext/**/*.rb",
69
- ]
70
- end
71
-
72
60
  task :fixtures do
73
61
  system 'git submodule init && git submodule update --recursive'
74
62
  raise "Couldn't clone controlrepo to fixtures directory" unless $?.success?
75
63
  end
64
+
65
+ begin
66
+ require 'voxpupuli/rubocop/rake'
67
+ rescue LoadError
68
+ # the voxpupuli-rubocop gem is optional
69
+ end
70
+
71
+ begin
72
+ require 'rubygems'
73
+ require 'github_changelog_generator/task'
74
+ rescue LoadError
75
+ # Do nothing if no required gem installed
76
+ else
77
+ GitHubChangelogGenerator::RakeTask.new :changelog do |config|
78
+ config.exclude_labels = %w[duplicate question invalid wontfix wont-fix skip-changelog github_actions]
79
+ config.user = 'voxpupuli'
80
+ config.project = 'onceover'
81
+ gem_version = Gem::Specification.load("#{config.project}.gemspec").version
82
+ config.future_release = gem_version
83
+ end
84
+ end
@@ -0,0 +1,27 @@
1
+ @vendored @puppet6
2
+ Feature: Automatically resolve modules vendored with puppet-agent package
3
+ Onceover should optionally attempt to resolve these vendored modules so that
4
+ users do not need to maintain these in their Puppetfile's unless they have a reason
5
+ to do so
6
+
7
+ Background:
8
+ Given onceover executable
9
+
10
+ Scenario: Auto resolve disabled and Puppetfile empty
11
+ Given initialized control repo "vendored"
12
+ When I run onceover command "run spec" with class "role::cron"
13
+ Then I should see error with message pattern "Evaluation Error: Error while evaluating a Resource Statement, Unknown resource type: 'cron'"
14
+
15
+ Scenario: Auto resolve enabled and Puppetfile empty
16
+ Given existing control repo "vendored"
17
+ When I run onceover command "run spec --auto_vendored=true" with class "role::cron"
18
+ Then the temporary Puppetfile should contain /mod 'puppetlabs-cron_core',\n.*git: 'https://github.com/puppetlabs\/puppetlabs-cron_core.git',\n.*ref: 'refs\/tags\/.*'/
19
+ And I should not see any errors
20
+
21
+ Scenario: Auto resolve enabled and cron_core specified in Puppetfile
22
+ Given existing control repo "vendored"
23
+ When I run onceover command "run spec --auto_vendored=true" with --puppetfile Puppetfile.cron
24
+ Then I should see message pattern "cron_core found in Puppetfile. Using the specified version"
25
+ Then the temporary Puppetfile should contain /mod 'puppetlabs\/cron_core'/
26
+ And I should not see any errors
27
+
@@ -27,19 +27,19 @@ Given(/^control repo "([^"]*)" without "([^"]*)"$/) do |controlrepo_name, filena
27
27
  FileUtils.rm_rf "#{@repo.root_folder}/#{filename}"
28
28
  end
29
29
 
30
- When(/^I run onceover command "([^"]*)"$/) do |command|
30
+ When(/^I run onceover command "([^"]*)"$/) do |command|
31
31
  @cmd.command = "#{command} --debug"
32
32
  log(@cmd)
33
33
  @cmd.run
34
34
  end
35
35
 
36
- When(/^I run onceover command "([^"]*)" with class "([^"]*)"$/) do |command, cls|
36
+ When(/^I run onceover command "([^"]*)" with class "([^"]*)"$/) do |command, cls|
37
37
  @cmd.command = "#{command} --classes #{cls}"
38
38
  log(@cmd)
39
39
  @cmd.run
40
40
  end
41
41
 
42
- When(/^I run onceover command "([^"]*)" with class "([^"]*)" on nodes "([^"]*)"$/) do |command, cls, nodes|
42
+ When(/^I run onceover command "([^"]*)" with class "([^"]*)" on nodes "([^"]*)"$/) do |command, cls, nodes|
43
43
  @cmd.command = "#{command} --classes #{cls} --nodes #{nodes}"
44
44
  log(@cmd)
45
45
  @cmd.run
@@ -109,7 +109,7 @@ Then(/^I should (not )?see message pattern "([^"]*)"$/) do |notword, msg_regexp|
109
109
  end
110
110
  end
111
111
 
112
- When(/^I run onceover command "([^"]*)" with \-\-puppetfile ([^"]*)$/) do |command, puppetfile|
112
+ When(/^I run onceover command "([^"]*)" with \-\-puppetfile ([^"]*)$/) do |command, puppetfile|
113
113
  puppetfile_path = @repo.root_folder + puppetfile
114
114
  @cmd.command = "#{command} --puppetfile #{puppetfile_path} --debug"
115
115
  log(@cmd)
@@ -117,7 +117,7 @@ When(/^I run onceover command "([^"]*)" with \-\-puppetfile ([^"]*)$/) do |comm
117
117
  end
118
118
 
119
119
  Then(/^([^"]*) should be copied to Puppetfile$/) do |puppetfile|
120
- source = @repo.root_folder + puppetfile
120
+ source = @repo.root_folder + puppetfile
121
121
  destination = @repo.onceover_temp_puppetfile
122
122
  expect(IO.read(source)).to eq(IO.read(destination))
123
123
  end
@@ -1,7 +1,6 @@
1
1
  require 'pathname'
2
2
 
3
3
  class Cache_Helper
4
-
5
4
  def cache_exists?
6
5
  File.directory?(dir + '/.onceover')
7
6
  end
@@ -1,7 +1,6 @@
1
1
  require "open3"
2
2
 
3
3
  class Command_Helper
4
-
5
4
  attr_reader(:output, :result)
6
5
 
7
6
  attr_writer(:command, :params, :controlrepo)
@@ -30,5 +29,4 @@ class Command_Helper
30
29
  def to_s
31
30
  return generate_command
32
31
  end
33
-
34
32
  end
@@ -1,5 +1,4 @@
1
1
  class ControlRepo_Helper
2
-
3
2
  attr_reader :tmp_folder
4
3
 
5
4
  def initialize( name )
@@ -34,5 +33,4 @@ class ControlRepo_Helper
34
33
  def add_line_to_puppetfile( line )
35
34
  open(puppetfile, 'a') { |f| f.puts line }
36
35
  end
37
-
38
36
  end
@@ -35,17 +35,17 @@ RSpec.configure do |c|
35
35
 
36
36
  #default option values
37
37
  defaults = {
38
- :nodeset => 'onceover-nodes',
38
+ :nodeset => 'onceover-nodes',
39
39
  }
40
40
  #read env vars
41
41
  env_vars = {
42
- :color => ENV['BEAKER_color'] || ENV.fetch('RS_COLOR', nil),
43
- :nodeset => ENV['BEAKER_set'] || ENV.fetch('RS_SET', nil),
42
+ :color => ENV['BEAKER_color'] || ENV.fetch('RS_COLOR', nil),
43
+ :nodeset => ENV['BEAKER_set'] || ENV.fetch('RS_SET', nil),
44
44
  :nodesetfile => ENV['BEAKER_setfile'] || ENV.fetch('RS_SETFILE', nil),
45
- :provision => ENV['BEAKER_provision'] || ENV.fetch('RS_PROVISION', nil),
46
- :keyfile => ENV['BEAKER_keyfile'] || ENV.fetch('RS_KEYFILE', nil),
47
- :debug => ENV['BEAKER_debug'] || ENV.fetch('RS_DEBUG', nil),
48
- :destroy => ENV['BEAKER_destroy'] || ENV.fetch('RS_DESTROY', nil),
45
+ :provision => ENV['BEAKER_provision'] || ENV.fetch('RS_PROVISION', nil),
46
+ :keyfile => ENV['BEAKER_keyfile'] || ENV.fetch('RS_KEYFILE', nil),
47
+ :debug => ENV['BEAKER_debug'] || ENV.fetch('RS_DEBUG', nil),
48
+ :destroy => ENV['BEAKER_destroy'] || ENV.fetch('RS_DESTROY', nil),
49
49
  }.compact
50
50
  #combine defaults and env_vars to determine overall options
51
51
  options = defaults.merge(env_vars)