From fae61382e804aa46522a7dc9aae3c1bb8c18a4f6 Mon Sep 17 00:00:00 2001 From: Gabriel Nagy Date: Wed, 10 Mar 2021 11:27:12 +0200 Subject: [PATCH] Revert "Merge pull request #8492 from GabrielNagy/PUP-10853/remove-legacy-facts" This reverts commit 8660b32739ada447e32722f1e92e7086ce28737c, reversing changes made to c6412ea369aa1613ca166b10fb819fcf6130814b. This also sneakily reverts e972610daa450d1ff083d159506c5c1275837636 by switching back to using legacy facts. When/If we decide to reintroduce this functionality, it should be enough to revert this revert. --- .gemspec | 2 +- .../lib/puppet/acceptance/agent_fqdn_utils.rb | 2 +- acceptance/tests/aix/nim_package_provider.rb | 2 +- acceptance/tests/catalog_with_binary_data.rb | 2 +- .../tests/direct_puppet/supports_utf8.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 +- .../parser_functions/hiera_in_templates.rb | 16 +-- .../reports/corrective_change_new_resource.rb | 2 +- .../corrective_change_outside_puppet.rb | 2 +- .../reports/corrective_change_via_puppet.rb | 2 +- .../file/ticket_6448_file_with_utf8_source.rb | 2 +- .../resource/service/service_enable_linux.rb | 2 +- ...et_5024_systemd_enabling_masked_service.rb | 2 +- .../tests/ssl/certificate_extensions.rb | 16 +-- acceptance/tests/ticket_15560_managehome.rb | 2 +- .../windows/QA-506_windows_exit_codes_test.rb | 2 +- ext/project_data.yaml | 2 +- install.rb | 4 +- 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 | 6 +- lib/puppet/provider/package/aix.rb | 4 +- lib/puppet/provider/package/appdmg.rb | 4 +- 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 | 8 +- 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 | 8 +- 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 | 10 +- 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 | 16 +-- 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 +- tasks/parallel.rake | 2 +- 146 files changed, 494 insertions(+), 493 deletions(-) diff --git a/.gemspec b/.gemspec index 28d56598767..e882337ebe8 100644 --- a/.gemspec +++ b/.gemspec @@ -31,7 +31,7 @@ Gem::Specification.new do |s| s.require_paths = ["lib"] s.summary = "Puppet, an automated configuration management tool" s.specification_version = 3 - s.add_runtime_dependency(%q, [">= 4.0.0", "< 5"]) + s.add_runtime_dependency(%q, [">= 2.4.0", "< 5"]) s.add_runtime_dependency(%q, [">= 3.2.1", "< 4"]) s.add_runtime_dependency(%q, "~> 1.0") s.add_runtime_dependency(%q, "~> 1.1") diff --git a/acceptance/lib/puppet/acceptance/agent_fqdn_utils.rb b/acceptance/lib/puppet/acceptance/agent_fqdn_utils.rb index 0934ed79957..84e35ff89f0 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('networking.fqdn')).stdout.chomp + @@hostname_to_fqdn[agent.hostname] = on(agent, facter('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 c6976a818ea..fa78a3feb68 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 os.release.full').stdout == '7.2' + on(aix, 'facter operatingsystemrelease').stdout == '7.2' end teardown do diff --git a/acceptance/tests/catalog_with_binary_data.rb b/acceptance/tests/catalog_with_binary_data.rb index 363d4509445..0c7a9d3a266 100644 --- a/acceptance/tests/catalog_with_binary_data.rb +++ b/acceptance/tests/catalog_with_binary_data.rb @@ -34,7 +34,7 @@ manifest = <<-MANIFEST class #{test_num}( ) { - \$test_path = \$facts['networking']['fqdn'] ? #{agent_tmp_dirs} + \$test_path = \$::fqdn ? #{agent_tmp_dirs} file { '#{test_num}': path => "\$test_path/#{test_num}", content => file('#{test_num}/binary_data'), diff --git a/acceptance/tests/direct_puppet/supports_utf8.rb b/acceptance/tests/direct_puppet/supports_utf8.rb index c5d38408ed4..d120c7bca73 100644 --- a/acceptance/tests/direct_puppet/supports_utf8.rb +++ b/acceptance/tests/direct_puppet/supports_utf8.rb @@ -34,7 +34,7 @@ file { '#{environmentpath}/#{tmp_environment}/manifests/site.pp': ensure => file, content => ' -\$test_path = \$facts["networking"]["fqdn"] ? #{tmp_file} +\$test_path = \$::fqdn ? #{tmp_file} file { \$test_path: content => @(UTF8) #{file_contents} diff --git a/acceptance/tests/language/binary_data_type.rb b/acceptance/tests/language/binary_data_type.rb index 85245a724ba..cee0adbf582 100644 --- a/acceptance/tests/language/binary_data_type.rb +++ b/acceptance/tests/language/binary_data_type.rb @@ -53,7 +53,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 $facts['os']['family'] == 'windows' { '#{tmp_filename_win}' } else { '#{tmp_filename_else}' }", + { :type => 'file', :parameters => { :namevar => "$pup_tmp_filename", :content => "$relaxed" }, :pre_code => "$pup_tmp_filename = if $osfamily == '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 7fad2d19291..9bb34be459a 100644 --- a/acceptance/tests/language/sensitive_data_type.rb +++ b/acceptance/tests/language/sensitive_data_type.rb @@ -58,7 +58,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 $facts['os']['family'] == '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 $osfamily == '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 afb815494c9..c2fd7d48694 100644 --- a/acceptance/tests/loader/autoload_from_resource_type_decl.rb +++ b/acceptance/tests/loader/autoload_from_resource_type_decl.rb @@ -41,7 +41,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('networking.fqdn') + fqdn = Facter.value(: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 214ad0dd4c3..176a2c2d83f 100644 --- a/acceptance/tests/lookup/merge_strategies.rb +++ b/acceptance/tests/lookup/merge_strategies.rb @@ -37,9 +37,9 @@ - "host" - "roles" - "profiles" - - "%{facts.os.name}" - - "%{facts.os.family}" - - "%{facts.kernel}" + - "%{::operatingsystem}" + - "%{::osfamily}" + - "%{::kernel}" - "common" :merge_behavior: deeper :deep_merge_options: diff --git a/acceptance/tests/parser_functions/hiera_in_templates.rb b/acceptance/tests/parser_functions/hiera_in_templates.rb index a7380e7f5e9..9940b169dc7 100644 --- a/acceptance/tests/parser_functions/hiera_in_templates.rb +++ b/acceptance/tests/parser_functions/hiera_in_templates.rb @@ -100,7 +100,7 @@ def create_environment(osfamilies, tmp_dirs) \\$msgs = hiera_array('message') notify {\\$msgs:} class {'#{@module_name}': - result_dir => hiera('result_dir')[\\$facts['networking']['hostname']], + result_dir => hiera('result_dir')[\\$::hostname], } } ", @@ -188,7 +188,7 @@ class #{@module_name} ( file { "#{moduledir}/manifests/mod_default.pp": content => " class #{@module_name}::mod_default { - \\$result_dir = hiera('result_dir')[\\$facts['networking']['hostname']] + \\$result_dir = hiera('result_dir')[\\$::hostname] notify{\\"module mod_default invoked.\\\\n\\":} file {\\\"\\\${result_dir}/mod_default\\\": ensure => 'file', @@ -202,7 +202,7 @@ class #{@module_name}::mod_default { file { "#{moduledir}/manifests/mod_osfamily.pp": content => " class #{@module_name}::mod_osfamily { - \\$result_dir = hiera('result_dir')[\\$facts['networking']['hostname']] + \\$result_dir = hiera('result_dir')[\\$::hostname] notify{\\"module mod_osfamily invoked.\\\\n\\":} file {\\\"\\\${result_dir}/mod_osfamily\\\": ensure => 'file', @@ -216,7 +216,7 @@ class #{@module_name}::mod_osfamily { file { "#{moduledir}/manifests/mod_production.pp": content => " class #{@module_name}::mod_production { - \\$result_dir = hiera('result_dir')[\\$facts['networking']['hostname']] + \\$result_dir = hiera('result_dir')[\\$::hostname] notify{\\"module mod_production invoked.\\\\n\\":} file {\\\"\\\${result_dir}/mod_production\\\": ensure => 'file', @@ -230,7 +230,7 @@ class #{@module_name}::mod_production { file { "#{moduledir}/manifests/mod_fqdn.pp": content => " class #{@module_name}::mod_fqdn { - \\$result_dir = hiera('result_dir')[\\$facts['networking']['hostname']] + \\$result_dir = hiera('result_dir')[\\$::hostname] notify{\\"module mod_fqdn invoked.\\\\n\\":} file {\\\"\\\${result_dir}/mod_fqdn\\\": ensure => 'file', @@ -271,7 +271,7 @@ class #{@module_name}::mod_fqdn { def find_osfamilies family_hash = {} agents.each do |agent| - res = on(agent, facter('os.family')) + res = on(agent, facter("osfamily")) osf = res.stdout.chomp family_hash[osf] = 1 end @@ -282,7 +282,7 @@ def find_tmp_dirs tmp_dirs = "" host_to_result_dir = {} agents.each do |agent| - h = on(agent, facter('networking.hostname')).stdout.chomp + h = on(agent, facter("hostname")).stdout.chomp t = agent.tmpdir("#{@module_name}_results") tmp_dirs += " #{h}: '#{t}'\n" host_to_result_dir[h] = t @@ -304,7 +304,7 @@ def find_tmp_dirs env_manifest = create_environment(find_osfamilies, tmp_dirs) apply_manifest_on(master, env_manifest, :catch_failures => true) agents.each do |agent| - resultdir = host_to_result_dir[on(agent, facter('networking.hostname')).stdout.chomp] + resultdir = host_to_result_dir[on(agent, facter("hostname")).stdout.chomp] step "Applying catalog to agent: #{agent}. result files in #{resultdir}" on( agent, diff --git a/acceptance/tests/reports/corrective_change_new_resource.rb b/acceptance/tests/reports/corrective_change_new_resource.rb index 67cfd58f17b..d33556ee051 100644 --- a/acceptance/tests/reports/corrective_change_new_resource.rb +++ b/acceptance/tests/reports/corrective_change_new_resource.rb @@ -36,7 +36,7 @@ file { '#{environmentpath}/#{tmp_environment}/manifests/site.pp': ensure => file, content => ' - \$test_path = \$facts["networking"]["fqdn"] ? #{tmp_file} + \$test_path = \$::fqdn ? #{tmp_file} file { \$test_path: content => @(UTF8) #{file_contents} diff --git a/acceptance/tests/reports/corrective_change_outside_puppet.rb b/acceptance/tests/reports/corrective_change_outside_puppet.rb index 8aad9a05cee..882a03996a6 100644 --- a/acceptance/tests/reports/corrective_change_outside_puppet.rb +++ b/acceptance/tests/reports/corrective_change_outside_puppet.rb @@ -37,7 +37,7 @@ file { '#{environmentpath}/#{tmp_environment}/manifests/site.pp': ensure => file, content => ' - \$test_path = \$facts["networking"]["fqdn"] ? #{tmp_file} + \$test_path = \$::fqdn ? #{tmp_file} file { \$test_path: content => @(UTF8) #{file_contents} diff --git a/acceptance/tests/reports/corrective_change_via_puppet.rb b/acceptance/tests/reports/corrective_change_via_puppet.rb index 33f9b933b2d..b30e2a6b65c 100644 --- a/acceptance/tests/reports/corrective_change_via_puppet.rb +++ b/acceptance/tests/reports/corrective_change_via_puppet.rb @@ -39,7 +39,7 @@ def create_manifest_for_file_resource(file_resource, file_contents, environment_ file { '#{environmentpath}/#{environment_name}/manifests/site.pp': ensure => file, content => ' - \$test_path = \$facts["networking"]["fqdn"] ? #{file_resource} + \$test_path = \$::fqdn ? #{file_resource} file { \$test_path: content => @(UTF8) #{file_contents} diff --git a/acceptance/tests/resource/file/ticket_6448_file_with_utf8_source.rb b/acceptance/tests/resource/file/ticket_6448_file_with_utf8_source.rb index 6f060e3feb3..bcb307dfee6 100644 --- a/acceptance/tests/resource/file/ticket_6448_file_with_utf8_source.rb +++ b/acceptance/tests/resource/file/ticket_6448_file_with_utf8_source.rb @@ -49,7 +49,7 @@ step 'create a site.pp on master containing a unicode file resource' do site_pp_contents = <<-SITE_PP - \$test_path = \$facts['networking']['fqdn'] ? #{agent_tmp_dirs} + \$test_path = \$::fqdn ? #{agent_tmp_dirs} file { "\$test_path/\uff72\uff67\u30d5\u30eb": ensure => present, source => "puppet:///modules/utf8_file_module/\u9759\u7684", diff --git a/acceptance/tests/resource/service/service_enable_linux.rb b/acceptance/tests/resource/service/service_enable_linux.rb index 647cb921560..b94e3608887 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('os.release.major')).stdout.chomp.to_i + majrelease = on(agent, facter('operatingsystemmajrelease')).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 642bbb0555c..66abb99019e 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 ($os['name'] == 'Fedora') and ($os['release']['major'] == '23') { + if ($::operatingsystem == 'Fedora') and ($::operatingsystemmajrelease == '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 bbb42826daa..a12fe63fdba 100644 --- a/acceptance/tests/ssl/certificate_extensions.rb +++ b/acceptance/tests/ssl/certificate_extensions.rb @@ -11,17 +11,17 @@ initialize_temp_dirs agent_certnames = [] - hostname = master.execute('facter networking.hostname') - fqdn = master.execute('facter networking.fqdn') + hostname = master.execute('facter hostname') + fqdn = master.execute('facter fqdn') teardown do step "Cleanup the test agent certs" - server_config = { + master_config = { 'main' => { 'server' => fqdn }, - 'server' => { 'dns_alt_names' => "puppet,#{hostname},#{fqdn}" } + 'master' => { 'dns_alt_names' => "puppet,#{hostname},#{fqdn}" } } - with_puppet_running_on(master, server_config) do + with_puppet_running_on(master, master_config) do on(master, "puppetserver ca clean --certname #{agent_certnames.join(',')}", :acceptable_exit_codes => [0,24]) @@ -29,11 +29,11 @@ end environments_dir = get_test_file_path(master, "environments") - server_config = { + master_config = { 'main' => { 'environmentpath' => environments_dir, }, - 'server' => { + 'master' => { 'autosign' => true, 'dns_alt_names' => "puppet,#{hostname},#{fqdn}", } @@ -74,7 +74,7 @@ } MANIFEST - with_puppet_running_on(master, server_config) do + with_puppet_running_on(master, master_config) do agents.each do |agent| next if agent == master diff --git a/acceptance/tests/ticket_15560_managehome.rb b/acceptance/tests/ticket_15560_managehome.rb index f875a1afe11..32ef946d216 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('os.release.full')).stdout.chomp + version = on(host, facter('operatingsystemrelease')).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 a85e3a09edd..e68c41c14c6 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("os.release.major")).stdout =~ /2003/) + if (on(agent, facter("find operatingsystemmajrelease")).stdout =~ /2003/) on(agent, "ln -s #{native_modules_path.gsub(/ /, '\ ')} /tmp/puppet_etc") modules_path = '/tmp/puppet_etc' else diff --git a/ext/project_data.yaml b/ext/project_data.yaml index 088773a8d33..7027c6349f3 100644 --- a/ext/project_data.yaml +++ b/ext/project_data.yaml @@ -17,7 +17,7 @@ gem_forge_project: 'puppet' gem_required_ruby_version: '>= 2.5.0' gem_required_rubygems_version: '> 1.3.1' gem_runtime_dependencies: - facter: ['>= 4.0.0', '< 5'] + facter: ['> 2.0.1', '< 5'] hiera: ['>= 3.2.1', '< 4'] semantic_puppet: '~> 1.0' fast_gettext: '~> 1.1' diff --git a/install.rb b/install.rb index 484e0e3704e..5d8c2e9952b 100755 --- a/install.rb +++ b/install.rb @@ -45,7 +45,7 @@ end PREREQS = %w{openssl facter cgi hiera} -MIN_FACTER_VERSION = 4.0 +MIN_FACTER_VERSION = 1.5 InstallOptions = OpenStruct.new @@ -242,7 +242,7 @@ def prepare_installation # Otherwise facter won't be guaranteed to be present. if InstallOptions.check_prereqs check_prereqs - $operatingsystem = Facter.value('os.name') + $operatingsystem = Facter.value :operatingsystem end if not InstallOptions.configdir.nil? diff --git a/lib/puppet/confiner.rb b/lib/puppet/confiner.rb index 39a51d94c4d..50282fd9769 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 'os.name' => [:redhat, :fedora] + # confine :operatingsystem => [: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 9679976d9a3..095da55a5ee 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" => Facter.value('networking.hostname'), + "h" => Facter.value("hostname"), "H" => [ - Facter.value('networking.hostname'), - Facter.value('networking.domain') + Facter.value("hostname"), + Facter.value("domain") ].join("."), - "d" => Facter.value('networking.domain') + "d" => Facter.value("domain") } end diff --git a/lib/puppet/indirector/catalog/compiler.rb b/lib/puppet/indirector/catalog/compiler.rb index 3e826f0b0f0..85f4a56a37b 100644 --- a/lib/puppet/indirector/catalog/compiler.rb +++ b/lib/puppet/indirector/catalog/compiler.rb @@ -410,9 +410,9 @@ def set_server_facts @server_facts["serverversion"] = Puppet.version.to_s # And then add the server name and IP - {"servername" => "networking.fqdn", - "serverip" => "networking.ip", - "serverip6" => "networking.ip6" + {"servername" => "fqdn", + "serverip" => "ipaddress", + "serverip6" => "ipaddress6" }.each do |var, fact| value = Facter.value(fact) if !value.nil? @@ -421,10 +421,10 @@ def set_server_facts end if @server_facts["servername"].nil? - host = Facter.value('networking.hostname') + host = Facter.value(:hostname) if host.nil? Puppet.warning _("Could not retrieve fact servername") - elsif (domain = Facter.value('networking.domain')) + elsif domain = Facter.value(: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 b6ff52e9557..422fb23bbb9 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 'os.name' => :windows - defaultfor 'os.name' => :windows + confine :operatingsystem => :windows + defaultfor :operatingsystem => :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 634b4e37033..4c2b5261273 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 'os.name' => :windows + confine :operatingsystem => :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 eba84d5a247..68c5441f9b4 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 'os.name' => :aix - confine 'os.name' => :aix + defaultfor :operatingsystem => :aix + confine :operatingsystem => :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 cbd9d85c605..35856b898bc 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 'os.name' => :darwin - defaultfor 'os.name' => :darwin + confine :operatingsystem => :darwin + defaultfor :operatingsystem => :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 0843999b106..38aafd6109e 100644 --- a/lib/puppet/provider/group/groupadd.rb +++ b/lib/puppet/provider/group/groupadd.rb @@ -6,7 +6,7 @@ commands :add => "groupadd", :delete => "groupdel", :modify => "groupmod" - has_feature :system_groups unless %w{HP-UX Solaris}.include? Facter.value('os.name') + has_feature :system_groups unless %w{HP-UX Solaris}.include? Facter.value(:operatingsystem) 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 25dbd2dc7a6..c9ea39de966 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 'os.name' => [:freebsd, :dragonfly] - confine 'os.name' => [:freebsd, :dragonfly] + defaultfor :operatingsystem => [:freebsd, :dragonfly] + confine :operatingsystem => [: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 97f529cf011..b10b350e9c5 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 'os.name' => :windows - confine 'os.name' => :windows + defaultfor :operatingsystem => :windows + confine :operatingsystem => :windows has_features :manages_members diff --git a/lib/puppet/provider/nameservice/directoryservice.rb b/lib/puppet/provider/nameservice/directoryservice.rb index 69fe57886fc..1c9c1771e35 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 'os.name' => :darwin - confine :feature => :cfpropertylist - defaultfor 'os.name' => :darwin + confine :operatingsystem => :darwin + confine :feature => :cfpropertylist + defaultfor :operatingsystem => :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 57a43bad925..c4f28a4caf9 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 'os.name' => [ :aix ] - defaultfor 'os.name' => :aix + confine :operatingsystem => [ :aix ] + defaultfor :operatingsystem => :aix attr_accessor :latest_info diff --git a/lib/puppet/provider/package/appdmg.rb b/lib/puppet/provider/package/appdmg.rb index 6ef11f7bdaa..487e7c2aa90 100644 --- a/lib/puppet/provider/package/appdmg.rb +++ b/lib/puppet/provider/package/appdmg.rb @@ -17,8 +17,8 @@ Puppet::Type.type(:package).provide(:appdmg, :parent => Puppet::Provider::Package) do desc "Package management which copies application bundles to a target." - confine 'os.name' => :darwin - confine :feature => :cfpropertylist + confine :operatingsystem => :darwin + confine :feature => :cfpropertylist commands :hdiutil => "/usr/bin/hdiutil" commands :curl => "/usr/bin/curl" diff --git a/lib/puppet/provider/package/apple.rb b/lib/puppet/provider/package/apple.rb index 52bb2bf50bb..1a6cecad720 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 'os.name' => :darwin + confine :operatingsystem => :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 4bba7ebcac3..44967cc0972 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 'os.family' => :debian + defaultfor :osfamily => :debian ENV['DEBIAN_FRONTEND'] = "noninteractive" diff --git a/lib/puppet/provider/package/blastwave.rb b/lib/puppet/provider/package/blastwave.rb index 15297a3c85f..1ace40fe0e9 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 'os.family' => :solaris + confine :osfamily => :solaris commands :pkgget => pkgget diff --git a/lib/puppet/provider/package/dnf.rb b/lib/puppet/provider/package/dnf.rb index 8eb9e9ceea8..16b6a650f3d 100644 --- a/lib/puppet/provider/package/dnf.rb +++ b/lib/puppet/provider/package/dnf.rb @@ -28,10 +28,10 @@ end end - 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 + defaultfor :operatingsystem => :fedora + notdefaultfor :operatingsystem => :fedora, :operatingsystemmajrelease => (19..21).to_a + defaultfor :osfamily => :redhat + notdefaultfor :osfamily => :redhat, :operatingsystemmajrelease => (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 dce936f85e7..305367968fb 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 'os.name' => :freebsd + confine :operatingsystem => :freebsd def self.listcmd command(:pkginfo) diff --git a/lib/puppet/provider/package/hpux.rb b/lib/puppet/provider/package/hpux.rb index d42309523de..4416f010157 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 'os.name' => "hp-ux" + confine :operatingsystem => "hp-ux" - defaultfor 'os.name' => "hp-ux" + defaultfor :operatingsystem => "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 f71e401e545..ea8d2ce45dd 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 'os.name' => :darwin + confine :operatingsystem => :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 fa1cef1b612..b47a93969bc 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 'os.name' => :openbsd - confine 'os.name' => :openbsd + defaultfor :operatingsystem => :openbsd + confine :operatingsystem => :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 afb25a3eb0a..1a110f40384 100644 --- a/lib/puppet/provider/package/opkg.rb +++ b/lib/puppet/provider/package/opkg.rb @@ -5,8 +5,8 @@ commands :opkg => "opkg" - confine 'os.name' => :openwrt - defaultfor 'os.name' => :openwrt + confine :operatingsystem => :openwrt + defaultfor :operatingsystem => :openwrt def self.instances packages = [] diff --git a/lib/puppet/provider/package/pacman.rb b/lib/puppet/provider/package/pacman.rb index 61596f96405..acd3b3ef7ac 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 'os.name' => [:archlinux, :manjarolinux] - defaultfor 'os.name' => [:archlinux, :manjarolinux] + confine :operatingsystem => [:archlinux, :manjarolinux] + defaultfor :operatingsystem => [: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 a0e7394ed12..c6777ce5d25 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 'os.family' => :solaris + confine :osfamily => :solaris - defaultfor 'os.family' => :solaris, :kernelrelease => ['5.11', '5.12'] + defaultfor :osfamily => :solaris, :kernelrelease => ['5.11', '5.12'] def self.instances pkg(:list, '-Hv').split("\n").map{|l| new(parse_line(l))} @@ -221,7 +221,7 @@ def install(nofail = false) command = 'update' end args = ['--accept'] - if Puppet::Util::Package.versioncmp(Facter.value('os.release.full'), '11.2') >= 0 + if Puppet::Util::Package.versioncmp(Facter.value(:operatingsystemrelease), '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 e14a7906063..c673d443bab 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 'os.name' => :darwin + confine :operatingsystem => :darwin confine :feature => :cfpropertylist - defaultfor 'os.name' => :darwin + defaultfor :operatingsystem => :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 3d5ee0142bf..8f2d7ef4911 100644 --- a/lib/puppet/provider/package/pkgin.rb +++ b/lib/puppet/provider/package/pkgin.rb @@ -5,7 +5,7 @@ commands :pkgin => "pkgin" - defaultfor 'os.name' => [ :smartos, :netbsd ] + defaultfor :operatingsystem => [ :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 6e9e0ee2599..d8e5b0fe91e 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 'os.name' => [:freebsd, :dragonfly] + confine :operatingsystem => [:freebsd, :dragonfly] - defaultfor 'os.name' => [:freebsd, :dragonfly] + defaultfor :operatingsystem => [: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 1663e823c0c..d0815e0260e 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 'os.family' => :solaris + confine :osfamily => :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 a8fd2f88d15..3f463beeda3 100644 --- a/lib/puppet/provider/package/portage.rb +++ b/lib/puppet/provider/package/portage.rb @@ -20,9 +20,9 @@ end end - confine 'os.family' => :gentoo + confine :osfamily => :gentoo - defaultfor 'os.family' => :gentoo + defaultfor :osfamily => :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 be5c6f60fba..7c1a81cddc4 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 'os.name' => :freebsd + # defaultfor :operatingsystem => :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 aa7e7cc247f..5cb2945fe0b 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 'os.name' => [:suse, :sles] + confine :operatingsystem => [: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 70852cfd210..20bf708a919 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 'os.family' => :solaris - defaultfor 'os.family' => :solaris + confine :osfamily => :solaris + defaultfor :osfamily => :solaris has_feature :install_options diff --git a/lib/puppet/provider/package/sunfreeware.rb b/lib/puppet/provider/package/sunfreeware.rb index d4473401851..118d36b66e9 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 'os.family' => :solaris + confine :osfamily => :solaris end diff --git a/lib/puppet/provider/package/tdnf.rb b/lib/puppet/provider/package/tdnf.rb index 4c17313c838..c633d58bbe5 100644 --- a/lib/puppet/provider/package/tdnf.rb +++ b/lib/puppet/provider/package/tdnf.rb @@ -24,5 +24,5 @@ end end - defaultfor 'os.name' => "PhotonOS" + defaultfor :operatingsystem => "PhotonOS" end diff --git a/lib/puppet/provider/package/up2date.rb b/lib/puppet/provider/package/up2date.rb index 6c998879c7a..d9eafbe25dc 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 'os.family' => :redhat, 'os.distro.release.full' => ["2.1", "3", "4"] + defaultfor :osfamily => :redhat, :lsbdistrelease => ["2.1", "3", "4"] - confine 'os.family' => :redhat + confine :osfamily => :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 d396c5df02c..32a049582bc 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 'os.name' => [:mandriva, :mandrake] + defaultfor :operatingsystem => [:mandriva, :mandrake] has_feature :versionable diff --git a/lib/puppet/provider/package/windows.rb b/lib/puppet/provider/package/windows.rb index 19fc155ed38..09de9bd2fe1 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 'os.name' => :windows - defaultfor 'os.name' => :windows + confine :operatingsystem => :windows + defaultfor :operatingsystem => :windows has_feature :installable has_feature :uninstallable diff --git a/lib/puppet/provider/package/yum.rb b/lib/puppet/provider/package/yum.rb index 4fe85b8d8dc..e26083f40e0 100644 --- a/lib/puppet/provider/package/yum.rb +++ b/lib/puppet/provider/package/yum.rb @@ -32,8 +32,8 @@ end end -defaultfor 'os.name' => :amazon -defaultfor 'os.family' => :redhat, 'os.release.major' => (4..7).to_a +defaultfor :operatingsystem => :amazon +defaultfor :osfamily => :redhat, :operatingsystemmajrelease => (4..7).to_a def insync?(is) return false if [:purged, :absent].include?(is) @@ -298,7 +298,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 Facter.value('os.release.major').to_i > 5 then ["-d", "0"] else [] end + no_debug = if Facter.value(:operatingsystemmajrelease).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 0033955b38c..5f5d6016d18 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 'os.name' => [:suse, :sles, :sled, :opensuse] - confine 'os.name' => [:suse, :sles, :sled, :opensuse] + defaultfor :operatingsystem => [:suse, :sles, :sled, :opensuse] + confine :operatingsystem => [: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 a1ca816cc5c..9576398597e 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 Facter.value('os.name') + case Facter.value(:operatingsystem) 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 688994531c1..146d048d557 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 'os.name' => [:freebsd, :dragonfly] + confine :operatingsystem => [: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 ce0a448f2f0..9352f3b005a 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 'os.name' => :cumuluslinux, 'os.release.major' => ['1','2'] - defaultfor 'os.name' => :debian, 'os.release.major' => ['5','6','7'] - defaultfor 'os.name' => :devuan + defaultfor :operatingsystem => :cumuluslinux, :operatingsystemmajrelease => ['1','2'] + defaultfor :operatingsystem => :debian, :operatingsystemmajrelease => ['5','6','7'] + defaultfor :operatingsystem => :devuan # Remove the symlinks def disable diff --git a/lib/puppet/provider/service/freebsd.rb b/lib/puppet/provider/service/freebsd.rb index cfc520b2998..9ad46053056 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 'os.name' => [:freebsd, :dragonfly] - defaultfor 'os.name' => [:freebsd, :dragonfly] + confine :operatingsystem => [:freebsd, :dragonfly] + defaultfor :operatingsystem => [: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 3f38fc2042c..4fecbde9dac 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 'os.name' => :gentoo + confine :operatingsystem => :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 b4378825fb9..3ab27b33224 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 Facter.value('os.name') + case Facter.value(:operatingsystem) 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 = Facter.value('os.name').downcase - family = Facter.value('os.family').downcase + os = Facter.value(:operatingsystem).downcase + family = Facter.value(:osfamily).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 Facter.value('os.family') == "cisco-wrlinux" + if Facter.value(:osfamily) == "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 @@ -171,7 +171,7 @@ def restartcmd end def texecute(type, command, fof = true, squelch = false, combine = true) - if type == :start && Facter.value('os.family') == "Solaris" + if type == :start && Facter.value(:osfamily) == "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 409c60bb4c1..bde8535cb13 100644 --- a/lib/puppet/provider/service/launchd.rb +++ b/lib/puppet/provider/service/launchd.rb @@ -42,9 +42,9 @@ commands :launchctl => "/bin/launchctl" - defaultfor 'os.name' => :darwin - confine 'os.name' => :darwin - confine :feature => :cfpropertylist + defaultfor :operatingsystem => :darwin + confine :operatingsystem => :darwin + confine :feature => :cfpropertylist has_feature :enableable has_feature :refreshable @@ -70,7 +70,7 @@ def self.launchd_paths # # @api private def self.get_os_version - @os_version ||= Facter.value('os.release.major').to_i + @os_version ||= Facter.value(:operatingsystemmajrelease).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 7a4f2c8d50b..34a7382d42a 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 'os.name' => :openbsd - defaultfor 'os.name' => :openbsd + confine :operatingsystem => :openbsd + defaultfor :operatingsystem => :openbsd has_feature :flaggable def startcmd diff --git a/lib/puppet/provider/service/openrc.rb b/lib/puppet/provider/service/openrc.rb index f6c91bfd621..8243f651e87 100644 --- a/lib/puppet/provider/service/openrc.rb +++ b/lib/puppet/provider/service/openrc.rb @@ -7,8 +7,8 @@ EOT - defaultfor 'os.name' => :gentoo - defaultfor 'os.name' => :funtoo + defaultfor :operatingsystem => :gentoo + defaultfor :operatingsystem => :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 2f8f93db14e..f1171275672 100644 --- a/lib/puppet/provider/service/openwrt.rb +++ b/lib/puppet/provider/service/openwrt.rb @@ -6,8 +6,8 @@ EOT - defaultfor 'os.name' => :openwrt - confine 'os.name' => :openwrt + defaultfor :operatingsystem => :openwrt + confine :operatingsystem => :openwrt has_feature :enableable diff --git a/lib/puppet/provider/service/rcng.rb b/lib/puppet/provider/service/rcng.rb index 47d914c4828..5e5d16bde4e 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 'os.name' => [:netbsd, :cargos] - confine 'os.name' => [:netbsd, :cargos] + defaultfor :operatingsystem => [:netbsd, :cargos] + confine :operatingsystem => [: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 bee68750c57..20c6afe0e80 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 'os.family' => :redhat - defaultfor 'os.family' => :suse, 'os.release.major' => ["10", "11"] + defaultfor :osfamily => :redhat + defaultfor :osfamily => :suse, :operatingsystemmajrelease => ["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 Facter.value('os.family') != 'Suse' || output =~ /^#{name}\s+(on|B)$/ + return :false unless Facter.value(:osfamily) != '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 bd1009c79df..50244c91305 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 'os.family' => :solaris + defaultfor :osfamily => :solaris - confine 'os.family' => :solaris + confine :osfamily => :solaris commands :adm => "/usr/sbin/svcadm", :svcs => "/usr/bin/svcs", @@ -125,14 +125,14 @@ def service_fmri # Returns true if the provider supports incomplete services. def supports_incomplete_services? - Puppet::Util::Package.versioncmp(Facter.value('os.release.full'), '11.1') >= 0 + Puppet::Util::Package.versioncmp(Facter.value(:operatingsystemrelease), '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: Facter.value('os.release.full') } + 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: Facter.value(:operatingsystemrelease) } end return @complete_service if @complete_service @@ -162,7 +162,7 @@ def disable end def restartcmd - if Puppet::Util::Package.versioncmp(Facter.value('os.release.full'), '11.2') >= 0 + if Puppet::Util::Package.versioncmp(Facter.value(:operatingsystemrelease), '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 acbf4ceb1f7..8276598769b 100644 --- a/lib/puppet/provider/service/src.rb +++ b/lib/puppet/provider/service/src.rb @@ -13,8 +13,8 @@ is not yet supported. " - defaultfor 'os.name' => :aix - confine 'os.name' => :aix + defaultfor :operatingsystem => :aix + confine :operatingsystem => :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 0277e882afe..6408f8cfb77 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 'os.family' => [:archlinux] - defaultfor 'os.family' => :redhat, 'os.release.major' => ["7", "8"] - 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"] + defaultfor :osfamily => [:archlinux] + defaultfor :osfamily => :redhat, :operatingsystemmajrelease => ["7", "8"] + 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"] def self.instances i = [] @@ -105,7 +105,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) && (Facter.value('os.family').casecmp('debian').zero?) + if (output.empty?) && (code > 0) && (Facter.value(:osfamily).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 9e0007d8c90..ac781b9ee43 100644 --- a/lib/puppet/provider/service/upstart.rb +++ b/lib/puppet/provider/service/upstart.rb @@ -10,14 +10,14 @@ " confine :any => [ - Facter.value('os.name') == 'Ubuntu', - (Facter.value('os.family') == 'RedHat' and Facter.value('os.release.full') =~ /^6\./), - (Facter.value('os.name') == 'Amazon' and Facter.value('os.release.major') =~ /\d{4}/), - Facter.value('os.name') == 'LinuxMint', + Facter.value(:operatingsystem) == 'Ubuntu', + (Facter.value(:osfamily) == 'RedHat' and Facter.value(:operatingsystemrelease) =~ /^6\./), + (Facter.value(:operatingsystem) == 'Amazon' and Facter.value(:operatingsystemmajrelease) =~ /\d{4}/), + Facter.value(:operatingsystem) == 'LinuxMint', ] - 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"] + defaultfor :operatingsystem => :ubuntu, :operatingsystemmajrelease => ["10.04", "12.04", "14.04", "14.10"] + defaultfor :operatingsystem => :LinuxMint, :operatingsystemmajrelease => ["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 Facter.value('os.family') == 'RedHat' + if Facter.value(:osfamily) == '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 0dee9ab7889..678fd84176b 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 'os.name' => :windows - confine 'os.name' => :windows + defaultfor :operatingsystem => :windows + confine :operatingsystem => :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 41c5195b7d9..de2fe9a6869 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 'os.name' => :aix - confine 'os.name' => :aix + defaultfor :operatingsystem => :aix + confine :operatingsystem => :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 0ee48e31ae1..65bde4fea37 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 'os.name' => :darwin - confine :feature => :cfpropertylist - defaultfor 'os.name' => :darwin + confine :operatingsystem => :darwin + confine :feature => :cfpropertylist + defaultfor :operatingsystem => :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 ||= Facter.value('os.macosx.version.major') + @os_version ||= Facter.value(:macosx_productversion_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 13503d0c357..0f1ef29ce8c 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 'os.name' => "hp-ux" - confine 'os.name' => "hp-ux" + defaultfor :operatingsystem => "hp-ux" + confine :operatingsystem => "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 8205c523824..1b550226e1a 100644 --- a/lib/puppet/provider/user/openbsd.rb +++ b/lib/puppet/provider/user/openbsd.rb @@ -10,8 +10,8 @@ :modify => "usermod", :password => "passwd" - defaultfor 'os.name' => :openbsd - confine 'os.name' => :openbsd + defaultfor :operatingsystem => :openbsd + confine :operatingsystem => :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 8db511ffcc7..a1706af14f6 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 'os.name' => [:freebsd, :dragonfly] - confine 'os.name' => [:freebsd, :dragonfly] + defaultfor :operatingsystem => [:freebsd, :dragonfly] + confine :operatingsystem => [: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 bc19c131a82..304a512daa7 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 'os.family' => :solaris + defaultfor :osfamily => :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 e9b92cd5685..e7e7f9e4005 100644 --- a/lib/puppet/provider/user/useradd.rb +++ b/lib/puppet/provider/user/useradd.rb @@ -21,13 +21,13 @@ options :expiry, :method => :sp_expire, :munge => proc { |value| if value == :absent - if Facter.value('os.name') == 'SLES' && Facter.value('os.release.major') == "11" + if Facter.value(:operatingsystem)=='SLES' && Facter.value(:operatingsystemmajrelease) == "11" -1 else '' end else - case Facter.value('os.name') + case Facter.value(:operatingsystem) when 'Solaris' # Solaris uses %m/%d/%Y for useradd/usermod expiry_year, expiry_month, expiry_day = value.split('-') @@ -161,7 +161,7 @@ def groups=(value) end has_features :manages_homedir, :allows_duplicates, :manages_expiry - has_features :system_users unless %w{HP-UX Solaris}.include? Facter.value('os.name') + has_features :system_users unless %w{HP-UX Solaris}.include? Facter.value(:operatingsystem) has_features :manages_passwords, :manages_password_age if Puppet.features.libshadow? has_features :manages_shell @@ -196,8 +196,8 @@ def check_manage_home # libuser does not implement the -m flag cmd << "-m" unless @resource.forcelocal? else - osfamily = Facter.value('os.family') - osversion = Facter.value('os.release.major').to_i + osfamily = Facter.value(:osfamily) + osversion = Facter.value(:operatingsystemmajrelease).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 @@ -293,7 +293,7 @@ def deletecmd cmd = [command(:delete)] end # Solaris `userdel -r` will fail if the homedir does not exist. - if @resource.managehome? && (('Solaris' != Facter.value('os.name')) || Dir.exist?(Dir.home(@resource[:name]))) + if @resource.managehome? && (('Solaris' != Facter.value(:operatingsystem)) || 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 57092c15628..00510940664 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 'os.name' => :windows - confine 'os.name' => :windows + defaultfor :operatingsystem => :windows + confine :operatingsystem => :windows has_features :manages_homedir, :manages_passwords, :manages_roles diff --git a/lib/puppet/reference/providers.rb b/lib/puppet/reference/providers.rb index ce2b5f6164c..52d6def6ffc 100644 --- a/lib/puppet/reference/providers.rb +++ b/lib/puppet/reference/providers.rb @@ -13,10 +13,11 @@ ret = "Details about this host:\n\n" # Throw some facts in there, so we know where the report is from. - 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')) + ["Ruby Version", "Puppet Version", "Operating System", "Operating System Release"].each do |label| + name = label.gsub(/\s+/, '') + value = Facter.value(name) + ret << option(label, value) + end ret << "\n" count = 1 diff --git a/lib/puppet/settings.rb b/lib/puppet/settings.rb index e73d79298cc..3b304801207 100644 --- a/lib/puppet/settings.rb +++ b/lib/puppet/settings.rb @@ -66,7 +66,7 @@ def self.app_defaults_for_run_mode(run_mode) } end - def self.default_certname + def self.default_certname() hostname = hostname_fact domain = domain_fact if domain and domain != "" @@ -77,12 +77,12 @@ def self.default_certname fqdn.to_s.gsub(/\.$/, '') end - def self.hostname_fact - Facter.value('networking.hostname') + def self.hostname_fact() + Facter.value :hostname end - def self.domain_fact - Facter.value('networking.domain') + def self.domain_fact() + Facter.value :domain end def self.default_config_file_name diff --git a/lib/puppet/type.rb b/lib/puppet/type.rb index 277160d70bc..4e8253ab1dd 100644 --- a/lib/puppet/type.rb +++ b/lib/puppet/type.rb @@ -1405,7 +1405,7 @@ def properties_to_audit(list) provide a symbolic title and an explicit namevar value: file { 'sshdconfig': - path => $os['name'] ? { + path => $operatingsystem ? { 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 8fb7bad6934..8e54bfa5410 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.${os['name']}", + "puppet:///modules/nfs/conf.${operatingsystem}", 'puppet:///modules/nfs/conf' ] } diff --git a/lib/puppet/type/package.rb b/lib/puppet/type/package.rb index 1929f0863f2..abddd42a9a4 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 = $os['name'] ? { + $ssl = $operatingsystem ? { solaris => SMCossl, default => openssl } @@ -254,7 +254,7 @@ def change_to_s(currentvalue, newvalue) ... - $ssh = $os['name'] ? { + $ssh = $operatingsystem ? { solaris => SMCossh, default => openssh } diff --git a/lib/puppet/type/resources.rb b/lib/puppet/type/resources.rb index 2909de6adc0..51c102c5f43 100644 --- a/lib/puppet/type/resources.rb +++ b/lib/puppet/type/resources.rb @@ -175,7 +175,7 @@ def self.system_users_max_uid end # Otherwise, use a sensible default based on the OS family - @system_users_max_uid ||= case Facter.value('os.family') + @system_users_max_uid ||= case Facter.value(:osfamily) when 'OpenBSD', 'FreeBSD' 999 else diff --git a/lib/puppet/util/filetype.rb b/lib/puppet/util/filetype.rb index 4c11598cf6f..41d5a964765 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?(Facter.value('os.name')) + if %w{Darwin FreeBSD DragonFly}.include?(Facter.value("operatingsystem")) 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 || Facter.value('os.name') == "HP-UX" + if @uid == Puppet::Util::SUIDManager.uid || Facter.value(:operatingsystem) == "HP-UX" return "crontab" else return "crontab -u #{@path}" diff --git a/lib/puppet/util/suidmanager.rb b/lib/puppet/util/suidmanager.rb index c009750836e..6c3cd818baf 100644 --- a/lib/puppet/util/suidmanager.rb +++ b/lib/puppet/util/suidmanager.rb @@ -18,7 +18,7 @@ module Puppet::Util::SUIDManager def osx_maj_ver return @osx_maj_ver unless @osx_maj_ver.nil? - @osx_maj_ver = Facter.value('os.macosx.version.major') || false + @osx_maj_ver = Facter.value('macosx_productversion_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 a4c5400146f..9d8c12983f4 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 'os.name' => [:debian, :ubuntu] + defaultfor :operatingsystem => [: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 1725650f8c1..bd3f7bae145 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 = $os['name'] ? { + $vdir = $operatingsystem? { '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 9ec205a10bb..520eccb448d 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 $os['name'] { + case $operatingsystem { "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 a94b7fab548..349f92288a7 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 $facts['os']['name'] { + case $operatingsystem { "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 1a71aad5265..a210f35570f 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 = $os['name']? { + $vdir = $operatingsystem? { '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 07a4ff5bafb..34f3b1e91a1 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 Facter.value('os.family') == 'Debian' + if Facter.value(:osfamily) == 'Debian' test_cmd = '/usr/bin/test' end - if Facter.value('os.name') == 'Darwin' + if Facter.value(:operatingsystem) == '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 969d5b8f0f9..a61bcb86ff0 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?(Facter.value('os.distro.release.full')) + if ['2.1', '3', '4'].include?(Facter.value(:lsbdistrelease)) :up2date else :yum end when 'Fedora' - if Puppet::Util::Package.versioncmp(Facter.value('os.release.major'), '22') >= 0 + if Puppet::Util::Package.versioncmp(Facter.value(:operatingsystemmajrelease), '22') >= 0 :dnf else :yum end when 'Suse' - if Puppet::Util::Package.versioncmp(Facter.value('os.release.major'), '10') >= 0 + if Puppet::Util::Package.versioncmp(Facter.value(:operatingsystemmajrelease), '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(Facter.value('os.name')) - pending("No default provider specified in this test for #{Facter.value('os.name')}") + unless default_provider = provider_name(Facter.value(:operatingsystem)) + pending("No default provider specified in this test for #{Facter.value(:operatingsystem)}") 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 28486b9c729..06f39e0e2ca 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('os.release.major').and_return('6') + allow(Facter).to receive(:value).with(:operatingsystemmajrelease).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('os.release.major').and_return('5') + allow(Facter).to receive(:value).with(:operatingsystemmajrelease).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 a26fc470e41..e7d339c7193 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 = {"os"=> {"name" => "cisco_ios"},"clientcert"=>"3750"} + indirection_fact_values = {"operatingsystem"=>"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.*os.*\n.*name.*cisco_ios/) + expect(device).to receive(:puts).with(/name.*3750.*\n.*values.*\n.*operatingsystem.*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 1df5bdab000..ddff0fc03bb 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/os.family').twice.and_raise(LoadError) - Puppet::Confine.test('os.family') - Puppet::Confine.test('os.family') + expect(Puppet::Confine).to receive(:require).with('puppet/confine/osfamily').twice.and_raise(LoadError) + Puppet::Confine.test(:osfamily) + Puppet::Confine.test(:osfamily) 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/os.family').once.and_raise(LoadError) - Puppet::Confine.test('os.family') - Puppet::Confine.test('os.family') + expect(Puppet::Confine).to receive(:require).with('puppet/confine/osfamily').once.and_raise(LoadError) + Puppet::Confine.test(:osfamily) + Puppet::Confine.test(:osfamily) end end end diff --git a/spec/unit/face/epp_face_spec.rb b/spec/unit/face/epp_face_spec.rb index edaeb07d252..d7f461df6d6 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 => {'os' => {'name' => 'Merwin'} }, - :e => '<%= $facts[os][name] %>', + :facts => {'operatingsystem' => 'Merwin'}, + :e => '<%= $facts[operatingsystem] %>', })).to eql("Merwin") end diff --git a/spec/unit/file_bucket/dipper_spec.rb b/spec/unit/file_bucket/dipper_spec.rb index f14d2a5961d..584d7dc2bd6 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 Facter.value('os.family') == 'Solaris' && - Puppet::Util::Package.versioncmp(Facter.value('os.release.full'), '11.0') >= 0 + if Facter.value(:osfamily) == 'Solaris' && + Puppet::Util::Package.versioncmp(Facter.value(:operatingsystemrelease), '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 312a67f46c3..74a7f7c61f3 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('networking.hostname').and_return(hostname.sub(/\..+/, '')) - allow(Facter).to receive(:value).with('networking.domain').and_return(hostname.sub(/^[^.]+\./, '')) + allow(Facter).to receive(:value).with("hostname").and_return(hostname.sub(/\..+/, '')) + allow(Facter).to receive(:value).with("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 18ac4dac501..da8bed128c1 100644 --- a/spec/unit/indirector/catalog/compiler_spec.rb +++ b/spec/unit/indirector/catalog/compiler_spec.rb @@ -389,10 +389,10 @@ def a_request_that_contains(facts) before do allow(Puppet).to receive(:version).and_return(1) set_facts({ - 'networking.fqdn' => "my.server.com", - 'networking.ip' => "my.ip.address", - 'networking.ip6' => nil - }) + 'fqdn' => "my.server.com", + 'ipaddress' => "my.ip.address", + 'ipaddress6' => nil + }) @request = Puppet::Indirector::Request.new(:catalog, :find, node_name, nil) allow(compiler).to receive(:compile) allow(Puppet::Node.indirection).to receive(:find).with(node_name, anything).and_return(node) @@ -424,16 +424,16 @@ def a_request_that_contains(facts) before do |example| allow(Puppet).to receive(:version).and_return(1) set_facts({ - 'networking.fqdn' => "my.server.com", - 'networking.ip' => nil, + 'fqdn' => "my.server.com", + 'ipaddress' => nil, }) if example.metadata[:nil_ipv6] set_facts({ - 'networking.ip6' => nil + 'ipaddress6' => nil }) else set_facts({ - 'networking.ip6' => "my.ipv6.address" + 'ipaddress6' => "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 710950a8261..94fd04927d6 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('os.family').and_return(os[:name]) + allow(Facter).to receive(:value).with('osfamily').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('os.family').and_return('ObscureLinuxDistro') + allow(Facter).to receive(:value).with('osfamily').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('os.family').and_return('Windows') + allow(Facter).to receive(:value).with('osfamily').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 ddf146b772c..2d54886b826 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 = $os['family'] ? { + $rootgroup = $osfamily ? { '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 = $os['family'] ? { + $rootgroup = $osfamily ? { '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 5ef2777083c..1f803d39944 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 = $os['family'] ? { + $rootgroup = $osfamily ? { '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 e731d9b5643..bb9e179895c 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 'os.family' => Debian" do - expect(Facter).to receive(:value).with('os.family').and_return("Debian") + it "should be the default provider on :osfamily => Debian" do + expect(Facter).to receive(:value).with(:osfamily).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 a95a6012303..9a4e9b8b3c9 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('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}") + 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}") 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('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}") + 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}") expect(described_class).to be_default end end it "should not be the default provider on rhel7" do - 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") + 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") 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('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") + 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") expect(described_class).to be_default end it "should be the default provider on rhel8" do - 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") + 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") 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 3bfa20893ad..c7386658748 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('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') + 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') 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('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) + 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) 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 bba0456349d..ca814cd97d5 100644 --- a/spec/unit/provider/package/gem_spec.rb +++ b/spec/unit/provider/package/gem_spec.rb @@ -474,9 +474,9 @@ end context 'when is defaultfor' do - let(:os) { Facter.value('os.name') } + let(:os) { Facter.value(:operatingsystem) } subject do - described_class.defaultfor('os.name': os) + described_class.defaultfor(operatingsystem: 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 09e7d197f0d..161bdd0b5ae 100644 --- a/spec/unit/provider/package/pip2_spec.rb +++ b/spec/unit/provider/package/pip2_spec.rb @@ -24,9 +24,9 @@ end context 'when is defaultfor' do - let(:os) { Facter.value('os.name') } + let(:os) { Facter.value(:operatingsystem) } subject do - described_class.defaultfor('os.name': os) + described_class.defaultfor(operatingsystem: 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 ed64234c3b6..5d6ecf0ec34 100644 --- a/spec/unit/provider/package/pip3_spec.rb +++ b/spec/unit/provider/package/pip3_spec.rb @@ -24,9 +24,9 @@ end context 'when is defaultfor' do - let(:os) { Facter.value('os.name') } + let(:os) { Facter.value(:operatingsystem) } subject do - described_class.defaultfor('os.name': os) + described_class.defaultfor(operatingsystem: 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 86e90d2e948..e0072ae1361 100644 --- a/spec/unit/provider/package/pip_spec.rb +++ b/spec/unit/provider/package/pip_spec.rb @@ -454,9 +454,9 @@ end context 'when is defaultfor' do - let(:os) { Facter.value('os.name') } + let(:os) { Facter.value(:operatingsystem) } subject do - described_class.defaultfor('os.name': os) + described_class.defaultfor(operatingsystem: 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 a9dd0e16497..3aa6bf26c6e 100644 --- a/spec/unit/provider/package/pkg_spec.rb +++ b/spec/unit/provider/package/pkg_spec.rb @@ -31,20 +31,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('os.family').and_return(:Solaris) + allow(Facter).to receive(:value).with(:osfamily).and_return(:Solaris) allow(Facter).to receive(:value).with(:kernelrelease).and_return("5.#{ver}") - allow(Facter).to receive(:value).with('os.name').and_return(:Solaris) - allow(Facter).to receive(:value).with('os.release.major').and_return("#{ver}") + allow(Facter).to receive(:value).with(:operatingsystem).and_return(:Solaris) + allow(Facter).to receive(:value).with(:operatingsystemmajrelease).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('os.family').and_return(:Solaris) + allow(Facter).to receive(:value).with(:osfamily).and_return(:Solaris) allow(Facter).to receive(:value).with(:kernelrelease).and_return("5.#{ver}") - allow(Facter).to receive(:value).with('os.name').and_return(:Solaris) - allow(Facter).to receive(:value).with('os.release.major').and_return("#{ver}") + allow(Facter).to receive(:value).with(:operatingsystem).and_return(:Solaris) + allow(Facter).to receive(:value).with(:operatingsystemmajrelease).and_return("#{ver}") expect(described_class).to be_default end end @@ -254,9 +254,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 'os.release.full' #{hash[:osrel]}" do + context "with :operatingsystemrelease #{hash[:osrel]}" do before :each do - allow(Facter).to receive(:value).with('os.release.full').and_return(hash[:osrel]) + allow(Facter).to receive(:value).with(:operatingsystemrelease).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 9d9b5d2973e..bacfafe688c 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('os.name').at_least(:once).and_return(:freebsd) + expect(Facter).to receive(:value).with(:operatingsystem).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 a8c309f93d3..114546f8a4f 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 'os.family' => Gentoo" do - expect(Facter).to receive(:value).with('os.family').and_return("Gentoo") + it "should be the default provider on :osfamily => Gentoo" do + expect(Facter).to receive(:value).with(:osfamily).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 b7ee578c7cf..e9c97c62158 100644 --- a/spec/unit/provider/package/puppet_gem_spec.rb +++ b/spec/unit/provider/package/puppet_gem_spec.rb @@ -88,9 +88,9 @@ end context 'when is defaultfor' do - let(:os) { Facter.value('os.name') } + let(:os) { Facter.value(:operatingsystem) } subject do - described_class.defaultfor('os.name': os) + described_class.defaultfor(operatingsystem: 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 545fe0545e8..e3cca15dadd 100644 --- a/spec/unit/provider/package/puppetserver_gem_spec.rb +++ b/spec/unit/provider/package/puppetserver_gem_spec.rb @@ -125,9 +125,9 @@ end context 'when is defaultfor' do - let(:os) { Facter.value('os.name') } + let(:os) { Facter.value(:operatingsystem) } subject do - described_class.defaultfor('os.name': os) + described_class.defaultfor(operatingsystem: 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 36e08a8425c..7f715b163d2 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('os.family').and_return(:redhat) - allow(Facter).to receive(:value).with('os.name').and_return("PhotonOS") + allow(Facter).to receive(:value).with(:osfamily).and_return(:redhat) + allow(Facter).to receive(:value).with(:operatingsystem).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 a23ba9d4b50..72bce2f5d28 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('os.family').and_return(osfamily) - allow(Facter).to receive(:value).with('os.distro.release.full').and_return(release) + allow(Facter).to receive(:value).with(:osfamily).and_return(osfamily) + allow(Facter).to receive(:value).with(:lsbdistrelease).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 c4a9d386a23..923af403e7e 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('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") + 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") 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('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) + 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) 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('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) + 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) expect(described_class).to be_default end end it "should not be default for redhat 8" do - 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') + 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') expect(described_class).not_to be_default end it "should not be default for Ubuntu 16.04" do - 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') + 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') 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('os.release.major').and_return('7') + allow(Facter).to receive(:value).with(:operatingsystemmajrelease).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 b0118c18e9a..0039f492e46 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) end it "retrieves a PID from the process table" do - allow(Facter).to receive(:value).with('os.name').and_return("CentOS") + allow(Facter).to receive(:value).with(:operatingsystem).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 b6fff65a11d..7f6236e36d8 100644 --- a/spec/unit/provider/service/bsd_spec.rb +++ b/spec/unit/provider/service/bsd_spec.rb @@ -10,8 +10,8 @@ before :each do allow(Puppet::Type.type(:service)).to receive(:defaultprovider).and_return(provider_class) - allow(Facter).to receive(:value).with('os.name').and_return(:netbsd) - allow(Facter).to receive(:value).with('os.family').and_return('NetBSD') + allow(Facter).to receive(:value).with(:operatingsystem).and_return(:netbsd) + allow(Facter).to receive(:value).with(:osfamily).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 fb272058bf7..5aa57a3accf 100644 --- a/spec/unit/provider/service/debian_spec.rb +++ b/spec/unit/provider/service/debian_spec.rb @@ -34,20 +34,20 @@ ['1','2'].each do |version| it "should be the default provider on CumulusLinux #{version}" do - 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(Facter).to receive(:value).with(:operatingsystem).at_least(:once).and_return('CumulusLinux') + expect(Facter).to receive(:value).with(:operatingsystemmajrelease).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('os.name').at_least(:once).and_return('Devuan') + expect(Facter).to receive(:value).with(:operatingsystem).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('os.name').at_least(:once).and_return('Debian') - expect(Facter).to receive(:value).with('os.release.major').and_return('7') + expect(Facter).to receive(:value).with(:operatingsystem).at_least(:once).and_return('Debian') + expect(Facter).to receive(:value).with(:operatingsystemmajrelease).and_return('7') expect(provider_class.default?).to be_truthy end @@ -151,8 +151,8 @@ context "when checking service status" do it "should use the service command" do - allow(Facter).to receive(:value).with('os.name').and_return('Debian') - allow(Facter).to receive(:value).with('os.release.major').and_return('8') + allow(Facter).to receive(:value).with(:operatingsystem).and_return('Debian') + allow(Facter).to receive(:value).with(:operatingsystemmajrelease).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 e5dbdc3b436..7ee52e9e81c 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('os.family').and_return('FreeBSD') + allow(Facter).to receive(:value).with(:osfamily).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 4c19d9e321e..335dc657af4 100644 --- a/spec/unit/provider/service/gentoo_spec.rb +++ b/spec/unit/provider/service/gentoo_spec.rb @@ -12,8 +12,8 @@ allow(Puppet::Type.type(:service)).to receive(:defaultprovider).and_return(provider_class) allow(FileTest).to receive(:file?).with('/sbin/rc-update').and_return(true) allow(FileTest).to receive(:executable?).with('/sbin/rc-update').and_return(true) - allow(Facter).to receive(:value).with('os.name').and_return('Gentoo') - allow(Facter).to receive(:value).with('os.family').and_return('Gentoo') + allow(Facter).to receive(:value).with(:operatingsystem).and_return('Gentoo') + allow(Facter).to receive(:value).with(:osfamily).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 853ef05f663..b9525fb1261 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('os.name').and_return('FreeBSD') - allow(Facter).to receive(:value).with('os.family').and_return('FreeBSD') + allow(Facter).to receive(:value).with(:operatingsystem).and_return('FreeBSD') + allow(Facter).to receive(:value).with(:osfamily).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('os.name').and_return('HP-UX') + allow(Facter).to receive(:value).with(:operatingsystem).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('os.name').and_return('Archlinux') + allow(Facter).to receive(:value).with(:operatingsystem).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('os.name').and_return('RedHat') + allow(Facter).to receive(:value).with(:operatingsystem).and_return('RedHat') end it "should set its default path to include /etc/init.d" do @@ -103,7 +103,7 @@ end it "should omit Yocto services on cisco-wrlinux" do - allow(Facter).to receive(:value).with('os.family').and_return('cisco-wrlinux') + allow(Facter).to receive(:value).with(:osfamily).and_return('cisco-wrlinux') exclude = 'umountfs' expect(provider_class.get_services(provider_class.defpath).map(&:name)).to eq(@services - [exclude]) end @@ -282,7 +282,7 @@ describe "when starting a service on Solaris" do it "should use ctrun" do - allow(Facter).to receive(:value).with('os.family').and_return('Solaris') + allow(Facter).to receive(:value).with(:osfamily).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("") allow($CHILD_STATUS).to receive(:exitstatus).and_return(0) provider.start @@ -291,7 +291,7 @@ describe "when starting a service on RedHat" do it "should not use ctrun" do - allow(Facter).to receive(:value).with('os.family').and_return('RedHat') + allow(Facter).to receive(:value).with(:osfamily).and_return('RedHat') expect(provider).to receive(:execute).with(['/service/path/myservice', :start], {:failonfail => true, :override_locale => false, :squelch => false, :combine => true}).and_return("") allow($CHILD_STATUS).to receive(:exitstatus).and_return(0) provider.start diff --git a/spec/unit/provider/service/openbsd_spec.rb b/spec/unit/provider/service/openbsd_spec.rb index 396aa3ea267..90f003b5705 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('os.name').and_return(:openbsd) - allow(Facter).to receive(:value).with('os.family').and_return('OpenBSD') + allow(Facter).to receive(:value).with(:operatingsystem).and_return(:openbsd) + allow(Facter).to receive(:value).with(:osfamily).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 99d32c9ae26..3e424fd222b 100644 --- a/spec/unit/provider/service/openwrt_spec.rb +++ b/spec/unit/provider/service/openwrt_spec.rb @@ -38,7 +38,7 @@ operatingsystem = 'openwrt' it "should be the default provider on #{operatingsystem}" do - expect(Facter).to receive(:value).with('os.name').and_return(operatingsystem) + expect(Facter).to receive(:value).with(:operatingsystem).and_return(operatingsystem) 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 1898d028de5..f4e2e7e5103 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('os.name').and_return(:netbsd) - allow(Facter).to receive(:value).with('os.family').and_return('NetBSD') + allow(Facter).to receive(:value).with(:operatingsystem).and_return(:netbsd) + allow(Facter).to receive(:value).with(:osfamily).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 fe7d3f69d95..652ca8f97aa 100644 --- a/spec/unit/provider/service/redhat_spec.rb +++ b/spec/unit/provider/service/redhat_spec.rb @@ -24,23 +24,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('os.name').and_return('CentOS') - allow(Facter).to receive(:value).with('os.family').and_return('RedHat') + allow(Facter).to receive(:value).with(:operatingsystem).and_return('CentOS') + allow(Facter).to receive(:value).with(:osfamily).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('os.family').and_return(osfamily) + expect(Facter).to receive(:value).with(:osfamily).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('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") + 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") expect(provider_class.default?).to be_truthy end @@ -87,7 +87,7 @@ context "when checking enabled? on Suse" do before :each do - expect(Facter).to receive(:value).with('os.family').and_return('Suse') + expect(Facter).to receive(:value).with(:osfamily).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 5d2ca235400..00b58c0c9f9 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('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') + 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') 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('os.release.full').and_return('11.3') + expect(Facter).to receive(:value).with(:operatingsystemrelease).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('os.release.full').and_return('11.2') + expect(Facter).to receive(:value).with(:operatingsystemrelease).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('os.release.full').and_return('10.3') + expect(Facter).to receive(:value).with(:operatingsystemrelease).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('os.release.full').and_return('10.3') + allow(Facter).to receive(:value).with(:operatingsystemrelease).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('os.release.full').and_return('11.3') + allow(Facter).to receive(:value).with(:operatingsystemrelease).and_return('11.3') allow(@provider).to receive(:complete_service?).and_return(false) expect(@provider.status).to eq(:stopped) end diff --git a/spec/unit/provider/service/systemd_spec.rb b/spec/unit/provider/service/systemd_spec.rb index d615c3173d3..33eac8ef9e3 100644 --- a/spec/unit/provider/service/systemd_spec.rb +++ b/spec/unit/provider/service/systemd_spec.rb @@ -27,149 +27,149 @@ osfamilies.each do |osfamily| it "should be the default provider on #{osfamily}" do - 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") + 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") expect(provider_class).to be_default end end [7, 8].each do |ver| it "should be the default provider on rhel#{ver}" do - 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) + 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) 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('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}") + 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}") 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('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}") + 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}") 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('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") + 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") 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('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") + 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") expect(provider_class).not_to be_default end it "should be the default provider on cumulus3" do - 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") + 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") expect(provider_class).to be_default end it "should be the default provider on sles12" do - 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") + 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") expect(provider_class).to be_default end it "should be the default provider on opensuse13" do - 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") + 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") 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('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") + 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") 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('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") + 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") expect(provider_class).to be_default end it "should not be the default provider on debian7" do - 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") + 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") expect(provider_class).not_to be_default end it "should be the default provider on debian8" do - 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") + 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") expect(provider_class).to be_default end it "should be the default provider on debian11" do - 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") + 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") expect(provider_class).to be_default end it "should be the default provider on debian bookworm/sid" do - 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") + 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") expect(provider_class).to be_default end it "should not be the default provider on ubuntu14.04" do - 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") + 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") 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('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}") + 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}") 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('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}") + 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}") 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('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}") + 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}") 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 10488c81812..3a4e5a08902 100644 --- a/spec/unit/provider/service/upstart_spec.rb +++ b/spec/unit/provider/service/upstart_spec.rb @@ -26,8 +26,8 @@ def lists_processes_as(output) end it "should be the default provider on Ubuntu" do - 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(Facter).to receive(:value).with(:operatingsystem).and_return("Ubuntu") + expect(Facter).to receive(:value).with(:operatingsystemmajrelease).and_return("12.04") expect(provider_class.default?).to be_truthy end @@ -55,7 +55,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('os.family').and_return('RedHat') + allow(Facter).to receive(:value).with(:osfamily).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 0d9308e5960..882e94f5111 100644 --- a/spec/unit/provider/user/directoryservice_spec.rb +++ b/spec/unit/provider/user/directoryservice_spec.rb @@ -1111,9 +1111,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 Facter.value("os.macosx.version.major") ONLY ONCE no matter how ' + + it 'should call Facter.value(:macosx_productversion_major) ONLY ONCE no matter how ' + 'many times get_os_version() is called' do - expect(Facter).to receive(:value).with('os.macosx.version.major').once.and_return('10.8') + expect(Facter).to receive(:value).with(:macosx_productversion_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 7a35dd92472..0079f357a7a 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('os.family').and_return('OpenBSD') - allow(Facter).to receive(:value).with('os.release.major') + allow(Facter).to receive(:value).with(:osfamily).and_return('OpenBSD') + allow(Facter).to receive(:value).with(:operatingsystemmajrelease) 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 fa48f3a33a4..a8a5ed750d0 100644 --- a/spec/unit/provider/user/useradd_spec.rb +++ b/spec/unit/provider/user/useradd_spec.rb @@ -75,8 +75,8 @@ context "when setting groups" do it "uses -G to set groups" do - allow(Facter).to receive(:value).with('os.family').and_return('Solaris') - allow(Facter).to receive(:value).with('os.release.major') + allow(Facter).to receive(:value).with(:osfamily).and_return('Solaris') + allow(Facter).to receive(:value).with(:operatingsystemmajrelease) resource[:ensure] = :present resource[:groups] = ['group1', 'group2'] expect(provider).to receive(:execute).with(['/usr/sbin/useradd', '-G', 'group1,group2', 'myuser'], kind_of(Hash)) @@ -84,8 +84,8 @@ end it "uses -G to set groups with -M on supported systems" do - allow(Facter).to receive(:value).with('os.family').and_return('RedHat') - allow(Facter).to receive(:value).with('os.release.major') + allow(Facter).to receive(:value).with(:osfamily).and_return('RedHat') + allow(Facter).to receive(:value).with(:operatingsystemmajrelease) resource[:ensure] = :present resource[:groups] = ['group1', 'group2'] expect(provider).to receive(:execute).with(['/usr/sbin/useradd', '-G', 'group1,group2', '-M', 'myuser'], kind_of(Hash)) @@ -303,14 +303,14 @@ describe "#expiry=" do it "should pass expiry to usermod as MM/DD/YY when on Solaris" do - expect(Facter).to receive(:value).with('os.name').and_return('Solaris') + expect(Facter).to receive(:value).with(:operatingsystem).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('os.name').and_return('not_solaris') + expect(Facter).to receive(:value).with(:operatingsystem).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' @@ -323,8 +323,8 @@ end it "should use -e with -1 when the expiry property is removed on SLES11" do - allow(Facter).to receive(:value).with('os.name').and_return('SLES') - allow(Facter).to receive(:value).with('os.release.major').and_return('11') + allow(Facter).to receive(:value).with(:operatingsystem).and_return('SLES') + allow(Facter).to receive(:value).with(:operatingsystemmajrelease).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 @@ -487,16 +487,16 @@ end it "should use -M flag if home is not managed on a supported system" do - allow(Facter).to receive(:value).with('os.family').and_return("RedHat") - allow(Facter).to receive(:value).with('os.release.major') + allow(Facter).to receive(:value).with(:osfamily).and_return("RedHat") + allow(Facter).to receive(:value).with(:operatingsystemmajrelease) 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('os.family').and_return("Suse") - allow(Facter).to receive(:value).with('os.release.major').and_return("11") + allow(Facter).to receive(:value).with(:osfamily).and_return("Suse") + allow(Facter).to receive(:value).with(:operatingsystemmajrelease).and_return("11") resource[:managehome] = :false expect(provider).to receive(:execute).with(excluding('-M'), kind_of(Hash)) provider.create @@ -557,14 +557,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('os.name').and_return('Solaris') + allow(Facter).to receive(:value).with(:operatingsystem).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('os.name').and_return('not_solaris') + allow(Facter).to receive(:value).with(:operatingsystem).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 5dd31da76a6..c79edf41637 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, - { 'os.name' => Facter.value('os.name') } => true, - { 'os.name' => :yayness } => false, + { :operatingsystem => Facter.value(:operatingsystem) } => true, + { :operatingsystem => :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, - { 'os.name' => Facter.value('os.name'), + { :operatingsystem => Facter.value(:operatingsystem), :exists => Puppet::Util.which(existing_command) } => true, - { 'os.name' => :yayness, + { :operatingsystem => :yayness, :exists => Puppet::Util.which(existing_command) } => false, - { 'os.name' => Facter.value('os.name'), + { :operatingsystem => Facter.value(:operatingsystem), :exists => "/this/file/does/not/exist" } => false, - { 'os.name' => :yayness, + { :operatingsystem => :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 Facter.value('os.name') end + let :os do Facter.value(:operatingsystem) end it { is_expected.to respond_to :specificity } it "should find the default provider" do type.provide(:nondefault) {} - subject.defaultfor 'os.name' => os + subject.defaultfor :operatingsystem => 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('os.family').at_least(:once).and_return("solaris") + expect(Facter).to receive(:value).with(:osfamily).at_least(:once).and_return("solaris") one = type.provide(:one) do - defaultfor 'os.family' => /solaris/ + defaultfor :osfamily => /solaris/ end expect(one).to be_default end it "should not match a non-matching regex " do - expect(Facter).to receive(:value).with('os.family').at_least(:once).and_return("redhat") + expect(Facter).to receive(:value).with(:osfamily).at_least(:once).and_return("redhat") one = type.provide(:one) do - defaultfor 'os.family' => /solaris/ + defaultfor :osfamily => /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('os.name').at_least(:once).and_return("fedora") - expect(Facter).to receive(:value).with('os.release.major').at_least(:once).and_return("24") + 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") one = type.provide(:one) do - defaultfor 'os.name' => "fedora", 'os.release.major' => /^2[2-9]$/ + defaultfor :operatingsystem => "fedora", :operatingsystemmajrelease => /^2[2-9]$/ end two = type.provide(:two) do - defaultfor 'os.name' => /fedora/, 'os.release.major' => '24' + defaultfor :operatingsystem => /fedora/, :operatingsystemmajrelease => '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 'os.name' => :os1 - subject.defaultfor 'os.name' => :os2 + subject.defaultfor :operatingsystem => :os1 + subject.defaultfor :operatingsystem => :os2 end let(:alternate) { type.provide(:alternate) {} } it "should be default for the first defaultfor" do - expect(Facter).to receive(:value).with('os.name').at_least(:once).and_return(:os1) + expect(Facter).to receive(:value).with(:operatingsystem).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('os.name').at_least(:once).and_return(:os2) + expect(Facter).to receive(:value).with(:operatingsystem).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 'os.name' => :os1 - subject.defaultfor 'os.name' => :os2, 'os.release.major' => "42" - subject.defaultfor 'os.name' => :os3, 'os.release.major' => /^4[2-9]$/ + subject.defaultfor :operatingsystem => :os1 + subject.defaultfor :operatingsystem => :os2, :operatingsystemmajrelease => "42" + subject.defaultfor :operatingsystem => :os3, :operatingsystemmajrelease => /^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('os.name').at_least(:once).and_return(:os2) - expect(Facter).to receive(:value).with('os.release.major').at_least(:once).and_return("42") + 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(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('os.name').at_least(:once).and_return(:os3) - expect(Facter).to receive(:value).with('os.release.major').at_least(:once).and_return("42") + 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(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('os.name').at_least(:once).and_return(:os1) + expect(Facter).to receive(:value).with(:operatingsystem).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 'os.name' => [:one, :two, :three, os] + subject.defaultfor :operatingsystem => [: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 'os.name' => :one + subject.defaultfor :operatingsystem => :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('os.name').at_least(:once).and_return("fedora") - expect(Facter).to receive(:value).with('os.release.major').at_least(:once).and_return("24") + 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") one = type.provide(:one) do - defaultfor 'os.name' => "fedora" - notdefaultfor 'os.name' => "fedora", 'os.release.major' => 24 + defaultfor :operatingsystem => "fedora" + notdefaultfor :operatingsystem => "fedora", :operatingsystemmajrelease => 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('os.name').at_least(:once).and_return("fedora") - expect(Facter).to receive(:value).with('os.release.major').at_least(:once).and_return("24") + 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") one = type.provide(:one) do - defaultfor 'os.name' => "fedora" - notdefaultfor 'os.name' => "fedora", 'os.release.major' => 42 + defaultfor :operatingsystem => "fedora" + notdefaultfor :operatingsystem => "fedora", :operatingsystemmajrelease => 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('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") + 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") one = type.provide(:one) do if defaultforspec[:one].key?(:defaultfor) - defaultfor 'os.family' => "redhat" if defaultforspec[:one][:defaultfor] - defaultfor 'os.family' => "ubuntu" if !defaultforspec[:one][:defaultfor] + defaultfor :osfamily => "redhat" if defaultforspec[:one][:defaultfor] + defaultfor :osfamily => "ubuntu" if !defaultforspec[:one][:defaultfor] end if defaultforspec[:one].key?(:notdefaultfor) - notdefaultfor 'os.name' => "centos" if defaultforspec[:one][:notdefaultfor] - notdefaultfor 'os.name' => "ubuntu" if !defaultforspec[:one][:notdefaultfor] + notdefaultfor :operatingsystem => "centos" if defaultforspec[:one][:notdefaultfor] + notdefaultfor :operatingsystem => "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 '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] + 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] end if defaultforspec[:two].key?(:notdefaultfor) - notdefaultfor 'os.release.full' => "27" if defaultforspec[:two][:notdefaultfor] - notdefaultfor 'os.release.full' => "99" if !defaultforspec[:two][:notdefaultfor] + notdefaultfor :operatingsystemrelease => "27" if defaultforspec[:two][:notdefaultfor] + notdefaultfor :operatingsystemrelease => "99" if !defaultforspec[:two][:notdefaultfor] end end diff --git a/spec/unit/type/package_spec.rb b/spec/unit/type/package_spec.rb index ca62eeac5a0..346b9411f74 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('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") + 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") 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 6c840e01657..cd17419f2bc 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('os.name').and_return(os) - allow(Facter).to receive(:value).with('os.family').and_return(os) + allow(Facter).to receive(:value).with(:operatingsystem).and_return(os) + allow(Facter).to receive(:value).with(:osfamily).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 bb002aef334..cc2e637c0fd 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 'os.name' => Facter.value('os.name') + defaultfor :operatingsystem => Facter.value(:operatingsystem) 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 'os.name' => Facter.value('os.name') + defaultfor :operatingsystem => Facter.value(:operatingsystem) mk_resource_methods class << self attr_accessor :names diff --git a/tasks/parallel.rake b/tasks/parallel.rake index 184aa90fcb8..3982f2249c8 100644 --- a/tasks/parallel.rake +++ b/tasks/parallel.rake @@ -401,7 +401,7 @@ else # Default group size in rspec examples DEFAULT_GROUP_SIZE = 1000 - process_count = [(args[:process_count] || Facter.value('processors.count')).to_i, 1].max + process_count = [(args[:process_count] || Facter.value("processorcount")).to_i, 1].max group_size = [(args[:group_size] || DEFAULT_GROUP_SIZE).to_i, 1].max abort unless Parallel::RSpec::Parallelizer.new(process_count, group_size, color_output?, args.extras).run