onceover 3.20.0 → 3.22.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (150) hide show
  1. checksums.yaml +4 -4
  2. data/.devcontainer/devcontainer.json +31 -0
  3. data/.github/workflows/release.yaml +24 -0
  4. data/.github/workflows/tests.yaml +5 -8
  5. data/.gitignore +0 -1
  6. data/.rubocop.yml +1 -1
  7. data/.vscode/extensions.json +4 -0
  8. data/Gemfile +12 -0
  9. data/README.md +46 -2
  10. data/Rakefile +1 -0
  11. data/cucumber.yml +1 -0
  12. data/factsets/Windows_Server-2008r2-64.json +184 -184
  13. data/factsets/Windows_Server-2012r2-64.json +165 -165
  14. data/factsets/windows-10-64.json +104 -104
  15. data/features/step_definitions/run.rb +4 -0
  16. data/features/zzz_run.feature +2 -8
  17. data/lib/onceover/beaker/spec_helper.rb +8 -8
  18. data/lib/onceover/cli/run.rb +1 -0
  19. data/lib/onceover/cli/show.rb +1 -1
  20. data/lib/onceover/controlrepo.rb +62 -34
  21. data/lib/onceover/deploy.rb +6 -3
  22. data/lib/onceover/rspec/formatters.rb +2 -4
  23. data/lib/onceover/runner.rb +2 -1
  24. data/lib/onceover/test.rb +1 -1
  25. data/lib/onceover/testconfig.rb +4 -2
  26. data/onceover.gemspec +6 -11
  27. data/spec/fixtures/controlrepos/caching/Puppetfile +17 -17
  28. data/spec/fixtures/controlrepos/puppet_controlrepo/.atom-build.json +9 -0
  29. data/spec/fixtures/controlrepos/puppet_controlrepo/.gitignore +5 -0
  30. data/spec/fixtures/controlrepos/puppet_controlrepo/.ruby-version +1 -0
  31. data/spec/fixtures/controlrepos/puppet_controlrepo/.travis.yml +13 -0
  32. data/spec/fixtures/controlrepos/puppet_controlrepo/Gemfile +22 -0
  33. data/spec/fixtures/controlrepos/puppet_controlrepo/Jenkinsfile +50 -0
  34. data/spec/fixtures/controlrepos/puppet_controlrepo/Puppetfile +102 -0
  35. data/spec/fixtures/controlrepos/puppet_controlrepo/README.md +4 -0
  36. data/spec/fixtures/controlrepos/puppet_controlrepo/Rakefile +6 -0
  37. data/spec/fixtures/controlrepos/puppet_controlrepo/data/common.yaml +558 -0
  38. data/spec/fixtures/controlrepos/puppet_controlrepo/data/datacenter/melbourne.yaml +12 -0
  39. data/spec/fixtures/controlrepos/puppet_controlrepo/data/datacenter/singapore.yaml +12 -0
  40. data/spec/fixtures/controlrepos/puppet_controlrepo/data/environments/development.yaml +3 -0
  41. data/spec/fixtures/controlrepos/puppet_controlrepo/data/environments/production.yaml +3 -0
  42. data/spec/fixtures/controlrepos/puppet_controlrepo/data/size/vol.large.yaml +27 -0
  43. data/spec/fixtures/controlrepos/puppet_controlrepo/environment.conf +3 -0
  44. data/spec/fixtures/controlrepos/puppet_controlrepo/hiera.yaml +25 -0
  45. data/spec/fixtures/controlrepos/puppet_controlrepo/manifests/site.pp +11 -0
  46. data/spec/fixtures/controlrepos/puppet_controlrepo/scripts/code_manager_config_version.rb +19 -0
  47. data/spec/fixtures/controlrepos/puppet_controlrepo/scripts/config_version.rb +25 -0
  48. data/spec/fixtures/controlrepos/puppet_controlrepo/scripts/config_version.sh +12 -0
  49. data/spec/fixtures/controlrepos/puppet_controlrepo/scripts/count_changed_classes.rb +26 -0
  50. data/spec/fixtures/controlrepos/puppet_controlrepo/scripts/get_changed_classes.rb +26 -0
  51. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/console/functions/user/token.pp +10 -0
  52. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/console/manifests/init.pp +14 -0
  53. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/console/manifests/user.pp +35 -0
  54. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/deployments/lib/puppet/functions/deployments/generate.rb +15 -0
  55. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/deployments/plans/signed_deployment.pp +126 -0
  56. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/facts.d/test.sh +2 -0
  57. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/files/artifactory/config_descriptor.xml +265 -0
  58. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/files/autosign.sh +23 -0
  59. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/files/hudson.tasks.Shell.xml +4 -0
  60. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/files/motd +4 -0
  61. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/files/polar_clock/index.html +198 -0
  62. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/apt.pp +9 -0
  63. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/aws_nodes.pp +54 -0
  64. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/base/aws.pp +9 -0
  65. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/base/rhel.pp +50 -0
  66. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/base/windows/hardening.pp +57 -0
  67. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/base/windows.pp +52 -0
  68. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/base.pp +79 -0
  69. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/cd4pe/artifactory.pp +64 -0
  70. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/cd4pe/connection.pp +95 -0
  71. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/cd4pe/haproxy.pp +65 -0
  72. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/cd4pe/replicated.pp +53 -0
  73. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/compile/balancer.pp +28 -0
  74. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/compile/master.pp +19 -0
  75. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/dns/host_record.pp +16 -0
  76. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/dns/server.pp +66 -0
  77. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/docker.pp +5 -0
  78. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/eyeunify/base.pp +43 -0
  79. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/eyeunify/core/database_connection.pp +42 -0
  80. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/eyeunify/core.pp +72 -0
  81. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/eyeunify/ctrl.pp +57 -0
  82. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/eyeunify/database.pp +32 -0
  83. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/eyeunify/exec.pp +11 -0
  84. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/file_sync/client.pp +165 -0
  85. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/file_sync/master_patch.pp +37 -0
  86. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/grafana/dashboard.pp +17 -0
  87. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/haproxy.pp +43 -0
  88. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/init.pp +3 -0
  89. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/jenkins/plugins.pp +87 -0
  90. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/jenkins.pp +65 -0
  91. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/jira/aio.pp +39 -0
  92. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/jira/app.pp +27 -0
  93. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/jira/db.pp +25 -0
  94. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/metrics/collectd/compile.pp +82 -0
  95. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/metrics/collectd.pp +28 -0
  96. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/metrics/dashboard.pp +28 -0
  97. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/mysql_server.pp +7 -0
  98. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/nginx.pp +24 -0
  99. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/polar_clock.pp +55 -0
  100. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/puppetmaster/api_auth.pp +82 -0
  101. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/puppetmaster/autosign.pp +33 -0
  102. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/puppetmaster/aws.pp +58 -0
  103. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/puppetmaster/tuning.pp +139 -0
  104. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/puppetmaster.pp +139 -0
  105. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/rvm.pp +13 -0
  106. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/sumologic.pp +11 -0
  107. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/sunburst/windows.pp +104 -0
  108. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/vagrant.pp +25 -0
  109. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/windows/webserver.pp +27 -0
  110. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/templates/cd4pe/connection_script.sh.epp +110 -0
  111. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/templates/controlrepo_deploy_jenkins_job.xml.epp +51 -0
  112. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/templates/dashboard.json.epp +403 -0
  113. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/templates/jenkins_secret_text.json.epp +1 -0
  114. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/templates/onceover_jenkins_job.xml.epp +51 -0
  115. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/templates/userdata.epp +17 -0
  116. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/role/manifests/cd4pe.pp +29 -0
  117. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/role/manifests/clock.pp +16 -0
  118. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/role/manifests/compile/balancer.pp +5 -0
  119. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/role/manifests/compile/master.pp +5 -0
  120. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/role/manifests/eyeunify/aio.pp +10 -0
  121. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/role/manifests/eyeunify/controller.pp +10 -0
  122. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/role/manifests/eyeunify/database.pp +7 -0
  123. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/role/manifests/eyeunify/exec.pp +6 -0
  124. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/role/manifests/init.pp +3 -0
  125. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/role/manifests/lb.pp +14 -0
  126. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/role/manifests/metrics.pp +5 -0
  127. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/role/manifests/mysql.pp +13 -0
  128. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/role/manifests/windows/base.pp +5 -0
  129. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/role/manifests/windows/webserver.pp +6 -0
  130. data/spec/fixtures/controlrepos/puppet_controlrepo/spec/.gitignore +5 -0
  131. data/spec/fixtures/controlrepos/puppet_controlrepo/spec/acceptance/nodesets/onceover-nodes.yml +94 -0
  132. data/spec/fixtures/controlrepos/puppet_controlrepo/spec/classes/test_spec.rb +8 -0
  133. data/spec/fixtures/controlrepos/puppet_controlrepo/spec/factsets/CentOS-7.0-64-master-2017.3.2.json +531 -0
  134. data/spec/fixtures/controlrepos/puppet_controlrepo/spec/factsets/CentOS-7.0-64-master.json +429 -0
  135. data/spec/fixtures/controlrepos/puppet_controlrepo/spec/factsets/CentOS-7.0-64.json +353 -0
  136. data/spec/fixtures/controlrepos/puppet_controlrepo/spec/factsets/Windows_Server-2008r2-64.json +184 -0
  137. data/spec/fixtures/controlrepos/puppet_controlrepo/spec/factsets/Windows_Server-2012r2-64.json +165 -0
  138. data/spec/fixtures/controlrepos/puppet_controlrepo/spec/hiera.yaml +18 -0
  139. data/spec/fixtures/controlrepos/puppet_controlrepo/spec/matchers/file_matchers.rb +16 -0
  140. data/spec/fixtures/controlrepos/puppet_controlrepo/spec/onceover.yaml +54 -0
  141. data/spec/fixtures/controlrepos/puppet_controlrepo/spec/pre_conditions/site.pp +150 -0
  142. data/spec/fixtures/controlrepos/puppet_controlrepo/spec/r10k.yaml +2 -0
  143. data/spec/fixtures/controlrepos/puppet_controlrepo/spec/shared_examples/helper.rb +91 -0
  144. data/spec/fixtures/controlrepos/puppet_controlrepo/spec/unit/00_parse_spec.rb +76 -0
  145. data/spec/fixtures/controlrepos/puppet_controlrepo/spec/unit/01_linting_spec_example.rb +69 -0
  146. data/spec/fixtures/controlrepos/puppet_controlrepo/spec/unit/03_puppetfile_spec_example.rb +35 -0
  147. data/templates/spec_helper.rb.erb +0 -2
  148. data/templates/test_spec.rb.erb +3 -0
  149. metadata +136 -77
  150. data/.gitmodules +0 -4
@@ -232,46 +232,74 @@ class Onceover
232
232
 
233
233
  output_array = []
234
234
  threads = []
235
+ error_array = []
235
236
  puppetfile.modules.each do |mod|
236
237
  threads << Thread.new do
237
- row = []
238
- logger.debug "Loading data for #{mod.full_name}"
239
- row << mod.full_name
240
- if mod.is_a?(R10K::Module::Forge)
241
- row << mod.expected_version
242
- row << mod.v3_module.current_release.version
243
-
244
- current = Versionomy.parse(mod.expected_version)
245
- latest = Versionomy.parse(mod.v3_module.current_release.version)
246
- row << if current.major < latest.major
247
- "Major".red
248
- elsif current.minor < latest.minor
249
- "Minor".yellow
250
- elsif current.tiny < latest.tiny
251
- "Tiny".green
252
- else
253
- "No".green
254
- end
255
-
256
- row << mod.v3_module.endorsement
257
- superseded_by = mod.v3_module.superseded_by
258
- row << (superseded_by.nil? ? '' : superseded_by[:slug])
259
- else
260
- row << "N/A"
261
- row << "N/A"
262
- row << "N/A"
263
- row << "N/A"
264
- row << "N/A"
238
+ begin
239
+ row = []
240
+ logger.debug "Loading data for #{mod.full_name}"
241
+ row << mod.full_name
242
+ if mod.is_a?(R10K::Module::Forge)
243
+ row << mod.expected_version
244
+ row << mod.v3_module.current_release.version
245
+
246
+ # Configure a custom version format to support modern Puppet Forge versions.
247
+ # (major.minor.tiny-patchlevel-patchlevel_minor)
248
+ # e.g. 8.5.0-0-2
249
+ puppetforge_format = Versionomy.default_format.modified_copy do
250
+ field(:patchlevel_minor) do
251
+ recognize_number(:default_value_optional => true,
252
+ :delimiter_regexp => '-',
253
+ :default_delimiter => '-')
254
+ end
255
+ end
256
+
257
+ current = puppetforge_format.parse(mod.expected_version)
258
+ latest = puppetforge_format.parse(mod.v3_module.current_release.version)
259
+ row << if current.major < latest.major
260
+ "Major".red
261
+ elsif current.minor < latest.minor
262
+ "Minor".yellow
263
+ elsif current.tiny < latest.tiny
264
+ "Tiny".green
265
+ elsif current.patchlevel < latest.patchlevel
266
+ "PatchLevel".green
267
+ elsif current.patchlevel_minor < latest.patchlevel_minor
268
+ "PatchLevel_minor".green
269
+ else
270
+ "No".green
271
+ end
272
+
273
+ row << mod.v3_module.endorsement
274
+ superseded_by = mod.v3_module.superseded_by
275
+ row << (superseded_by.nil? ? '' : superseded_by[:slug])
276
+ else
277
+ row << "N/A"
278
+ row << "N/A"
279
+ row << "N/A"
280
+ row << "N/A"
281
+ row << "N/A"
282
+ end
283
+ output_array << row
284
+ rescue RuntimeError => e
285
+ error = []
286
+ error << mod.full_name
287
+ error << mod.expected_version
288
+ error << mod.v3_module.current_release.version
289
+ error << e.message
290
+ error_array << error
291
+ logger.debug "Error loading module #{mod.full_name} - #{e.inspect}"
292
+ end
265
293
  end
266
- output_array << row
267
294
  end
268
- end
269
295
 
270
296
  threads.map(&:join)
271
297
 
272
298
  output_array.sort_by! { |line| line[0] }
299
+ error_array.sort_by! { |line| line[0] } unless error_array.empty?
273
300
 
274
301
  puts Terminal::Table.new(headings: ["Full Name", "Current Version", "Latest Version", "Out of Date?", "Endorsement", "Superseded by"], rows: output_array)
302
+ puts Terminal::Table.new(headings: ["Issue assessing module", "Current", "Latest", "Error"], rows: error_array) unless error_array.empty?
275
303
  end
276
304
 
277
305
  def update_puppetfile
@@ -489,7 +517,7 @@ class Onceover
489
517
  # Add .onceover to Gitignore
490
518
  gitignore_path = File.expand_path('.gitignore', repo.root)
491
519
  if File.exist? gitignore_path
492
- gitignore_content = (File.open(gitignore_path, 'r') {|f| f.read }).split("\n")
520
+ gitignore_content = (File.read(gitignore_path)).split("\n")
493
521
  message = "#{'changed'.green}"
494
522
  else
495
523
  message = "#{'created'.green}"
@@ -498,7 +526,7 @@ class Onceover
498
526
 
499
527
  unless gitignore_content.include?(".onceover")
500
528
  gitignore_content << ".onceover\n"
501
- File.open(gitignore_path, 'w') {|f| f.write(gitignore_content.join("\n")) }
529
+ File.write(gitignore_path, gitignore_content.join("\n"))
502
530
  puts "#{message} #{Pathname.new(gitignore_path).relative_path_from(Pathname.new(Dir.pwd)).to_s}"
503
531
  end
504
532
  end
@@ -575,7 +603,7 @@ class Onceover
575
603
  else
576
604
  template = File.read(File.expand_path("./#{template_name}", template_dir))
577
605
  end
578
- ERB.new(template, nil, '-').result(bind)
606
+ ERB.new(template, trim_mode: '-').result(bind)
579
607
  end
580
608
 
581
609
  def self.init_write_file(contents, out_file)
@@ -583,7 +611,7 @@ class Onceover
583
611
  if File.exist?(out_file)
584
612
  puts "#{'skipped'.yellow} #{Pathname.new(out_file).relative_path_from(Pathname.new(Dir.pwd)).to_s} #{'(exists)'.yellow}"
585
613
  else
586
- File.open(out_file,'w') {|f| f.write(contents)}
614
+ File.write(out_file, contents)
587
615
  puts "#{'created'.green} #{Pathname.new(out_file).relative_path_from(Pathname.new(Dir.pwd)).to_s}"
588
616
  end
589
617
  end
@@ -86,9 +86,12 @@ class Onceover
86
86
  FileUtils.copy repo.puppetfile, "#{temp_controlrepo}/Puppetfile"
87
87
  puppetfile_contents = File.read("#{temp_controlrepo}/Puppetfile")
88
88
 
89
- logger.debug "replacing :control_branch mentions in the Puppetfile with #{git_branch}"
90
- new_puppetfile_contents = puppetfile_contents.gsub(/:control_branch/, "'#{git_branch}'")
91
- File.write("#{temp_controlrepo}/Puppetfile", new_puppetfile_contents)
89
+ # Avoid touching thing if we don't need to
90
+ if /:control_branch/.match(puppetfile_contents)
91
+ logger.debug "replacing :control_branch mentions in the Puppetfile with #{git_branch}"
92
+ new_puppetfile_contents = puppetfile_contents.gsub(":control_branch", "'#{git_branch}'")
93
+ File.write("#{temp_controlrepo}/Puppetfile", new_puppetfile_contents)
94
+ end
92
95
  end
93
96
 
94
97
  # Remove all files written by the last onceover run, but not the ones
@@ -266,9 +266,7 @@ class OnceoverFormatterParallel < OnceoverFormatter
266
266
  FileUtils.mkdir_p "#{RSpec.configuration.onceover_tempdir}/parallel"
267
267
 
268
268
  # Dump the notification to a unique file
269
- File.open("#{RSpec.configuration.onceover_tempdir}/parallel/results-#{random_string}.yaml", "w") do |file|
270
- file.write(extract_failures(notification).to_yaml)
271
- end
269
+ File.write("#{RSpec.configuration.onceover_tempdir}/parallel/results-#{random_string}.yaml", extract_failures(notification).to_yaml)
272
270
  end
273
271
 
274
272
  def output_results(directory)
@@ -280,7 +278,7 @@ class OnceoverFormatterParallel < OnceoverFormatter
280
278
  # Merge data
281
279
  roles = files.reduce({}) do |errs, file|
282
280
  # Read all files and merge them
283
- errs.merge(YAML.load(File.read(file))) {|key, oldval, newval| [oldval, newval].flatten }# rubocop:disable Security/YAMLLoad
281
+ errs.merge(YAML.load_file(file)) {|key, oldval, newval| [oldval, newval].flatten }
284
282
  end
285
283
 
286
284
  # Delete files from the disk
@@ -78,13 +78,14 @@ class Onceover
78
78
  Dir.chdir(@repo.tempdir) do
79
79
  # Disable warnings unless we are running in debug mode
80
80
  unless logger.level.zero?
81
- previous_rubyopt = ENV['RUBYOPT']
81
+ previous_rubyopt = ENV.fetch('RUBYOPT', nil)
82
82
  ENV['RUBYOPT'] = ENV['RUBYOPT'].to_s + ' -W0'
83
83
  end
84
84
 
85
85
  # NOTE: This is the way to provide options to rspec according to:
86
86
  # https://github.com/puppetlabs/puppetlabs_spec_helper/blob/master/lib/puppetlabs_spec_helper/rake_tasks.rb#L51
87
87
  ENV['CI_SPEC_OPTIONS'] = ENV['CI_SPEC_OPTIONS'].to_s + @config.filter_tags.map { |tag| " --tag #{tag}" }.join unless @config.filter_tags.nil?
88
+ ENV['CI_SPEC_OPTIONS'] = ENV['CI_SPEC_OPTIONS'].to_s + ' --fail-fast' if @config.fail_fast
88
89
 
89
90
  if @config.opts[:parallel]
90
91
  logger.debug "Running #{@command_prefix}rake parallel_spec from #{@repo.tempdir}"
data/lib/onceover/test.rb CHANGED
@@ -72,7 +72,7 @@ class Onceover
72
72
  if classes.count > 1
73
73
  class_msg = "#{classes.count}_classes"
74
74
  else
75
- class_msg = classes[0].name.gsub(/::/,'__')
75
+ class_msg = classes[0].name.gsub("::",'__')
76
76
  end
77
77
 
78
78
  if nodes.count > 1
@@ -27,12 +27,13 @@ class Onceover
27
27
  attr_accessor :after_conditions
28
28
  attr_accessor :skip_r10k
29
29
  attr_accessor :force
30
+ attr_accessor :fail_fast
30
31
  attr_accessor :strict_variables
31
32
  attr_accessor :formatters
32
33
 
33
34
  def initialize(file, opts = {})
34
35
  begin
35
- config = YAML.safe_load(File.read(file), [Symbol])
36
+ config = YAML.safe_load(File.read(file), permitted_classes: [Symbol])
36
37
  rescue Errno::ENOENT
37
38
  raise "Could not find #{file}"
38
39
  rescue Psych::SyntaxError
@@ -79,6 +80,7 @@ class Onceover
79
80
  @filter_nodes = opts[:nodes] ? [opts[:nodes].split(',')].flatten.map {|x| Onceover::Node.find(x)} : nil
80
81
  @skip_r10k = opts[:skip_r10k] ? true : false
81
82
  @force = opts[:force] || false
83
+ @fail_fast = opts[:fail_fast] || false
82
84
 
83
85
  # Validate the mock_functions
84
86
  if @mock_functions && @mock_functions.any? { |name, details| details.has_key? 'type' }
@@ -242,7 +244,7 @@ class Onceover
242
244
  source_files.each do |source_file|
243
245
  target_file = File.join(repo.tempdir, 'spec', source_file.sub(/^#{repo.spec_dir}/, ''))
244
246
  if File.directory?(source_file)
245
- FileUtils.cp_r source_file, target_file unless File.exists? target_file
247
+ FileUtils.cp_r source_file, target_file unless File.exist? target_file
246
248
  else
247
249
  FileUtils.mkdir_p File.dirname target_file
248
250
  FileUtils.cp source_file, target_file
data/onceover.gemspec CHANGED
@@ -1,10 +1,10 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
 
3
- $LOAD_PATH.unshift File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift File.expand_path('lib', __dir__)
4
4
 
5
- Gem::Specification.new do |s|
5
+ Gem::Specification.new do |s| # rubocop:disable Gemspec/RequireMFA
6
6
  s.name = "onceover"
7
- s.version = "3.20.0"
7
+ s.version = "3.22.0"
8
8
  s.authors = ["Dylan Ratcliffe"]
9
9
  s.email = ["dylan.ratcliffe@puppet.com"]
10
10
  s.homepage = "https://github.com/dylanratcliffe/onceover"
@@ -19,25 +19,20 @@ Gem::Specification.new do |s|
19
19
 
20
20
  # Runtime dependencies, but also probably dependencies of requiring projects
21
21
  s.add_runtime_dependency 'backticks', '>= 1.0.2'
22
- s.add_runtime_dependency 'colored', '~> 1.2'
22
+ s.add_runtime_dependency 'colored', '>= 1.2'
23
23
  s.add_runtime_dependency 'cri', '>= 2.6'
24
24
  s.add_runtime_dependency 'deep_merge', '>= 1.0.0'
25
25
  s.add_runtime_dependency 'git'
26
26
  s.add_runtime_dependency 'logging', '>= 2.0.0'
27
- s.add_runtime_dependency 'multi_json', '~> 1.10'
27
+ s.add_runtime_dependency 'multi_json', '>= 1.10'
28
28
  s.add_runtime_dependency 'parallel_tests', ">= 2.0.0"
29
29
  s.add_runtime_dependency 'puppet', '>=4.0'
30
30
  s.add_runtime_dependency 'puppetlabs_spec_helper', ">= 0.4.0"
31
31
  s.add_runtime_dependency 'r10k', '>=2.1.0'
32
32
  s.add_runtime_dependency 'rake', '>= 10.0.0'
33
33
  s.add_runtime_dependency 'rspec', '>= 3.0.0'
34
- s.add_runtime_dependency 'rspec-puppet', ">= 2.4.0"
35
34
  s.add_runtime_dependency 'rspec_junit_formatter', '>= 0.2.0'
35
+ s.add_runtime_dependency 'rspec-puppet', ">= 2.4.0"
36
36
  s.add_runtime_dependency 'terminal-table', '>= 1.8.0'
37
37
  s.add_runtime_dependency 'versionomy', '>= 0.5.0'
38
-
39
- s.add_development_dependency 'cucumber', '~> 4.1'
40
- s.add_development_dependency 'pry', '~> 0.13.1'
41
- s.add_development_dependency 'rubocop', '~> 1.6', '>= 1.6.1'
42
- s.add_development_dependency 'rubygems-tasks', '~> 0.2.5'
43
38
  end
@@ -1,17 +1,17 @@
1
- forge "http://forge.puppetlabs.com"
2
- #
3
- # I want to download some modules to check if r10k feature in Onceover works correctly.
4
- #
5
-
6
- # Versions should be updated to be the latest at the time you start
7
- mod "puppetlabs/stdlib", '4.11.0'
8
-
9
- # Modules from Git
10
- # Examples: https://github.com/puppetlabs/r10k/blob/master/doc/puppetfile.mkd#examples
11
- mod 'apache',
12
- :git => 'https://github.com/puppetlabs/puppetlabs-apache',
13
- :commit => '83401079053dca11d61945bd9beef9ecf7576cbf'
14
-
15
- #mod 'apache',
16
- # :git => 'https://github.com/puppetlabs/puppetlabs-apache',
17
- # :branch => 'docs_experiment'
1
+ forge "http://forge.puppetlabs.com"
2
+ #
3
+ # I want to download some modules to check if r10k feature in Onceover works correctly.
4
+ #
5
+
6
+ # Versions should be updated to be the latest at the time you start
7
+ mod "puppetlabs/stdlib", '4.11.0'
8
+
9
+ # Modules from Git
10
+ # Examples: https://github.com/puppetlabs/r10k/blob/master/doc/puppetfile.mkd#examples
11
+ mod 'apache',
12
+ :git => 'https://github.com/puppetlabs/puppetlabs-apache',
13
+ :commit => '83401079053dca11d61945bd9beef9ecf7576cbf'
14
+
15
+ #mod 'apache',
16
+ # :git => 'https://github.com/puppetlabs/puppetlabs-apache',
17
+ # :branch => 'docs_experiment'
@@ -0,0 +1,9 @@
1
+ {
2
+ "cmd": "bundle exec onceover run spec",
3
+ "name": "onceover spec",
4
+ "cwd": "{PROJECT_PATH}",
5
+ "errorMatch": [
6
+ "compilation:\\s.*production\\/(?<file>[\\w\\/]*.pp):(?<line>\\d*):(?<col>\\d*)"
7
+ ],
8
+ "atomCommandName": "onceover:spec"
9
+ }
@@ -0,0 +1,5 @@
1
+ .onceover
2
+ .DS_Store
3
+ .bundle
4
+ Gemfile.lock
5
+ vendor
@@ -0,0 +1,13 @@
1
+ language: ruby
2
+
3
+ cache:
4
+ bundler: true
5
+ directories:
6
+ - .onceover
7
+
8
+ script: bundle exec onceover run spec --force
9
+ bundler_args: --without development --path vendor/bundle
10
+
11
+ rvm:
12
+ - 2.3.0
13
+ - 2.3.3
@@ -0,0 +1,22 @@
1
+ source 'https://rubygems.org'
2
+
3
+ group :development do
4
+ gem 'pry'
5
+ gem 'pry-byebug'
6
+ gem 'rb-readline'
7
+ gem 'puppet-debugger'
8
+ end
9
+
10
+ if ENV['ONCEOVER_gem'] == 'local'
11
+ gem 'onceover', :path => '/Users/dylan/git/onceover'
12
+ # gem 'onceover-octocatalog-diff', :path => '/Users/dylan/git/onceover-octocatalog-diff'
13
+ else
14
+ gem 'onceover', :git => 'https://github.com/dylanratcliffe/onceover.git'#, :branch => 'issue-51'
15
+ # gem 'onceover-octocatalog-diff', :git => 'https://github.com/dylanratcliffe/onceover-octocatalog-diff.git'
16
+ end
17
+
18
+ gem 'hiera-eyaml'
19
+ gem 'puppet', ENV['PUPPET_version'] || '~> 8'
20
+
21
+ # Require by telegraf module
22
+ gem 'toml-rb'
@@ -0,0 +1,50 @@
1
+ node {
2
+ puppet.credentials 'PE-Deploy-Token'
3
+ stage('Git Checkout') { // for display purposes
4
+ // Get some code from a GitHub repository
5
+ checkout([
6
+ $class: 'GitSCM',
7
+ branches: [[name: env.BRANCH_NAME]],
8
+ doGenerateSubmoduleConfigurations: false,
9
+ userRemoteConfigs: [[url: 'https://github.com/dylanratcliffe/puppet_controlrepo.git']]])
10
+ }
11
+ stage('Install Gems') {
12
+ // Run the onceover tests
13
+ sh '''source /usr/local/rvm/scripts/rvm && bundle install --path=.gems --binstubs'''
14
+ }
15
+ stage('Run Onceover Tests') {
16
+ // Run the onceover tests
17
+ try {
18
+ sh '''source /usr/local/rvm/scripts/rvm && ./bin/onceover run spec'''
19
+ } catch (error) {
20
+ junit '.onceover/spec.xml'
21
+ throw error
22
+ }
23
+ }
24
+ stage('Deploy Code') {
25
+ echo env.BRANCH_NAME
26
+ puppet.codeDeploy env.BRANCH_NAME
27
+ }
28
+ stage('Run Puppet') {
29
+ // Get all of the classes that have changed
30
+ changedClasses = sh(returnStdout: true, script: './scripts/get_changed_classes.rb').trim().split('\n')
31
+ // Get the number of classes that have changed
32
+ numChangedClasses = sh(returnStdout: true, script: './scripts/count_changed_classes.rb').trim().toInteger()
33
+ // Generate a query that we will use
34
+ nodeQuery = ('nodes { resources { type = "Class" and title in ' + ("[\"" + changedClasses.join("\",\"") + "\"]") + ' } and catalog_environment = "' + env.BRANCH_NAME +'" }').toString()
35
+ // If things have changed then execute the query
36
+ if (numChangedClasses > 0) {
37
+ echo nodeQuery
38
+ affectedNodes = puppet.query nodeQuery
39
+ // If nothing has been affected by the change we don't need to try to
40
+ // initiate the run
41
+ if (affectedNodes.size() > 0) {
42
+ puppet.job env.BRANCH_NAME, query: nodeQuery
43
+ } else {
44
+ echo "Classes: " + changedClasses.join(",") + " changed. But no nodes were affected, skipping run."
45
+ }
46
+ } else {
47
+ echo "No classes changed, skipping this step."
48
+ }
49
+ }
50
+ }
@@ -0,0 +1,102 @@
1
+ #mod 'dylanratcliffe/sumologic',
2
+ # :git => 'https://github.com/dylanratcliffe/sumologic.git'
3
+ mod 'dylanratcliffe/sumologic', '1.0.2'
4
+ mod 'nwops-debug', '0.1.3'
5
+ mod 'puppetlabs/mysql', '8.0.0'
6
+ mod 'puppetlabs/inifile', '2.5.0'
7
+ mod 'puppet-r10k', '6.8.0'
8
+ mod 'gentoo/portage', '2.3.0'
9
+ mod 'puppetlabs/gcc', '0.3.0'
10
+ mod 'puppetlabs/git', '0.5.0'
11
+ mod 'puppetlabs/pe_gem', '0.2.0'
12
+ mod 'puppetlabs/ruby', '1.0.0'
13
+ mod 'puppetlabs/vcsrepo', '2.4.0'
14
+ mod 'puppet-make', '2.1.1'
15
+ mod 'puppet/jira', '3.5.2'
16
+ mod 'actionjack/crowd', '0.1.1'
17
+ mod 'puppetlabs/java', '3.3.0'
18
+ mod 'puppetlabs-java_ks', '2.3.0'
19
+ mod 'puppetlabs/postgresql', '5.11.0'
20
+ mod 'mkrakowitzer/deploy', '0.0.3'
21
+ mod 'nanliu/staging', '1.0.3'
22
+ mod 'puppetlabs/apt', '6.3.0'
23
+ mod 'puppetlabs/concat', '5.2.0'
24
+ mod 'puppetlabs/firewall', '1.15.0'
25
+ mod 'puppet/hiera', '3.3.4'
26
+ mod 'danzilio/report_all_the_things', '0.1.0'
27
+ mod 'rtyler-jenkins', '1.7.0'
28
+ mod 'unibet/vagrant', '0.2.1'
29
+ mod 'darin/zypprepo', '1.0.2'
30
+ mod 'puppet/nginx', '0.15.0'
31
+ mod 'puppet/nodejs', '6.0.0'
32
+ mod 'puppet/wget', '2.0.1'
33
+ mod 'stahnma/epel', '1.3.1'
34
+ mod 'puppetlabs/apache', '4.0.0'
35
+ mod 'puppet/collectd', '10.1.0'
36
+ mod 'puppet-yum', '3.1.1'
37
+ mod 'puppetlabs/puppetserver_gem', '1.1.1'
38
+ mod 'WhatsARanjit/node_manager', '0.7.1'
39
+
40
+ mod 'pltraining-rbac', '0.0.10'
41
+ mod 'camptocamp/systemd', '2.1.0'
42
+ mod 'puppetlabs/stdlib', '5.2.0'
43
+ mod 'maestrodev/rvm', '1.13.1'
44
+ mod 'golja/gnupg', '1.2.3'
45
+ mod 'treydock/gpg_key', '0.1.0'
46
+ mod 'evenup/hubot', '0.2.0'
47
+ mod 'puppetlabs/haproxy', '4.3.0'
48
+ mod 'puppetlabs/aws', '2.1.0'
49
+ #mod 'danieldreier/autosign', '0.1.2'
50
+ mod 'autosign',
51
+ :git => 'https://github.com/dylanratcliffe/puppet-autosign.git',
52
+ :ref => '07ca3e0ad181483bd40ad1bd25466a19ac240fa7'
53
+ mod 'puppetlabs/hocon', '0.9.4' # Hold due to MODULES-5837
54
+ mod 'puppetlabs/dsc', '1.8.0'
55
+ mod 'puppetlabs/powershell', '2.2.0'
56
+ mod 'puppetlabs/reboot', '2.1.2'
57
+ mod 'puppetlabs/chocolatey', '3.1.1'
58
+ mod 'puppet-selinux', '1.6.1'
59
+ mod 'puppet-windows_env', '3.2.0'
60
+ mod 'puppet-archive', '7.0.0'
61
+ mod 'puppetlabs-transition', '0.1.1'
62
+ mod 'dylanratcliffe-windows_disk_facts','0.2.5'
63
+ mod 'biemond-wildfly', '2.3.2'
64
+ mod 'jethrocarr-initfact', '1.0.1'
65
+ mod 'puppetlabs-iis', '4.5.0'
66
+ mod 'puppetlabs-registry', '2.1.0'
67
+ mod 'puppetlabs-acl', '3.2.1'
68
+ mod 'trlinkin-noop', '1.0.0'
69
+ mod 'puppetlabs-puppet_agent', '2.0.1'
70
+ mod 'puppetlabs-exec', '0.3.0'
71
+ # CIDR Based Facts Example
72
+ mod 'dylanratcliffe-cidr_facts', '0.1.6'
73
+ mod 'puppet-grafana', '7.0.0'
74
+ mod 'puppetlabs-puppet_metrics_dashboard', '2.5.0'
75
+ mod 'puppet-telegraf', '4.1.0'
76
+
77
+ mod 'compliance_api',
78
+ :git => 'https://github.com/dylanratcliffe/puppet-compliance_api.git',
79
+ :ref => 'master'
80
+
81
+ mod 'deployment_signature',
82
+ :git => 'https://github.com/dylanratcliffe/puppet-deployment_signature.git',
83
+ :ref => 'master'
84
+
85
+
86
+ mod 'puppetlabs-bolt_shim', '0.2.1'
87
+ mod 'puppetlabs-facts', '0.5.0'
88
+ mod 'puppetlabs-service', '0.5.0'
89
+ mod 'puppetlabs-package', '0.4.1'
90
+ mod 'puppetlabs-puppet_conf', '0.3.0'
91
+ mod 'puppetlabs-yumrepo_core', '1.0.7'
92
+ mod 'puppetlabs-augeas_core', '1.0.4'
93
+ mod 'puppetlabs-cd4pe', '3.0.1'
94
+ mod 'puppetlabs-puppet_authorization', '0.5.1'
95
+ mod 'puppetlabs-docker', '3.12.1'
96
+ mod 'puppetlabs-translate', '1.2.0'
97
+ mod 'puppetlabs-pe_databases', '1.1.0'
98
+ mod 'puppetlabs-cron_core', '1.0.4'
99
+ mod 'puppetlabs-support_tasks', '1.1.2'
100
+ mod 'inkblot-bind', '7.4.0'
101
+ mod 'saz-resolv_conf', '4.2.1'
102
+ mod 'kinners00-nessus_agent', '1.1.3'
@@ -0,0 +1,4 @@
1
+ # puppet_controlrepo
2
+
3
+ [![Build Status](https://travis-ci.org/dylanratcliffe/puppet_controlrepo.svg?branch=production)](https://travis-ci.org/dylanratcliffe/puppet_controlrepo)
4
+
@@ -0,0 +1,6 @@
1
+ require 'puppetlabs_spec_helper/rake_tasks'
2
+
3
+ #desc "Run acceptance tests"
4
+ #RSpec::Core::RakeTask.new(:acceptance) do |t|
5
+ # t.pattern = 'spec/acceptance'
6
+ #end