From 48eb9aa62984d359e028709d0e3b3ec8e68538d6 Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Fri, 17 Mar 2023 09:39:37 +0100 Subject: [PATCH] Introduce RuboCop --- .github/workflows/test.yml | 23 ++ .rubocop.yml | 5 + .rubocop_todo.yml | 239 +++++++++++++++ Gemfile | 4 +- Rakefile | 105 +++---- facterdb.gemspec | 12 +- facts/Gemfile | 8 +- facts/Vagrantfile | 596 ++++++++++++++++++------------------- lib/facterdb.rb | 45 +-- lib/facterdb/bin.rb | 2 +- rakelib/rhel_alts.rake | 18 +- spec/facterdb_spec.rb | 74 ++--- spec/facts_spec.rb | 20 +- 13 files changed, 718 insertions(+), 433 deletions(-) create mode 100644 .rubocop.yml create mode 100644 .rubocop_todo.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 59d3fb12..e5618750 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -7,6 +7,20 @@ on: - master jobs: + rubocop: + env: + BUNDLE_WITHOUT: release + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Install Ruby ${{ matrix.ruby }} + uses: ruby/setup-ruby@v1 + with: + ruby-version: "3.2" + bundler-cache: true + - name: Run Rubocop + run: bundle exec rake rubocop + test: runs-on: ubuntu-latest strategy: @@ -30,3 +44,12 @@ jobs: run: bundle exec rake spec - name: Build gem run: gem build *.gemspec + + tests: + needs: + - rubocop + - test + runs-on: ubuntu-latest + name: Test suite + steps: + - run: echo Test suite completed diff --git a/.rubocop.yml b/.rubocop.yml new file mode 100644 index 00000000..12e57db6 --- /dev/null +++ b/.rubocop.yml @@ -0,0 +1,5 @@ +--- +inherit_from: .rubocop_todo.yml + +inherit_gem: + voxpupuli-rubocop: rubocop.yml diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml new file mode 100644 index 00000000..93f64e17 --- /dev/null +++ b/.rubocop_todo.yml @@ -0,0 +1,239 @@ +# This configuration was generated by +# `rubocop --auto-gen-config` +# on 2023-06-21 07:47:32 UTC using RuboCop version 1.50.2. +# The point is for the user to remove these configuration records +# one by one as the offenses are removed from the code base. +# Note that changes in the inspected code, or installation of new +# versions of RuboCop, may require this file to be generated again. + +# Offense count: 2 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: AllowSafeAssignment. +Lint/AssignmentInCondition: + Exclude: + - 'Gemfile' + - 'facts/Gemfile' + +# Offense count: 1 +# Configuration parameters: IgnoreLiteralBranches, IgnoreConstantBranches. +Lint/DuplicateBranch: + Exclude: + - 'Rakefile' + +# Offense count: 1 +# Configuration parameters: AllowComments, AllowNil. +Lint/SuppressedException: + Exclude: + - 'Rakefile' + +# Offense count: 3 +Lint/UselessAssignment: + Exclude: + - 'spec/facts_spec.rb' + +# Offense count: 2 +# Configuration parameters: MinNameLength, AllowNamesEndingInNumbers, AllowedNames, ForbiddenNames. +# AllowedNames: as, at, by, cc, db, id, if, in, io, ip, of, on, os, pp, to +Naming/MethodParameterName: + Exclude: + - 'Rakefile' + - 'lib/facterdb.rb' + +# Offense count: 1 +# This cop supports unsafe autocorrection (--autocorrect-all). +Performance/MapCompact: + Exclude: + - 'lib/facterdb.rb' + +# Offense count: 7 +# This cop supports unsafe autocorrection (--autocorrect-all). +Performance/StringInclude: + Exclude: + - 'Rakefile' + +# Offense count: 3 +# Configuration parameters: Prefixes, AllowedPatterns. +# Prefixes: when, with, without +RSpec/ContextWording: + Exclude: + - 'spec/facterdb_spec.rb' + +# Offense count: 1 +# Configuration parameters: IgnoredMetadata. +RSpec/DescribeClass: + Exclude: + - '**/spec/features/**/*' + - '**/spec/requests/**/*' + - '**/spec/routing/**/*' + - '**/spec/system/**/*' + - '**/spec/views/**/*' + - 'spec/facts_spec.rb' + +# Offense count: 12 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: SkipBlocks, EnforcedStyle. +# SupportedStyles: described_class, explicit +RSpec/DescribedClass: + Exclude: + - 'spec/facterdb_spec.rb' + +# Offense count: 3 +# Configuration parameters: CountAsOne. +RSpec/ExampleLength: + Max: 9 + +# Offense count: 1 +# Configuration parameters: Include, CustomTransform, IgnoreMethods, SpecSuffixOnly. +# Include: **/*_spec*rb*, **/spec/**/* +RSpec/FilePath: + Exclude: + - 'spec/facterdb_spec.rb' + +# Offense count: 4 +# Configuration parameters: Max. +RSpec/IndexedLet: + Exclude: + - 'spec/facterdb_spec.rb' + +# Offense count: 4 +RSpec/MultipleExpectations: + Max: 7 + +# Offense count: 11 +# Configuration parameters: AllowSubject. +RSpec/MultipleMemoizedHelpers: + Max: 6 + +# Offense count: 11 +# Configuration parameters: AllowedGroups. +RSpec/NestedGroups: + Max: 4 + +# Offense count: 2 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: Strict, EnforcedStyle, AllowedExplicitMatchers. +# SupportedStyles: inflected, explicit +RSpec/PredicateMatcher: + Exclude: + - 'spec/facterdb_spec.rb' + +# Offense count: 2 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: MinBranchesCount. +Style/CaseLikeIf: + Exclude: + - 'Rakefile' + - 'lib/facterdb.rb' + +# Offense count: 2 +# Configuration parameters: AllowedConstants. +Style/Documentation: + Exclude: + - 'spec/**/*' + - 'test/**/*' + - 'lib/facterdb.rb' + - 'lib/facterdb/bin.rb' + +# Offense count: 13 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: EnforcedStyle. +# SupportedStyles: always, always_true, never +Style/FrozenStringLiteralComment: + Exclude: + - 'Gemfile' + - 'Rakefile' + - 'bin/facterdb' + - 'facterdb.gemspec' + - 'facts/Gemfile' + - 'facts/Vagrantfile' + - 'lib/facterdb.rb' + - 'lib/facterdb/bin.rb' + - 'lib/facterdb/version.rb' + - 'rakelib/rhel_alts.rake' + - 'spec/facterdb_spec.rb' + - 'spec/facts_spec.rb' + - 'spec/spec_helper.rb' + +# Offense count: 1 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: AllowedReceivers. +# AllowedReceivers: Thread.current +Style/HashEachMethods: + Exclude: + - 'spec/facts_spec.rb' + +# Offense count: 1 +# This cop supports unsafe autocorrection (--autocorrect-all). +Style/HashTransformKeys: + Exclude: + - 'lib/facterdb.rb' + +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +Style/IfUnlessModifier: + Exclude: + - 'lib/facterdb.rb' + +# Offense count: 1 +# This cop supports unsafe autocorrection (--autocorrect-all). +Style/MapToHash: + Exclude: + - 'lib/facterdb.rb' + +# Offense count: 1 +Style/MixinUsage: + Exclude: + - 'spec/spec_helper.rb' + +# Offense count: 2 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: EnforcedStyle. +# SupportedStyles: literals, strict +Style/MutableConstant: + Exclude: + - 'facts/Vagrantfile' + - 'lib/facterdb/version.rb' + +# Offense count: 1 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: EnforcedStyle, AllowedMethods, AllowedPatterns. +# SupportedStyles: predicate, comparison +Style/NumericPredicate: + Exclude: + - 'spec/**/*' + - 'Rakefile' + +# Offense count: 1 +# Configuration parameters: AllowedMethods. +# AllowedMethods: respond_to_missing? +Style/OptionalBooleanParameter: + Exclude: + - 'lib/facterdb.rb' + +# Offense count: 1 +# This cop supports unsafe autocorrection (--autocorrect-all). +Style/SlicingWithRange: + Exclude: + - 'Rakefile' + +# Offense count: 1 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: Mode. +Style/StringConcatenation: + Exclude: + - 'lib/facterdb.rb' + +# Offense count: 1 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: AllowMethodsWithArguments, AllowedMethods, AllowedPatterns, AllowComments. +# AllowedMethods: define_method +Style/SymbolProc: + Exclude: + - 'Rakefile' + +# Offense count: 4 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns. +# URISchemes: http, https +Layout/LineLength: + Max: 179 diff --git a/Gemfile b/Gemfile index 84d56274..761ff21e 100644 --- a/Gemfile +++ b/Gemfile @@ -3,9 +3,9 @@ source ENV['GEM_SOURCE'] || 'https://rubygems.org' gemspec if facterversion = ENV['FACTER_GEM_VERSION'] - gem 'facter', facterversion, :require => false + gem 'facter', facterversion, require: false else - gem 'facter', :require => false + gem 'facter', require: false end group :development do diff --git a/Rakefile b/Rakefile index 7521fa70..683c9655 100644 --- a/Rakefile +++ b/Rakefile @@ -14,7 +14,7 @@ begin config.exclude_labels = %w[duplicate question invalid wontfix maintenance] config.user = 'voxpupuli' config.project = 'facterdb' - config.release_url = "https://rubygems.org/gems/facterdb/versions/%s" + config.release_url = 'https://rubygems.org/gems/facterdb/versions/%s' config.since_tag = '0.3.11' end rescue LoadError @@ -24,23 +24,22 @@ rescue LoadError end end - # Generate a human-friendly OS label based on a given factset def factset_to_os_label(fs) os_rel = '???' os_name = '????' if fs.key?(:os) && fs[:os].key?('release') && (fs[:os]['release']['major'] =~ /\d/) os_name = fs[:os]['name'] - fail = Hash.new + fail = {} os = fs[:os] distro = os.fetch('lsb', os.fetch('distro', fail)) - if distro.key?('id') - os_id = distro['id'] - elsif distro.key?('distid') - os_id = distro['distid'] - else - os_id = '@@@@@@@@@@' - end + os_id = if distro.key?('id') + distro['id'] + elsif distro.key?('distid') + distro['distid'] + else + '@@@@@@@@@@' + end os_rel = fs[:os]['release']['major'] os__rel = fs[:os]['release']['full'] elsif fs.key? :operatingsystem @@ -49,50 +48,50 @@ def factset_to_os_label(fs) os_rel = fs.fetch(:operatingsystemmajrelease, fs.fetch(:lsbmajdistrelease, nil)) os__rel = fs.fetch(:lsbdistrelease, fs.fetch(:operatingsystemrelease, '@@@')) else - require 'pp' pp fs - fail( 'ERROR: unrecognized facterset format' ) + raise('ERROR: unrecognized facterset format') end # Sanitize OS names to match the formats used in the facterdb README label = "#{os_name} #{os_rel}" - if os_name =~ /^(Archlinux|Gentoo)$/ + if /^(Archlinux|Gentoo)$/.match?(os_name) label = os_name elsif os_name =~ /^(SLES|FreeBSD|OpenSuSE)$/ || - (os_name =~ /^(RedHat|Scientific|OracleLinux|CentOS|AlmaLinux)/ && os_rel.nil?) + (os_name =~ /^(RedHat|Scientific|OracleLinux|CentOS|AlmaLinux)/ && os_rel.nil?) label = "#{os_name} #{os__rel.split('.').first}" - elsif os_name =~ /^(OpenBSD|Ubuntu|Fedora)$/ + elsif /^(OpenBSD|Ubuntu|Fedora)$/.match?(os_name) label = "#{os_name} #{os__rel}" - elsif os_name =~ /^(Solaris)/ - if fs.key?(:os) && fs[:os].key?('release') && (fs[:os]['release']['major'] =~ /\d/) - label = "#{os_name} #{os_rel}" - elsif fs.key?(:operatingsystemmajrelease) - label = "#{os_name} #{os_rel}" - else - label = "#{os_name} #{os__rel.split('.')[1]}" - end - elsif fs[:_facterdb_filename] =~ /sles-15-/ - label = "SLES 15" + elsif /^(Solaris)/.match?(os_name) + label = if fs.key?(:os) && fs[:os].key?('release') && (fs[:os]['release']['major'] =~ /\d/) + "#{os_name} #{os_rel}" + elsif fs.key?(:operatingsystemmajrelease) + "#{os_name} #{os_rel}" + else + "#{os_name} #{os__rel.split('.')[1]}" + end + elsif /sles-15-/.match?(fs[:_facterdb_filename]) + label = 'SLES 15' elsif os_name.start_with?('Debian') && os_id == 'LinuxMint' label = "#{os_id} #{fs[:lsbmajdistrelease]}" elsif os_name.start_with?('Debian') && os_id == 'Raspbian' label = "#{os_id} #{os_rel}" - elsif os_name =~ /^windows$/ + elsif /^windows$/.match?(os_name) db_filename = fs[:_facterdb_filename] || 'there_is_no_filename' - if db_filename =~ /windows-10-/ - label = "Windows 10" - elsif db_filename =~ /windows-7-/ - label = "Windows 7" - elsif db_filename =~ /windows-8[\d.]*-/ - label = "Windows #{os__rel.sub('6.2.9200','8').sub('6.3.9600','8.1')}" - elsif db_filename =~ /windows-.+-core-/ - label = "Windows Server #{os__rel.sub('6.3.9600','2012 R2')} Core" - elsif db_filename =~ /windows-2008/ || db_filename =~ /windows-2012/ || db_filename =~ /windows-2016/ - label = "Windows Server #{os__rel.sub('6.1.7600','2008 R2').sub('6.3.9600','2012 R2').sub('10.0.14393', '2016')}" - elsif db_filename =~ /windows-2019/ - label = 'Windows Server 2019' - else - label = "#{os_name} #{os__rel}" - end + label = if /windows-10-/.match?(db_filename) + 'Windows 10' + elsif /windows-7-/.match?(db_filename) + 'Windows 7' + elsif /windows-8[\d.]*-/.match?(db_filename) + "Windows #{os__rel.sub('6.2.9200', '8').sub('6.3.9600', '8.1')}" + elsif /windows-.+-core-/.match?(db_filename) + "Windows Server #{os__rel.sub('6.3.9600', '2012 R2')} Core" + elsif db_filename =~ /windows-2008/ || db_filename =~ /windows-2012/ || db_filename =~ /windows-2016/ + "Windows Server #{os__rel.sub('6.1.7600', '2008 R2').sub('6.3.9600', '2012 R2').sub('10.0.14393', + '2016')}" + elsif /windows-2019/.match?(db_filename) + 'Windows Server 2019' + else + "#{os_name} #{os__rel}" + end end label @@ -102,15 +101,15 @@ desc 'generate a markdown table of Facter/OS coverage (for the README)' task :table do require_relative 'lib/facterdb' # Turn on the source injection - old_env = ENV['FACTERDB_INJECT_SOURCE'] + old_env = ENV.fetch('FACTERDB_INJECT_SOURCE', nil) ENV['FACTERDB_INJECT_SOURCE'] = 'true' - factsets = FacterDB.get_facts() + factsets = FacterDB.get_facts # Restore the source injection ENV['FACTERDB_INJECT_SOURCE'] = old_env - facter_versions = factsets.map { |x| + facter_versions = factsets.map do |x| Gem::Version.new(x[:facterversion].split('.')[0..1].join('.')) - }.uniq.sort.map(&:to_s) + end.uniq.sort.map(&:to_s) os_facter_matrix = {} # Process the facts and create a hash of all the OS and facter combinations @@ -134,13 +133,13 @@ task :table do new_readme = readme[0..readme.index { |r| r.start_with?('| ') } - 1] # Write out a nice table - os_version_width = (os_versions.map{|x| x.size } + [17]).max - new_readme << "| #{'operating system'.center(os_version_width)} |#{facter_versions.map{|x| " #{x} |" }.join}" - new_readme << "| #{'-' * (os_version_width)} |#{facter_versions.map{|x| " --- |" }.join}" + os_version_width = (os_versions.map { |x| x.size } + [17]).max + new_readme << "| #{'operating system'.center(os_version_width)} |#{facter_versions.map { |x| " #{x} |" }.join}" + new_readme << "| #{'-' * os_version_width} |#{facter_versions.map { |_x| ' --- |' }.join}" os_versions.each do |label| - fvs = facter_versions.map{ |facter_version| os_facter_matrix[label][facter_version] || 0 } + fvs = facter_versions.map { |facter_version| os_facter_matrix[label][facter_version] || 0 } row = "| #{label.ljust(os_version_width)} |" - fvs.each { |fv| row += (fv > 0? " #{fv.to_s.center(3)} |" : " |" ) } + fvs.each { |fv| row += (fv > 0 ? " #{fv.to_s.center(3)} |" : ' |') } new_readme << row end @@ -149,4 +148,10 @@ task :table do end end +begin + require 'voxpupuli/rubocop/rake' +rescue LoadError + # the voxpupuli-rubocop gem is optional +end + task default: 'spec' diff --git a/facterdb.gemspec b/facterdb.gemspec index 2d23b541..8bfcc114 100644 --- a/facterdb.gemspec +++ b/facterdb.gemspec @@ -1,6 +1,5 @@ -# -*- encoding: utf-8 -*- -$LOAD_PATH.unshift File.expand_path("../lib", __FILE__) -require "facterdb/version" +$LOAD_PATH.unshift File.expand_path('lib', __dir__) +require 'facterdb/version' Gem::Specification.new do |s| s.name = 'facterdb' @@ -13,16 +12,17 @@ Gem::Specification.new do |s| s.licenses = 'Apache-2.0' s.files = `git ls-files`.split("\n") - s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n") - s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) } + s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) } # we have that configured in our CI file s.required_ruby_version = Gem::Requirement.new('>= 2.7.0') s.add_development_dependency 'coveralls' - s.add_development_dependency 'rake' s.add_development_dependency 'pry' + s.add_development_dependency 'rake' s.add_development_dependency 'rspec' + + s.add_development_dependency 'voxpupuli-rubocop', '~> 1.3.0' s.add_runtime_dependency 'facter', '< 5.0.0' s.add_runtime_dependency 'jgrep' end diff --git a/facts/Gemfile b/facts/Gemfile index cb3dfadf..23027a1a 100644 --- a/facts/Gemfile +++ b/facts/Gemfile @@ -1,13 +1,13 @@ -source ENV['GEM_SOURCE'] || "https://rubygems.org" +source ENV['GEM_SOURCE'] || 'https://rubygems.org' -gem 'json', :require => false gem 'ffi' +gem 'json', require: false # workaround for https://tickets.puppetlabs.com/projects/FACT/issues/FACT-3091 # facter requires/uses the sys-filesystem gem, but it is currently not listed in the gemspec file from facter gem 'sys-filesystem' if facterversion = ENV['FACTER_GEM_VERSION'] - gem 'facter', facterversion, :require => false + gem 'facter', facterversion, require: false else - gem 'facter', :require => false + gem 'facter', require: false end diff --git a/facts/Vagrantfile b/facts/Vagrantfile index 72cd3731..f640dc79 100644 --- a/facts/Vagrantfile +++ b/facts/Vagrantfile @@ -2,242 +2,242 @@ # vi: set ft=ruby : # Vagrantfile API/syntax version. Don't touch unless you know what you're doing! -VAGRANTFILE_API_VERSION = "2" +VAGRANTFILE_API_VERSION = '2' Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| - - config.vm.hostname = "foo.example.com" - config.vm.provider "virtualbox" do |v| + config.vm.hostname = 'foo.example.com' + config.vm.provider 'virtualbox' do |v| v.gui = false end - config.vm.define "debian-10-x86_64" do |host| - host.vm.box = "debian/contrib-buster64" - host.vm.provision "file", source: "Gemfile", destination: "Gemfile" - host.vm.provision "shell", path: "get_facts.sh" - host.vm.provision "shell", inline: "/sbin/shutdown -h now" - end - config.vm.define "debian-11-x86_64" do |host| - host.vm.box = "boxomatic/debian-11" - host.vm.provision "file", source: "Gemfile", destination: "Gemfile" - host.vm.provision "shell", path: "get_facts.sh" - host.vm.provision "shell", inline: "/sbin/shutdown -h now" - end - config.vm.define "linuxmint-19-x86_64" do |host| - host.vm.box = "ltsp/linuxmint-19.1-cinnamon-64bit" - host.vm.provision "shell", inline: "export DEBIAN_FRONTEND=noninteractive && apt-get update && apt-get install -y ruby ruby-dev libc6-dev" - host.vm.provision "file", source: "Gemfile", destination: "Gemfile" - host.vm.provision "shell", path: "get_facts.sh" - host.vm.provision "shell", inline: "/sbin/shutdown -h now" - end - config.vm.define "ubuntu-18.04-x86_64" do |host| - host.vm.box = "ubuntu/bionic64" - host.vm.provision "file", source: "Gemfile", destination: "Gemfile" - host.vm.provision "shell", path: "get_facts.sh" - host.vm.provision "shell", inline: "/sbin/shutdown -h now" - end - config.vm.define "ubuntu-20.04-x86_64" do |host| - host.vm.box = "ubuntu/focal64" - host.vm.provision "file", source: "Gemfile", destination: "Gemfile" - host.vm.provision "shell", path: "get_facts.sh" - host.vm.provision "shell", inline: "/sbin/shutdown -h now" - end - config.vm.define "ubuntu-21.04-x86_64" do |host| - host.vm.box = "ubuntu/hirsute64" - host.vm.provision "file", source: "Gemfile", destination: "Gemfile" - host.vm.provision "shell", path: "get_facts.sh" - host.vm.provision "shell", inline: "/sbin/shutdown -h now" - end - config.vm.define "ubuntu-21.10-x86_64" do |host| - host.vm.box = "ubuntu/impish64" - host.vm.provision "file", source: "Gemfile", destination: "Gemfile" - host.vm.provision "shell", path: "get_facts.sh" - host.vm.provision "shell", inline: "/sbin/shutdown -h now" - end - config.vm.define "ubuntu-22.04-x86_64" do |host| - host.vm.box = "ubuntu/jammy64" - host.vm.provision "file", source: "Gemfile", destination: "Gemfile" - host.vm.provision "shell", path: "get_facts.sh" - host.vm.provision "shell", inline: "/sbin/shutdown -h now" - end - # the ssh bits on this did not work right, most of the steps for + config.vm.define 'debian-10-x86_64' do |host| + host.vm.box = 'debian/contrib-buster64' + host.vm.provision 'file', source: 'Gemfile', destination: 'Gemfile' + host.vm.provision 'shell', path: 'get_facts.sh' + host.vm.provision 'shell', inline: '/sbin/shutdown -h now' + end + config.vm.define 'debian-11-x86_64' do |host| + host.vm.box = 'boxomatic/debian-11' + host.vm.provision 'file', source: 'Gemfile', destination: 'Gemfile' + host.vm.provision 'shell', path: 'get_facts.sh' + host.vm.provision 'shell', inline: '/sbin/shutdown -h now' + end + config.vm.define 'linuxmint-19-x86_64' do |host| + host.vm.box = 'ltsp/linuxmint-19.1-cinnamon-64bit' + host.vm.provision 'shell', + inline: 'export DEBIAN_FRONTEND=noninteractive && apt-get update && apt-get install -y ruby ruby-dev libc6-dev' + host.vm.provision 'file', source: 'Gemfile', destination: 'Gemfile' + host.vm.provision 'shell', path: 'get_facts.sh' + host.vm.provision 'shell', inline: '/sbin/shutdown -h now' + end + config.vm.define 'ubuntu-18.04-x86_64' do |host| + host.vm.box = 'ubuntu/bionic64' + host.vm.provision 'file', source: 'Gemfile', destination: 'Gemfile' + host.vm.provision 'shell', path: 'get_facts.sh' + host.vm.provision 'shell', inline: '/sbin/shutdown -h now' + end + config.vm.define 'ubuntu-20.04-x86_64' do |host| + host.vm.box = 'ubuntu/focal64' + host.vm.provision 'file', source: 'Gemfile', destination: 'Gemfile' + host.vm.provision 'shell', path: 'get_facts.sh' + host.vm.provision 'shell', inline: '/sbin/shutdown -h now' + end + config.vm.define 'ubuntu-21.04-x86_64' do |host| + host.vm.box = 'ubuntu/hirsute64' + host.vm.provision 'file', source: 'Gemfile', destination: 'Gemfile' + host.vm.provision 'shell', path: 'get_facts.sh' + host.vm.provision 'shell', inline: '/sbin/shutdown -h now' + end + config.vm.define 'ubuntu-21.10-x86_64' do |host| + host.vm.box = 'ubuntu/impish64' + host.vm.provision 'file', source: 'Gemfile', destination: 'Gemfile' + host.vm.provision 'shell', path: 'get_facts.sh' + host.vm.provision 'shell', inline: '/sbin/shutdown -h now' + end + config.vm.define 'ubuntu-22.04-x86_64' do |host| + host.vm.box = 'ubuntu/jammy64' + host.vm.provision 'file', source: 'Gemfile', destination: 'Gemfile' + host.vm.provision 'shell', path: 'get_facts.sh' + host.vm.provision 'shell', inline: '/sbin/shutdown -h now' + end + # the ssh bits on this did not work right, most of the steps for # generating things were done manually - config.vm.define "ubuntu-22.10-x86_64" do |host| - host.vm.box = "ubuntu/kinetic64" - host.vm.provision "file", source: "Gemfile", destination: "Gemfile" - host.vm.provision "shell", path: "get_facts.sh" - host.vm.provision "shell", inline: "/sbin/shutdown -h now" - end - config.vm.define "centos-7-x86_64" do |host| - host.vm.box = "centos/7" + config.vm.define 'ubuntu-22.10-x86_64' do |host| + host.vm.box = 'ubuntu/kinetic64' + host.vm.provision 'file', source: 'Gemfile', destination: 'Gemfile' + host.vm.provision 'shell', path: 'get_facts.sh' + host.vm.provision 'shell', inline: '/sbin/shutdown -h now' + end + config.vm.define 'centos-7-x86_64' do |host| + host.vm.box = 'centos/7' host.vm.network :private_network, ip: '10.0.0.2' - host.vm.synced_folder ".", "/vagrant", :nfs => true, :nfs_udp => false - host.vm.provision "shell", inline: "yum -y install ruby-devel gcc wget net-tools" - host.vm.provision "file", source: "Gemfile", destination: "Gemfile" - host.vm.provision "shell", path: "get_facts.sh" - host.vm.provision "shell", inline: "/sbin/shutdown -h now" - end - config.vm.define "centos-8-x86_64" do |host| - host.vm.box = "centos/8" - host.vm.synced_folder ".", "/vagrant" - host.vm.provision "shell", inline: "dnf -y install wget make gcc net-tools" - host.vm.provision "file", source: "Gemfile", destination: "Gemfile" - host.vm.provision "shell", path: "get_facts.sh" - host.vm.provision "shell", inline: "/sbin/shutdown -h now" + host.vm.synced_folder '.', '/vagrant', nfs: true, nfs_udp: false + host.vm.provision 'shell', inline: 'yum -y install ruby-devel gcc wget net-tools' + host.vm.provision 'file', source: 'Gemfile', destination: 'Gemfile' + host.vm.provision 'shell', path: 'get_facts.sh' + host.vm.provision 'shell', inline: '/sbin/shutdown -h now' + end + config.vm.define 'centos-8-x86_64' do |host| + host.vm.box = 'centos/8' + host.vm.synced_folder '.', '/vagrant' + host.vm.provision 'shell', inline: 'dnf -y install wget make gcc net-tools' + host.vm.provision 'file', source: 'Gemfile', destination: 'Gemfile' + host.vm.provision 'shell', path: 'get_facts.sh' + host.vm.provision 'shell', inline: '/sbin/shutdown -h now' host.vbguest.auto_update = true end - config.vm.define "centos-stream8-x86_64" do |host| - host.vm.box = "centos/stream8" - host.vm.synced_folder ".", "/vagrant" - host.vm.provision "shell", inline: "dnf -y install wget make gcc net-tools" - host.vm.provision "file", source: "Gemfile", destination: "Gemfile" - host.vm.provision "shell", path: "get_facts.sh" - host.vm.provision "shell", inline: "/sbin/shutdown -h now" + config.vm.define 'centos-stream8-x86_64' do |host| + host.vm.box = 'centos/stream8' + host.vm.synced_folder '.', '/vagrant' + host.vm.provision 'shell', inline: 'dnf -y install wget make gcc net-tools' + host.vm.provision 'file', source: 'Gemfile', destination: 'Gemfile' + host.vm.provision 'shell', path: 'get_facts.sh' + host.vm.provision 'shell', inline: '/sbin/shutdown -h now' host.vbguest.auto_update = true end # will work after https://www.centos.org/centos-stream/#tab-3 got updated # in the meantime images are at https://cloud.centos.org/centos/9-stream/x86_64/images/ # can be imported with vagrant box add --name centos/stream9 $url - config.vm.define "centos-stream9-x86_64" do |host| - host.vm.box = "centos/stream9" - host.vm.synced_folder ".", "/vagrant" - host.vm.provision "shell", inline: "dnf -y install wget make gcc net-tools" - host.vm.provision "file", source: "Gemfile", destination: "Gemfile" - host.vm.provision "shell", path: "get_facts.sh" - host.vm.provision "shell", inline: "/sbin/shutdown -h now" + config.vm.define 'centos-stream9-x86_64' do |host| + host.vm.box = 'centos/stream9' + host.vm.synced_folder '.', '/vagrant' + host.vm.provision 'shell', inline: 'dnf -y install wget make gcc net-tools' + host.vm.provision 'file', source: 'Gemfile', destination: 'Gemfile' + host.vm.provision 'shell', path: 'get_facts.sh' + host.vm.provision 'shell', inline: '/sbin/shutdown -h now' host.vbguest.auto_update = true end - config.vm.define "almalinux-8-x86_64" do |host| - host.vm.box = "almalinux/8" - host.vm.synced_folder ".", "/vagrant" - host.vm.provision "shell", inline: "dnf -y install wget make gcc net-tools" - host.vm.provision "file", source: "Gemfile", destination: "Gemfile" - host.vm.provision "shell", path: "get_facts.sh" - host.vm.provision "shell", inline: "/sbin/shutdown -h now" - end - config.vm.define "almalinux-9-x86_64" do |host| - host.vm.box = "almalinux/9" - host.vm.synced_folder ".", "/vagrant" - host.vm.provision "shell", inline: "dnf -y install wget make gcc net-tools" - host.vm.provision "file", source: "Gemfile", destination: "Gemfile" - host.vm.provision "shell", path: "get_facts.sh" - host.vm.provision "shell", inline: "/sbin/shutdown -h now" - end - config.vm.define "rockylinux-8-x86_64" do |host| - host.vm.box = "rockylinux/8" - host.vm.synced_folder ".", "/vagrant" - host.vm.provision "shell", inline: "dnf -y install wget make gcc net-tools" - host.vm.provision "file", source: "Gemfile", destination: "Gemfile" - host.vm.provision "shell", path: "get_facts.sh" - host.vm.provision "shell", inline: "/sbin/shutdown -h now" - end - config.vm.define "rockylinux-9-x86_64" do |host| - host.vm.box = "rockylinux/9" - host.vm.synced_folder ".", "/vagrant" - host.vm.provision "shell", inline: "dnf -y install wget make gcc net-tools" - host.vm.provision "file", source: "Gemfile", destination: "Gemfile" - host.vm.provision "shell", path: "get_facts.sh" - host.vm.provision "shell", inline: "/sbin/shutdown -h now" - end - config.vm.define "redhat-8-x86_64" do |host| - host.vm.box = "generic/rhel8" - host.vm.synced_folder ".", "/vagrant" - host.vm.provision "file", source: "Gemfile", destination: "Gemfile" - host.vm.provision "shell", path: "get_facts.sh" - host.vm.provision "shell", inline: "/sbin/shutdown -h now" - end - config.vm.define "archlinux-x86_64" do |host| - host.vm.box = "archlinux/archlinux" - host.vm.provision "file", source: "Gemfile", destination: "Gemfile" - #host.vm.provision "shell", path: "get_facts.sh" - #host.vm.provision "shell", inline: "/sbin/shutdown -h now" - end - config.vm.define "sles-11sp1-x86_64" do |host| - host.vm.box = "suse/sles11sp3" - host.vm.network "private_network", ip: "192.168.123.2" - host.vm.synced_folder ".", "/vagrant", type: "nfs" - host.vm.provision "file", source: "Gemfile", destination: "Gemfile" - host.vm.provision "shell", path: "get_facts.sh" - host.vm.provision "shell", inline: "/sbin/shutdown -h now" - end - config.vm.define "sles-12sp1-x86_64" do |host| - host.vm.box = "idar/sles12sp3" - host.vm.provision "file", source: "Gemfile", destination: "Gemfile" - host.vm.provision "shell", path: "get_facts.sh" - host.vm.provision "shell", inline: "/sbin/shutdown -h now" - end - config.vm.define "sles-15-x86_64" do |host| - host.vm.box = "trueability/sles-15-sp1" - host.vm.provision "file", source: "Gemfile", destination: "Gemfile" - host.vm.provision "shell", inline: [ - "SUSEConnect -p sle-module-desktop-applications/15.1/x86_64", - "SUSEConnect -p sle-module-legacy/15.1/x86_64", - "zypper install --no-confirm net-tools-deprecated", + config.vm.define 'almalinux-8-x86_64' do |host| + host.vm.box = 'almalinux/8' + host.vm.synced_folder '.', '/vagrant' + host.vm.provision 'shell', inline: 'dnf -y install wget make gcc net-tools' + host.vm.provision 'file', source: 'Gemfile', destination: 'Gemfile' + host.vm.provision 'shell', path: 'get_facts.sh' + host.vm.provision 'shell', inline: '/sbin/shutdown -h now' + end + config.vm.define 'almalinux-9-x86_64' do |host| + host.vm.box = 'almalinux/9' + host.vm.synced_folder '.', '/vagrant' + host.vm.provision 'shell', inline: 'dnf -y install wget make gcc net-tools' + host.vm.provision 'file', source: 'Gemfile', destination: 'Gemfile' + host.vm.provision 'shell', path: 'get_facts.sh' + host.vm.provision 'shell', inline: '/sbin/shutdown -h now' + end + config.vm.define 'rockylinux-8-x86_64' do |host| + host.vm.box = 'rockylinux/8' + host.vm.synced_folder '.', '/vagrant' + host.vm.provision 'shell', inline: 'dnf -y install wget make gcc net-tools' + host.vm.provision 'file', source: 'Gemfile', destination: 'Gemfile' + host.vm.provision 'shell', path: 'get_facts.sh' + host.vm.provision 'shell', inline: '/sbin/shutdown -h now' + end + config.vm.define 'rockylinux-9-x86_64' do |host| + host.vm.box = 'rockylinux/9' + host.vm.synced_folder '.', '/vagrant' + host.vm.provision 'shell', inline: 'dnf -y install wget make gcc net-tools' + host.vm.provision 'file', source: 'Gemfile', destination: 'Gemfile' + host.vm.provision 'shell', path: 'get_facts.sh' + host.vm.provision 'shell', inline: '/sbin/shutdown -h now' + end + config.vm.define 'redhat-8-x86_64' do |host| + host.vm.box = 'generic/rhel8' + host.vm.synced_folder '.', '/vagrant' + host.vm.provision 'file', source: 'Gemfile', destination: 'Gemfile' + host.vm.provision 'shell', path: 'get_facts.sh' + host.vm.provision 'shell', inline: '/sbin/shutdown -h now' + end + config.vm.define 'archlinux-x86_64' do |host| + host.vm.box = 'archlinux/archlinux' + host.vm.provision 'file', source: 'Gemfile', destination: 'Gemfile' + # host.vm.provision "shell", path: "get_facts.sh" + # host.vm.provision "shell", inline: "/sbin/shutdown -h now" + end + config.vm.define 'sles-11sp1-x86_64' do |host| + host.vm.box = 'suse/sles11sp3' + host.vm.network 'private_network', ip: '192.168.123.2' + host.vm.synced_folder '.', '/vagrant', type: 'nfs' + host.vm.provision 'file', source: 'Gemfile', destination: 'Gemfile' + host.vm.provision 'shell', path: 'get_facts.sh' + host.vm.provision 'shell', inline: '/sbin/shutdown -h now' + end + config.vm.define 'sles-12sp1-x86_64' do |host| + host.vm.box = 'idar/sles12sp3' + host.vm.provision 'file', source: 'Gemfile', destination: 'Gemfile' + host.vm.provision 'shell', path: 'get_facts.sh' + host.vm.provision 'shell', inline: '/sbin/shutdown -h now' + end + config.vm.define 'sles-15-x86_64' do |host| + host.vm.box = 'trueability/sles-15-sp1' + host.vm.provision 'file', source: 'Gemfile', destination: 'Gemfile' + host.vm.provision 'shell', inline: [ + 'SUSEConnect -p sle-module-desktop-applications/15.1/x86_64', + 'SUSEConnect -p sle-module-legacy/15.1/x86_64', + 'zypper install --no-confirm net-tools-deprecated', ].join(' && ') - host.vm.provision "shell", path: "get_facts.sh" - host.vm.provision "shell", inline: "/sbin/shutdown -h now" - end - config.vm.define "opensuse-42.3-x86_64" do |host| - host.vm.box = "opensuse/openSUSE-42.3-x86_64" - host.vm.provision "file", source: "Gemfile", destination: "Gemfile" - host.vm.provision "shell", path: "get_facts.sh" - end - config.vm.define "opensuse-Tumbleweed-x86_64" do |host| - host.vm.box = "opensuse/openSUSE-Tumbleweed-x86_64" - host.vm.provision "file", source: "Gemfile", destination: "Gemfile" - host.vm.provision "shell", path: "get_facts.sh" - end - config.vm.define "opensuse-15.4-x86_64" do |host| - host.vm.box = "opensuse/Leap-15.4.x86_64" - host.vm.provision "file", source: "Gemfile", destination: "Gemfile" - host.vm.provision "shell", path: "get_facts.sh" - end - config.vm.define "freebsd-11-x86_64" do |host| - host.vm.box = "bento/freebsd-11" - host.vm.synced_folder ".", "/vagrant" - host.vm.provision "shell", inline: "pkg install -y bash devel/ruby-gems" - host.vm.provision "file", source: "Gemfile", destination: "Gemfile" - host.vm.provision "shell", path: "get_facts.sh" - host.vm.provision "shell", inline: "/sbin/shutdown -p now" - end - config.vm.define "freebsd-12-x86_64" do |host| - host.vm.box = "bento/freebsd-12" - host.vm.synced_folder ".", "/vagrant" - host.vm.provision "shell", inline: "pkg install -y bash devel/ruby-gems" - host.vm.provision "file", source: "Gemfile", destination: "Gemfile" - host.vm.provision "shell", path: "get_facts.sh" - host.vm.provision "shell", inline: "/sbin/shutdown -p now" - end - config.vm.define "freebsd-13-x86_64" do |host| - host.vm.box = "bento/freebsd-13" - host.vm.synced_folder ".", "/vagrant" - host.vm.provision "shell", inline: "pkg install -y bash devel/ruby-gems" - host.vm.provision "file", source: "Gemfile", destination: "Gemfile" - host.vm.provision "shell", path: "get_facts.sh" - host.vm.provision "shell", inline: "/sbin/shutdown -p now" - end - config.vm.define "gentoo-x86_64" do |host| - host.vm.box = "generic/gentoo" - host.vm.synced_folder ".", "/vagrant" - host.vm.provision "shell", inline: "emerge-webrsync && emerge app-crypt/gnupg net-misc/curl" - host.vm.provision "file", source: "Gemfile", destination: "Gemfile" - host.vm.provision "shell", path: "get_facts.sh" - host.vm.provision "shell", inline: "/sbin/shutdown -h now" - end - config.vm.define "solaris-11-x86_64" do |host| - host.vm.box = "http://benden.us/vagrant/solaris-11.2.box" + host.vm.provision 'shell', path: 'get_facts.sh' + host.vm.provision 'shell', inline: '/sbin/shutdown -h now' + end + config.vm.define 'opensuse-42.3-x86_64' do |host| + host.vm.box = 'opensuse/openSUSE-42.3-x86_64' + host.vm.provision 'file', source: 'Gemfile', destination: 'Gemfile' + host.vm.provision 'shell', path: 'get_facts.sh' + end + config.vm.define 'opensuse-Tumbleweed-x86_64' do |host| + host.vm.box = 'opensuse/openSUSE-Tumbleweed-x86_64' + host.vm.provision 'file', source: 'Gemfile', destination: 'Gemfile' + host.vm.provision 'shell', path: 'get_facts.sh' + end + config.vm.define 'opensuse-15.4-x86_64' do |host| + host.vm.box = 'opensuse/Leap-15.4.x86_64' + host.vm.provision 'file', source: 'Gemfile', destination: 'Gemfile' + host.vm.provision 'shell', path: 'get_facts.sh' + end + config.vm.define 'freebsd-11-x86_64' do |host| + host.vm.box = 'bento/freebsd-11' + host.vm.synced_folder '.', '/vagrant' + host.vm.provision 'shell', inline: 'pkg install -y bash devel/ruby-gems' + host.vm.provision 'file', source: 'Gemfile', destination: 'Gemfile' + host.vm.provision 'shell', path: 'get_facts.sh' + host.vm.provision 'shell', inline: '/sbin/shutdown -p now' + end + config.vm.define 'freebsd-12-x86_64' do |host| + host.vm.box = 'bento/freebsd-12' + host.vm.synced_folder '.', '/vagrant' + host.vm.provision 'shell', inline: 'pkg install -y bash devel/ruby-gems' + host.vm.provision 'file', source: 'Gemfile', destination: 'Gemfile' + host.vm.provision 'shell', path: 'get_facts.sh' + host.vm.provision 'shell', inline: '/sbin/shutdown -p now' + end + config.vm.define 'freebsd-13-x86_64' do |host| + host.vm.box = 'bento/freebsd-13' + host.vm.synced_folder '.', '/vagrant' + host.vm.provision 'shell', inline: 'pkg install -y bash devel/ruby-gems' + host.vm.provision 'file', source: 'Gemfile', destination: 'Gemfile' + host.vm.provision 'shell', path: 'get_facts.sh' + host.vm.provision 'shell', inline: '/sbin/shutdown -p now' + end + config.vm.define 'gentoo-x86_64' do |host| + host.vm.box = 'generic/gentoo' + host.vm.synced_folder '.', '/vagrant' + host.vm.provision 'shell', inline: 'emerge-webrsync && emerge app-crypt/gnupg net-misc/curl' + host.vm.provision 'file', source: 'Gemfile', destination: 'Gemfile' + host.vm.provision 'shell', path: 'get_facts.sh' + host.vm.provision 'shell', inline: '/sbin/shutdown -h now' + end + config.vm.define 'solaris-11-x86_64' do |host| + host.vm.box = 'http://benden.us/vagrant/solaris-11.2.box' host.ssh.insert_key = false - host.vm.provision "shell", inline: "pkg info gcc || pkg install gcc" - host.vm.provision "file", source: "Gemfile", destination: "Gemfile" - host.vm.provision "shell", path: "get_facts.sh" - host.vm.provision "shell", inline: "/sbin/shutdown -i S -g0 -y 'Bye' &" - end - config.vm.define "openbsd-6.4-x86_64" do |host| - host.vm.box = "generic/openbsd6" - host.vm.box_version = "~> 1.9.18" + host.vm.provision 'shell', inline: 'pkg info gcc || pkg install gcc' + host.vm.provision 'file', source: 'Gemfile', destination: 'Gemfile' + host.vm.provision 'shell', path: 'get_facts.sh' + host.vm.provision 'shell', inline: "/sbin/shutdown -i S -g0 -y 'Bye' &" + end + config.vm.define 'openbsd-6.4-x86_64' do |host| + host.vm.box = 'generic/openbsd6' + host.vm.box_version = '~> 1.9.18' host.vm.network :private_network, ip: '10.0.0.2' - host.vm.synced_folder ".", "/vagrant", :nfs => true - host.vm.provision "shell", inline: <<-SCRIPT.gsub(/^ +/, '') + host.vm.synced_folder '.', '/vagrant', nfs: true + host.vm.provision 'shell', inline: <<-SCRIPT.gsub(/^ +/, '') . ~/.profile pkg_info -qe 'bash->=0' || pkg_add bash @@ -245,100 +245,100 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| ln -sf /usr/local/bin/gem24 /usr/bin/gem ln -sf /usr/local/bin/ruby24 /usr/bin/ruby SCRIPT - host.vm.provision "file", source: "Gemfile", destination: "Gemfile" - host.vm.provision "shell", path: "get_facts.sh" - host.vm.provision "shell", inline: "/sbin/shutdown -h now" + host.vm.provision 'file', source: 'Gemfile', destination: 'Gemfile' + host.vm.provision 'shell', path: 'get_facts.sh' + host.vm.provision 'shell', inline: '/sbin/shutdown -h now' end - config.vm.define "osx-10.10-x86_64" do |host| - host.vm.box = "AndrewDryga/vagrant-box-osx" + config.vm.define 'osx-10.10-x86_64' do |host| + host.vm.box = 'AndrewDryga/vagrant-box-osx' host.vm.network :private_network, ip: '10.0.0.2' - host.vm.synced_folder ".", "/vagrant", :nfs => true - host.vm.provision "file", source: "Gemfile", destination: "Gemfile" - host.vm.provision "shell", path: "get_facts.sh" - host.vm.provision "shell", inline: "/sbin/shutdown -h now" + host.vm.synced_folder '.', '/vagrant', nfs: true + host.vm.provision 'file', source: 'Gemfile', destination: 'Gemfile' + host.vm.provision 'shell', path: 'get_facts.sh' + host.vm.provision 'shell', inline: '/sbin/shutdown -h now' end - config.vm.define "windows-7-x86_64" do |host| + config.vm.define 'windows-7-x86_64' do |host| host.vm.hostname = 'foo' - host.vm.box = "ferventcoder/win7pro-x64-nocm-lite" - host.vm.communicator = "winrm" + host.vm.box = 'ferventcoder/win7pro-x64-nocm-lite' + host.vm.communicator = 'winrm' host.vm.guest = :windows - host.vm.network :private_network, :auto_network => true - host.vm.network "forwarded_port", guest: 22, host: 2200, id: "ssh", auto_correct: true + host.vm.network :private_network, auto_network: true + host.vm.network 'forwarded_port', guest: 22, host: 2200, id: 'ssh', auto_correct: true host.windows.set_work_network = true - host.vm.provision 'shell', path: "windows_get_facts.ps1" - #host.vm.provision 'shell', inline: "Stop-Computer -AsJob" - host.vm.provision 'shell', inline: "shutdown -s -f -c \"Fact Collection Complete\"" - #host.vm.post_up_message = 'Note that windows machines do not automatically shutdown. You must run a \'vagrant destroy\' or \'vagrant halt\' to terminate/stop the build vm.' + host.vm.provision 'shell', path: 'windows_get_facts.ps1' + # host.vm.provision 'shell', inline: "Stop-Computer -AsJob" + host.vm.provision 'shell', inline: 'shutdown -s -f -c "Fact Collection Complete"' + # host.vm.post_up_message = 'Note that windows machines do not automatically shutdown. You must run a \'vagrant destroy\' or \'vagrant halt\' to terminate/stop the build vm.' end - config.vm.define "windows-2012r2-core-x86_64" do |host| + config.vm.define 'windows-2012r2-core-x86_64' do |host| host.vm.hostname = 'foo' - host.vm.box = "windows-2012r2-core-x86_64" - host.vm.communicator = "winrm" + host.vm.box = 'windows-2012r2-core-x86_64' + host.vm.communicator = 'winrm' host.vm.guest = :windows - host.vm.network :private_network, :auto_network => true - host.vm.network "forwarded_port", guest: 22, host: 2200, id: "ssh", auto_correct: true + host.vm.network :private_network, auto_network: true + host.vm.network 'forwarded_port', guest: 22, host: 2200, id: 'ssh', auto_correct: true host.windows.set_work_network = true - host.vm.provision 'shell', path: "windows_get_facts.ps1" - host.vm.provision 'shell', inline: "shutdown -s -f -c \"Fact Collection Complete\"" - end - config.vm.define "amazonlinux-2-x86_64" do |host| - host.vm.box = "bento/amazonlinux-2" - host.vm.provision "shell", inline: "yum -y install gcc glibc-devel" - host.vm.provision "file", source: "Gemfile", destination: "Gemfile" - host.vm.provision "shell", path: "get_facts.sh" - host.vm.provision "shell", inline: "/sbin/shutdown -h now" - end - config.vm.define "fedora-32-x86_64" do |host| - host.vm.box = "generic/fedora32" - host.vm.synced_folder ".", "/vagrant" - host.vm.provision "shell", inline: "dnf -y install wget make gcc net-tools" - host.vm.provision "file", source: "Gemfile", destination: "Gemfile" - host.vm.provision "shell", path: "get_facts.sh" - host.vm.provision "shell", inline: "/sbin/shutdown -h now" - end - config.vm.define "fedora-33-x86_64" do |host| - host.vm.box = "generic/fedora33" - host.vm.synced_folder ".", "/vagrant" + host.vm.provision 'shell', path: 'windows_get_facts.ps1' + host.vm.provision 'shell', inline: 'shutdown -s -f -c "Fact Collection Complete"' + end + config.vm.define 'amazonlinux-2-x86_64' do |host| + host.vm.box = 'bento/amazonlinux-2' + host.vm.provision 'shell', inline: 'yum -y install gcc glibc-devel' + host.vm.provision 'file', source: 'Gemfile', destination: 'Gemfile' + host.vm.provision 'shell', path: 'get_facts.sh' + host.vm.provision 'shell', inline: '/sbin/shutdown -h now' + end + config.vm.define 'fedora-32-x86_64' do |host| + host.vm.box = 'generic/fedora32' + host.vm.synced_folder '.', '/vagrant' + host.vm.provision 'shell', inline: 'dnf -y install wget make gcc net-tools' + host.vm.provision 'file', source: 'Gemfile', destination: 'Gemfile' + host.vm.provision 'shell', path: 'get_facts.sh' + host.vm.provision 'shell', inline: '/sbin/shutdown -h now' + end + config.vm.define 'fedora-33-x86_64' do |host| + host.vm.box = 'generic/fedora33' + host.vm.synced_folder '.', '/vagrant' # there's no official support for fedora 33, so we need ruby and facter from Fedora - host.vm.provision "shell", inline: "dnf -y install wget make gcc net-tools ruby ruby-devel facter" - host.vm.provision "file", source: "Gemfile", destination: "Gemfile" - host.vm.provision "shell", path: "get_facts.sh" - host.vm.provision "shell", inline: "/sbin/shutdown -h now" - end - config.vm.define "fedora-34-x86_64" do |host| - host.vm.box = "generic/fedora34" - host.vm.synced_folder ".", "/vagrant" - host.vm.provision "shell", inline: "dnf -y install wget make gcc net-tools" - host.vm.provision "file", source: "Gemfile", destination: "Gemfile" - host.vm.provision "shell", path: "get_facts.sh" - host.vm.provision "shell", inline: "/sbin/shutdown -h now" - end - config.vm.define "fedora-35-x86_64" do |host| - host.vm.box = "generic/fedora35" - host.vm.synced_folder ".", "/vagrant" + host.vm.provision 'shell', inline: 'dnf -y install wget make gcc net-tools ruby ruby-devel facter' + host.vm.provision 'file', source: 'Gemfile', destination: 'Gemfile' + host.vm.provision 'shell', path: 'get_facts.sh' + host.vm.provision 'shell', inline: '/sbin/shutdown -h now' + end + config.vm.define 'fedora-34-x86_64' do |host| + host.vm.box = 'generic/fedora34' + host.vm.synced_folder '.', '/vagrant' + host.vm.provision 'shell', inline: 'dnf -y install wget make gcc net-tools' + host.vm.provision 'file', source: 'Gemfile', destination: 'Gemfile' + host.vm.provision 'shell', path: 'get_facts.sh' + host.vm.provision 'shell', inline: '/sbin/shutdown -h now' + end + config.vm.define 'fedora-35-x86_64' do |host| + host.vm.box = 'generic/fedora35' + host.vm.synced_folder '.', '/vagrant' # there's no official support for fedora 35, so we need ruby 2.7 and facter from Fedora - host.vm.provision "shell", inline: "dnf -y module install ruby:2.7/default" - host.vm.provision "shell", inline: "dnf -y install wget make gcc net-tools facter ruby-devel" - host.vm.provision "file", source: "Gemfile", destination: "Gemfile" - host.vm.provision "shell", path: "get_facts.sh" - host.vm.provision "shell", inline: "/sbin/shutdown -h now" - end - config.vm.define "fedora-36-x86_64" do |host| - host.vm.box = "generic/fedora36" - host.vm.synced_folder ".", "/vagrant" + host.vm.provision 'shell', inline: 'dnf -y module install ruby:2.7/default' + host.vm.provision 'shell', inline: 'dnf -y install wget make gcc net-tools facter ruby-devel' + host.vm.provision 'file', source: 'Gemfile', destination: 'Gemfile' + host.vm.provision 'shell', path: 'get_facts.sh' + host.vm.provision 'shell', inline: '/sbin/shutdown -h now' + end + config.vm.define 'fedora-36-x86_64' do |host| + host.vm.box = 'generic/fedora36' + host.vm.synced_folder '.', '/vagrant' # there's no official support for fedora 36, so we need facter from Fedora - host.vm.provision "shell", inline: "dnf -y install facter ruby ruby-devel wget make gcc net-tools" - host.vm.provision "file", source: "Gemfile", destination: "Gemfile" - host.vm.provision "shell", path: "get_facts.sh" - host.vm.provision "shell", inline: "/sbin/shutdown -h now" - end - config.vm.define "fedora-37-x86_64" do |host| - host.vm.box = "generic/fedora37" - host.vm.synced_folder ".", "/vagrant" + host.vm.provision 'shell', inline: 'dnf -y install facter ruby ruby-devel wget make gcc net-tools' + host.vm.provision 'file', source: 'Gemfile', destination: 'Gemfile' + host.vm.provision 'shell', path: 'get_facts.sh' + host.vm.provision 'shell', inline: '/sbin/shutdown -h now' + end + config.vm.define 'fedora-37-x86_64' do |host| + host.vm.box = 'generic/fedora37' + host.vm.synced_folder '.', '/vagrant' # there's no official support for fedora 37, so we need facter from Fedora - host.vm.provision "shell", inline: "dnf -y install facter ruby ruby-devel wget make gcc net-tools" - host.vm.provision "file", source: "Gemfile", destination: "Gemfile" - host.vm.provision "shell", path: "get_facts.sh" - host.vm.provision "shell", inline: "/sbin/shutdown -h now" + host.vm.provision 'shell', inline: 'dnf -y install facter ruby ruby-devel wget make gcc net-tools' + host.vm.provision 'file', source: 'Gemfile', destination: 'Gemfile' + host.vm.provision 'shell', path: 'get_facts.sh' + host.vm.provision 'shell', inline: '/sbin/shutdown -h now' end end diff --git a/lib/facterdb.rb b/lib/facterdb.rb index 45751cce..e30e9cef 100644 --- a/lib/facterdb.rb +++ b/lib/facterdb.rb @@ -34,9 +34,11 @@ def self.inject_source? def self.read_json_file(f) content = File.read(f) return content unless inject_source? + # Find the opening brace first_brace = content.index('{') return content if first_brace.nil? + # Inject source file information json_injection = "\"_facterdb_filename\": #{File.basename(f).to_json}, " json_injection += "\"_facterdb_path\": #{File.expand_path(f).to_json}, " @@ -47,16 +49,18 @@ def self.read_json_file(f) # @return [Array[String]] - list of all files found in the default facterdb facts path def self.default_fact_files return [] unless use_defaultdb? + proj_root = File.join(File.dirname(File.dirname(__FILE__))) facts_dir = File.expand_path(File.join(proj_root, 'facts')) - Dir.glob(File.join(facts_dir, "**", '*.facts')) + Dir.glob(File.join(facts_dir, '**', '*.facts')) end # @return [Array[String]] - list of all files found in the user supplied facterdb facts path # @param fact_paths [String] - a comma separated list of paths to search for fact files - def self.external_fact_files(fact_paths = ENV['FACTERDB_SEARCH_PATHS']) + def self.external_fact_files(fact_paths = ENV.fetch('FACTERDB_SEARCH_PATHS', nil)) fact_paths ||= '' return [] if fact_paths.empty? + paths = fact_paths.split(File::PATH_SEPARATOR).map do |fact_path| unless File.directory?(fact_path) warn("[FACTERDB] Ignoring external facts path #{fact_path} as it is not a directory") @@ -74,27 +78,29 @@ def self.facterdb_fact_files (external_fact_files + default_fact_files).uniq end - def self.get_os_facts(facter_version='*', filter=[]) + def self.get_os_facts(facter_version = '*', filter = []) if facter_version == '*' if filter.is_a?(Array) - filter_str = filter.map { |f| f.map { |k,v | "#{k}=#{v}" }.join(' and ') }.join(' or ') + filter_str = filter.map { |f| f.map { |k, v| "#{k}=#{v}" }.join(' and ') }.join(' or ') elsif filter.is_a?(Hash) - filter_str = filter.map { |k,v | "#{k}=#{v}" }.join(' and ') + filter_str = filter.map { |k, v| "#{k}=#{v}" }.join(' and ') elsif filter.is_a?(String) filter_str = filter else raise 'filter must be either an Array a Hash or a String' end + elsif filter.is_a?(Array) + filter_str = "facterversion=/^#{facter_version}/ and (#{filter.map do |f| + f.map do |k, v| + "#{k}=#{v}" + end.join(' and ') + end.join(' or ')})" + elsif filter.is_a?(Hash) + filter_str = "facterversion=/^#{facter_version}/ and (#{filter.map { |k, v| "#{k}=#{v}" }.join(' and ')})" + elsif filter.is_a?(String) + filter_str = "facterversion=/^#{facter_version}/ and (#{filter})" else - if filter.is_a?(Array) - filter_str = "facterversion=/^#{facter_version}/ and (#{filter.map { |f| f.map { |k,v | "#{k}=#{v}" }.join(' and ') }.join(' or ')})" - elsif filter.is_a?(Hash) - filter_str = "facterversion=/^#{facter_version}/ and (#{filter.map { |k,v | "#{k}=#{v}" }.join(' and ')})" - elsif filter.is_a?(String) - filter_str = "facterversion=/^#{facter_version}/ and (#{filter})" - else - raise 'filter must be either an Array a Hash or a String' - end + raise 'filter must be either an Array a Hash or a String' end warn "[DEPRECATION] `get_os_facts` is deprecated. Please use `get_facts(#{filter_str})` instead." @@ -104,12 +110,12 @@ def self.get_os_facts(facter_version='*', filter=[]) # @return [String] - the string filter # @param filter [Object] - The filter to convert to jgrep string - def self.generate_filter_str(filter=nil) + def self.generate_filter_str(filter = nil) case filter when ::Array - '(' + filter.map { |f| f.map { |k,v | "#{k}=#{v}" }.join(' and ') }.join(') or (') + ')' + '(' + filter.map { |f| f.map { |k, v| "#{k}=#{v}" }.join(' and ') }.join(') or (') + ')' when ::Hash - filter.map { |k,v | "#{k}=#{v}" }.join(' and ') + filter.map { |k, v| "#{k}=#{v}" }.join(' and ') when ::String filter when ::NilClass @@ -130,12 +136,13 @@ def self.valid_filters?(filters) # @return [Array] - array of hashes of facts # @param filter [Object] - The filter to convert to jgrep string - def self.get_facts(filter=nil, cache=true) + def self.get_facts(filter = nil, cache = true) if cache && filter && filter == Thread.current[:facterdb_last_filter_seen] return Thread.current[:facterdb_last_facts_seen] end + filter_str = generate_filter_str(filter) - result = JGrep.jgrep(database, filter_str).map { |hash| Hash[hash.map{ |k, v| [k.to_sym, v] }] } + result = JGrep.jgrep(database, filter_str).map { |hash| hash.map { |k, v| [k.to_sym, v] }.to_h } if cache Thread.current[:facterdb_last_filter_seen] = filter Thread.current[:facterdb_last_facts_seen] = result diff --git a/lib/facterdb/bin.rb b/lib/facterdb/bin.rb index 9d0b1bb6..663d2028 100644 --- a/lib/facterdb/bin.rb +++ b/lib/facterdb/bin.rb @@ -8,7 +8,7 @@ def initialize(args) end def run - puts JSON.pretty_generate(FacterDB::get_os_facts('*', @args[0])) + puts JSON.pretty_generate(FacterDB.get_os_facts('*', @args[0])) end end end diff --git a/rakelib/rhel_alts.rake b/rakelib/rhel_alts.rake index eaccbb33..49fbe036 100644 --- a/rakelib/rhel_alts.rake +++ b/rakelib/rhel_alts.rake @@ -3,22 +3,22 @@ task :rhel_alts do Dir[File.join(__dir__, '..', 'facts', '*', 'centos-*-x86_64.facts')].each do |f| centos_factset = File.read(f) - rhel_path = f.gsub(%r{centos-}, 'redhat-') + rhel_path = f.gsub(/centos-/, 'redhat-') File.open(rhel_path, 'w') do |fd| - fd.puts centos_factset.gsub(%r{CentOS}, 'RedHat') + fd.puts centos_factset.gsub(/CentOS/, 'RedHat') end - oracle_path = f.gsub(%r{centos-}, 'oraclelinux-') + oracle_path = f.gsub(/centos-/, 'oraclelinux-') File.open(oracle_path, 'w') do |fd| - fd.puts centos_factset.gsub(%r{CentOS}, 'OracleLinux') + fd.puts centos_factset.gsub(/CentOS/, 'OracleLinux') end # Scientific isn't going to be updated to 8 - if File.basename(f)[%r{-(\d+)-}, 1].to_i <= 7 - scientific_path = f.gsub(%r{centos-}, 'scientific-') - File.open(scientific_path, 'w') do |fd| - fd.puts centos_factset.gsub(%r{CentOS}, 'Scientific') - end + next unless File.basename(f)[/-(\d+)-/, 1].to_i <= 7 + + scientific_path = f.gsub(/centos-/, 'scientific-') + File.open(scientific_path, 'w') do |fd| + fd.puts centos_factset.gsub(/CentOS/, 'Scientific') end end end diff --git a/spec/facterdb_spec.rb b/spec/facterdb_spec.rb index 0df68988..5fac2a26 100644 --- a/spec/facterdb_spec.rb +++ b/spec/facterdb_spec.rb @@ -16,14 +16,14 @@ end let(:facts_24_path) { File.join(project_dir, 'facts', '2.4') } - let(:facts_24_count) { Dir.glob(File.join(facts_24_path,'*.facts')).count } + let(:facts_24_count) { Dir.glob(File.join(facts_24_path, '*.facts')).count } let(:facts_23_path) { File.join(project_dir, 'facts', '2.3') } - let(:facts_23_count) { Dir.glob(File.join(facts_23_path,'*.facts')).count } + let(:facts_23_count) { Dir.glob(File.join(facts_23_path, '*.facts')).count } describe '.use_defaultdb?' do subject { described_class.use_defaultdb? } - before(:each) do + before do ENV.delete('FACTERDB_SKIP_DEFAULTDB') end @@ -32,7 +32,7 @@ end context 'when FACTERDB_SKIP_DEFAULTDB environment variable is set' do - before(:each) do + before do ENV['FACTERDB_SKIP_DEFAULTDB'] = '1' end @@ -45,7 +45,7 @@ let(:non_directory_path) { File.join('this', 'is', 'not', 'a', 'directory') } - before(:each) do + before do ENV.delete('FACTERDB_SEARCH_PATHS') allow(File).to receive(:directory?).and_call_original allow(File).to receive(:directory?).with(non_directory_path).and_return(false) @@ -73,7 +73,7 @@ object = defined?(Warning) ? Warning : Kernel allow(object).to receive(:warn).and_call_original - allow(object).to receive(:warn).with(a_string_matching(%r{is not a directory})) + allow(object).to receive(:warn).with(a_string_matching(/is not a directory/)) expect(file_count).to eq(facts_24_count) end @@ -105,7 +105,7 @@ it 'ignores the path that is not a directory' do object = defined?(Warning) ? Warning : Kernel allow(object).to receive(:warn).and_call_original - allow(object).to receive(:warn).with(a_string_matching(%r{is not a directory})) + allow(object).to receive(:warn).with(a_string_matching(/is not a directory/)) expect(file_count).to eq(facts_24_count) end @@ -116,7 +116,7 @@ describe '.default_fact_files' do subject(:default_fact_files) { described_class.default_fact_files } - before(:each) do + before do ENV.delete('FACTERDB_SKIP_DEFAULTDB') end @@ -128,7 +128,7 @@ end context 'when FACTERDB_SKIP_DEFAULTDB environment variable is set' do - before(:each) do + before do ENV['FACTERDB_SKIP_DEFAULTDB'] = '1' end @@ -139,11 +139,11 @@ describe '.facterdb_fact_files' do subject(:facterdb_fact_files) { described_class.facterdb_fact_files } - before(:each) do + before do ENV.delete('FACTERDB_SKIP_DEFAULTDB') end - after(:each) do + after do ENV.delete('FACTERDB_SEARCH_PATHS') end @@ -154,7 +154,7 @@ end context 'with no loaded fact sets' do - before(:each) do + before do ENV['FACTERDB_SKIP_DEFAULTDB'] = '1' ENV.delete('FACTERDB_SEARCH_PATHS') end @@ -166,7 +166,7 @@ describe '.database' do subject(:database) { described_class.database } - before(:each) do + before do ENV.delete('FACTERDB_SKIP_DEFAULTDB') ENV.delete('FACTERDB_SEARCH_PATHS') FacterDB.instance_variable_set(:@database, nil) @@ -183,7 +183,7 @@ context 'when FACTERDB_INJECT_SOURCE environment variable is set' do subject(:json_database) { JSON.parse(database) } - before(:each) do + before do ENV['FACTERDB_INJECT_SOURCE'] = '1' end @@ -200,14 +200,14 @@ describe '.get_os_facts' do subject(:result) { FacterDB.get_os_facts(facter_version, filter) } - before(:each) do + before do object = defined?(Warning) ? Warning : Kernel allow(object).to receive(:warn).and_call_original - allow(object).to receive(:warn).with(a_string_matching(%r{`get_os_facts` is deprecated})) + allow(object).to receive(:warn).with(a_string_matching(/`get_os_facts` is deprecated/)) end context 'without parameters' do - subject(:result) { FacterDB.get_os_facts() } + subject(:result) { FacterDB.get_os_facts } include_examples 'returns a result' end @@ -216,13 +216,13 @@ let(:facter_version) { '*' } context 'with an Array filter' do - let(:filter) { [{ :osfamily => 'Debian' }] } + let(:filter) { [{ osfamily: 'Debian' }] } include_examples 'returns a result' end context 'with a Hash filter' do - let(:filter) { { :osfamily => 'Debian' } } + let(:filter) { { osfamily: 'Debian' } } include_examples 'returns a result' end @@ -237,7 +237,7 @@ let(:filter) { true } it 'raises an error' do - expect { result }.to raise_error(%r{filter must be either}) + expect { result }.to raise_error(/filter must be either/) end end end @@ -247,19 +247,19 @@ shared_examples 'returns only the specified version' do it 'only includes fact sets for the specified version' do - expect(result).to all(include(:facterversion => match(%r{\A2\.4}))) + expect(result).to all(include(facterversion: match(/\A2\.4/))) end end context 'with an Array filter' do - let(:filter) { [{ :osfamily => 'Debian' }] } + let(:filter) { [{ osfamily: 'Debian' }] } include_examples 'returns a result' include_examples 'returns only the specified version' end context 'with a Hash filter' do - let(:filter) { { :osfamily => 'Debian' } } + let(:filter) { { osfamily: 'Debian' } } include_examples 'returns a result' include_examples 'returns only the specified version' @@ -276,7 +276,7 @@ let(:filter) { true } it 'raises an error' do - expect { result }.to raise_error(%r{filter must be either}) + expect { result }.to raise_error(/filter must be either/) end end end @@ -284,29 +284,29 @@ describe '.valid_filters?' do it 'invalid and false' do - expect( FacterDB.valid_filters?('and')).to be_falsey + expect(FacterDB.valid_filters?('and')).to be_falsey end it 'valid and true' do - expect( FacterDB.valid_filters?('foo')).to be_truthy + expect(FacterDB.valid_filters?('foo')).to be_truthy end end describe '.generate_filter_str' do it 'invalid type' do - expect{FacterDB.generate_filter_str(3)}.to raise_error(FacterDB::Errors::InvalidFilter) + expect { FacterDB.generate_filter_str(3) }.to raise_error(FacterDB::Errors::InvalidFilter) end it 'with string' do - expect(FacterDB.generate_filter_str('foo')).to eq("foo") + expect(FacterDB.generate_filter_str('foo')).to eq('foo') end it 'with hash' do - expect(FacterDB.generate_filter_str({:osfamily => 'Debian'})).to eq("osfamily=Debian") + expect(FacterDB.generate_filter_str({ osfamily: 'Debian' })).to eq('osfamily=Debian') end it 'with Array' do - expect(FacterDB.generate_filter_str([:osfamily => 'Debian'])).to eq("(osfamily=Debian)") + expect(FacterDB.generate_filter_str([osfamily: 'Debian'])).to eq('(osfamily=Debian)') end it 'empty' do @@ -324,32 +324,32 @@ let(:filter) { nil } context 'without parameters' do - include_examples "returns a result" + include_examples 'returns a result' end context 'with an Array filter' do - let(:filter) { [:osfamily => 'Debian'] } + let(:filter) { [osfamily: 'Debian'] } - include_examples "returns a result" + include_examples 'returns a result' end context 'with a Hash filter' do - let(:filter) { { :osfamily => 'Debian' } } + let(:filter) { { osfamily: 'Debian' } } - include_examples "returns a result" + include_examples 'returns a result' end context 'with a String filter' do let(:filter) { 'osfamily=Debian' } - include_examples "returns a result" + include_examples 'returns a result' end context 'with a filter of an unsupported type' do let(:filter) { true } it 'raises an error' do - expect { result }.to raise_error(%r{filter must be either}) + expect { result }.to raise_error(/filter must be either/) end end end diff --git a/spec/facts_spec.rb b/spec/facts_spec.rb index 7e414cc6..d32fb753 100644 --- a/spec/facts_spec.rb +++ b/spec/facts_spec.rb @@ -14,7 +14,7 @@ RSpec::Matchers.define :be_valid_json do match do |actual| - content = File.open(actual, 'rb') { |file| file.read } + content = File.binread(actual) valid = false begin obj = JSON.parse(content) @@ -41,17 +41,17 @@ end describe 'Default Facts' do - before(:each) do + before do ENV['FACTERDB_SKIP_DEFAULTDB'] = nil FacterDB.instance_variable_set(:@database, nil) end describe 'fact files' do - it 'should not contain duplicate fact sets' do + it 'does not contain duplicate fact sets' do # Gather all of the default files and hash the content file_hashes = {} FacterDB.default_fact_files.each do |filepath| - file_hash = Digest::SHA256.hexdigest( File.open(filepath, 'rb') { |file| file.read } ) + file_hash = Digest::SHA256.hexdigest(File.binread(filepath)) file_hashes[file_hash] ||= [] file_hashes[file_hash] << filepath end @@ -67,7 +67,7 @@ relative_path = Pathname.new(filepath).relative_path_from(project_dir).to_s describe relative_path do subject(:content) do - JSON.parse(File.open(filepath, 'rb') { |file| file.read }) + JSON.parse(File.binread(filepath)) end it 'contains a valid JSON document' do @@ -88,9 +88,11 @@ expect(content['networking']['fqdn']).to eq('foo.example.com') end end + it 'contains the legacy ipaddress fact' do expect(content['ipaddress']).to not_be_nil.and not_be_empty end + it 'contains no facts from puppetlabs/stdlib' do expect(content['root_home']).to be_nil expect(content['service_provider']).to be_nil @@ -100,21 +102,25 @@ expect(content['pe_version']).to be_nil expect(content['package_provider']).to be_nil end + it 'contains no facts from puppet/systemd' do expect(content['systemd']).to be_nil expect(content['systemd_version']).to be_nil expect(content['systemd_internal_services']).to be_nil end + it 'contains a legacy hostname, domain and fqdn fact' do expect(content['hostname']).to eq('foo') expect(content['fqdn']).to eq('foo.example.com') expect(content['domain']).to eq('example.com') end + it 'contains the legacy osfamily fact' do - expect(content['osfamily']).to_not be_nil + expect(content['osfamily']).not_to be_nil end + it 'contains the legacy operatingsystem fact' do - expect(content['operatingsystem']).to_not be_nil + expect(content['operatingsystem']).not_to be_nil end end end