From 82cef2371352b648cc60aa7b7cedaa973c38ad35 Mon Sep 17 00:00:00 2001 From: Christopher Thorn Date: Tue, 31 Jan 2023 16:34:36 -0800 Subject: [PATCH] (PUP-10853) Remove legacy facts Replaces legacy facts with newer structured facts. --- .../lib/puppet/acceptance/agent_fqdn_utils.rb | 2 +- acceptance/tests/aix/nim_package_provider.rb | 2 +- acceptance/tests/language/binary_data_type.rb | 2 +- .../tests/language/sensitive_data_type.rb | 2 +- .../autoload_from_resource_type_decl.rb | 2 +- acceptance/tests/lookup/merge_strategies.rb | 6 +- .../resource/service/service_enable_linux.rb | 2 +- ...et_5024_systemd_enabling_masked_service.rb | 2 +- .../tests/ssl/certificate_extensions.rb | 4 +- acceptance/tests/ticket_15560_managehome.rb | 2 +- .../windows/QA-506_windows_exit_codes_test.rb | 2 +- install.rb | 34 +++--- lib/puppet/confiner.rb | 2 +- lib/puppet/file_serving/mount/file.rb | 8 +- lib/puppet/indirector/catalog/compiler.rb | 10 +- lib/puppet/provider/exec/windows.rb | 4 +- lib/puppet/provider/file/windows.rb | 2 +- lib/puppet/provider/group/aix.rb | 4 +- lib/puppet/provider/group/directoryservice.rb | 4 +- lib/puppet/provider/group/groupadd.rb | 2 +- lib/puppet/provider/group/pw.rb | 4 +- lib/puppet/provider/group/windows_adsi.rb | 4 +- .../provider/nameservice/directoryservice.rb | 4 +- lib/puppet/provider/package/aix.rb | 4 +- lib/puppet/provider/package/appdmg.rb | 2 +- lib/puppet/provider/package/apple.rb | 2 +- lib/puppet/provider/package/apt.rb | 2 +- lib/puppet/provider/package/blastwave.rb | 2 +- lib/puppet/provider/package/dnf.rb | 8 +- lib/puppet/provider/package/freebsd.rb | 2 +- lib/puppet/provider/package/hpux.rb | 4 +- lib/puppet/provider/package/macports.rb | 2 +- lib/puppet/provider/package/openbsd.rb | 4 +- lib/puppet/provider/package/opkg.rb | 4 +- lib/puppet/provider/package/pacman.rb | 4 +- lib/puppet/provider/package/pkg.rb | 6 +- lib/puppet/provider/package/pkgdmg.rb | 4 +- lib/puppet/provider/package/pkgin.rb | 2 +- lib/puppet/provider/package/pkgng.rb | 4 +- lib/puppet/provider/package/pkgutil.rb | 2 +- lib/puppet/provider/package/portage.rb | 4 +- lib/puppet/provider/package/portupgrade.rb | 2 +- lib/puppet/provider/package/rug.rb | 2 +- lib/puppet/provider/package/sun.rb | 4 +- lib/puppet/provider/package/sunfreeware.rb | 2 +- lib/puppet/provider/package/tdnf.rb | 2 +- lib/puppet/provider/package/up2date.rb | 4 +- lib/puppet/provider/package/urpmi.rb | 2 +- lib/puppet/provider/package/windows.rb | 4 +- lib/puppet/provider/package/yum.rb | 6 +- lib/puppet/provider/package/zypper.rb | 4 +- lib/puppet/provider/service/base.rb | 2 +- lib/puppet/provider/service/bsd.rb | 2 +- lib/puppet/provider/service/debian.rb | 6 +- lib/puppet/provider/service/freebsd.rb | 4 +- lib/puppet/provider/service/gentoo.rb | 2 +- lib/puppet/provider/service/init.rb | 10 +- lib/puppet/provider/service/launchd.rb | 6 +- lib/puppet/provider/service/openbsd.rb | 4 +- lib/puppet/provider/service/openrc.rb | 4 +- lib/puppet/provider/service/openwrt.rb | 4 +- lib/puppet/provider/service/rcng.rb | 4 +- lib/puppet/provider/service/redhat.rb | 6 +- lib/puppet/provider/service/smf.rb | 10 +- lib/puppet/provider/service/src.rb | 4 +- lib/puppet/provider/service/systemd.rb | 28 ++--- lib/puppet/provider/service/upstart.rb | 14 +-- lib/puppet/provider/service/windows.rb | 4 +- lib/puppet/provider/user/aix.rb | 4 +- lib/puppet/provider/user/directoryservice.rb | 6 +- lib/puppet/provider/user/hpux.rb | 4 +- lib/puppet/provider/user/openbsd.rb | 4 +- lib/puppet/provider/user/pw.rb | 4 +- lib/puppet/provider/user/user_role_add.rb | 2 +- lib/puppet/provider/user/useradd.rb | 12 +- lib/puppet/provider/user/windows_adsi.rb | 4 +- lib/puppet/reference/providers.rb | 9 +- lib/puppet/settings.rb | 4 +- lib/puppet/type.rb | 2 +- lib/puppet/type/file/source.rb | 2 +- lib/puppet/type/package.rb | 4 +- lib/puppet/type/resources.rb | 2 +- lib/puppet/util/filetype.rb | 4 +- lib/puppet/util/suidmanager.rb | 2 +- .../lib/puppet/provider/a2mod/debian.rb | 2 +- .../jamtur01-apache/manifests/init.pp | 2 +- .../jamtur01-apache/manifests/params.pp | 2 +- .../releases/jamtur01-apache/manifests/ssl.pp | 2 +- .../jamtur01-apache/manifests/vhost.pp | 2 +- spec/integration/type/file_spec.rb | 4 +- spec/integration/type/package_spec.rb | 10 +- spec/shared_examples/rhel_package_provider.rb | 4 +- spec/unit/application/device_spec.rb | 4 +- spec/unit/confine_spec.rb | 12 +- spec/unit/face/epp_face_spec.rb | 4 +- spec/unit/file_bucket/dipper_spec.rb | 4 +- spec/unit/file_serving/mount/file_spec.rb | 4 +- spec/unit/indirector/catalog/compiler_spec.rb | 14 +-- spec/unit/module_tool/tar_spec.rb | 6 +- .../pops/serialization/serialization_spec.rb | 4 +- .../pops/serialization/to_from_hr_spec.rb | 2 +- spec/unit/provider/package/apt_spec.rb | 4 +- spec/unit/provider/package/dnf_spec.rb | 30 ++--- spec/unit/provider/package/dnfmodule_spec.rb | 12 +- spec/unit/provider/package/gem_spec.rb | 4 +- spec/unit/provider/package/pip2_spec.rb | 4 +- spec/unit/provider/package/pip3_spec.rb | 4 +- spec/unit/provider/package/pip_spec.rb | 4 +- spec/unit/provider/package/pkg_spec.rb | 16 +-- spec/unit/provider/package/pkgng_spec.rb | 2 +- spec/unit/provider/package/portage_spec.rb | 4 +- spec/unit/provider/package/puppet_gem_spec.rb | 4 +- .../provider/package/puppetserver_gem_spec.rb | 4 +- spec/unit/provider/package/tdnf_spec.rb | 4 +- spec/unit/provider/package/up2date_spec.rb | 4 +- spec/unit/provider/package/yum_spec.rb | 32 ++--- spec/unit/provider/service/base_spec.rb | 2 +- spec/unit/provider/service/bsd_spec.rb | 4 +- spec/unit/provider/service/debian_spec.rb | 14 +-- spec/unit/provider/service/freebsd_spec.rb | 2 +- spec/unit/provider/service/gentoo_spec.rb | 4 +- spec/unit/provider/service/init_spec.rb | 16 +-- spec/unit/provider/service/openbsd_spec.rb | 4 +- spec/unit/provider/service/openwrt_spec.rb | 2 +- spec/unit/provider/service/rcng_spec.rb | 4 +- spec/unit/provider/service/redhat_spec.rb | 14 +-- spec/unit/provider/service/smf_spec.rb | 16 +-- spec/unit/provider/service/systemd_spec.rb | 114 +++++++++--------- spec/unit/provider/service/upstart_spec.rb | 6 +- .../provider/user/directoryservice_spec.rb | 4 +- spec/unit/provider/user/openbsd_spec.rb | 4 +- spec/unit/provider/user/useradd_spec.rb | 28 ++--- spec/unit/provider_spec.rb | 102 ++++++++-------- spec/unit/type/package_spec.rb | 6 +- spec/unit/type/resources_spec.rb | 4 +- spec/unit/type_spec.rb | 4 +- 136 files changed, 477 insertions(+), 478 deletions(-) diff --git a/acceptance/lib/puppet/acceptance/agent_fqdn_utils.rb b/acceptance/lib/puppet/acceptance/agent_fqdn_utils.rb index 84e35ff89f0..0934ed79957 100644 --- a/acceptance/lib/puppet/acceptance/agent_fqdn_utils.rb +++ b/acceptance/lib/puppet/acceptance/agent_fqdn_utils.rb @@ -7,7 +7,7 @@ module AgentFqdnUtils # convert from an Beaker::Host (agent) to the systems fqdn as returned by facter def agent_to_fqdn(agent) unless @@hostname_to_fqdn.has_key?(agent.hostname) - @@hostname_to_fqdn[agent.hostname] = on(agent, facter('fqdn')).stdout.chomp + @@hostname_to_fqdn[agent.hostname] = on(agent, facter('networking.fqdn')).stdout.chomp end @@hostname_to_fqdn[agent.hostname] end diff --git a/acceptance/tests/aix/nim_package_provider.rb b/acceptance/tests/aix/nim_package_provider.rb index 345792fd6f6..6c310683d45 100644 --- a/acceptance/tests/aix/nim_package_provider.rb +++ b/acceptance/tests/aix/nim_package_provider.rb @@ -8,7 +8,7 @@ version = on(aix, 'puppet --version').stdout version && Gem::Version.new(version) > Gem::Version.new('6.4.0') && - on(aix, 'facter operatingsystemrelease').stdout == '7.2' + on(aix, 'facter os.release.full').stdout == '7.2' end teardown do diff --git a/acceptance/tests/language/binary_data_type.rb b/acceptance/tests/language/binary_data_type.rb index 6bf68b1e9e5..00a4a2fd56b 100644 --- a/acceptance/tests/language/binary_data_type.rb +++ b/acceptance/tests/language/binary_data_type.rb @@ -61,7 +61,7 @@ :assertions => { :assert_match => 'Notice: A:\\xF0\\x9F\\x91\\x92' } }, { :type => 'notify', :parameters => { :namevar => "B:${type($bin_file)}" }, :pre_code => '$bin_file=binary_file("empty/blah.txt")', :assertions => { :assert_match => 'Notice: B:Binary' } }, - { :type => 'file', :parameters => { :namevar => "$pup_tmp_filename", :content => "$relaxed" }, :pre_code => "$pup_tmp_filename = if $osfamily == 'windows' { '#{tmp_filename_win}' } else { '#{tmp_filename_else}' }", + { :type => 'file', :parameters => { :namevar => "$pup_tmp_filename", :content => "$relaxed" }, :pre_code => "$pup_tmp_filename = if $facts['os']['family'] == 'windows' { '#{tmp_filename_win}' } else { '#{tmp_filename_else}' }", :assertions => { :assert_match => /#{base64_relaxed}/ } }, ] diff --git a/acceptance/tests/language/sensitive_data_type.rb b/acceptance/tests/language/sensitive_data_type.rb index c0b48f3a43b..e92f0326a38 100644 --- a/acceptance/tests/language/sensitive_data_type.rb +++ b/acceptance/tests/language/sensitive_data_type.rb @@ -65,7 +65,7 @@ {:type => 'notify', :parameters => {:namevar => "C:meh", :message => '"C:${$mehC.unwrap |$unwrapped| { "blk_${unwrapped}_blk" } } nonblk_${mehC}_nonblk"'}, :pre_code => '$mehC=Sensitive.new("sekritC")', :assertions => {:assert_match => ["C:blk_sekritC_blk", "nonblk_#{notify_redacted}_nonblk"]}}, # for --show_diff - {:type => 'file', :parameters => {:namevar => "$pup_tmp_filename", :content => "Sensitive.new('sekritD')"}, :pre_code => "$pup_tmp_filename = if $osfamily == 'windows' { '#{tmp_filename_win}' } else { '#{tmp_filename_else}' }", + {:type => 'file', :parameters => {:namevar => "$pup_tmp_filename", :content => "Sensitive.new('sekritD')"}, :pre_code => "$pup_tmp_filename = if $facts['os']['family'] == 'windows' { '#{tmp_filename_win}' } else { '#{tmp_filename_else}' }", :assertions => [{:refute_match => 'sekritD'}, {:assert_match => /#{tmp_environment}\.txt..content. #{file_redacted}/}]}, ] diff --git a/acceptance/tests/loader/autoload_from_resource_type_decl.rb b/acceptance/tests/loader/autoload_from_resource_type_decl.rb index 332ce54e427..e50f801e494 100644 --- a/acceptance/tests/loader/autoload_from_resource_type_decl.rb +++ b/acceptance/tests/loader/autoload_from_resource_type_decl.rb @@ -45,7 +45,7 @@ def empty_execution_log_file(host, path) custom_type = <<-END Puppet::Type.newtype(:type_tst) do newparam(:name, :namevar => true) do - fqdn = Facter.value(:fqdn) + fqdn = Facter.value('networking.fqdn') if fqdn == '#{agent_to_fqdn(master)}' File.open("#{execution_log[agent_to_fqdn(master)]}", 'a+') { |f| f.puts("found_type_tst: " + Time.now.to_s) } end diff --git a/acceptance/tests/lookup/merge_strategies.rb b/acceptance/tests/lookup/merge_strategies.rb index 2a3fc431acc..79cfd36ed6f 100644 --- a/acceptance/tests/lookup/merge_strategies.rb +++ b/acceptance/tests/lookup/merge_strategies.rb @@ -43,9 +43,9 @@ - "host" - "roles" - "profiles" - - "%{::operatingsystem}" - - "%{::osfamily}" - - "%{::kernel}" + - "%{facts.os.name}" + - "%{facts.os.family}" + - "%{facts.kernel}" - "common" :merge_behavior: deeper :deep_merge_options: diff --git a/acceptance/tests/resource/service/service_enable_linux.rb b/acceptance/tests/resource/service/service_enable_linux.rb index c48795efb9a..716a5cd57a0 100644 --- a/acceptance/tests/resource/service/service_enable_linux.rb +++ b/acceptance/tests/resource/service/service_enable_linux.rb @@ -22,7 +22,7 @@ agents.each do |agent| platform = agent.platform.variant osname = on(agent, facter('os.name')).stdout.chomp - majrelease = on(agent, facter('operatingsystemmajrelease')).stdout.chomp.to_i + majrelease = on(agent, facter('os.release.major')).stdout.chomp.to_i init_script_systemd = "/usr/lib/systemd/system/#{package_name[platform]}.service" symlink_systemd = "/etc/systemd/system/multi-user.target.wants/#{package_name[platform]}.service" diff --git a/acceptance/tests/resource/service/ticket_5024_systemd_enabling_masked_service.rb b/acceptance/tests/resource/service/ticket_5024_systemd_enabling_masked_service.rb index 67b5598c14c..8c989ea0dd7 100644 --- a/acceptance/tests/resource/service/ticket_5024_systemd_enabling_masked_service.rb +++ b/acceptance/tests/resource/service/ticket_5024_systemd_enabling_masked_service.rb @@ -43,7 +43,7 @@ package { '#{package_name[platform]}': ensure => present, } - if ($::operatingsystem == 'Fedora') and ($::operatingsystemmajrelease == '23') { + if ($os['name'] == 'Fedora') and ($os['release']['major'] == '23') { package{'libnghttp2': ensure => latest, install_options => '--best', diff --git a/acceptance/tests/ssl/certificate_extensions.rb b/acceptance/tests/ssl/certificate_extensions.rb index a12fe63fdba..545a5b59eab 100644 --- a/acceptance/tests/ssl/certificate_extensions.rb +++ b/acceptance/tests/ssl/certificate_extensions.rb @@ -11,8 +11,8 @@ initialize_temp_dirs agent_certnames = [] - hostname = master.execute('facter hostname') - fqdn = master.execute('facter fqdn') + hostname = master.execute('facter networking.hostname') + fqdn = master.execute('facter networking.fqdn') teardown do step "Cleanup the test agent certs" diff --git a/acceptance/tests/ticket_15560_managehome.rb b/acceptance/tests/ticket_15560_managehome.rb index 459315755ff..8a5fb77a892 100644 --- a/acceptance/tests/ticket_15560_managehome.rb +++ b/acceptance/tests/ticket_15560_managehome.rb @@ -30,7 +30,7 @@ deleteable_profile = true - version = on(host, facter('operatingsystemrelease')).stdout.chomp + version = on(host, facter('os.release.full')).stdout.chomp if version =~ /^5\.[012]|2003/ homedir = "C:/Documents and Settings/#{username}" deleteable_profile = false diff --git a/acceptance/tests/windows/QA-506_windows_exit_codes_test.rb b/acceptance/tests/windows/QA-506_windows_exit_codes_test.rb index 74332c01b57..e66c84c0edb 100644 --- a/acceptance/tests/windows/QA-506_windows_exit_codes_test.rb +++ b/acceptance/tests/windows/QA-506_windows_exit_codes_test.rb @@ -58,7 +58,7 @@ native_modules_path = on(agent, puppet("config print #{module_path_config_property}")).stdout.gsub('C:', '/cygdrive/c').strip #Check to see if we are running on Windows 2003. Do a crazy hack to get around SCP issues. - if (on(agent, facter("find operatingsystemmajrelease")).stdout =~ /2003/) + if (on(agent, facter("os.release.major")).stdout =~ /2003/) on(agent, "ln -s #{native_modules_path.gsub(/ /, '\ ')} /tmp/puppet_etc") modules_path = '/tmp/puppet_etc' else diff --git a/install.rb b/install.rb index 5d84055f0a0..659c430390e 100755 --- a/install.rb +++ b/install.rb @@ -92,7 +92,7 @@ def do_man(man, strip = 'man/') FileUtils.install(mf, omf, mode: 0644, preserve: true, verbose: true) # Solaris does not support gzipped man pages. When called with # --no-check-prereqs/without facter the default gzip behavior still applies - unless $operatingsystem == "Solaris" + unless $osname == "Solaris" gzip = %x{which gzip} gzip.chomp! %x{#{gzip} -f #{omf}} @@ -234,16 +234,16 @@ def prepare_installation RbConfig::CONFIG['bindir'] = "/usr/bin" end - # Here we only set $operatingsystem if we have opted to check for prereqs. + # Here we only set $osname if we have opted to check for prereqs. # Otherwise facter won't be guaranteed to be present. if InstallOptions.check_prereqs check_prereqs - $operatingsystem = Facter.value :operatingsystem + $osname = Facter.value('os.name') end if not InstallOptions.configdir.nil? configdir = InstallOptions.configdir - elsif $operatingsystem == "windows" + elsif $osname == "windows" configdir = File.join(ENV['ALLUSERSPROFILE'], "PuppetLabs", "puppet", "etc") else configdir = "/etc/puppetlabs/puppet" @@ -251,7 +251,7 @@ def prepare_installation if not InstallOptions.codedir.nil? codedir = InstallOptions.codedir - elsif $operatingsystem == "windows" + elsif $osname == "windows" codedir = File.join(ENV['ALLUSERSPROFILE'], "PuppetLabs", "code") else codedir = "/etc/puppetlabs/code" @@ -259,7 +259,7 @@ def prepare_installation if not InstallOptions.vardir.nil? vardir = InstallOptions.vardir - elsif $operatingsystem == "windows" + elsif $osname == "windows" vardir = File.join(ENV['ALLUSERSPROFILE'], "PuppetLabs", "puppet", "cache") else vardir = "/opt/puppetlabs/puppet/cache" @@ -267,7 +267,7 @@ def prepare_installation if not InstallOptions.publicdir.nil? publicdir = InstallOptions.publicdir - elsif $operatingsystem == "windows" + elsif $osname == "windows" publicdir = File.join(ENV['ALLUSERSPROFILE'], "PuppetLabs", "puppet", "public") else publicdir = "/opt/puppetlabs/puppet/public" @@ -275,7 +275,7 @@ def prepare_installation if not InstallOptions.rundir.nil? rundir = InstallOptions.rundir - elsif $operatingsystem == "windows" + elsif $osname == "windows" rundir = File.join(ENV['ALLUSERSPROFILE'], "PuppetLabs", "puppet", "var", "run") else rundir = "/var/run/puppetlabs" @@ -283,7 +283,7 @@ def prepare_installation if not InstallOptions.logdir.nil? logdir = InstallOptions.logdir - elsif $operatingsystem == "windows" + elsif $osname == "windows" logdir = File.join(ENV['ALLUSERSPROFILE'], "PuppetLabs", "puppet", "var", "log") else logdir = "/var/log/puppetlabs/puppet" @@ -298,7 +298,7 @@ def prepare_installation if not InstallOptions.localedir.nil? localedir = InstallOptions.localedir else - if $operatingsystem == "windows" + if $osname == "windows" localedir = File.join(ENV['PROGRAMFILES'], "Puppet Labs", "Puppet", "puppet", "share", "locale") else localedir = "/opt/puppetlabs/puppet/share/locale" @@ -376,7 +376,7 @@ def prepare_installation # by stripping the drive letter, but only if the basedir is not empty. # def join(basedir, dir) - return "#{basedir}#{dir[2..-1]}" if $operatingsystem == "windows" and basedir.length > 0 and dir.length > 2 + return "#{basedir}#{dir[2..-1]}" if $osname == "windows" and basedir.length > 0 and dir.length > 2 "#{basedir}#{dir}" end @@ -398,7 +398,7 @@ def build_rdoc(files) def build_ri(files) return unless $haverdoc - return if $operatingsystem == "windows" + return if $osname == "windows" begin ri = RDoc::RDoc.new #ri.document(["--ri-site", "--merge"] + files) @@ -427,14 +427,14 @@ def install_binfile(from, op_file, target) File.open(from) do |ip| File.open(tmp_file.path, "w") do |op| - op.puts "#!#{ruby}" unless $operatingsystem == "windows" + op.puts "#!#{ruby}" unless $osname == "windows" contents = ip.readlines contents.shift if contents[0] =~ /^#!/ op.write contents.join end end - if $operatingsystem == "windows" && InstallOptions.batch_files + if $osname == "windows" && InstallOptions.batch_files installed_wrapper = false unless File.extname(from) =~ /\.(cmd|bat)/ @@ -484,7 +484,7 @@ def install_binfile(from, op_file, target) prepare_installation - if $operatingsystem == "windows" + if $osname == "windows" windows_bins = glob(%w{ext/windows/*bat}) end @@ -492,8 +492,8 @@ def install_binfile(from, op_file, target) #build_ri(ri) if InstallOptions.ri do_configs(configs, InstallOptions.config_dir) if InstallOptions.configs do_bins(bins, InstallOptions.bin_dir) - do_bins(windows_bins, InstallOptions.bin_dir, 'ext/windows/') if $operatingsystem == "windows" && InstallOptions.batch_files + do_bins(windows_bins, InstallOptions.bin_dir, 'ext/windows/') if $osname == "windows" && InstallOptions.batch_files do_libs(libs) do_locales(locales) - do_man(man) unless $operatingsystem == "windows" + do_man(man) unless $osname == "windows" end diff --git a/lib/puppet/confiner.rb b/lib/puppet/confiner.rb index 08dd56f84fc..b6e2fbc3f79 100644 --- a/lib/puppet/confiner.rb +++ b/lib/puppet/confiner.rb @@ -16,7 +16,7 @@ module Puppet::Confiner # * `:any` => an array of expressions that will be ORed together # # @example - # confine :operatingsystem => [:redhat, :fedora] + # confine 'os.name' => [:redhat, :fedora] # confine :true { ... } # # @param hash [Hash<{Symbol => Object}>] hash of confines diff --git a/lib/puppet/file_serving/mount/file.rb b/lib/puppet/file_serving/mount/file.rb index 3b645fb9885..83951e7c912 100644 --- a/lib/puppet/file_serving/mount/file.rb +++ b/lib/puppet/file_serving/mount/file.rb @@ -3,12 +3,12 @@ class Puppet::FileServing::Mount::File < Puppet::FileServing::Mount def self.localmap @localmap ||= { - "h" => Puppet.runtime[:facter].value("hostname"), + "h" => Puppet.runtime[:facter].value('networking.hostname'), "H" => [ - Puppet.runtime[:facter].value("hostname"), - Puppet.runtime[:facter].value("domain") + Puppet.runtime[:facter].value('networking.hostname'), + Puppet.runtime[:facter].value('networking.domain') ].join("."), - "d" => Puppet.runtime[:facter].value("domain") + "d" => Puppet.runtime[:facter].value('networking.domain') } end diff --git a/lib/puppet/indirector/catalog/compiler.rb b/lib/puppet/indirector/catalog/compiler.rb index 9a6db303d47..e15f021e0e7 100644 --- a/lib/puppet/indirector/catalog/compiler.rb +++ b/lib/puppet/indirector/catalog/compiler.rb @@ -429,9 +429,9 @@ def set_server_facts @server_facts["serverversion"] = Puppet.version.to_s # And then add the server name and IP - {"servername" => "fqdn", - "serverip" => "ipaddress", - "serverip6" => "ipaddress6" + {"servername" => "networking.fqdn", + "serverip" => "networking.ip", + "serverip6" => "networking.ip6" }.each do |var, fact| value = Puppet.runtime[:facter].value(fact) if !value.nil? @@ -440,10 +440,10 @@ def set_server_facts end if @server_facts["servername"].nil? - host = Puppet.runtime[:facter].value(:hostname) + host = Puppet.runtime[:facter].value('networking.hostname') if host.nil? Puppet.warning _("Could not retrieve fact servername") - elsif domain = Puppet.runtime[:facter].value(:domain) #rubocop:disable Lint/AssignmentInCondition + elsif domain = Puppet.runtime[:facter].value('networking.domain') #rubocop:disable Lint/AssignmentInCondition @server_facts["servername"] = [host, domain].join(".") else @server_facts["servername"] = host diff --git a/lib/puppet/provider/exec/windows.rb b/lib/puppet/provider/exec/windows.rb index 15b43d41f44..52de0fee229 100644 --- a/lib/puppet/provider/exec/windows.rb +++ b/lib/puppet/provider/exec/windows.rb @@ -2,8 +2,8 @@ Puppet::Type.type(:exec).provide :windows, :parent => Puppet::Provider::Exec do - confine :operatingsystem => :windows - defaultfor :operatingsystem => :windows + confine 'os.name' => :windows + defaultfor 'os.name' => :windows desc <<-'EOT' Execute external binaries on Windows systems. As with the `posix` diff --git a/lib/puppet/provider/file/windows.rb b/lib/puppet/provider/file/windows.rb index cfadd425a13..57c63d25d4b 100644 --- a/lib/puppet/provider/file/windows.rb +++ b/lib/puppet/provider/file/windows.rb @@ -1,7 +1,7 @@ Puppet::Type.type(:file).provide :windows do desc "Uses Microsoft Windows functionality to manage file ownership and permissions." - confine :operatingsystem => :windows + confine 'os.name' => :windows has_feature :manages_symlinks if Puppet.features.manages_symlinks? include Puppet::Util::Warnings diff --git a/lib/puppet/provider/group/aix.rb b/lib/puppet/provider/group/aix.rb index a15e896d26b..845d7ed8f26 100644 --- a/lib/puppet/provider/group/aix.rb +++ b/lib/puppet/provider/group/aix.rb @@ -6,8 +6,8 @@ desc "Group management for AIX." # This will the default provider for this platform - defaultfor :operatingsystem => :aix - confine :operatingsystem => :aix + defaultfor 'os.name' => :aix + confine 'os.name' => :aix # Commands that manage the element commands :list => "/usr/sbin/lsgroup" diff --git a/lib/puppet/provider/group/directoryservice.rb b/lib/puppet/provider/group/directoryservice.rb index f45422a695f..3d21d055b86 100644 --- a/lib/puppet/provider/group/directoryservice.rb +++ b/lib/puppet/provider/group/directoryservice.rb @@ -6,8 +6,8 @@ " commands :dscl => "/usr/bin/dscl" - confine :operatingsystem => :darwin - defaultfor :operatingsystem => :darwin + confine 'os.name' => :darwin + defaultfor 'os.name' => :darwin has_feature :manages_members def members_insync?(current, should) diff --git a/lib/puppet/provider/group/groupadd.rb b/lib/puppet/provider/group/groupadd.rb index cb225f9fa22..7b809ab3a44 100644 --- a/lib/puppet/provider/group/groupadd.rb +++ b/lib/puppet/provider/group/groupadd.rb @@ -9,7 +9,7 @@ commands :add => "groupadd", :delete => "groupdel", :modify => "groupmod" - has_feature :system_groups unless %w{HP-UX Solaris}.include? Puppet.runtime[:facter].value(:operatingsystem) + has_feature :system_groups unless %w{HP-UX Solaris}.include? Puppet.runtime[:facter].value('os.name') verify :gid, _("GID must be an integer") do |value| value.is_a? Integer diff --git a/lib/puppet/provider/group/pw.rb b/lib/puppet/provider/group/pw.rb index c6cf3f6a9f1..dbc6c221669 100644 --- a/lib/puppet/provider/group/pw.rb +++ b/lib/puppet/provider/group/pw.rb @@ -6,8 +6,8 @@ commands :pw => "pw" has_features :manages_members - defaultfor :operatingsystem => [:freebsd, :dragonfly] - confine :operatingsystem => [:freebsd, :dragonfly] + defaultfor 'os.name' => [:freebsd, :dragonfly] + confine 'os.name' => [:freebsd, :dragonfly] options :members, :flag => "-M", :method => :mem diff --git a/lib/puppet/provider/group/windows_adsi.rb b/lib/puppet/provider/group/windows_adsi.rb index 26208fde2f2..6992cf630cf 100644 --- a/lib/puppet/provider/group/windows_adsi.rb +++ b/lib/puppet/provider/group/windows_adsi.rb @@ -4,8 +4,8 @@ desc "Local group management for Windows. Group members can be both users and groups. Additionally, local groups can contain domain users." - defaultfor :operatingsystem => :windows - confine :operatingsystem => :windows + defaultfor 'os.name' => :windows + confine 'os.name' => :windows has_features :manages_members diff --git a/lib/puppet/provider/nameservice/directoryservice.rb b/lib/puppet/provider/nameservice/directoryservice.rb index a6bdf5c045e..325bbc6f50a 100644 --- a/lib/puppet/provider/nameservice/directoryservice.rb +++ b/lib/puppet/provider/nameservice/directoryservice.rb @@ -18,9 +18,9 @@ class << self commands :dscl => "/usr/bin/dscl" commands :dseditgroup => "/usr/sbin/dseditgroup" commands :sw_vers => "/usr/bin/sw_vers" - confine :operatingsystem => :darwin + confine 'os.name' => :darwin confine :feature => :cfpropertylist - defaultfor :operatingsystem => :darwin + defaultfor 'os.name' => :darwin # There is no generalized mechanism for provider cache management, but we can # use post_resource_eval, which will be run for each suitable provider at the diff --git a/lib/puppet/provider/package/aix.rb b/lib/puppet/provider/package/aix.rb index 1bad7cb9a6c..a6fb588a33a 100644 --- a/lib/puppet/provider/package/aix.rb +++ b/lib/puppet/provider/package/aix.rb @@ -24,8 +24,8 @@ # AIX supports versionable packages with and without a NIM server has_feature :versionable - confine :operatingsystem => [ :aix ] - defaultfor :operatingsystem => :aix + confine 'os.name' => [ :aix ] + defaultfor 'os.name' => :aix attr_accessor :latest_info diff --git a/lib/puppet/provider/package/appdmg.rb b/lib/puppet/provider/package/appdmg.rb index 6feedaea6c0..e67a267ee03 100644 --- a/lib/puppet/provider/package/appdmg.rb +++ b/lib/puppet/provider/package/appdmg.rb @@ -17,7 +17,7 @@ Puppet::Type.type(:package).provide(:appdmg, :parent => Puppet::Provider::Package) do desc "Package management which copies application bundles to a target." - confine :operatingsystem => :darwin + confine 'os.name' => :darwin confine :feature => :cfpropertylist commands :hdiutil => "/usr/bin/hdiutil" diff --git a/lib/puppet/provider/package/apple.rb b/lib/puppet/provider/package/apple.rb index 330c5b7a4f2..5cf061b40fe 100644 --- a/lib/puppet/provider/package/apple.rb +++ b/lib/puppet/provider/package/apple.rb @@ -8,7 +8,7 @@ automatically add the `.pkg` extension, so leave that off when specifying the package name." - confine :operatingsystem => :darwin + confine 'os.name' => :darwin commands :installer => "/usr/sbin/installer" def self.instances diff --git a/lib/puppet/provider/package/apt.rb b/lib/puppet/provider/package/apt.rb index 670b68fa0fb..e9d672e97e0 100644 --- a/lib/puppet/provider/package/apt.rb +++ b/lib/puppet/provider/package/apt.rb @@ -19,7 +19,7 @@ commands :aptmark => "/usr/bin/apt-mark" commands :preseed => "/usr/bin/debconf-set-selections" - defaultfor :osfamily => :debian + defaultfor 'os.family' => :debian ENV['DEBIAN_FRONTEND'] = "noninteractive" diff --git a/lib/puppet/provider/package/blastwave.rb b/lib/puppet/provider/package/blastwave.rb index 1ace40fe0e9..15297a3c85f 100644 --- a/lib/puppet/provider/package/blastwave.rb +++ b/lib/puppet/provider/package/blastwave.rb @@ -4,7 +4,7 @@ pkgget = "pkg-get" pkgget = "/opt/csw/bin/pkg-get" if FileTest.executable?("/opt/csw/bin/pkg-get") - confine :osfamily => :solaris + confine 'os.family' => :solaris commands :pkgget => pkgget diff --git a/lib/puppet/provider/package/dnf.rb b/lib/puppet/provider/package/dnf.rb index 16b6a650f3d..8eb9e9ceea8 100644 --- a/lib/puppet/provider/package/dnf.rb +++ b/lib/puppet/provider/package/dnf.rb @@ -28,10 +28,10 @@ end end - defaultfor :operatingsystem => :fedora - notdefaultfor :operatingsystem => :fedora, :operatingsystemmajrelease => (19..21).to_a - defaultfor :osfamily => :redhat - notdefaultfor :osfamily => :redhat, :operatingsystemmajrelease => (4..7).to_a + defaultfor 'os.name' => :fedora + notdefaultfor 'os.name' => :fedora, 'os.release.major' => (19..21).to_a + defaultfor 'os.family' => :redhat + notdefaultfor 'os.family' => :redhat, 'os.release.major' => (4..7).to_a def self.update_command # In DNF, update is deprecated for upgrade diff --git a/lib/puppet/provider/package/freebsd.rb b/lib/puppet/provider/package/freebsd.rb index 305367968fb..dce936f85e7 100644 --- a/lib/puppet/provider/package/freebsd.rb +++ b/lib/puppet/provider/package/freebsd.rb @@ -9,7 +9,7 @@ :pkgadd => "/usr/sbin/pkg_add", :pkgdelete => "/usr/sbin/pkg_delete" - confine :operatingsystem => :freebsd + confine 'os.name' => :freebsd def self.listcmd command(:pkginfo) diff --git a/lib/puppet/provider/package/hpux.rb b/lib/puppet/provider/package/hpux.rb index 10523b8e246..57f83146746 100644 --- a/lib/puppet/provider/package/hpux.rb +++ b/lib/puppet/provider/package/hpux.rb @@ -10,9 +10,9 @@ :swlist => "/usr/sbin/swlist", :swremove => "/usr/sbin/swremove" - confine :operatingsystem => "hp-ux" + confine 'os.name' => "hp-ux" - defaultfor :operatingsystem => "hp-ux" + defaultfor 'os.name' => "hp-ux" def self.instances # TODO: This is very hard on HP-UX! diff --git a/lib/puppet/provider/package/macports.rb b/lib/puppet/provider/package/macports.rb index 99a96d04d93..e9d99938271 100644 --- a/lib/puppet/provider/package/macports.rb +++ b/lib/puppet/provider/package/macports.rb @@ -12,7 +12,7 @@ Revisions are only used internally for ensuring the latest version/revision of a port. " - confine :operatingsystem => :darwin + confine 'os.name' => :darwin has_command(:port, "/opt/local/bin/port") do environment :HOME => "/opt/local" diff --git a/lib/puppet/provider/package/openbsd.rb b/lib/puppet/provider/package/openbsd.rb index 4ddadb39f21..eaa47d220fc 100644 --- a/lib/puppet/provider/package/openbsd.rb +++ b/lib/puppet/provider/package/openbsd.rb @@ -13,8 +13,8 @@ :pkgadd => "pkg_add", :pkgdelete => "pkg_delete" - defaultfor :operatingsystem => :openbsd - confine :operatingsystem => :openbsd + defaultfor 'os.name' => :openbsd + confine 'os.name' => :openbsd has_feature :versionable has_feature :install_options diff --git a/lib/puppet/provider/package/opkg.rb b/lib/puppet/provider/package/opkg.rb index 0a48f5f82ac..452f6502227 100644 --- a/lib/puppet/provider/package/opkg.rb +++ b/lib/puppet/provider/package/opkg.rb @@ -5,8 +5,8 @@ commands :opkg => "opkg" - confine :operatingsystem => :openwrt - defaultfor :operatingsystem => :openwrt + confine 'os.name' => :openwrt + defaultfor 'os.name' => :openwrt def self.instances packages = [] diff --git a/lib/puppet/provider/package/pacman.rb b/lib/puppet/provider/package/pacman.rb index 600721faaab..cf8fa956973 100644 --- a/lib/puppet/provider/package/pacman.rb +++ b/lib/puppet/provider/package/pacman.rb @@ -17,8 +17,8 @@ def self.yaourt? # Yaourt is a common AUR helper which, if installed, we can use to query the AUR commands :yaourt => "/usr/bin/yaourt" if yaourt? - confine :operatingsystem => [:archlinux, :manjarolinux] - defaultfor :operatingsystem => [:archlinux, :manjarolinux] + confine 'os.name' => [:archlinux, :manjarolinux] + defaultfor 'os.name' => [:archlinux, :manjarolinux] has_feature :install_options has_feature :uninstall_options has_feature :upgradeable diff --git a/lib/puppet/provider/package/pkg.rb b/lib/puppet/provider/package/pkg.rb index e6ebebb36d3..8abbff83d7c 100644 --- a/lib/puppet/provider/package/pkg.rb +++ b/lib/puppet/provider/package/pkg.rb @@ -28,9 +28,9 @@ commands :pkg => "/usr/bin/pkg" - confine :osfamily => :solaris + confine 'os.family' => :solaris - defaultfor :osfamily => :solaris, :kernelrelease => ['5.11', '5.12'] + defaultfor 'os.family' => :solaris, :kernelrelease => ['5.11', '5.12'] def self.instances pkg(:list, '-Hv').split("\n").map{|l| new(parse_line(l))} @@ -228,7 +228,7 @@ def install(nofail = false) command = 'update' end args = ['--accept'] - if Puppet::Util::Package.versioncmp(Puppet.runtime[:facter].value(:operatingsystemrelease), '11.2') >= 0 + if Puppet::Util::Package.versioncmp(Puppet.runtime[:facter].value('os.release.full'), '11.2') >= 0 args.push('--sync-actuators-timeout', '900') end args.concat(join_options(@resource[:install_options])) if @resource[:install_options] diff --git a/lib/puppet/provider/package/pkgdmg.rb b/lib/puppet/provider/package/pkgdmg.rb index ff7b06bfe2b..753dc1ba958 100644 --- a/lib/puppet/provider/package/pkgdmg.rb +++ b/lib/puppet/provider/package/pkgdmg.rb @@ -35,9 +35,9 @@ whether a package has been installed. Thus, to install new a version of a package, you must create a new DMG with a different filename." - confine :operatingsystem => :darwin + confine 'os.name' => :darwin confine :feature => :cfpropertylist - defaultfor :operatingsystem => :darwin + defaultfor 'os.name' => :darwin commands :installer => "/usr/sbin/installer" commands :hdiutil => "/usr/bin/hdiutil" commands :curl => "/usr/bin/curl" diff --git a/lib/puppet/provider/package/pkgin.rb b/lib/puppet/provider/package/pkgin.rb index a985c6d56a9..5c4b540ec1d 100644 --- a/lib/puppet/provider/package/pkgin.rb +++ b/lib/puppet/provider/package/pkgin.rb @@ -5,7 +5,7 @@ commands :pkgin => "pkgin" - defaultfor :operatingsystem => [ :smartos, :netbsd ] + defaultfor 'os.name' => [ :smartos, :netbsd ] has_feature :installable, :uninstallable, :upgradeable, :versionable diff --git a/lib/puppet/provider/package/pkgng.rb b/lib/puppet/provider/package/pkgng.rb index 3b8afe87d80..07fd7eaa76d 100644 --- a/lib/puppet/provider/package/pkgng.rb +++ b/lib/puppet/provider/package/pkgng.rb @@ -5,9 +5,9 @@ commands :pkg => "/usr/local/sbin/pkg" - confine :operatingsystem => [:freebsd, :dragonfly] + confine 'os.name' => [:freebsd, :dragonfly] - defaultfor :operatingsystem => [:freebsd, :dragonfly] + defaultfor 'os.name' => [:freebsd, :dragonfly] has_feature :versionable has_feature :upgradeable diff --git a/lib/puppet/provider/package/pkgutil.rb b/lib/puppet/provider/package/pkgutil.rb index d0815e0260e..1663e823c0c 100644 --- a/lib/puppet/provider/package/pkgutil.rb +++ b/lib/puppet/provider/package/pkgutil.rb @@ -7,7 +7,7 @@ pkgutil_bin = "/opt/csw/bin/pkgutil" end - confine :osfamily => :solaris + confine 'os.family' => :solaris has_command(:pkguti, pkgutil_bin) do environment :HOME => ENV['HOME'] diff --git a/lib/puppet/provider/package/portage.rb b/lib/puppet/provider/package/portage.rb index 1fbf4b99012..e738fa3c5aa 100644 --- a/lib/puppet/provider/package/portage.rb +++ b/lib/puppet/provider/package/portage.rb @@ -20,9 +20,9 @@ end end - confine :osfamily => :gentoo + confine 'os.family' => :gentoo - defaultfor :osfamily => :gentoo + defaultfor 'os.family' => :gentoo def self.instances result_format = self.eix_result_format diff --git a/lib/puppet/provider/package/portupgrade.rb b/lib/puppet/provider/package/portupgrade.rb index 3f32bc87c27..e30f02d8622 100644 --- a/lib/puppet/provider/package/portupgrade.rb +++ b/lib/puppet/provider/package/portupgrade.rb @@ -18,7 +18,7 @@ :portinfo => "/usr/sbin/pkg_info" ## Activate this only once approved by someone important. - # defaultfor :operatingsystem => :freebsd + # defaultfor 'os.name' => :freebsd # Remove unwanted environment variables. %w{INTERACTIVE UNAME}.each do |var| diff --git a/lib/puppet/provider/package/rug.rb b/lib/puppet/provider/package/rug.rb index 5cb2945fe0b..aa7e7cc247f 100644 --- a/lib/puppet/provider/package/rug.rb +++ b/lib/puppet/provider/package/rug.rb @@ -5,7 +5,7 @@ commands :rug => "/usr/bin/rug" commands :rpm => "rpm" - confine :operatingsystem => [:suse, :sles] + confine 'os.name' => [:suse, :sles] # Install a package using 'rug'. def install diff --git a/lib/puppet/provider/package/sun.rb b/lib/puppet/provider/package/sun.rb index 0df246ae9fc..c80982c689e 100644 --- a/lib/puppet/provider/package/sun.rb +++ b/lib/puppet/provider/package/sun.rb @@ -14,8 +14,8 @@ :pkgadd => "/usr/sbin/pkgadd", :pkgrm => "/usr/sbin/pkgrm" - confine :osfamily => :solaris - defaultfor :osfamily => :solaris + confine 'os.family' => :solaris + defaultfor 'os.family' => :solaris has_feature :install_options diff --git a/lib/puppet/provider/package/sunfreeware.rb b/lib/puppet/provider/package/sunfreeware.rb index 118d36b66e9..d4473401851 100644 --- a/lib/puppet/provider/package/sunfreeware.rb +++ b/lib/puppet/provider/package/sunfreeware.rb @@ -5,5 +5,5 @@ has not actually been tested." commands :pkgget => "pkg-get" - confine :osfamily => :solaris + confine 'os.family' => :solaris end diff --git a/lib/puppet/provider/package/tdnf.rb b/lib/puppet/provider/package/tdnf.rb index c633d58bbe5..1d7c1b26249 100644 --- a/lib/puppet/provider/package/tdnf.rb +++ b/lib/puppet/provider/package/tdnf.rb @@ -24,5 +24,5 @@ end end - defaultfor :operatingsystem => "PhotonOS" + defaultfor 'os.name' => "PhotonOS" end diff --git a/lib/puppet/provider/package/up2date.rb b/lib/puppet/provider/package/up2date.rb index d9eafbe25dc..6c998879c7a 100644 --- a/lib/puppet/provider/package/up2date.rb +++ b/lib/puppet/provider/package/up2date.rb @@ -4,9 +4,9 @@ commands :up2date => "/usr/sbin/up2date-nox" - defaultfor :osfamily => :redhat, :lsbdistrelease => ["2.1", "3", "4"] + defaultfor 'os.family' => :redhat, 'os.distro.release.full' => ["2.1", "3", "4"] - confine :osfamily => :redhat + confine 'os.family' => :redhat # Install a package using 'up2date'. def install diff --git a/lib/puppet/provider/package/urpmi.rb b/lib/puppet/provider/package/urpmi.rb index 32a049582bc..d396c5df02c 100644 --- a/lib/puppet/provider/package/urpmi.rb +++ b/lib/puppet/provider/package/urpmi.rb @@ -2,7 +2,7 @@ desc "Support via `urpmi`." commands :urpmi => "urpmi", :urpmq => "urpmq", :rpm => "rpm", :urpme => "urpme" - defaultfor :operatingsystem => [:mandriva, :mandrake] + defaultfor 'os.name' => [:mandriva, :mandrake] has_feature :versionable diff --git a/lib/puppet/provider/package/windows.rb b/lib/puppet/provider/package/windows.rb index 69b6ad82190..5ddd885792b 100644 --- a/lib/puppet/provider/package/windows.rb +++ b/lib/puppet/provider/package/windows.rb @@ -20,8 +20,8 @@ `install_options` or `uninstall_options` attributes, respectively. Puppet will automatically quote any option that contains spaces." - confine :operatingsystem => :windows - defaultfor :operatingsystem => :windows + confine 'os.name' => :windows + defaultfor 'os.name' => :windows has_feature :installable has_feature :uninstallable diff --git a/lib/puppet/provider/package/yum.rb b/lib/puppet/provider/package/yum.rb index ca55c865815..3dfa48f7143 100644 --- a/lib/puppet/provider/package/yum.rb +++ b/lib/puppet/provider/package/yum.rb @@ -32,8 +32,8 @@ end end -defaultfor :operatingsystem => :amazon -defaultfor :osfamily => :redhat, :operatingsystemmajrelease => (4..7).to_a +defaultfor 'os.name' => :amazon +defaultfor 'os.family' => :redhat, 'os.release.major' => (4..7).to_a def insync?(is) return false if [:purged, :absent].include?(is) @@ -303,7 +303,7 @@ def install # Yum on el-4 and el-5 returns exit status 0 when trying to install a package it doesn't recognize; # ensure we capture output to check for errors. - no_debug = if Puppet.runtime[:facter].value(:operatingsystemmajrelease).to_i > 5 then ["-d", "0"] else [] end + no_debug = if Puppet.runtime[:facter].value('os.release.major').to_i > 5 then ["-d", "0"] else [] end command = [command(:cmd)] + no_debug + ["-e", error_level, "-y", install_options, operation, wanted].compact output = execute(command) diff --git a/lib/puppet/provider/package/zypper.rb b/lib/puppet/provider/package/zypper.rb index 464a80b5f6d..aeca798f5e9 100644 --- a/lib/puppet/provider/package/zypper.rb +++ b/lib/puppet/provider/package/zypper.rb @@ -9,8 +9,8 @@ commands :zypper => "/usr/bin/zypper" - defaultfor :operatingsystem => [:suse, :sles, :sled, :opensuse] - confine :operatingsystem => [:suse, :sles, :sled, :opensuse] + defaultfor 'os.name' => [:suse, :sles, :sled, :opensuse] + confine 'os.name' => [:suse, :sles, :sled, :opensuse] # @api private # Reset the latest version hash to nil diff --git a/lib/puppet/provider/service/base.rb b/lib/puppet/provider/service/base.rb index 0afe92359ee..cc80509ac7f 100644 --- a/lib/puppet/provider/service/base.rb +++ b/lib/puppet/provider/service/base.rb @@ -15,7 +15,7 @@ # ported from the facter 2.x implementation, since facter 3.x # is dropping the fact (for which this was the only use) def getps - case Puppet.runtime[:facter].value(:operatingsystem) + case Puppet.runtime[:facter].value('os.name') when 'OpenWrt' 'ps www' when 'FreeBSD', 'NetBSD', 'OpenBSD', 'Darwin', 'DragonFly' diff --git a/lib/puppet/provider/service/bsd.rb b/lib/puppet/provider/service/bsd.rb index 146d048d557..688994531c1 100644 --- a/lib/puppet/provider/service/bsd.rb +++ b/lib/puppet/provider/service/bsd.rb @@ -5,7 +5,7 @@ Uses `rc.conf.d` for service enabling and disabling. EOT - confine :operatingsystem => [:freebsd, :dragonfly] + confine 'os.name' => [:freebsd, :dragonfly] def rcconf_dir '/etc/rc.conf.d' diff --git a/lib/puppet/provider/service/debian.rb b/lib/puppet/provider/service/debian.rb index c6ba5b34b05..3a99c44d306 100644 --- a/lib/puppet/provider/service/debian.rb +++ b/lib/puppet/provider/service/debian.rb @@ -19,9 +19,9 @@ confine :false => Puppet::FileSystem.exist?('/proc/1/comm') && Puppet::FileSystem.read('/proc/1/comm').include?('systemd') - defaultfor :operatingsystem => :cumuluslinux, :operatingsystemmajrelease => ['1','2'] - defaultfor :operatingsystem => :debian, :operatingsystemmajrelease => ['5','6','7'] - defaultfor :operatingsystem => :devuan + defaultfor 'os.name' => :cumuluslinux, 'os.release.major' => ['1','2'] + defaultfor 'os.name' => :debian, 'os.release.major' => ['5','6','7'] + defaultfor 'os.name' => :devuan # Remove the symlinks def disable diff --git a/lib/puppet/provider/service/freebsd.rb b/lib/puppet/provider/service/freebsd.rb index d97c605e34b..0430c3557c0 100644 --- a/lib/puppet/provider/service/freebsd.rb +++ b/lib/puppet/provider/service/freebsd.rb @@ -2,8 +2,8 @@ desc "Provider for FreeBSD and DragonFly BSD. Uses the `rcvar` argument of init scripts and parses/edits rc files." - confine :operatingsystem => [:freebsd, :dragonfly] - defaultfor :operatingsystem => [:freebsd, :dragonfly] + confine 'os.name' => [:freebsd, :dragonfly] + defaultfor 'os.name' => [:freebsd, :dragonfly] def rcconf() '/etc/rc.conf' end def rcconf_local() '/etc/rc.conf.local' end diff --git a/lib/puppet/provider/service/gentoo.rb b/lib/puppet/provider/service/gentoo.rb index 4fecbde9dac..3f38fc2042c 100644 --- a/lib/puppet/provider/service/gentoo.rb +++ b/lib/puppet/provider/service/gentoo.rb @@ -10,7 +10,7 @@ commands :update => "/sbin/rc-update" - confine :operatingsystem => :gentoo + confine 'os.name' => :gentoo def disable output = update :del, @resource[:name], :default diff --git a/lib/puppet/provider/service/init.rb b/lib/puppet/provider/service/init.rb index 02c220bb192..4d25f4b7ee8 100644 --- a/lib/puppet/provider/service/init.rb +++ b/lib/puppet/provider/service/init.rb @@ -4,7 +4,7 @@ desc "Standard `init`-style service management." def self.defpath - case Puppet.runtime[:facter].value(:operatingsystem) + case Puppet.runtime[:facter].value('os.name') when "FreeBSD", "DragonFly" ["/etc/rc.d", "/usr/local/etc/rc.d"] when "HP-UX" @@ -21,8 +21,8 @@ def self.defpath # Debian and Ubuntu should use the Debian provider. # RedHat systems should use the RedHat provider. confine :true => begin - os = Puppet.runtime[:facter].value(:operatingsystem).downcase - family = Puppet.runtime[:facter].value(:osfamily).downcase + os = Puppet.runtime[:facter].value('os.name').downcase + family = Puppet.runtime[:facter].value('os.family').downcase !(os == 'debian' || os == 'ubuntu' || family == 'redhat') end @@ -54,7 +54,7 @@ def self.excludes # these excludes were found with grep -r -L start /etc/init.d excludes += %w{rcS module-init-tools} # Prevent puppet failing on unsafe scripts from Yocto Linux - if Puppet.runtime[:facter].value(:osfamily) == "cisco-wrlinux" + if Puppet.runtime[:facter].value('os.family') == "cisco-wrlinux" excludes += %w{banner.sh bootmisc.sh checkroot.sh devpts.sh dmesg.sh hostname.sh mountall.sh mountnfs.sh populate-volatile.sh rmnologin.sh save-rtc.sh sendsigs sysfs.sh umountfs @@ -172,7 +172,7 @@ def restartcmd end def service_execute(type, command, fof = true, squelch = false, combine = true) - if type == :start && Puppet.runtime[:facter].value(:osfamily) == "Solaris" + if type == :start && Puppet.runtime[:facter].value('os.family') == "Solaris" command = ["/usr/bin/ctrun -l child", command].flatten.join(" ") end super(type, command, fof, squelch, combine) diff --git a/lib/puppet/provider/service/launchd.rb b/lib/puppet/provider/service/launchd.rb index b98929e9f4d..aa525fcfd1a 100644 --- a/lib/puppet/provider/service/launchd.rb +++ b/lib/puppet/provider/service/launchd.rb @@ -42,8 +42,8 @@ commands :launchctl => "/bin/launchctl" - defaultfor :operatingsystem => :darwin - confine :operatingsystem => :darwin + defaultfor 'os.name' => :darwin + confine 'os.name' => :darwin confine :feature => :cfpropertylist has_feature :enableable @@ -70,7 +70,7 @@ def self.launchd_paths # # @api private def self.get_os_version - @os_version ||= Puppet.runtime[:facter].value(:operatingsystemmajrelease).to_i + @os_version ||= Facter.value('os.release.major').to_i end # Defines the path to the overrides plist file where service enabling diff --git a/lib/puppet/provider/service/openbsd.rb b/lib/puppet/provider/service/openbsd.rb index 34a7382d42a..7a4f2c8d50b 100644 --- a/lib/puppet/provider/service/openbsd.rb +++ b/lib/puppet/provider/service/openbsd.rb @@ -4,8 +4,8 @@ commands :rcctl => '/usr/sbin/rcctl' - confine :operatingsystem => :openbsd - defaultfor :operatingsystem => :openbsd + confine 'os.name' => :openbsd + defaultfor 'os.name' => :openbsd has_feature :flaggable def startcmd diff --git a/lib/puppet/provider/service/openrc.rb b/lib/puppet/provider/service/openrc.rb index 8243f651e87..f6c91bfd621 100644 --- a/lib/puppet/provider/service/openrc.rb +++ b/lib/puppet/provider/service/openrc.rb @@ -7,8 +7,8 @@ EOT - defaultfor :operatingsystem => :gentoo - defaultfor :operatingsystem => :funtoo + defaultfor 'os.name' => :gentoo + defaultfor 'os.name' => :funtoo has_command(:rcstatus, '/bin/rc-status') do environment :RC_SVCNAME => nil diff --git a/lib/puppet/provider/service/openwrt.rb b/lib/puppet/provider/service/openwrt.rb index f1171275672..2f8f93db14e 100644 --- a/lib/puppet/provider/service/openwrt.rb +++ b/lib/puppet/provider/service/openwrt.rb @@ -6,8 +6,8 @@ EOT - defaultfor :operatingsystem => :openwrt - confine :operatingsystem => :openwrt + defaultfor 'os.name' => :openwrt + confine 'os.name' => :openwrt has_feature :enableable diff --git a/lib/puppet/provider/service/rcng.rb b/lib/puppet/provider/service/rcng.rb index 5e5d16bde4e..47d914c4828 100644 --- a/lib/puppet/provider/service/rcng.rb +++ b/lib/puppet/provider/service/rcng.rb @@ -3,8 +3,8 @@ RCng service management with rc.d EOT - defaultfor :operatingsystem => [:netbsd, :cargos] - confine :operatingsystem => [:netbsd, :cargos] + defaultfor 'os.name' => [:netbsd, :cargos] + confine 'os.name' => [:netbsd, :cargos] def self.defpath "/etc/rc.d" diff --git a/lib/puppet/provider/service/redhat.rb b/lib/puppet/provider/service/redhat.rb index 4b73eb2db5b..dce7d75c6d3 100644 --- a/lib/puppet/provider/service/redhat.rb +++ b/lib/puppet/provider/service/redhat.rb @@ -8,8 +8,8 @@ commands :chkconfig => "/sbin/chkconfig", :service => "/sbin/service" - defaultfor :osfamily => :redhat - defaultfor :osfamily => :suse, :operatingsystemmajrelease => ["10", "11"] + defaultfor 'os.family' => :redhat + defaultfor 'os.family' => :suse, 'os.release.major' => ["10", "11"] # Remove the symlinks def disable @@ -35,7 +35,7 @@ def enabled? # For Suse OS family, chkconfig returns 0 even if the service is disabled or non-existent # Therefore, check the output for ' on' (or ' B for boot services) # to see if it is enabled - return :false unless Puppet.runtime[:facter].value(:osfamily) != 'Suse' || output =~ /^#{name}\s+(on|B)$/ + return :false unless Puppet.runtime[:facter].value('os.family') != 'Suse' || output =~ /^#{name}\s+(on|B)$/ :true end diff --git a/lib/puppet/provider/service/smf.rb b/lib/puppet/provider/service/smf.rb index e71eccb403b..9cef683d8ea 100644 --- a/lib/puppet/provider/service/smf.rb +++ b/lib/puppet/provider/service/smf.rb @@ -18,9 +18,9 @@ be imported if it does not exist. EOT - defaultfor :osfamily => :solaris + defaultfor 'os.family' => :solaris - confine :osfamily => :solaris + confine 'os.family' => :solaris commands :adm => "/usr/sbin/svcadm", :svcs => "/usr/bin/svcs", @@ -101,14 +101,14 @@ def service_fmri # Returns true if the provider supports incomplete services. def supports_incomplete_services? - Puppet::Util::Package.versioncmp(Puppet.runtime[:facter].value(:operatingsystemrelease), '11.1') >= 0 + Puppet::Util::Package.versioncmp(Puppet.runtime[:facter].value('os.release.full'), '11.1') >= 0 end # Returns true if the service is complete. A complete service is a service that # has the general/complete property defined. def complete_service? unless supports_incomplete_services? - raise Puppet::Error, _("Cannot query if the %{service} service is complete: The concept of complete/incomplete services was introduced in Solaris 11.1. You are on a Solaris %{release} machine.") % { service: @resource[:name], release: Puppet.runtime[:facter].value(:operatingsystemrelease) } + raise Puppet::Error, _("Cannot query if the %{service} service is complete: The concept of complete/incomplete services was introduced in Solaris 11.1. You are on a Solaris %{release} machine.") % { service: @resource[:name], release: Puppet.runtime[:facter].value('os.release.full') } end return @complete_service if @complete_service @@ -138,7 +138,7 @@ def disable end def restartcmd - if Puppet::Util::Package.versioncmp(Puppet.runtime[:facter].value(:operatingsystemrelease), '11.2') >= 0 + if Puppet::Util::Package.versioncmp(Puppet.runtime[:facter].value('os.release.full'), '11.2') >= 0 [command(:adm), :restart, "-s", self.service_fmri] else # Synchronous restart only supported in Solaris 11.2 and above diff --git a/lib/puppet/provider/service/src.rb b/lib/puppet/provider/service/src.rb index d8d4619772c..18341e2160e 100644 --- a/lib/puppet/provider/service/src.rb +++ b/lib/puppet/provider/service/src.rb @@ -13,8 +13,8 @@ is not yet supported. " - defaultfor :operatingsystem => :aix - confine :operatingsystem => :aix + defaultfor 'os.name' => :aix + confine 'os.name' => :aix optional_commands :stopsrc => "/usr/bin/stopsrc", :startsrc => "/usr/bin/startsrc", diff --git a/lib/puppet/provider/service/systemd.rb b/lib/puppet/provider/service/systemd.rb index 6a451f0f8a0..df701ba1337 100644 --- a/lib/puppet/provider/service/systemd.rb +++ b/lib/puppet/provider/service/systemd.rb @@ -13,19 +13,19 @@ confine :true => Puppet::FileSystem.exist?('/proc/1/comm') && Puppet::FileSystem.read('/proc/1/comm').include?('systemd') - defaultfor :osfamily => [:archlinux] - defaultfor :osfamily => :redhat, :operatingsystemmajrelease => ["7", "8", "9"] - defaultfor :osfamily => :redhat, :operatingsystem => :fedora - defaultfor :osfamily => :suse - defaultfor :osfamily => :coreos - defaultfor :operatingsystem => :amazon, :operatingsystemmajrelease => ["2"] - defaultfor :operatingsystem => :debian - notdefaultfor :operatingsystem => :debian, :operatingsystemmajrelease => ["5", "6", "7"] # These are using the "debian" method - defaultfor :operatingsystem => :LinuxMint - notdefaultfor :operatingsystem => :LinuxMint, :operatingsystemmajrelease => ["10", "11", "12", "13", "14", "15", "16", "17"] # These are using upstart - defaultfor :operatingsystem => :ubuntu - notdefaultfor :operatingsystem => :ubuntu, :operatingsystemmajrelease => ["10.04", "12.04", "14.04", "14.10"] # These are using upstart - defaultfor :operatingsystem => :cumuluslinux, :operatingsystemmajrelease => ["3", "4"] + defaultfor 'os.family' => [:archlinux] + defaultfor 'os.family' => :redhat, 'os.release.major' => ["7", "8", "9"] + defaultfor 'os.family' => :redhat, 'os.name' => :fedora + defaultfor 'os.family' => :suse + defaultfor 'os.family' => :coreos + defaultfor 'os.name' => :amazon, 'os.release.major' => ["2"] + defaultfor 'os.name' => :debian + notdefaultfor 'os.name' => :debian, 'os.release.major' => ["5", "6", "7"] # These are using the "debian" method + defaultfor 'os.name' => :LinuxMint + notdefaultfor 'os.name' => :LinuxMint, 'os.release.major' => ["10", "11", "12", "13", "14", "15", "16", "17"] # These are using upstart + defaultfor 'os.name' => :ubuntu + notdefaultfor 'os.name' => :ubuntu, 'os.release.major' => ["10.04", "12.04", "14.04", "14.10"] # These are using upstart + defaultfor 'os.name' => :cumuluslinux, 'os.release.major' => ["3", "4"] def self.instances i = [] @@ -110,7 +110,7 @@ def enabled? # The indirect state indicates that the unit is not enabled. return :false if output == 'indirect' return :true if (code == 0) - if (output.empty?) && (code > 0) && (Puppet.runtime[:facter].value(:osfamily).casecmp('debian').zero?) + if (output.empty?) && (code > 0) && (Puppet.runtime[:facter].value('os.family').casecmp('debian').zero?) ret = debian_enabled? return ret if ret end diff --git a/lib/puppet/provider/service/upstart.rb b/lib/puppet/provider/service/upstart.rb index 4a72c980e16..71f84429447 100644 --- a/lib/puppet/provider/service/upstart.rb +++ b/lib/puppet/provider/service/upstart.rb @@ -10,14 +10,14 @@ " confine :any => [ - Puppet.runtime[:facter].value(:operatingsystem) == 'Ubuntu', - (Puppet.runtime[:facter].value(:osfamily) == 'RedHat' and Puppet.runtime[:facter].value(:operatingsystemrelease) =~ /^6\./), - (Puppet.runtime[:facter].value(:operatingsystem) == 'Amazon' and Puppet.runtime[:facter].value(:operatingsystemmajrelease) =~ /\d{4}/), - Puppet.runtime[:facter].value(:operatingsystem) == 'LinuxMint', + Puppet.runtime[:facter].value('os.name') == 'Ubuntu', + (Puppet.runtime[:facter].value('os.family') == 'RedHat' and Puppet.runtime[:facter].value('os.release.full') =~ /^6\./), + (Puppet.runtime[:facter].value('os.name') == 'Amazon' and Puppet.runtime[:facter].value('os.release.major') =~ /\d{4}/), + Puppet.runtime[:facter].value('os.name') == 'LinuxMint', ] - defaultfor :operatingsystem => :ubuntu, :operatingsystemmajrelease => ["10.04", "12.04", "14.04", "14.10"] - defaultfor :operatingsystem => :LinuxMint, :operatingsystemmajrelease => ["10", "11", "12", "13", "14", "15", "16", "17"] + defaultfor 'os.name' => :ubuntu, 'os.release.major' => ["10.04", "12.04", "14.04", "14.10"] + defaultfor 'os.name' => :LinuxMint, 'os.release.major' => ["10", "11", "12", "13", "14", "15", "16", "17"] commands :start => "/sbin/start", :stop => "/sbin/stop", @@ -57,7 +57,7 @@ def self.instances def self.excludes excludes = super - if Puppet.runtime[:facter].value(:osfamily) == 'RedHat' + if Puppet.runtime[:facter].value('os.family') == 'RedHat' # Puppet cannot deal with services that have instances, so we have to # ignore these services using instances on redhat based systems. excludes += %w[serial tty] diff --git a/lib/puppet/provider/service/windows.rb b/lib/puppet/provider/service/windows.rb index e3dde13712c..d2f27fe61fa 100644 --- a/lib/puppet/provider/service/windows.rb +++ b/lib/puppet/provider/service/windows.rb @@ -11,8 +11,8 @@ services as a specific user. EOT - defaultfor :operatingsystem => :windows - confine :operatingsystem => :windows + defaultfor 'os.name' => :windows + confine 'os.name' => :windows has_feature :refreshable, :configurable_timeout, :manages_logon_credentials diff --git a/lib/puppet/provider/user/aix.rb b/lib/puppet/provider/user/aix.rb index b6929c656b5..490520945f7 100644 --- a/lib/puppet/provider/user/aix.rb +++ b/lib/puppet/provider/user/aix.rb @@ -17,8 +17,8 @@ Puppet::Type.type(:user).provide :aix, :parent => Puppet::Provider::AixObject do desc "User management for AIX." - defaultfor :operatingsystem => :aix - confine :operatingsystem => :aix + defaultfor 'os.name' => :aix + confine 'os.name' => :aix # Commands that manage the element commands :list => "/usr/sbin/lsuser" diff --git a/lib/puppet/provider/user/directoryservice.rb b/lib/puppet/provider/user/directoryservice.rb index b185e1fe200..beca92e4899 100644 --- a/lib/puppet/provider/user/directoryservice.rb +++ b/lib/puppet/provider/user/directoryservice.rb @@ -16,9 +16,9 @@ commands :dscacheutil => '/usr/bin/dscacheutil' # Provider confines and defaults - confine :operatingsystem => :darwin + confine 'os.name' => :darwin confine :feature => :cfpropertylist - defaultfor :operatingsystem => :darwin + defaultfor 'os.name' => :darwin # Need this to create getter/setter methods automagically # This command creates methods that return @property_hash[:value] @@ -159,7 +159,7 @@ def self.generate_attribute_hash(input_hash) end def self.get_os_version - @os_version ||= Puppet.runtime[:facter].value(:macosx_productversion_major) + @os_version ||= Puppet.runtime[:facter].value('os.macosx.version.major') end # Use dscl to retrieve an array of hashes containing attributes about all diff --git a/lib/puppet/provider/user/hpux.rb b/lib/puppet/provider/user/hpux.rb index 0f1ef29ce8c..13503d0c357 100644 --- a/lib/puppet/provider/user/hpux.rb +++ b/lib/puppet/provider/user/hpux.rb @@ -5,8 +5,8 @@ New functionality provides for changing trusted computing passwords and resetting password expirations under trusted computing." - defaultfor :operatingsystem => "hp-ux" - confine :operatingsystem => "hp-ux" + defaultfor 'os.name' => "hp-ux" + confine 'os.name' => "hp-ux" commands :modify => "/usr/sam/lbin/usermod.sam", :delete => "/usr/sam/lbin/userdel.sam", :add => "/usr/sam/lbin/useradd.sam" options :comment, :method => :gecos diff --git a/lib/puppet/provider/user/openbsd.rb b/lib/puppet/provider/user/openbsd.rb index 584166bf5ed..d8781e6e2f2 100644 --- a/lib/puppet/provider/user/openbsd.rb +++ b/lib/puppet/provider/user/openbsd.rb @@ -10,8 +10,8 @@ :modify => "usermod", :password => "passwd" - defaultfor :operatingsystem => :openbsd - confine :operatingsystem => :openbsd + defaultfor 'os.name' => :openbsd + confine 'os.name' => :openbsd options :home, :flag => "-d", :method => :dir options :comment, :method => :gecos diff --git a/lib/puppet/provider/user/pw.rb b/lib/puppet/provider/user/pw.rb index cee1cd128cf..1a011be0b55 100644 --- a/lib/puppet/provider/user/pw.rb +++ b/lib/puppet/provider/user/pw.rb @@ -7,8 +7,8 @@ commands :pw => "pw" has_features :manages_homedir, :allows_duplicates, :manages_passwords, :manages_expiry, :manages_shell - defaultfor :operatingsystem => [:freebsd, :dragonfly] - confine :operatingsystem => [:freebsd, :dragonfly] + defaultfor 'os.name' => [:freebsd, :dragonfly] + confine 'os.name' => [:freebsd, :dragonfly] options :home, :flag => "-d", :method => :dir options :comment, :method => :gecos diff --git a/lib/puppet/provider/user/user_role_add.rb b/lib/puppet/provider/user/user_role_add.rb index 1a841d38c1d..7813d51626d 100644 --- a/lib/puppet/provider/user/user_role_add.rb +++ b/lib/puppet/provider/user/user_role_add.rb @@ -6,7 +6,7 @@ desc "User and role management on Solaris, via `useradd` and `roleadd`." - defaultfor :osfamily => :solaris + defaultfor 'os.family' => :solaris commands :add => "useradd", :delete => "userdel", :modify => "usermod", :password => "passwd", :role_add => "roleadd", :role_delete => "roledel", :role_modify => "rolemod" options :home, :flag => "-d", :method => :dir diff --git a/lib/puppet/provider/user/useradd.rb b/lib/puppet/provider/user/useradd.rb index 616cf7b269a..3cbd00b6b01 100644 --- a/lib/puppet/provider/user/useradd.rb +++ b/lib/puppet/provider/user/useradd.rb @@ -24,13 +24,13 @@ options :expiry, :method => :sp_expire, :munge => proc { |value| if value == :absent - if Puppet.runtime[:facter].value(:operatingsystem)=='SLES' && Puppet.runtime[:facter].value(:operatingsystemmajrelease) == "11" + if Puppet.runtime[:facter].value('os.name')=='SLES' && Puppet.runtime[:facter].value('os.release.major') == "11" -1 else '' end else - case Puppet.runtime[:facter].value(:operatingsystem) + case Puppet.runtime[:facter].value('os.name') when 'Solaris' # Solaris uses %m/%d/%Y for useradd/usermod expiry_year, expiry_month, expiry_day = value.split('-') @@ -216,7 +216,7 @@ def password=(value) end has_features :manages_homedir, :allows_duplicates, :manages_expiry - has_features :system_users unless %w{HP-UX Solaris}.include? Puppet.runtime[:facter].value(:operatingsystem) + has_features :system_users unless %w{HP-UX Solaris}.include? Puppet.runtime[:facter].value('os.name') has_features :manages_passwords, :manages_password_age if Puppet.features.libshadow? has_features :manages_shell @@ -251,8 +251,8 @@ def check_manage_home # libuser does not implement the -m flag cmd << "-m" unless @resource.forcelocal? else - osfamily = Puppet.runtime[:facter].value(:osfamily) - osversion = Puppet.runtime[:facter].value(:operatingsystemmajrelease).to_i + osfamily = Puppet.runtime[:facter].value('os.family') + osversion = Puppet.runtime[:facter].value('os.release.major').to_i # SLES 11 uses pwdutils instead of shadow, which does not have -M # Solaris and OpenBSD use different useradd flavors unless osfamily =~ /Solaris|OpenBSD/ || osfamily == 'Suse' && osversion <= 11 @@ -350,7 +350,7 @@ def deletecmd cmd = [command(:delete)] end # Solaris `userdel -r` will fail if the homedir does not exist. - if @resource.managehome? && (('Solaris' != Puppet.runtime[:facter].value(:operatingsystem)) || Dir.exist?(Dir.home(@resource[:name]))) + if @resource.managehome? && (('Solaris' != Puppet.runtime[:facter].value('os.name')) || Dir.exist?(Dir.home(@resource[:name]))) cmd << '-r' end cmd << @resource[:name] diff --git a/lib/puppet/provider/user/windows_adsi.rb b/lib/puppet/provider/user/windows_adsi.rb index a584f05bdd2..bdf17a2ff18 100644 --- a/lib/puppet/provider/user/windows_adsi.rb +++ b/lib/puppet/provider/user/windows_adsi.rb @@ -3,8 +3,8 @@ Puppet::Type.type(:user).provide :windows_adsi do desc "Local user management for Windows." - defaultfor :operatingsystem => :windows - confine :operatingsystem => :windows + defaultfor 'os.name' => :windows + confine 'os.name' => :windows has_features :manages_homedir, :manages_passwords, :manages_roles diff --git a/lib/puppet/reference/providers.rb b/lib/puppet/reference/providers.rb index dac0f9d18b0..9c5943bb7ce 100644 --- a/lib/puppet/reference/providers.rb +++ b/lib/puppet/reference/providers.rb @@ -13,11 +13,10 @@ ret = "Details about this host:\n\n" # Throw some facts in there, so we know where the report is from. - ["Ruby Version", "Puppet Version", "Operating System", "Operating System Release"].each do |label| - name = label.gsub(/\s+/, '') - value = Puppet.runtime[:facter].value(name) - ret << option(label, value) - end + ret << option('Ruby Version', Facter.value('ruby.version')) + ret << option('Puppet Version', Facter.value('puppetversion')) + ret << option('Operating System', Facter.value('os.name')) + ret << option('Operating System Release', Facter.value('os.release.full')) ret << "\n" count = 1 diff --git a/lib/puppet/settings.rb b/lib/puppet/settings.rb index 7136e742bc1..96a7364ac07 100644 --- a/lib/puppet/settings.rb +++ b/lib/puppet/settings.rb @@ -79,11 +79,11 @@ def self.default_certname() end def self.hostname_fact() - Puppet.runtime[:facter].value :hostname + Puppet.runtime[:facter].value 'networking.hostname' end def self.domain_fact() - Puppet.runtime[:facter].value :domain + Puppet.runtime[:facter].value 'networking.domain' end def self.default_config_file_name diff --git a/lib/puppet/type.rb b/lib/puppet/type.rb index b0f0091dde4..7b3c8e66ab0 100644 --- a/lib/puppet/type.rb +++ b/lib/puppet/type.rb @@ -1374,7 +1374,7 @@ def properties_to_audit(list) provide a symbolic title and an explicit namevar value: file { 'sshdconfig': - path => $operatingsystem ? { + path => $os['name'] ? { solaris => '/usr/local/etc/ssh/sshd_config', default => '/etc/ssh/sshd_config', }, diff --git a/lib/puppet/type/file/source.rb b/lib/puppet/type/file/source.rb index e59c4a2ab20..4b277031927 100644 --- a/lib/puppet/type/file/source.rb +++ b/lib/puppet/type/file/source.rb @@ -72,7 +72,7 @@ module Puppet file { '/etc/nfs.conf': source => [ "puppet:///modules/nfs/conf.${host}", - "puppet:///modules/nfs/conf.${operatingsystem}", + "puppet:///modules/nfs/conf.${os['name']}", 'puppet:///modules/nfs/conf' ] } diff --git a/lib/puppet/type/package.rb b/lib/puppet/type/package.rb index 2af6b4a45d3..1a52a2b03ac 100644 --- a/lib/puppet/type/package.rb +++ b/lib/puppet/type/package.rb @@ -242,7 +242,7 @@ def change_to_s(currentvalue, newvalue) conditionally: # In the 'openssl' class - $ssl = $operatingsystem ? { + $ssl = $os['name'] ? { solaris => SMCossl, default => openssl } @@ -254,7 +254,7 @@ def change_to_s(currentvalue, newvalue) ... - $ssh = $operatingsystem ? { + $ssh = $os['name'] ? { solaris => SMCossh, default => openssh } diff --git a/lib/puppet/type/resources.rb b/lib/puppet/type/resources.rb index 0aef31c92a7..257ea1b7c88 100644 --- a/lib/puppet/type/resources.rb +++ b/lib/puppet/type/resources.rb @@ -170,7 +170,7 @@ def self.system_users_max_uid end # Otherwise, use a sensible default based on the OS family - @system_users_max_uid ||= case Puppet.runtime[:facter].value(:osfamily) + @system_users_max_uid ||= case Puppet.runtime[:facter].value('os.family') when 'OpenBSD', 'FreeBSD' 999 else diff --git a/lib/puppet/util/filetype.rb b/lib/puppet/util/filetype.rb index e0d24197d1a..298c17711e1 100644 --- a/lib/puppet/util/filetype.rb +++ b/lib/puppet/util/filetype.rb @@ -215,7 +215,7 @@ def read # Remove a specific @path's cron tab. def remove cmd = "#{cmdbase} -r" - if %w{Darwin FreeBSD DragonFly}.include?(Puppet.runtime[:facter].value("operatingsystem")) + if %w{Darwin FreeBSD DragonFly}.include?(Puppet.runtime[:facter].value('os.name')) cmd = "/bin/echo yes | #{cmd}" end @@ -244,7 +244,7 @@ def write(text) # Only add the -u flag when the @path is different. Fedora apparently # does not think I should be allowed to set the @path to my own user name def cmdbase - if @uid == Puppet::Util::SUIDManager.uid || Puppet.runtime[:facter].value(:operatingsystem) == "HP-UX" + if @uid == Puppet::Util::SUIDManager.uid || Puppet.runtime[:facter].value('os.name') == "HP-UX" return "crontab" else return "crontab -u #{@path}" diff --git a/lib/puppet/util/suidmanager.rb b/lib/puppet/util/suidmanager.rb index 45703baa4df..12d6440c662 100644 --- a/lib/puppet/util/suidmanager.rb +++ b/lib/puppet/util/suidmanager.rb @@ -17,7 +17,7 @@ module Puppet::Util::SUIDManager def osx_maj_ver return @osx_maj_ver unless @osx_maj_ver.nil? - @osx_maj_ver = Puppet.runtime[:facter].value('macosx_productversion_major') || false + @osx_maj_ver = Puppet.runtime[:facter].value('os.macosx.version.major') || false end module_function :osx_maj_ver diff --git a/spec/fixtures/releases/jamtur01-apache/lib/puppet/provider/a2mod/debian.rb b/spec/fixtures/releases/jamtur01-apache/lib/puppet/provider/a2mod/debian.rb index 9d8c12983f4..a4c5400146f 100644 --- a/spec/fixtures/releases/jamtur01-apache/lib/puppet/provider/a2mod/debian.rb +++ b/spec/fixtures/releases/jamtur01-apache/lib/puppet/provider/a2mod/debian.rb @@ -4,7 +4,7 @@ commands :encmd => "a2enmod" commands :discmd => "a2dismod" - defaultfor :operatingsystem => [:debian, :ubuntu] + defaultfor 'os.name' => [:debian, :ubuntu] def create encmd resource[:name] diff --git a/spec/fixtures/releases/jamtur01-apache/manifests/init.pp b/spec/fixtures/releases/jamtur01-apache/manifests/init.pp index bd3f7bae145..1725650f8c1 100644 --- a/spec/fixtures/releases/jamtur01-apache/manifests/init.pp +++ b/spec/fixtures/releases/jamtur01-apache/manifests/init.pp @@ -21,7 +21,7 @@ 'headers' : ensure => present; 'expires' : ensure => present; } - $vdir = $operatingsystem? { + $vdir = $os['name'] ? { 'ubuntu' => '/etc/apache2/sites-enabled/', default => '/etc/httpd/conf.d', } diff --git a/spec/fixtures/releases/jamtur01-apache/manifests/params.pp b/spec/fixtures/releases/jamtur01-apache/manifests/params.pp index 520eccb448d..9ec205a10bb 100644 --- a/spec/fixtures/releases/jamtur01-apache/manifests/params.pp +++ b/spec/fixtures/releases/jamtur01-apache/manifests/params.pp @@ -2,7 +2,7 @@ $user = 'www-data' $group = 'www-data' - case $operatingsystem { + case $os['name'] { "centos": { $apache_name = httpd $ssl_package = mod_ssl diff --git a/spec/fixtures/releases/jamtur01-apache/manifests/ssl.pp b/spec/fixtures/releases/jamtur01-apache/manifests/ssl.pp index 349f92288a7..a94b7fab548 100644 --- a/spec/fixtures/releases/jamtur01-apache/manifests/ssl.pp +++ b/spec/fixtures/releases/jamtur01-apache/manifests/ssl.pp @@ -2,7 +2,7 @@ include apache - case $operatingsystem { + case $facts['os']['name'] { "centos": { package { $apache::params::ssl_package: require => Package['httpd'], diff --git a/spec/fixtures/releases/jamtur01-apache/manifests/vhost.pp b/spec/fixtures/releases/jamtur01-apache/manifests/vhost.pp index a210f35570f..1a71aad5265 100644 --- a/spec/fixtures/releases/jamtur01-apache/manifests/vhost.pp +++ b/spec/fixtures/releases/jamtur01-apache/manifests/vhost.pp @@ -1,6 +1,6 @@ define apache::vhost( $port, $docroot, $ssl=true, $template='apache/vhost-default.conf.erb', $priority, $serveraliases = '' ) { include apache - $vdir = $operatingsystem? { + $vdir = $os['name']? { 'ubuntu' => '/etc/apache2/sites-enabled/', default => '/etc/httpd/conf.d', } diff --git a/spec/integration/type/file_spec.rb b/spec/integration/type/file_spec.rb index b1b140e462a..68849d99a06 100644 --- a/spec/integration/type/file_spec.rb +++ b/spec/integration/type/file_spec.rb @@ -1710,11 +1710,11 @@ def grant_everyone_full_access(path) describe "when using validate_cmd" do test_cmd = '/bin/test' - if Puppet.runtime[:facter].value(:osfamily) == 'Debian' + if Puppet.runtime[:facter].value('os.family') == 'Debian' test_cmd = '/usr/bin/test' end - if Puppet.runtime[:facter].value(:operatingsystem) == 'Darwin' + if Puppet.runtime[:facter].value('os.name') == 'Darwin' stat_cmd = "stat -f '%Lp'" else stat_cmd = "stat --format=%a" diff --git a/spec/integration/type/package_spec.rb b/spec/integration/type/package_spec.rb index 00fbaa1fb90..c4ae05f4f93 100644 --- a/spec/integration/type/package_spec.rb +++ b/spec/integration/type/package_spec.rb @@ -21,19 +21,19 @@ def provider_name(os) when 'Darwin' :pkgdmg when 'RedHat' - if ['2.1', '3', '4'].include?(Puppet.runtime[:facter].value(:lsbdistrelease)) + if ['2.1', '3', '4'].include?(Puppet.runtime[:facter].value('os.distro.release.full')) :up2date else :yum end when 'Fedora' - if Puppet::Util::Package.versioncmp(Puppet.runtime[:facter].value(:operatingsystemmajrelease), '22') >= 0 + if Puppet::Util::Package.versioncmp(Puppet.runtime[:facter].value('os.release.major'), '22') >= 0 :dnf else :yum end when 'Suse' - if Puppet::Util::Package.versioncmp(Puppet.runtime[:facter].value(:operatingsystemmajrelease), '10') >= 0 + if Puppet::Util::Package.versioncmp(Puppet.runtime[:facter].value('os.release.major'), '10') >= 0 :zypper else :rug @@ -54,8 +54,8 @@ def provider_name(os) end it "should choose the correct provider each platform" do - unless default_provider = provider_name(Puppet.runtime[:facter].value(:operatingsystem)) - pending("No default provider specified in this test for #{Puppet.runtime[:facter].value(:operatingsystem)}") + unless default_provider = provider_name(Puppet.runtime[:facter].value('os.name')) + pending("No default provider specified in this test for #{Puppet.runtime[:facter].value('os.name')}") end expect(Puppet::Type.type(:package).defaultprovider.name).to eq(default_provider) end diff --git a/spec/shared_examples/rhel_package_provider.rb b/spec/shared_examples/rhel_package_provider.rb index 06f39e0e2ca..28486b9c729 100644 --- a/spec/shared_examples/rhel_package_provider.rb +++ b/spec/shared_examples/rhel_package_provider.rb @@ -69,7 +69,7 @@ allow(Puppet::Util).to receive(:which).with("rpm").and_return("/bin/rpm") allow(provider).to receive(:which).with("rpm").and_return("/bin/rpm") expect(Puppet::Util::Execution).to receive(:execute).with(["/bin/rpm", "--version"], {:combine => true, :custom_environment => {}, :failonfail => true}).and_return(Puppet::Util::Execution::ProcessOutput.new("4.10.1\n", 0)).at_most(:once) - allow(Facter).to receive(:value).with(:operatingsystemmajrelease).and_return('6') + allow(Facter).to receive(:value).with('os.release.major').and_return('6') end it "should call #{provider_name} install for :installed" do @@ -81,7 +81,7 @@ if provider_name == 'yum' context 'on el-5' do before(:each) do - allow(Facter).to receive(:value).with(:operatingsystemmajrelease).and_return('5') + allow(Facter).to receive(:value).with('os.release.major').and_return('5') end it "should catch #{provider_name} install failures when status code is wrong" do diff --git a/spec/unit/application/device_spec.rb b/spec/unit/application/device_spec.rb index a9a1882ec5a..5a31671c050 100644 --- a/spec/unit/application/device_spec.rb +++ b/spec/unit/application/device_spec.rb @@ -482,10 +482,10 @@ end it "retrieves facts" do - indirection_fact_values = {"operatingsystem"=>"cisco_ios","clientcert"=>"3750"} + indirection_fact_values = {"os"=> {"name" => "cisco_ios"},"clientcert"=>"3750"} indirection_facts = Puppet::Node::Facts.new("nil", indirection_fact_values) expect(Puppet::Node::Facts.indirection).to receive(:find).with(nil, anything()).and_return(indirection_facts) - expect(device).to receive(:puts).with(/name.*3750.*\n.*values.*\n.*operatingsystem.*cisco_ios/) + expect(device).to receive(:puts).with(/name.*3750.*\n.*values.*\n.*os.*\n.*name.*cisco_ios/) expect { device.main }.to exit_with 0 end end diff --git a/spec/unit/confine_spec.rb b/spec/unit/confine_spec.rb index ddff0fc03bb..1df5bdab000 100644 --- a/spec/unit/confine_spec.rb +++ b/spec/unit/confine_spec.rb @@ -84,16 +84,16 @@ def pass?(value) describe "when requiring" do it "does not cache failed requires when always_retry_plugins is true" do Puppet[:always_retry_plugins] = true - expect(Puppet::Confine).to receive(:require).with('puppet/confine/osfamily').twice.and_raise(LoadError) - Puppet::Confine.test(:osfamily) - Puppet::Confine.test(:osfamily) + expect(Puppet::Confine).to receive(:require).with('puppet/confine/os.family').twice.and_raise(LoadError) + Puppet::Confine.test('os.family') + Puppet::Confine.test('os.family') end it "caches failed requires when always_retry_plugins is false" do Puppet[:always_retry_plugins] = false - expect(Puppet::Confine).to receive(:require).with('puppet/confine/osfamily').once.and_raise(LoadError) - Puppet::Confine.test(:osfamily) - Puppet::Confine.test(:osfamily) + expect(Puppet::Confine).to receive(:require).with('puppet/confine/os.family').once.and_raise(LoadError) + Puppet::Confine.test('os.family') + Puppet::Confine.test('os.family') end end end diff --git a/spec/unit/face/epp_face_spec.rb b/spec/unit/face/epp_face_spec.rb index d7f461df6d6..c12a59362ad 100644 --- a/spec/unit/face/epp_face_spec.rb +++ b/spec/unit/face/epp_face_spec.rb @@ -311,8 +311,8 @@ it "facts can be overridden" do expect(eppface.render({ - :facts => {'operatingsystem' => 'Merwin'}, - :e => '<%= $facts[operatingsystem] %>', + :facts => {'os' => {'name' => 'Merwin'} }, + :e => '<%= $facts[os][name] %>', })).to eql("Merwin") end diff --git a/spec/unit/file_bucket/dipper_spec.rb b/spec/unit/file_bucket/dipper_spec.rb index 3de6f4e5601..bed4481f834 100644 --- a/spec/unit/file_bucket/dipper_spec.rb +++ b/spec/unit/file_bucket/dipper_spec.rb @@ -104,8 +104,8 @@ def make_tmp_file(contents) # Diff without the context # Lines we need to see match 'Content' instead of trimming diff output filter out # surrounding noise...or hard code the check values - if Puppet.runtime[:facter].value(:osfamily) == 'Solaris' && - Puppet::Util::Package.versioncmp(Puppet.runtime[:facter].value(:operatingsystemrelease), '11.0') >= 0 + if Puppet.runtime[:facter].value('os.family') == 'Solaris' && + Puppet::Util::Package.versioncmp(Puppet.runtime[:facter].value('os.release.full'), '11.0') >= 0 # Use gdiff on Solaris diff12 = Puppet::Util::Execution.execute("gdiff -uN #{file1} #{file2}| grep Content") diff21 = Puppet::Util::Execution.execute("gdiff -uN #{file2} #{file1}| grep Content") diff --git a/spec/unit/file_serving/mount/file_spec.rb b/spec/unit/file_serving/mount/file_spec.rb index 74a7f7c61f3..7c9dd5ffafa 100644 --- a/spec/unit/file_serving/mount/file_spec.rb +++ b/spec/unit/file_serving/mount/file_spec.rb @@ -3,8 +3,8 @@ module FileServingMountTesting def stub_facter(hostname) - allow(Facter).to receive(:value).with("hostname").and_return(hostname.sub(/\..+/, '')) - allow(Facter).to receive(:value).with("domain").and_return(hostname.sub(/^[^.]+\./, '')) + allow(Facter).to receive(:value).with("networking.hostname").and_return(hostname.sub(/\..+/, '')) + allow(Facter).to receive(:value).with("networking.domain").and_return(hostname.sub(/^[^.]+\./, '')) end end diff --git a/spec/unit/indirector/catalog/compiler_spec.rb b/spec/unit/indirector/catalog/compiler_spec.rb index e4d10dd2863..8042f2dc65f 100644 --- a/spec/unit/indirector/catalog/compiler_spec.rb +++ b/spec/unit/indirector/catalog/compiler_spec.rb @@ -432,9 +432,9 @@ def a_request_that_contains(facts) before do allow(Puppet).to receive(:version).and_return(1) set_facts({ - 'fqdn' => "my.server.com", - 'ipaddress' => "my.ip.address", - 'ipaddress6' => nil + 'networking.fqdn' => "my.server.com", + 'networking.ip' => "my.ip.address", + 'networking.ip6' => nil }) @request = Puppet::Indirector::Request.new(:catalog, :find, node_name, nil) allow(compiler).to receive(:compile) @@ -467,16 +467,16 @@ def a_request_that_contains(facts) before do |example| allow(Puppet).to receive(:version).and_return(1) set_facts({ - 'fqdn' => "my.server.com", - 'ipaddress' => nil, + 'networking.fqdn' => "my.server.com", + 'networking.ip' => nil, }) if example.metadata[:nil_ipv6] set_facts({ - 'ipaddress6' => nil + 'networking.ip6' => nil }) else set_facts({ - 'ipaddress6' => "my.ipv6.address" + 'networking.ip6' => "my.ipv6.address" }) end @request = Puppet::Indirector::Request.new(:catalog, :find, node_name, nil) diff --git a/spec/unit/module_tool/tar_spec.rb b/spec/unit/module_tool/tar_spec.rb index 94fd04927d6..710950a8261 100644 --- a/spec/unit/module_tool/tar_spec.rb +++ b/spec/unit/module_tool/tar_spec.rb @@ -7,7 +7,7 @@ { :name => 'Windows', :win => true } ].each do |os| it "always prefers minitar if it and zlib are present, even with tar available" do - allow(Facter).to receive(:value).with('osfamily').and_return(os[:name]) + allow(Facter).to receive(:value).with('os.family').and_return(os[:name]) allow(Puppet::Util).to receive(:which).with('tar').and_return('/usr/bin/tar') allow(Puppet::Util::Platform).to receive(:windows?).and_return(os[:win]) allow(Puppet).to receive(:features).and_return(double(:minitar? => true, :zlib? => true)) @@ -17,7 +17,7 @@ end it "falls back to tar when minitar not present and not on Windows" do - allow(Facter).to receive(:value).with('osfamily').and_return('ObscureLinuxDistro') + allow(Facter).to receive(:value).with('os.family').and_return('ObscureLinuxDistro') allow(Puppet::Util).to receive(:which).with('tar').and_return('/usr/bin/tar') allow(Puppet::Util::Platform).to receive(:windows?).and_return(false) allow(Puppet).to receive(:features).and_return(double(:minitar? => false)) @@ -26,7 +26,7 @@ end it "fails when there is no possible implementation" do - allow(Facter).to receive(:value).with('osfamily').and_return('Windows') + allow(Facter).to receive(:value).with('os.family').and_return('Windows') allow(Puppet::Util).to receive(:which).with('tar') allow(Puppet::Util::Platform).to receive(:windows?).and_return(true) allow(Puppet).to receive(:features).and_return(double(:minitar? => false, :zlib? => false)) diff --git a/spec/unit/pops/serialization/serialization_spec.rb b/spec/unit/pops/serialization/serialization_spec.rb index 2d54886b826..ddf146b772c 100644 --- a/spec/unit/pops/serialization/serialization_spec.rb +++ b/spec/unit/pops/serialization/serialization_spec.rb @@ -298,7 +298,7 @@ def parse(string) it 'nested Expression' do expr = parse(<<-CODE) - $rootgroup = $osfamily ? { + $rootgroup = $os['family'] ? { 'Solaris' => 'wheel', /(Darwin|FreeBSD)/ => 'wheel', default => 'root', @@ -435,7 +435,7 @@ def _pcore_init_hash it 'can write and read an AST expression' do expr = parse(<<-CODE) - $rootgroup = $osfamily ? { + $rootgroup = $os['family'] ? { 'Solaris' => 'wheel', /(Darwin|FreeBSD)/ => 'wheel', default => 'root', diff --git a/spec/unit/pops/serialization/to_from_hr_spec.rb b/spec/unit/pops/serialization/to_from_hr_spec.rb index 1f803d39944..5ef2777083c 100644 --- a/spec/unit/pops/serialization/to_from_hr_spec.rb +++ b/spec/unit/pops/serialization/to_from_hr_spec.rb @@ -344,7 +344,7 @@ def parse(string) it 'nested Expression' do expr = parse(<<-CODE) - $rootgroup = $osfamily ? { + $rootgroup = $os['family'] ? { 'Solaris' => 'wheel', /(Darwin|FreeBSD)/ => 'wheel', default => 'root', diff --git a/spec/unit/provider/package/apt_spec.rb b/spec/unit/provider/package/apt_spec.rb index bb9e179895c..e731d9b5643 100644 --- a/spec/unit/provider/package/apt_spec.rb +++ b/spec/unit/provider/package/apt_spec.rb @@ -14,8 +14,8 @@ resource.provider end - it "should be the default provider on :osfamily => Debian" do - expect(Facter).to receive(:value).with(:osfamily).and_return("Debian") + it "should be the default provider on 'os.family' => Debian" do + expect(Facter).to receive(:value).with('os.family').and_return("Debian") expect(described_class.default?).to be_truthy end diff --git a/spec/unit/provider/package/dnf_spec.rb b/spec/unit/provider/package/dnf_spec.rb index 9a4e9b8b3c9..a95a6012303 100644 --- a/spec/unit/provider/package/dnf_spec.rb +++ b/spec/unit/provider/package/dnf_spec.rb @@ -6,40 +6,40 @@ context 'default' do (19..21).each do |ver| it "should not be the default provider on fedora#{ver}" do - allow(Facter).to receive(:value).with(:osfamily).and_return(:redhat) - allow(Facter).to receive(:value).with(:operatingsystem).and_return(:fedora) - allow(Facter).to receive(:value).with(:operatingsystemmajrelease).and_return("#{ver}") + allow(Facter).to receive(:value).with('os.family').and_return(:redhat) + allow(Facter).to receive(:value).with('os.name').and_return(:fedora) + allow(Facter).to receive(:value).with('os.release.major').and_return("#{ver}") expect(described_class).to_not be_default end end (22..26).each do |ver| it "should be the default provider on fedora#{ver}" do - allow(Facter).to receive(:value).with(:osfamily).and_return(:redhat) - allow(Facter).to receive(:value).with(:operatingsystem).and_return(:fedora) - allow(Facter).to receive(:value).with(:operatingsystemmajrelease).and_return("#{ver}") + allow(Facter).to receive(:value).with('os.family').and_return(:redhat) + allow(Facter).to receive(:value).with('os.name').and_return(:fedora) + allow(Facter).to receive(:value).with('os.release.major').and_return("#{ver}") expect(described_class).to be_default end end it "should not be the default provider on rhel7" do - allow(Facter).to receive(:value).with(:osfamily).and_return(:redhat) - allow(Facter).to receive(:value).with(:operatingsystem).and_return(:redhat) - allow(Facter).to receive(:value).with(:operatingsystemmajrelease).and_return("7") + allow(Facter).to receive(:value).with('os.family').and_return(:redhat) + allow(Facter).to receive(:value).with('os.name').and_return(:redhat) + allow(Facter).to receive(:value).with('os.release.major').and_return("7") expect(described_class).to_not be_default end it "should be the default provider on some random future fedora" do - allow(Facter).to receive(:value).with(:osfamily).and_return(:redhat) - allow(Facter).to receive(:value).with(:operatingsystem).and_return(:fedora) - allow(Facter).to receive(:value).with(:operatingsystemmajrelease).and_return("8675") + allow(Facter).to receive(:value).with('os.family').and_return(:redhat) + allow(Facter).to receive(:value).with('os.name').and_return(:fedora) + allow(Facter).to receive(:value).with('os.release.major').and_return("8675") expect(described_class).to be_default end it "should be the default provider on rhel8" do - allow(Facter).to receive(:value).with(:osfamily).and_return(:redhat) - allow(Facter).to receive(:value).with(:operatingsystem).and_return(:redhat) - allow(Facter).to receive(:value).with(:operatingsystemmajrelease).and_return("8") + allow(Facter).to receive(:value).with('os.family').and_return(:redhat) + allow(Facter).to receive(:value).with('os.name').and_return(:redhat) + allow(Facter).to receive(:value).with('os.release.major').and_return("8") expect(described_class).to be_default end end diff --git a/spec/unit/provider/package/dnfmodule_spec.rb b/spec/unit/provider/package/dnfmodule_spec.rb index cdb90e7550a..5dc8f9d756c 100644 --- a/spec/unit/provider/package/dnfmodule_spec.rb +++ b/spec/unit/provider/package/dnfmodule_spec.rb @@ -24,18 +24,18 @@ before(:each) { allow(Puppet::Util).to receive(:which).with('/usr/bin/dnf').and_return(dnf_path) } it "should have lower specificity" do - allow(Facter).to receive(:value).with(:osfamily).and_return(:redhat) - allow(Facter).to receive(:value).with(:operatingsystem).and_return(:redhat) - allow(Facter).to receive(:value).with(:operatingsystemmajrelease).and_return('8') + allow(Facter).to receive(:value).with('os.family').and_return(:redhat) + allow(Facter).to receive(:value).with('os.name').and_return(:redhat) + allow(Facter).to receive(:value).with('os.release.major').and_return('8') expect(described_class.specificity).to be < 200 end describe "should be an opt-in provider" do Array(4..8).each do |ver| it "should not be default for redhat #{ver}" do - allow(Facter).to receive(:value).with(:operatingsystem).and_return('redhat') - allow(Facter).to receive(:value).with(:osfamily).and_return('redhat') - allow(Facter).to receive(:value).with(:operatingsystemmajrelease).and_return(ver.to_s) + allow(Facter).to receive(:value).with('os.name').and_return('redhat') + allow(Facter).to receive(:value).with('os.family').and_return('redhat') + allow(Facter).to receive(:value).with('os.release.major').and_return(ver.to_s) expect(described_class).not_to be_default end end diff --git a/spec/unit/provider/package/gem_spec.rb b/spec/unit/provider/package/gem_spec.rb index 0c0c9fd3f7a..3dd09700a16 100644 --- a/spec/unit/provider/package/gem_spec.rb +++ b/spec/unit/provider/package/gem_spec.rb @@ -476,9 +476,9 @@ end context 'when is defaultfor' do - let(:os) { Puppet.runtime[:facter].value(:operatingsystem) } + let(:os) { Puppet.runtime[:facter].value('os.name') } subject do - described_class.defaultfor(operatingsystem: os) + described_class.defaultfor('os.name': os) described_class.specificity end it { is_expected.to be > 100 } diff --git a/spec/unit/provider/package/pip2_spec.rb b/spec/unit/provider/package/pip2_spec.rb index 473114b8ec3..9471482d23b 100644 --- a/spec/unit/provider/package/pip2_spec.rb +++ b/spec/unit/provider/package/pip2_spec.rb @@ -26,9 +26,9 @@ end context 'when is defaultfor' do - let(:os) { Puppet.runtime[:facter].value(:operatingsystem) } + let(:os) { Puppet.runtime[:facter].value('os.name') } subject do - described_class.defaultfor(operatingsystem: os) + described_class.defaultfor('os.name': os) described_class.specificity end it { is_expected.to be > 100 } diff --git a/spec/unit/provider/package/pip3_spec.rb b/spec/unit/provider/package/pip3_spec.rb index bb792b2b1c4..49bdc22eda1 100644 --- a/spec/unit/provider/package/pip3_spec.rb +++ b/spec/unit/provider/package/pip3_spec.rb @@ -26,9 +26,9 @@ end context 'when is defaultfor' do - let(:os) { Puppet.runtime[:facter].value(:operatingsystem) } + let(:os) { Puppet.runtime[:facter].value('os.name') } subject do - described_class.defaultfor(operatingsystem: os) + described_class.defaultfor('os.name': os) described_class.specificity end it { is_expected.to be > 100 } diff --git a/spec/unit/provider/package/pip_spec.rb b/spec/unit/provider/package/pip_spec.rb index c16c4953cac..f57d9ffab62 100644 --- a/spec/unit/provider/package/pip_spec.rb +++ b/spec/unit/provider/package/pip_spec.rb @@ -493,9 +493,9 @@ end context 'when is defaultfor' do - let(:os) { Puppet.runtime[:facter].value(:operatingsystem) } + let(:os) { Puppet.runtime[:facter].value('os.name') } subject do - described_class.defaultfor(operatingsystem: os) + described_class.defaultfor('os.name': os) described_class.specificity end it { is_expected.to be > 100 } diff --git a/spec/unit/provider/package/pkg_spec.rb b/spec/unit/provider/package/pkg_spec.rb index b2345387b3a..588f2574738 100644 --- a/spec/unit/provider/package/pkg_spec.rb +++ b/spec/unit/provider/package/pkg_spec.rb @@ -21,20 +21,20 @@ def self.it_should_respond_to(*actions) context 'default' do [ 10 ].each do |ver| it "should not be the default provider on Solaris #{ver}" do - allow(Facter).to receive(:value).with(:osfamily).and_return(:Solaris) + allow(Facter).to receive(:value).with('os.family').and_return(:Solaris) allow(Facter).to receive(:value).with(:kernelrelease).and_return("5.#{ver}") - allow(Facter).to receive(:value).with(:operatingsystem).and_return(:Solaris) - allow(Facter).to receive(:value).with(:operatingsystemmajrelease).and_return("#{ver}") + allow(Facter).to receive(:value).with('os.name').and_return(:Solaris) + allow(Facter).to receive(:value).with('os.release.major').and_return("#{ver}") expect(described_class).to_not be_default end end [ 11, 12 ].each do |ver| it "should be the default provider on Solaris #{ver}" do - allow(Facter).to receive(:value).with(:osfamily).and_return(:Solaris) + allow(Facter).to receive(:value).with('os.family').and_return(:Solaris) allow(Facter).to receive(:value).with(:kernelrelease).and_return("5.#{ver}") - allow(Facter).to receive(:value).with(:operatingsystem).and_return(:Solaris) - allow(Facter).to receive(:value).with(:operatingsystemmajrelease).and_return("#{ver}") + allow(Facter).to receive(:value).with('os.name').and_return(:Solaris) + allow(Facter).to receive(:value).with('os.release.major').and_return("#{ver}") expect(described_class).to be_default end end @@ -240,9 +240,9 @@ def self.it_should_respond_to(*actions) { :osrel => '11.0', :flags => ['--accept'] }, { :osrel => '11.2', :flags => ['--accept', '--sync-actuators-timeout', '900'] }, ].each do |hash| - context "with :operatingsystemrelease #{hash[:osrel]}" do + context "with 'os.release.full' #{hash[:osrel]}" do before :each do - allow(Facter).to receive(:value).with(:operatingsystemrelease).and_return(hash[:osrel]) + allow(Facter).to receive(:value).with('os.release.full').and_return(hash[:osrel]) end it "should support install options" do diff --git a/spec/unit/provider/package/pkgng_spec.rb b/spec/unit/provider/package/pkgng_spec.rb index bacfafe688c..9d9b5d2973e 100644 --- a/spec/unit/provider/package/pkgng_spec.rb +++ b/spec/unit/provider/package/pkgng_spec.rb @@ -220,7 +220,7 @@ def run_in_catalog(*resources) describe "confine" do context "on FreeBSD" do it "should be the default provider" do - expect(Facter).to receive(:value).with(:operatingsystem).at_least(:once).and_return(:freebsd) + expect(Facter).to receive(:value).with('os.name').at_least(:once).and_return(:freebsd) expect(described_class).to be_default end end diff --git a/spec/unit/provider/package/portage_spec.rb b/spec/unit/provider/package/portage_spec.rb index 114546f8a4f..a8c309f93d3 100644 --- a/spec/unit/provider/package/portage_spec.rb +++ b/spec/unit/provider/package/portage_spec.rb @@ -72,8 +72,8 @@ expect(described_class).to be_reinstallable end - it "should be the default provider on :osfamily => Gentoo" do - expect(Facter).to receive(:value).with(:osfamily).and_return("Gentoo") + it "should be the default provider on 'os.family' => Gentoo" do + expect(Facter).to receive(:value).with('os.family').and_return("Gentoo") expect(described_class.default?).to be_truthy end diff --git a/spec/unit/provider/package/puppet_gem_spec.rb b/spec/unit/provider/package/puppet_gem_spec.rb index 681bf20f12d..065800c2b2b 100644 --- a/spec/unit/provider/package/puppet_gem_spec.rb +++ b/spec/unit/provider/package/puppet_gem_spec.rb @@ -118,9 +118,9 @@ end context 'when is defaultfor' do - let(:os) { Puppet.runtime[:facter].value(:operatingsystem) } + let(:os) { Puppet.runtime[:facter].value('os.name') } subject do - described_class.defaultfor(operatingsystem: os) + described_class.defaultfor('os.name': os) described_class.specificity end it { is_expected.to be > 100 } diff --git a/spec/unit/provider/package/puppetserver_gem_spec.rb b/spec/unit/provider/package/puppetserver_gem_spec.rb index 170877b8a79..da4b9082784 100644 --- a/spec/unit/provider/package/puppetserver_gem_spec.rb +++ b/spec/unit/provider/package/puppetserver_gem_spec.rb @@ -127,9 +127,9 @@ end context 'when is defaultfor' do - let(:os) { Puppet.runtime[:facter].value(:operatingsystem) } + let(:os) { Puppet.runtime[:facter].value('os.name') } subject do - described_class.defaultfor(operatingsystem: os) + described_class.defaultfor('os.name': os) described_class.specificity end it { is_expected.to be > 100 } diff --git a/spec/unit/provider/package/tdnf_spec.rb b/spec/unit/provider/package/tdnf_spec.rb index 7f715b163d2..36e08a8425c 100644 --- a/spec/unit/provider/package/tdnf_spec.rb +++ b/spec/unit/provider/package/tdnf_spec.rb @@ -7,8 +7,8 @@ context 'default' do it 'should be the default provider on PhotonOS' do - allow(Facter).to receive(:value).with(:osfamily).and_return(:redhat) - allow(Facter).to receive(:value).with(:operatingsystem).and_return("PhotonOS") + allow(Facter).to receive(:value).with('os.family').and_return(:redhat) + allow(Facter).to receive(:value).with('os.name').and_return("PhotonOS") expect(described_class).to be_default end end diff --git a/spec/unit/provider/package/up2date_spec.rb b/spec/unit/provider/package/up2date_spec.rb index 72bce2f5d28..a23ba9d4b50 100644 --- a/spec/unit/provider/package/up2date_spec.rb +++ b/spec/unit/provider/package/up2date_spec.rb @@ -13,8 +13,8 @@ osfamilies.each do |osfamily| releases.each do |release| it "should be the default provider on #{osfamily} #{release}" do - allow(Facter).to receive(:value).with(:osfamily).and_return(osfamily) - allow(Facter).to receive(:value).with(:lsbdistrelease).and_return(release) + allow(Facter).to receive(:value).with('os.family').and_return(osfamily) + allow(Facter).to receive(:value).with('os.distro.release.full').and_return(release) expect(subject.default?).to be_truthy end end diff --git a/spec/unit/provider/package/yum_spec.rb b/spec/unit/provider/package/yum_spec.rb index 923af403e7e..c4a9d386a23 100644 --- a/spec/unit/provider/package/yum_spec.rb +++ b/spec/unit/provider/package/yum_spec.rb @@ -17,42 +17,42 @@ it_behaves_like 'RHEL package provider', described_class, 'yum' it "should have lower specificity" do - allow(Facter).to receive(:value).with(:osfamily).and_return(:redhat) - allow(Facter).to receive(:value).with(:operatingsystem).and_return(:fedora) - allow(Facter).to receive(:value).with(:operatingsystemmajrelease).and_return("22") + allow(Facter).to receive(:value).with('os.family').and_return(:redhat) + allow(Facter).to receive(:value).with('os.name').and_return(:fedora) + allow(Facter).to receive(:value).with('os.release.major').and_return("22") expect(described_class.specificity).to be < 200 end describe "should have logical defaults" do [2, 2018].each do |ver| it "should be the default provider on Amazon Linux #{ver}" do - allow(Facter).to receive(:value).with(:operatingsystem).and_return('amazon') - allow(Facter).to receive(:value).with(:osfamily).and_return('redhat') - allow(Facter).to receive(:value).with(:operatingsystemmajrelease).and_return(ver) + allow(Facter).to receive(:value).with('os.name').and_return('amazon') + allow(Facter).to receive(:value).with('os.family').and_return('redhat') + allow(Facter).to receive(:value).with('os.release.major').and_return(ver) expect(described_class).to be_default end end Array(4..7).each do |ver| it "should be default for redhat #{ver}" do - allow(Facter).to receive(:value).with(:operatingsystem).and_return('redhat') - allow(Facter).to receive(:value).with(:osfamily).and_return('redhat') - allow(Facter).to receive(:value).with(:operatingsystemmajrelease).and_return(ver.to_s) + allow(Facter).to receive(:value).with('os.name').and_return('redhat') + allow(Facter).to receive(:value).with('os.family').and_return('redhat') + allow(Facter).to receive(:value).with('os.release.major').and_return(ver.to_s) expect(described_class).to be_default end end it "should not be default for redhat 8" do - allow(Facter).to receive(:value).with(:operatingsystem).and_return('redhat') - allow(Facter).to receive(:value).with(:osfamily).and_return('redhat') - allow(Facter).to receive(:value).with(:operatingsystemmajrelease).and_return('8') + allow(Facter).to receive(:value).with('os.name').and_return('redhat') + allow(Facter).to receive(:value).with('os.family').and_return('redhat') + allow(Facter).to receive(:value).with('os.release.major').and_return('8') expect(described_class).not_to be_default end it "should not be default for Ubuntu 16.04" do - allow(Facter).to receive(:value).with(:operatingsystem).and_return('ubuntu') - allow(Facter).to receive(:value).with(:osfamily).and_return('ubuntu') - allow(Facter).to receive(:value).with(:operatingsystemmajrelease).and_return('16.04') + allow(Facter).to receive(:value).with('os.name').and_return('ubuntu') + allow(Facter).to receive(:value).with('os.family').and_return('ubuntu') + allow(Facter).to receive(:value).with('os.release.major').and_return('16.04') expect(described_class).not_to be_default end end @@ -346,7 +346,7 @@ describe 'install' do before do resource[:ensure] = ensure_value - allow(Facter).to receive(:value).with(:operatingsystemmajrelease).and_return('7') + allow(Facter).to receive(:value).with('os.release.major').and_return('7') allow(described_class).to receive(:command).with(:cmd).and_return('/usr/bin/yum') allow(provider).to receive(:query).twice.and_return(nil, ensure: '18.3.2') allow(provider).to receive(:insync?).with('18.3.2').and_return(true) diff --git a/spec/unit/provider/service/base_spec.rb b/spec/unit/provider/service/base_spec.rb index b7d2cfb6ed5..ea9220376ef 100644 --- a/spec/unit/provider/service/base_spec.rb +++ b/spec/unit/provider/service/base_spec.rb @@ -98,7 +98,7 @@ def execute_command(command, options) it "retrieves a PID from the process table" do allow(Facter).to receive(:value).and_call_original - allow(Facter).to receive(:value).with(:operatingsystem).and_return("CentOS") + allow(Facter).to receive(:value).with('os.name').and_return("CentOS") ps_output = File.binread(my_fixture("ps_ef.mixed_encoding")).force_encoding(Encoding::UTF_8) expect(executor).to receive(:execute).with("ps -ef").and_return(ps_output) diff --git a/spec/unit/provider/service/bsd_spec.rb b/spec/unit/provider/service/bsd_spec.rb index e01670927ba..58c1efac12c 100644 --- a/spec/unit/provider/service/bsd_spec.rb +++ b/spec/unit/provider/service/bsd_spec.rb @@ -6,8 +6,8 @@ before :each do allow(Puppet::Type.type(:service)).to receive(:defaultprovider).and_return(provider_class) - allow(Facter).to receive(:value).with(:operatingsystem).and_return(:netbsd) - allow(Facter).to receive(:value).with(:osfamily).and_return('NetBSD') + allow(Facter).to receive(:value).with('os.name').and_return(:netbsd) + allow(Facter).to receive(:value).with('os.family').and_return('NetBSD') allow(provider_class).to receive(:defpath).and_return('/etc/rc.conf.d') @provider = provider_class.new allow(@provider).to receive(:initscript) diff --git a/spec/unit/provider/service/debian_spec.rb b/spec/unit/provider/service/debian_spec.rb index 85510bc7eca..7961a036da5 100644 --- a/spec/unit/provider/service/debian_spec.rb +++ b/spec/unit/provider/service/debian_spec.rb @@ -30,20 +30,20 @@ ['1','2'].each do |version| it "should be the default provider on CumulusLinux #{version}" do - expect(Facter).to receive(:value).with(:operatingsystem).at_least(:once).and_return('CumulusLinux') - expect(Facter).to receive(:value).with(:operatingsystemmajrelease).and_return(version) + expect(Facter).to receive(:value).with('os.name').at_least(:once).and_return('CumulusLinux') + expect(Facter).to receive(:value).with('os.release.major').and_return(version) expect(provider_class.default?).to be_truthy end end it "should be the default provider on Devuan" do - expect(Facter).to receive(:value).with(:operatingsystem).at_least(:once).and_return('Devuan') + expect(Facter).to receive(:value).with('os.name').at_least(:once).and_return('Devuan') expect(provider_class.default?).to be_truthy end it "should be the default provider on Debian" do - expect(Facter).to receive(:value).with(:operatingsystem).at_least(:once).and_return('Debian') - expect(Facter).to receive(:value).with(:operatingsystemmajrelease).and_return('7') + expect(Facter).to receive(:value).with('os.name').at_least(:once).and_return('Debian') + expect(Facter).to receive(:value).with('os.release.major').and_return('7') expect(provider_class.default?).to be_truthy end @@ -149,8 +149,8 @@ context "when checking service status" do it "should use the service command" do - allow(Facter).to receive(:value).with(:operatingsystem).and_return('Debian') - allow(Facter).to receive(:value).with(:operatingsystemmajrelease).and_return('8') + allow(Facter).to receive(:value).with('os.name').and_return('Debian') + allow(Facter).to receive(:value).with('os.release.major').and_return('8') allow(@resource).to receive(:[]).with(:hasstatus).and_return(:true) expect(@provider.statuscmd).to eq(["service", @resource[:name], "status"]) end diff --git a/spec/unit/provider/service/freebsd_spec.rb b/spec/unit/provider/service/freebsd_spec.rb index 2f71d5a03d3..12dcfa0a7e8 100644 --- a/spec/unit/provider/service/freebsd_spec.rb +++ b/spec/unit/provider/service/freebsd_spec.rb @@ -7,7 +7,7 @@ before :each do @provider = provider_class.new allow(@provider).to receive(:initscript) - allow(Facter).to receive(:value).with(:osfamily).and_return('FreeBSD') + allow(Facter).to receive(:value).with('os.family').and_return('FreeBSD') end it "should correctly parse rcvar for FreeBSD < 7" do diff --git a/spec/unit/provider/service/gentoo_spec.rb b/spec/unit/provider/service/gentoo_spec.rb index 4e72ce87cb3..f449f667dc5 100644 --- a/spec/unit/provider/service/gentoo_spec.rb +++ b/spec/unit/provider/service/gentoo_spec.rb @@ -8,8 +8,8 @@ allow(Puppet::Type.type(:service)).to receive(:defaultprovider).and_return(provider_class) allow(Puppet::FileSystem).to receive(:file?).with('/sbin/rc-update').and_return(true) allow(Puppet::FileSystem).to receive(:executable?).with('/sbin/rc-update').and_return(true) - allow(Facter).to receive(:value).with(:operatingsystem).and_return('Gentoo') - allow(Facter).to receive(:value).with(:osfamily).and_return('Gentoo') + allow(Facter).to receive(:value).with('os.name').and_return('Gentoo') + allow(Facter).to receive(:value).with('os.family').and_return('Gentoo') # The initprovider (parent of the gentoo provider) does a stat call # before it even tries to execute an initscript. We use sshd in all the diff --git a/spec/unit/provider/service/init_spec.rb b/spec/unit/provider/service/init_spec.rb index 8fcfe5b832d..5918aa11e60 100644 --- a/spec/unit/provider/service/init_spec.rb +++ b/spec/unit/provider/service/init_spec.rb @@ -39,8 +39,8 @@ describe "when running on FreeBSD" do before :each do - allow(Facter).to receive(:value).with(:operatingsystem).and_return('FreeBSD') - allow(Facter).to receive(:value).with(:osfamily).and_return('FreeBSD') + allow(Facter).to receive(:value).with('os.name').and_return('FreeBSD') + allow(Facter).to receive(:value).with('os.family').and_return('FreeBSD') end it "should set its default path to include /etc/rc.d and /usr/local/etc/rc.d" do @@ -50,7 +50,7 @@ describe "when running on HP-UX" do before :each do - allow(Facter).to receive(:value).with(:operatingsystem).and_return('HP-UX') + allow(Facter).to receive(:value).with('os.name').and_return('HP-UX') end it "should set its default path to include /sbin/init.d" do @@ -60,7 +60,7 @@ describe "when running on Archlinux" do before :each do - allow(Facter).to receive(:value).with(:operatingsystem).and_return('Archlinux') + allow(Facter).to receive(:value).with('os.name').and_return('Archlinux') end it "should set its default path to include /etc/rc.d" do @@ -70,7 +70,7 @@ describe "when not running on FreeBSD, HP-UX or Archlinux" do before :each do - allow(Facter).to receive(:value).with(:operatingsystem).and_return('RedHat') + allow(Facter).to receive(:value).with('os.name').and_return('RedHat') end it "should set its default path to include /etc/init.d" do @@ -110,7 +110,7 @@ end it "should omit Yocto services on cisco-wrlinux" do - allow(Facter).to receive(:value).with(:osfamily).and_return('cisco-wrlinux') + allow(Facter).to receive(:value).with('os.family').and_return('cisco-wrlinux') exclude = 'umountfs' expect(provider_class.get_services(provider_class.defpath).map(&:name)).to eq(@services - [exclude]) end @@ -295,7 +295,7 @@ describe "when starting a service on Solaris" do it "should use ctrun" do - allow(Facter).to receive(:value).with(:osfamily).and_return('Solaris') + allow(Facter).to receive(:value).with('os.family').and_return('Solaris') expect(provider).to receive(:execute) .with('/usr/bin/ctrun -l child /service/path/myservice start', {:failonfail => true, :override_locale => false, :squelch => false, :combine => true}) .and_return(process_output) @@ -305,7 +305,7 @@ describe "when starting a service on RedHat" do it "should not use ctrun" do - allow(Facter).to receive(:value).with(:osfamily).and_return('RedHat') + allow(Facter).to receive(:value).with('os.family').and_return('RedHat') expect(provider).to receive(:execute) .with(['/service/path/myservice', :start], {:failonfail => true, :override_locale => false, :squelch => false, :combine => true}) .and_return(process_output) diff --git a/spec/unit/provider/service/openbsd_spec.rb b/spec/unit/provider/service/openbsd_spec.rb index 187769e9218..be79c45db1e 100644 --- a/spec/unit/provider/service/openbsd_spec.rb +++ b/spec/unit/provider/service/openbsd_spec.rb @@ -6,8 +6,8 @@ before :each do allow(Puppet::Type.type(:service)).to receive(:defaultprovider).and_return(provider_class) - allow(Facter).to receive(:value).with(:operatingsystem).and_return(:openbsd) - allow(Facter).to receive(:value).with(:osfamily).and_return('OpenBSD') + allow(Facter).to receive(:value).with('os.name').and_return(:openbsd) + allow(Facter).to receive(:value).with('os.family').and_return('OpenBSD') allow(FileTest).to receive(:file?).with('/usr/sbin/rcctl').and_return(true) allow(FileTest).to receive(:executable?).with('/usr/sbin/rcctl').and_return(true) end diff --git a/spec/unit/provider/service/openwrt_spec.rb b/spec/unit/provider/service/openwrt_spec.rb index da3e43ccce2..c08d383676c 100644 --- a/spec/unit/provider/service/openwrt_spec.rb +++ b/spec/unit/provider/service/openwrt_spec.rb @@ -33,7 +33,7 @@ end it "should be the default provider on 'openwrt'" do - expect(Facter).to receive(:value).with(:operatingsystem).and_return('openwrt') + expect(Facter).to receive(:value).with('os.name').and_return('openwrt') expect(provider_class.default?).to be_truthy end diff --git a/spec/unit/provider/service/rcng_spec.rb b/spec/unit/provider/service/rcng_spec.rb index f4e2e7e5103..1898d028de5 100644 --- a/spec/unit/provider/service/rcng_spec.rb +++ b/spec/unit/provider/service/rcng_spec.rb @@ -6,8 +6,8 @@ before :each do allow(Puppet::Type.type(:service)).to receive(:defaultprovider).and_return(provider_class) - allow(Facter).to receive(:value).with(:operatingsystem).and_return(:netbsd) - allow(Facter).to receive(:value).with(:osfamily).and_return('NetBSD') + allow(Facter).to receive(:value).with('os.name').and_return(:netbsd) + allow(Facter).to receive(:value).with('os.family').and_return('NetBSD') allow(provider_class).to receive(:defpath).and_return('/etc/rc.d') @provider = provider_class.new allow(@provider).to receive(:initscript) diff --git a/spec/unit/provider/service/redhat_spec.rb b/spec/unit/provider/service/redhat_spec.rb index 7804245b6fd..e15d14be468 100644 --- a/spec/unit/provider/service/redhat_spec.rb +++ b/spec/unit/provider/service/redhat_spec.rb @@ -15,23 +15,23 @@ allow(@provider).to receive(:get).with(:hasstatus).and_return(false) allow(FileTest).to receive(:file?).with('/sbin/service').and_return(true) allow(FileTest).to receive(:executable?).with('/sbin/service').and_return(true) - allow(Facter).to receive(:value).with(:operatingsystem).and_return('CentOS') - allow(Facter).to receive(:value).with(:osfamily).and_return('RedHat') + allow(Facter).to receive(:value).with('os.name').and_return('CentOS') + allow(Facter).to receive(:value).with('os.family').and_return('RedHat') end osfamilies = [ 'RedHat' ] osfamilies.each do |osfamily| it "should be the default provider on #{osfamily}" do - expect(Facter).to receive(:value).with(:osfamily).and_return(osfamily) + expect(Facter).to receive(:value).with('os.family').and_return(osfamily) expect(provider_class.default?).to be_truthy end end it "should be the default provider on sles11" do - allow(Facter).to receive(:value).with(:osfamily).and_return(:suse) - allow(Facter).to receive(:value).with(:operatingsystem).and_return(:suse) - allow(Facter).to receive(:value).with(:operatingsystemmajrelease).and_return("11") + allow(Facter).to receive(:value).with('os.family').and_return(:suse) + allow(Facter).to receive(:value).with('os.name').and_return(:suse) + allow(Facter).to receive(:value).with('os.release.major').and_return("11") expect(provider_class.default?).to be_truthy end @@ -81,7 +81,7 @@ context "when checking enabled? on Suse" do before :each do - expect(Facter).to receive(:value).with(:osfamily).and_return('Suse') + expect(Facter).to receive(:value).with('os.family').and_return('Suse') end it "should check for on" do diff --git a/spec/unit/provider/service/smf_spec.rb b/spec/unit/provider/service/smf_spec.rb index 753c3cffffd..3ec55a200ea 100644 --- a/spec/unit/provider/service/smf_spec.rb +++ b/spec/unit/provider/service/smf_spec.rb @@ -24,9 +24,9 @@ def set_resource_params(params = {}) allow(FileTest).to receive(:executable?).with('/usr/sbin/svcadm').and_return(true) allow(FileTest).to receive(:file?).with('/usr/bin/svcs').and_return(true) allow(FileTest).to receive(:executable?).with('/usr/bin/svcs').and_return(true) - allow(Facter).to receive(:value).with(:operatingsystem).and_return('Solaris') - allow(Facter).to receive(:value).with(:osfamily).and_return('Solaris') - allow(Facter).to receive(:value).with(:operatingsystemrelease).and_return('11.2') + allow(Facter).to receive(:value).with('os.name').and_return('Solaris') + allow(Facter).to receive(:value).with('os.family').and_return('Solaris') + allow(Facter).to receive(:value).with('os.release.full').and_return('11.2') end context ".instances" do it "should have an instances method" do @@ -173,19 +173,19 @@ def set_resource_params(params = {}) end it 'returns the right command for restarting the service for Solaris versions newer than 11.2' do - expect(Facter).to receive(:value).with(:operatingsystemrelease).and_return('11.3') + expect(Facter).to receive(:value).with('os.release.full').and_return('11.3') expect(@provider.restartcmd).to eql([@provider.command(:adm), :restart, '-s', fmri]) end it 'returns the right command for restarting the service on Solaris 11.2' do - expect(Facter).to receive(:value).with(:operatingsystemrelease).and_return('11.2') + expect(Facter).to receive(:value).with('os.release.full').and_return('11.2') expect(@provider.restartcmd).to eql([@provider.command(:adm), :restart, '-s', fmri]) end it 'returns the right command for restarting the service for Solaris versions older than Solaris 11.2' do - expect(Facter).to receive(:value).with(:operatingsystemrelease).and_return('10.3') + expect(Facter).to receive(:value).with('os.release.full').and_return('10.3') expect(@provider.restartcmd).to eql([@provider.command(:adm), :restart, fmri]) end @@ -281,7 +281,7 @@ def transition_service(from, to, tries) before(:each) do allow(@provider).to receive(:service_states).and_return(states) - allow(Facter).to receive(:value).with(:operatingsystemrelease).and_return('10.3') + allow(Facter).to receive(:value).with('os.release.full').and_return('10.3') end it "should run the status command if it's passed in" do @@ -336,7 +336,7 @@ def transition_service(from, to, tries) end it "should return stopped for an incomplete service on Solaris 11" do - allow(Facter).to receive(:value).with(:operatingsystemrelease).and_return('11.3') + allow(Facter).to receive(:value).with('os.release.full').and_return('11.3') allow(@provider).to receive(:complete_service?).and_return(false) allow(@provider).to receive(:svcs).with('-l', @provider.resource[:name]).and_return(File.read(my_fixture('svcs_fmri.out'))) expect(@provider.status).to eq(:stopped) diff --git a/spec/unit/provider/service/systemd_spec.rb b/spec/unit/provider/service/systemd_spec.rb index 48dafc46c29..0cda0e8ba58 100644 --- a/spec/unit/provider/service/systemd_spec.rb +++ b/spec/unit/provider/service/systemd_spec.rb @@ -22,149 +22,149 @@ osfamilies.each do |osfamily| it "should be the default provider on #{osfamily}" do - allow(Facter).to receive(:value).with(:osfamily).and_return(osfamily) - allow(Facter).to receive(:value).with(:operatingsystem).and_return(osfamily) - allow(Facter).to receive(:value).with(:operatingsystemmajrelease).and_return("1234") + allow(Facter).to receive(:value).with('os.family').and_return(osfamily) + allow(Facter).to receive(:value).with('os.name').and_return(osfamily) + allow(Facter).to receive(:value).with('os.release.major').and_return("1234") expect(provider_class).to be_default end end [7, 8, 9].each do |ver| it "should be the default provider on rhel#{ver}" do - allow(Facter).to receive(:value).with(:osfamily).and_return(:redhat) - allow(Facter).to receive(:value).with(:operatingsystem).and_return(:redhat) - allow(Facter).to receive(:value).with(:operatingsystemmajrelease).and_return(ver.to_s) + allow(Facter).to receive(:value).with('os.family').and_return(:redhat) + allow(Facter).to receive(:value).with('os.name').and_return(:redhat) + allow(Facter).to receive(:value).with('os.release.major').and_return(ver.to_s) expect(provider_class).to be_default end end [ 4, 5, 6 ].each do |ver| it "should not be the default provider on rhel#{ver}" do - allow(Facter).to receive(:value).with(:osfamily).and_return(:redhat) - allow(Facter).to receive(:value).with(:operatingsystem).and_return(:redhat) - allow(Facter).to receive(:value).with(:operatingsystemmajrelease).and_return("#{ver}") + allow(Facter).to receive(:value).with('os.family').and_return(:redhat) + allow(Facter).to receive(:value).with('os.name').and_return(:redhat) + allow(Facter).to receive(:value).with('os.release.major').and_return("#{ver}") expect(provider_class).not_to be_default end end [ 17, 18, 19, 20, 21, 22, 23 ].each do |ver| it "should be the default provider on fedora#{ver}" do - allow(Facter).to receive(:value).with(:osfamily).and_return(:redhat) - allow(Facter).to receive(:value).with(:operatingsystem).and_return(:fedora) - allow(Facter).to receive(:value).with(:operatingsystemmajrelease).and_return("#{ver}") + allow(Facter).to receive(:value).with('os.family').and_return(:redhat) + allow(Facter).to receive(:value).with('os.name').and_return(:fedora) + allow(Facter).to receive(:value).with('os.release.major').and_return("#{ver}") expect(provider_class).to be_default end end it "should be the default provider on Amazon Linux 2.0" do - allow(Facter).to receive(:value).with(:osfamily).and_return(:redhat) - allow(Facter).to receive(:value).with(:operatingsystem).and_return(:amazon) - allow(Facter).to receive(:value).with(:operatingsystemmajrelease).and_return("2") + allow(Facter).to receive(:value).with('os.family').and_return(:redhat) + allow(Facter).to receive(:value).with('os.name').and_return(:amazon) + allow(Facter).to receive(:value).with('os.release.major').and_return("2") expect(provider_class).to be_default end it "should not be the default provider on Amazon Linux 2017.09" do - allow(Facter).to receive(:value).with(:osfamily).and_return(:redhat) - allow(Facter).to receive(:value).with(:operatingsystem).and_return(:amazon) - allow(Facter).to receive(:value).with(:operatingsystemmajrelease).and_return("2017") + allow(Facter).to receive(:value).with('os.family').and_return(:redhat) + allow(Facter).to receive(:value).with('os.name').and_return(:amazon) + allow(Facter).to receive(:value).with('os.release.major').and_return("2017") expect(provider_class).not_to be_default end it "should be the default provider on cumulus3" do - allow(Facter).to receive(:value).with(:osfamily).and_return(:debian) - allow(Facter).to receive(:value).with(:operatingsystem).and_return('CumulusLinux') - allow(Facter).to receive(:value).with(:operatingsystemmajrelease).and_return("3") + allow(Facter).to receive(:value).with('os.family').and_return(:debian) + allow(Facter).to receive(:value).with('os.name').and_return('CumulusLinux') + allow(Facter).to receive(:value).with('os.release.major').and_return("3") expect(provider_class).to be_default end it "should be the default provider on sles12" do - allow(Facter).to receive(:value).with(:osfamily).and_return(:suse) - allow(Facter).to receive(:value).with(:operatingsystem).and_return(:suse) - allow(Facter).to receive(:value).with(:operatingsystemmajrelease).and_return("12") + allow(Facter).to receive(:value).with('os.family').and_return(:suse) + allow(Facter).to receive(:value).with('os.name').and_return(:suse) + allow(Facter).to receive(:value).with('os.release.major').and_return("12") expect(provider_class).to be_default end it "should be the default provider on opensuse13" do - allow(Facter).to receive(:value).with(:osfamily).and_return(:suse) - allow(Facter).to receive(:value).with(:operatingsystem).and_return(:suse) - allow(Facter).to receive(:value).with(:operatingsystemmajrelease).and_return("13") + allow(Facter).to receive(:value).with('os.family').and_return(:suse) + allow(Facter).to receive(:value).with('os.name').and_return(:suse) + allow(Facter).to receive(:value).with('os.release.major').and_return("13") expect(provider_class).to be_default end # tumbleweed is a rolling release with date-based major version numbers it "should be the default provider on tumbleweed" do - allow(Facter).to receive(:value).with(:osfamily).and_return(:suse) - allow(Facter).to receive(:value).with(:operatingsystem).and_return(:suse) - allow(Facter).to receive(:value).with(:operatingsystemmajrelease).and_return("20150829") + allow(Facter).to receive(:value).with('os.family').and_return(:suse) + allow(Facter).to receive(:value).with('os.name').and_return(:suse) + allow(Facter).to receive(:value).with('os.release.major').and_return("20150829") expect(provider_class).to be_default end # leap is the next generation suse release it "should be the default provider on leap" do - allow(Facter).to receive(:value).with(:osfamily).and_return(:suse) - allow(Facter).to receive(:value).with(:operatingsystem).and_return(:leap) - allow(Facter).to receive(:value).with(:operatingsystemmajrelease).and_return("42") + allow(Facter).to receive(:value).with('os.family').and_return(:suse) + allow(Facter).to receive(:value).with('os.name').and_return(:leap) + allow(Facter).to receive(:value).with('os.release.major').and_return("42") expect(provider_class).to be_default end it "should not be the default provider on debian7" do - allow(Facter).to receive(:value).with(:osfamily).and_return(:debian) - allow(Facter).to receive(:value).with(:operatingsystem).and_return(:debian) - allow(Facter).to receive(:value).with(:operatingsystemmajrelease).and_return("7") + allow(Facter).to receive(:value).with('os.family').and_return(:debian) + allow(Facter).to receive(:value).with('os.name').and_return(:debian) + allow(Facter).to receive(:value).with('os.release.major').and_return("7") expect(provider_class).not_to be_default end it "should be the default provider on debian8" do - allow(Facter).to receive(:value).with(:osfamily).and_return(:debian) - allow(Facter).to receive(:value).with(:operatingsystem).and_return(:debian) - allow(Facter).to receive(:value).with(:operatingsystemmajrelease).and_return("8") + allow(Facter).to receive(:value).with('os.family').and_return(:debian) + allow(Facter).to receive(:value).with('os.name').and_return(:debian) + allow(Facter).to receive(:value).with('os.release.major').and_return("8") expect(provider_class).to be_default end it "should be the default provider on debian11" do - allow(Facter).to receive(:value).with(:osfamily).and_return(:debian) - allow(Facter).to receive(:value).with(:operatingsystem).and_return(:debian) - allow(Facter).to receive(:value).with(:operatingsystemmajrelease).and_return("11") + allow(Facter).to receive(:value).with('os.family').and_return(:debian) + allow(Facter).to receive(:value).with('os.name').and_return(:debian) + allow(Facter).to receive(:value).with('os.release.major').and_return("11") expect(provider_class).to be_default end it "should be the default provider on debian bookworm/sid" do - allow(Facter).to receive(:value).with(:osfamily).and_return(:debian) - allow(Facter).to receive(:value).with(:operatingsystem).and_return(:debian) - allow(Facter).to receive(:value).with(:operatingsystemmajrelease).and_return("bookworm/sid") + allow(Facter).to receive(:value).with('os.family').and_return(:debian) + allow(Facter).to receive(:value).with('os.name').and_return(:debian) + allow(Facter).to receive(:value).with('os.release.major').and_return("bookworm/sid") expect(provider_class).to be_default end it "should not be the default provider on ubuntu14.04" do - allow(Facter).to receive(:value).with(:osfamily).and_return(:debian) - allow(Facter).to receive(:value).with(:operatingsystem).and_return(:ubuntu) - allow(Facter).to receive(:value).with(:operatingsystemmajrelease).and_return("14.04") + allow(Facter).to receive(:value).with('os.family').and_return(:debian) + allow(Facter).to receive(:value).with('os.name').and_return(:ubuntu) + allow(Facter).to receive(:value).with('os.release.major').and_return("14.04") expect(provider_class).not_to be_default end [ '15.04', '15.10', '16.04', '16.10', '17.04', '17.10', '18.04' ].each do |ver| it "should be the default provider on ubuntu#{ver}" do - allow(Facter).to receive(:value).with(:osfamily).and_return(:debian) - allow(Facter).to receive(:value).with(:operatingsystem).and_return(:ubuntu) - allow(Facter).to receive(:value).with(:operatingsystemmajrelease).and_return("#{ver}") + allow(Facter).to receive(:value).with('os.family').and_return(:debian) + allow(Facter).to receive(:value).with('os.name').and_return(:ubuntu) + allow(Facter).to receive(:value).with('os.release.major').and_return("#{ver}") expect(provider_class).to be_default end end [ '10', '11', '12', '13', '14', '15', '16', '17' ].each do |ver| it "should not be the default provider on LinuxMint#{ver}" do - allow(Facter).to receive(:value).with(:osfamily).and_return(:debian) - allow(Facter).to receive(:value).with(:operatingsystem).and_return(:LinuxMint) - allow(Facter).to receive(:value).with(:operatingsystemmajrelease).and_return("#{ver}") + allow(Facter).to receive(:value).with('os.family').and_return(:debian) + allow(Facter).to receive(:value).with('os.name').and_return(:LinuxMint) + allow(Facter).to receive(:value).with('os.release.major').and_return("#{ver}") expect(provider_class).not_to be_default end end [ '18', '19' ].each do |ver| it "should be the default provider on LinuxMint#{ver}" do - allow(Facter).to receive(:value).with(:osfamily).and_return(:debian) - allow(Facter).to receive(:value).with(:operatingsystem).and_return(:LinuxMint) - allow(Facter).to receive(:value).with(:operatingsystemmajrelease).and_return("#{ver}") + allow(Facter).to receive(:value).with('os.family').and_return(:debian) + allow(Facter).to receive(:value).with('os.name').and_return(:LinuxMint) + allow(Facter).to receive(:value).with('os.release.major').and_return("#{ver}") expect(provider_class).to be_default end end diff --git a/spec/unit/provider/service/upstart_spec.rb b/spec/unit/provider/service/upstart_spec.rb index b2432b9a0f7..866f65cec4b 100644 --- a/spec/unit/provider/service/upstart_spec.rb +++ b/spec/unit/provider/service/upstart_spec.rb @@ -23,8 +23,8 @@ def lists_processes_as(output) end it "should be the default provider on Ubuntu" do - expect(Facter).to receive(:value).with(:operatingsystem).and_return("Ubuntu") - expect(Facter).to receive(:value).with(:operatingsystemmajrelease).and_return("12.04") + expect(Facter).to receive(:value).with('os.name').and_return("Ubuntu") + expect(Facter).to receive(:value).with('os.release.major').and_return("12.04") expect(provider_class.default?).to be_truthy end @@ -52,7 +52,7 @@ def lists_processes_as(output) describe "excluding services" do it "ignores tty and serial on Redhat systems" do - allow(Facter).to receive(:value).with(:osfamily).and_return('RedHat') + allow(Facter).to receive(:value).with('os.family').and_return('RedHat') expect(provider_class.excludes).to include 'serial' expect(provider_class.excludes).to include 'tty' end diff --git a/spec/unit/provider/user/directoryservice_spec.rb b/spec/unit/provider/user/directoryservice_spec.rb index 431a42a781a..14a1183cf0d 100644 --- a/spec/unit/provider/user/directoryservice_spec.rb +++ b/spec/unit/provider/user/directoryservice_spec.rb @@ -1142,9 +1142,9 @@ module Puppet::Util::Plist provider.class.instance_variable_set(:@os_version, nil) if provider.class.instance_variable_defined? :@os_version end - it 'should call Puppet.runtime[:facter].value(:macosx_productversion_major) ONLY ONCE no matter how ' + + it 'should call Puppet.runtime[:facter].value(os.macosx.version.major) ONLY ONCE no matter how ' + 'many times get_os_version() is called' do - expect(Facter).to receive(:value).with(:macosx_productversion_major).once.and_return('10.8') + expect(Facter).to receive(:value).with('os.macosx.version.major').once.and_return('10.8') expect(provider.class.get_os_version).to eq('10.8') expect(provider.class.get_os_version).to eq('10.8') expect(provider.class.get_os_version).to eq('10.8') diff --git a/spec/unit/provider/user/openbsd_spec.rb b/spec/unit/provider/user/openbsd_spec.rb index c26e403937e..2729facf52e 100644 --- a/spec/unit/provider/user/openbsd_spec.rb +++ b/spec/unit/provider/user/openbsd_spec.rb @@ -44,8 +44,8 @@ describe "#addcmd" do it "should return an array with the full command and expiry as MM/DD/YY" do - allow(Facter).to receive(:value).with(:osfamily).and_return('OpenBSD') - allow(Facter).to receive(:value).with(:operatingsystemmajrelease) + allow(Facter).to receive(:value).with('os.family').and_return('OpenBSD') + allow(Facter).to receive(:value).with('os.release.major') resource[:expiry] = "1997-06-01" expect(provider.addcmd).to eq(['/usr/sbin/useradd', '-e', 'June 01 1997', 'myuser']) end diff --git a/spec/unit/provider/user/useradd_spec.rb b/spec/unit/provider/user/useradd_spec.rb index d879c10fb6d..d0c3f7f66bd 100644 --- a/spec/unit/provider/user/useradd_spec.rb +++ b/spec/unit/provider/user/useradd_spec.rb @@ -76,8 +76,8 @@ context "when setting groups" do it "uses -G to set groups" do - allow(Facter).to receive(:value).with(:osfamily).and_return('Solaris') - allow(Facter).to receive(:value).with(:operatingsystemmajrelease) + allow(Facter).to receive(:value).with('os.family').and_return('Solaris') + allow(Facter).to receive(:value).with('os.release.major') resource[:ensure] = :present resource[:groups] = ['group1', 'group2'] expect(provider).to receive(:execute).with(['/usr/sbin/useradd', '-G', 'group1,group2', 'myuser'], kind_of(Hash)) @@ -85,8 +85,8 @@ end it "uses -G to set groups with -M on supported systems" do - allow(Facter).to receive(:value).with(:osfamily).and_return('RedHat') - allow(Facter).to receive(:value).with(:operatingsystemmajrelease) + allow(Facter).to receive(:value).with('os.family').and_return('RedHat') + allow(Facter).to receive(:value).with('os.release.major') resource[:ensure] = :present resource[:groups] = ['group1', 'group2'] expect(provider).to receive(:execute).with(['/usr/sbin/useradd', '-G', 'group1,group2', '-M', 'myuser'], kind_of(Hash)) @@ -304,14 +304,14 @@ describe "#expiry=" do it "should pass expiry to usermod as MM/DD/YY when on Solaris" do - expect(Facter).to receive(:value).with(:operatingsystem).and_return('Solaris') + expect(Facter).to receive(:value).with('os.name').and_return('Solaris') resource[:expiry] = '2012-10-31' expect(provider).to receive(:execute).with(['/usr/sbin/usermod', '-e', '10/31/2012', 'myuser'], hash_including(custom_environment: {})) provider.expiry = '2012-10-31' end it "should pass expiry to usermod as YYYY-MM-DD when not on Solaris" do - expect(Facter).to receive(:value).with(:operatingsystem).and_return('not_solaris') + expect(Facter).to receive(:value).with('os.name').and_return('not_solaris') resource[:expiry] = '2012-10-31' expect(provider).to receive(:execute).with(['/usr/sbin/usermod', '-e', '2012-10-31', 'myuser'], hash_including(custom_environment: {})) provider.expiry = '2012-10-31' @@ -324,8 +324,8 @@ end it "should use -e with -1 when the expiry property is removed on SLES11" do - allow(Facter).to receive(:value).with(:operatingsystem).and_return('SLES') - allow(Facter).to receive(:value).with(:operatingsystemmajrelease).and_return('11') + allow(Facter).to receive(:value).with('os.name').and_return('SLES') + allow(Facter).to receive(:value).with('os.release.major').and_return('11') resource[:expiry] = :absent expect(provider).to receive(:execute).with(['/usr/sbin/usermod', '-e', -1, 'myuser'], hash_including(custom_environment: {})) provider.expiry = :absent @@ -543,16 +543,16 @@ end it "should use -M flag if home is not managed on a supported system" do - allow(Facter).to receive(:value).with(:osfamily).and_return("RedHat") - allow(Facter).to receive(:value).with(:operatingsystemmajrelease) + allow(Facter).to receive(:value).with('os.family').and_return("RedHat") + allow(Facter).to receive(:value).with('os.release.major') resource[:managehome] = :false expect(provider).to receive(:execute).with(include('-M'), kind_of(Hash)) provider.create end it "should not use -M flag if home is not managed on an unsupported system" do - allow(Facter).to receive(:value).with(:osfamily).and_return("Suse") - allow(Facter).to receive(:value).with(:operatingsystemmajrelease).and_return("11") + allow(Facter).to receive(:value).with('os.family').and_return("Suse") + allow(Facter).to receive(:value).with('os.release.major').and_return("11") resource[:managehome] = :false expect(provider).to receive(:execute).with(excluding('-M'), kind_of(Hash)) provider.create @@ -613,14 +613,14 @@ end it "should return an array with the full command and expiry as MM/DD/YY when on Solaris" do - allow(Facter).to receive(:value).with(:operatingsystem).and_return('Solaris') + allow(Facter).to receive(:value).with('os.name').and_return('Solaris') expect(described_class).to receive(:system_users?).and_return(true) resource[:expiry] = "2012-08-18" expect(provider.addcmd).to eq(['/usr/sbin/useradd', '-e', '08/18/2012', '-G', 'somegroup', '-o', '-m', '-r', 'myuser']) end it "should return an array with the full command and expiry as YYYY-MM-DD when not on Solaris" do - allow(Facter).to receive(:value).with(:operatingsystem).and_return('not_solaris') + allow(Facter).to receive(:value).with('os.name').and_return('not_solaris') expect(described_class).to receive(:system_users?).and_return(true) resource[:expiry] = "2012-08-18" expect(provider.addcmd).to eq(['/usr/sbin/useradd', '-e', '2012-08-18', '-G', 'somegroup', '-o', '-m', '-r', 'myuser']) diff --git a/spec/unit/provider_spec.rb b/spec/unit/provider_spec.rb index 4cb72a1356e..97ab82292f6 100644 --- a/spec/unit/provider_spec.rb +++ b/spec/unit/provider_spec.rb @@ -222,20 +222,20 @@ def existing_command { :true => false } => false, { :false => false } => true, { :false => true } => false, - { :operatingsystem => Puppet.runtime[:facter].value(:operatingsystem) } => true, - { :operatingsystem => :yayness } => false, + { 'os.name' => Puppet.runtime[:facter].value('os.name') } => true, + { 'os.name' => :yayness } => false, { :nothing => :yayness } => false, { :exists => Puppet::Util.which(existing_command) } => true, { :exists => "/this/file/does/not/exist" } => false, { :true => true, :exists => Puppet::Util.which(existing_command) } => true, { :true => true, :exists => "/this/file/does/not/exist" } => false, - { :operatingsystem => Puppet.runtime[:facter].value(:operatingsystem), + { 'os.name' => Puppet.runtime[:facter].value('os.name'), :exists => Puppet::Util.which(existing_command) } => true, - { :operatingsystem => :yayness, + { 'os.name' => :yayness, :exists => Puppet::Util.which(existing_command) } => false, - { :operatingsystem => Puppet.runtime[:facter].value(:operatingsystem), + { 'os.name' => Puppet.runtime[:facter].value('os.name'), :exists => "/this/file/does/not/exist" } => false, - { :operatingsystem => :yayness, + { 'os.name' => :yayness, :exists => "/this/file/does/not/exist" } => false, }.each do |confines, result| it "should confine #{confines.inspect} to #{result}" do @@ -269,32 +269,32 @@ def existing_command end context "default providers" do - let :os do Puppet.runtime[:facter].value(:operatingsystem) end + let :os do Puppet.runtime[:facter].value('os.name') end it { is_expected.to respond_to :specificity } it "should find the default provider" do type.provide(:nondefault) {} - subject.defaultfor :operatingsystem => os + subject.defaultfor 'os.name' => os expect(subject.name).to eq(type.defaultprovider.name) end describe "regex matches" do it "should match a singular regex" do - expect(Facter).to receive(:value).with(:osfamily).at_least(:once).and_return("solaris") + expect(Facter).to receive(:value).with('os.family').at_least(:once).and_return("solaris") one = type.provide(:one) do - defaultfor :osfamily => /solaris/ + defaultfor 'os.family' => /solaris/ end expect(one).to be_default end it "should not match a non-matching regex " do - expect(Facter).to receive(:value).with(:osfamily).at_least(:once).and_return("redhat") + expect(Facter).to receive(:value).with('os.family').at_least(:once).and_return("redhat") one = type.provide(:one) do - defaultfor :osfamily => /solaris/ + defaultfor 'os.family' => /solaris/ end expect(one).to_not be_default @@ -302,15 +302,15 @@ def existing_command it "should allow a mix of regex and string" do - expect(Facter).to receive(:value).with(:operatingsystem).at_least(:once).and_return("fedora") - expect(Facter).to receive(:value).with(:operatingsystemmajrelease).at_least(:once).and_return("24") + expect(Facter).to receive(:value).with('os.name').at_least(:once).and_return("fedora") + expect(Facter).to receive(:value).with('os.release.major').at_least(:once).and_return("24") one = type.provide(:one) do - defaultfor :operatingsystem => "fedora", :operatingsystemmajrelease => /^2[2-9]$/ + defaultfor 'os.name' => "fedora", 'os.release.major' => /^2[2-9]$/ end two = type.provide(:two) do - defaultfor :operatingsystem => /fedora/, :operatingsystemmajrelease => '24' + defaultfor 'os.name' => /fedora/, 'os.release.major' => '24' end expect(one).to be_default @@ -320,21 +320,21 @@ def existing_command describe "when there are multiple defaultfor's of equal specificity" do before :each do - subject.defaultfor :operatingsystem => :os1 - subject.defaultfor :operatingsystem => :os2 + subject.defaultfor 'os.name' => :os1 + subject.defaultfor 'os.name' => :os2 end let(:alternate) { type.provide(:alternate) {} } it "should be default for the first defaultfor" do - expect(Facter).to receive(:value).with(:operatingsystem).at_least(:once).and_return(:os1) + expect(Facter).to receive(:value).with('os.name').at_least(:once).and_return(:os1) expect(provider).to be_default expect(alternate).not_to be_default end it "should be default for the last defaultfor" do - expect(Facter).to receive(:value).with(:operatingsystem).at_least(:once).and_return(:os2) + expect(Facter).to receive(:value).with('os.name').at_least(:once).and_return(:os2) expect(provider).to be_default expect(alternate).not_to be_default @@ -343,31 +343,31 @@ def existing_command describe "when there are multiple defaultfor's with different specificity" do before :each do - subject.defaultfor :operatingsystem => :os1 - subject.defaultfor :operatingsystem => :os2, :operatingsystemmajrelease => "42" - subject.defaultfor :operatingsystem => :os3, :operatingsystemmajrelease => /^4[2-9]$/ + subject.defaultfor 'os.name' => :os1 + subject.defaultfor 'os.name' => :os2, 'os.release.major' => "42" + subject.defaultfor 'os.name' => :os3, 'os.release.major' => /^4[2-9]$/ end let(:alternate) { type.provide(:alternate) {} } it "should be default for a more specific, but matching, defaultfor" do - expect(Facter).to receive(:value).with(:operatingsystem).at_least(:once).and_return(:os2) - expect(Facter).to receive(:value).with(:operatingsystemmajrelease).at_least(:once).and_return("42") + expect(Facter).to receive(:value).with('os.name').at_least(:once).and_return(:os2) + expect(Facter).to receive(:value).with('os.release.major').at_least(:once).and_return("42") expect(provider).to be_default expect(alternate).not_to be_default end it "should be default for a more specific, but matching, defaultfor with regex" do - expect(Facter).to receive(:value).with(:operatingsystem).at_least(:once).and_return(:os3) - expect(Facter).to receive(:value).with(:operatingsystemmajrelease).at_least(:once).and_return("42") + expect(Facter).to receive(:value).with('os.name').at_least(:once).and_return(:os3) + expect(Facter).to receive(:value).with('os.release.major').at_least(:once).and_return("42") expect(provider).to be_default expect(alternate).not_to be_default end it "should be default for a less specific, but matching, defaultfor" do - expect(Facter).to receive(:value).with(:operatingsystem).at_least(:once).and_return(:os1) + expect(Facter).to receive(:value).with('os.name').at_least(:once).and_return(:os1) expect(provider).to be_default expect(alternate).not_to be_default @@ -377,7 +377,7 @@ def existing_command it "should consider any true value enough to be default" do alternate = type.provide(:alternate) {} - subject.defaultfor :operatingsystem => [:one, :two, :three, os] + subject.defaultfor 'os.name' => [:one, :two, :three, os] expect(subject.name).to eq(type.defaultprovider.name) expect(subject).to be_default @@ -386,29 +386,29 @@ def existing_command it "should not be default if the defaultfor doesn't match" do expect(subject).not_to be_default - subject.defaultfor :operatingsystem => :one + subject.defaultfor 'os.name' => :one expect(subject).not_to be_default end it "should not be default if the notdefaultfor does match" do - expect(Facter).to receive(:value).with(:operatingsystem).at_least(:once).and_return("fedora") - expect(Facter).to receive(:value).with(:operatingsystemmajrelease).at_least(:once).and_return("24") + expect(Facter).to receive(:value).with('os.name').at_least(:once).and_return("fedora") + expect(Facter).to receive(:value).with('os.release.major').at_least(:once).and_return("24") one = type.provide(:one) do - defaultfor :operatingsystem => "fedora" - notdefaultfor :operatingsystem => "fedora", :operatingsystemmajrelease => 24 + defaultfor 'os.name' => "fedora" + notdefaultfor 'os.name' => "fedora", 'os.release.major' => 24 end expect(one).not_to be_default end it "should be default if the notdefaultfor doesn't match" do - expect(Facter).to receive(:value).with(:operatingsystem).at_least(:once).and_return("fedora") - expect(Facter).to receive(:value).with(:operatingsystemmajrelease).at_least(:once).and_return("24") + expect(Facter).to receive(:value).with('os.name').at_least(:once).and_return("fedora") + expect(Facter).to receive(:value).with('os.release.major').at_least(:once).and_return("24") one = type.provide(:one) do - defaultfor :operatingsystem => "fedora" - notdefaultfor :operatingsystem => "fedora", :operatingsystemmajrelease => 42 + defaultfor 'os.name' => "fedora" + notdefaultfor 'os.name' => "fedora", 'os.release.major' => 42 end expect(one).to be_default @@ -519,18 +519,18 @@ def existing_command end it "with the specification: %{spec}" % { spec: thisspec.join(', ') } do - allow(Facter).to receive(:value).with(:osfamily).and_return("redhat") - allow(Facter).to receive(:value).with(:operatingsystem).and_return("centos") - allow(Facter).to receive(:value).with(:operatingsystemrelease).and_return("27") + allow(Facter).to receive(:value).with('os.family').and_return("redhat") + allow(Facter).to receive(:value).with('os.name').and_return("centos") + allow(Facter).to receive(:value).with('os.release.full').and_return("27") one = type.provide(:one) do if defaultforspec[:one].key?(:defaultfor) - defaultfor :osfamily => "redhat" if defaultforspec[:one][:defaultfor] - defaultfor :osfamily => "ubuntu" if !defaultforspec[:one][:defaultfor] + defaultfor 'os.family' => "redhat" if defaultforspec[:one][:defaultfor] + defaultfor 'os.family' => "ubuntu" if !defaultforspec[:one][:defaultfor] end if defaultforspec[:one].key?(:notdefaultfor) - notdefaultfor :operatingsystem => "centos" if defaultforspec[:one][:notdefaultfor] - notdefaultfor :operatingsystem => "ubuntu" if !defaultforspec[:one][:notdefaultfor] + notdefaultfor 'os.name' => "centos" if defaultforspec[:one][:notdefaultfor] + notdefaultfor 'os.name' => "ubuntu" if !defaultforspec[:one][:notdefaultfor] end end @@ -538,14 +538,14 @@ def existing_command provider_options[:parent] = one if defaultforspec[:two][:derived] # :two inherits from one, if spec'd two = type.provide(:two, provider_options) do if defaultforspec[:two].key?(:defaultfor) || defaultforspec[:two].key?(:extradefaultfor) - defaultfor :osfamily => "redhat" if defaultforspec[:two][:defaultfor] - defaultfor :osfamily => "redhat",# defaultforspec[:two][:extradefaultfor] has two parts - :operatingsystem => "centos" if defaultforspec[:two][:extradefaultfor] - defaultfor :osfamily => "ubuntu" if !defaultforspec[:two][:defaultfor] + defaultfor 'os.family' => "redhat" if defaultforspec[:two][:defaultfor] + defaultfor 'os.family' => "redhat",# defaultforspec[:two][:extradefaultfor] has two parts + 'os.name' => "centos" if defaultforspec[:two][:extradefaultfor] + defaultfor 'os.family' => "ubuntu" if !defaultforspec[:two][:defaultfor] end if defaultforspec[:two].key?(:notdefaultfor) - notdefaultfor :operatingsystemrelease => "27" if defaultforspec[:two][:notdefaultfor] - notdefaultfor :operatingsystemrelease => "99" if !defaultforspec[:two][:notdefaultfor] + notdefaultfor 'os.release.full' => "27" if defaultforspec[:two][:notdefaultfor] + notdefaultfor 'os.release.full' => "99" if !defaultforspec[:two][:notdefaultfor] end end diff --git a/spec/unit/type/package_spec.rb b/spec/unit/type/package_spec.rb index 346b9411f74..ca62eeac5a0 100644 --- a/spec/unit/type/package_spec.rb +++ b/spec/unit/type/package_spec.rb @@ -370,9 +370,9 @@ def setprops(properties) it "should select dnf over yum for dnf supported fedora versions" do dnf = Puppet::Type.type(:package).provider(:dnf) yum = Puppet::Type.type(:package).provider(:yum) - allow(Facter).to receive(:value).with(:osfamily).and_return(:redhat) - allow(Facter).to receive(:value).with(:operatingsystem).and_return(:fedora) - allow(Facter).to receive(:value).with(:operatingsystemmajrelease).and_return("22") + allow(Facter).to receive(:value).with('os.family').and_return(:redhat) + allow(Facter).to receive(:value).with('os.name').and_return(:fedora) + allow(Facter).to receive(:value).with('os.release.major').and_return("22") expect(dnf.specificity).to be > yum.specificity end diff --git a/spec/unit/type/resources_spec.rb b/spec/unit/type/resources_spec.rb index 0b1a47cd17e..2872fd386b1 100644 --- a/spec/unit/type/resources_spec.rb +++ b/spec/unit/type/resources_spec.rb @@ -124,8 +124,8 @@ def self.instances context "on #{os}" do before :each do allow(Facter).to receive(:value).with(:kernel).and_return(os) - allow(Facter).to receive(:value).with(:operatingsystem).and_return(os) - allow(Facter).to receive(:value).with(:osfamily).and_return(os) + allow(Facter).to receive(:value).with('os.name').and_return(os) + allow(Facter).to receive(:value).with('os.family').and_return(os) allow(Puppet::FileSystem).to receive(:exist?).with('/etc/login.defs').and_return(false) @res = Puppet::Type.type(:resources).new :name => :user, :purge => true, :unless_system_user => true @res.catalog = Puppet::Resource::Catalog.new diff --git a/spec/unit/type_spec.rb b/spec/unit/type_spec.rb index 9bc6205ed50..3dd341f80b4 100644 --- a/spec/unit/type_spec.rb +++ b/spec/unit/type_spec.rb @@ -1142,7 +1142,7 @@ def self.title_patterns before :each do type.provide(:default) do - defaultfor :operatingsystem => Puppet.runtime[:facter].value(:operatingsystem) + defaultfor 'os.name' => Puppet.runtime[:facter].value('os.name') mk_resource_methods class << self attr_accessor :params @@ -1172,7 +1172,7 @@ def self.instances context "with a default provider" do before :each do type.provide(:default) do - defaultfor :operatingsystem => Puppet.runtime[:facter].value(:operatingsystem) + defaultfor 'os.name' => Puppet.runtime[:facter].value('os.name') mk_resource_methods class << self attr_accessor :names