Skip to content

Commit 66a2b18

Browse files
cthorn42bastelfreak
authored andcommitted
(PUP-10853) Remove legacy facts
Replaces legacy facts with newer structured facts. This is cherry-picked from 82cef23
1 parent 947f807 commit 66a2b18

File tree

134 files changed

+473
-474
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

134 files changed

+473
-474
lines changed

acceptance/lib/puppet/acceptance/agent_fqdn_utils.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ module AgentFqdnUtils
77
# convert from an Beaker::Host (agent) to the systems fqdn as returned by facter
88
def agent_to_fqdn(agent)
99
unless @@hostname_to_fqdn.has_key?(agent.hostname)
10-
@@hostname_to_fqdn[agent.hostname] = on(agent, facter('fqdn')).stdout.chomp
10+
@@hostname_to_fqdn[agent.hostname] = on(agent, facter('networking.fqdn')).stdout.chomp
1111
end
1212
@@hostname_to_fqdn[agent.hostname]
1313
end

acceptance/tests/aix/nim_package_provider.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
version = on(aix, 'puppet --version').stdout
99
version &&
1010
Gem::Version.new(version) > Gem::Version.new('6.4.0') &&
11-
on(aix, 'facter operatingsystemrelease').stdout == '7.2'
11+
on(aix, 'facter os.release.full').stdout == '7.2'
1212
end
1313

1414
teardown do

acceptance/tests/language/binary_data_type.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
:assertions => { :assert_match => 'Notice: A:\\xF0\\x9F\\x91\\x92' } },
6262
{ :type => 'notify', :parameters => { :namevar => "B:${type($bin_file)}" }, :pre_code => '$bin_file=binary_file("empty/blah.txt")',
6363
:assertions => { :assert_match => 'Notice: B:Binary' } },
64-
{ :type => 'file', :parameters => { :namevar => "$pup_tmp_filename", :content => "$relaxed" }, :pre_code => "$pup_tmp_filename = if $osfamily == 'windows' { '#{tmp_filename_win}' } else { '#{tmp_filename_else}' }",
64+
{ :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}' }",
6565
:assertions => { :assert_match => /#{base64_relaxed}/ } },
6666
]
6767

acceptance/tests/language/sensitive_data_type.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
{:type => 'notify', :parameters => {:namevar => "C:meh", :message => '"C:${$mehC.unwrap |$unwrapped| { "blk_${unwrapped}_blk" } } nonblk_${mehC}_nonblk"'}, :pre_code => '$mehC=Sensitive.new("sekritC")',
6666
:assertions => {:assert_match => ["C:blk_sekritC_blk", "nonblk_#{notify_redacted}_nonblk"]}},
6767
# for --show_diff
68-
{: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}' }",
68+
{: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}' }",
6969
:assertions => [{:refute_match => 'sekritD'}, {:assert_match => /#{tmp_environment}\.txt..content. #{file_redacted}/}]},
7070

7171
]

acceptance/tests/loader/autoload_from_resource_type_decl.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def empty_execution_log_file(host, path)
4545
custom_type = <<-END
4646
Puppet::Type.newtype(:type_tst) do
4747
newparam(:name, :namevar => true) do
48-
fqdn = Facter.value(:fqdn)
48+
fqdn = Facter.value('networking.fqdn')
4949
if fqdn == '#{agent_to_fqdn(master)}'
5050
File.open("#{execution_log[agent_to_fqdn(master)]}", 'a+') { |f| f.puts("found_type_tst: " + Time.now.to_s) }
5151
end

acceptance/tests/lookup/merge_strategies.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@
4343
- "host"
4444
- "roles"
4545
- "profiles"
46-
- "%{::operatingsystem}"
47-
- "%{::osfamily}"
48-
- "%{::kernel}"
46+
- "%{facts.os.name}"
47+
- "%{facts.os.family}"
48+
- "%{facts.kernel}"
4949
- "common"
5050
:merge_behavior: deeper
5151
:deep_merge_options:

acceptance/tests/resource/service/service_enable_linux.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
agents.each do |agent|
2323
platform = agent.platform.variant
2424
osname = on(agent, facter('os.name')).stdout.chomp
25-
majrelease = on(agent, facter('operatingsystemmajrelease')).stdout.chomp.to_i
25+
majrelease = on(agent, facter('os.release.major')).stdout.chomp.to_i
2626

2727
init_script_systemd = "/usr/lib/systemd/system/#{package_name[platform]}.service"
2828
symlink_systemd = "/etc/systemd/system/multi-user.target.wants/#{package_name[platform]}.service"

acceptance/tests/ssl/certificate_extensions.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
initialize_temp_dirs
1212

1313
agent_certnames = []
14-
hostname = master.execute('facter hostname')
15-
fqdn = master.execute('facter fqdn')
14+
hostname = master.execute('facter networking.hostname')
15+
fqdn = master.execute('facter networking.fqdn')
1616

1717
teardown do
1818
step "Cleanup the test agent certs"

acceptance/tests/ticket_15560_managehome.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030

3131
deleteable_profile = true
3232

33-
version = on(host, facter('operatingsystemrelease')).stdout.chomp
33+
version = on(host, facter('os.release.full')).stdout.chomp
3434
if version =~ /^5\.[012]|2003/
3535
homedir = "C:/Documents and Settings/#{username}"
3636
deleteable_profile = false

acceptance/tests/windows/QA-506_windows_exit_codes_test.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
native_modules_path = on(agent, puppet("config print #{module_path_config_property}")).stdout.gsub('C:', '/cygdrive/c').strip
5959

6060
#Check to see if we are running on Windows 2003. Do a crazy hack to get around SCP issues.
61-
if (on(agent, facter("find operatingsystemmajrelease")).stdout =~ /2003/)
61+
if (on(agent, facter("os.release.major")).stdout =~ /2003/)
6262
on(agent, "ln -s #{native_modules_path.gsub(/ /, '\ ')} /tmp/puppet_etc")
6363
modules_path = '/tmp/puppet_etc'
6464
else

install.rb

+17-17
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ def do_man(man, strip = 'man/')
9292
FileUtils.install(mf, omf, mode: 0644, preserve: true, verbose: true)
9393
# Solaris does not support gzipped man pages. When called with
9494
# --no-check-prereqs/without facter the default gzip behavior still applies
95-
unless $operatingsystem == "Solaris"
95+
unless $osname == "Solaris"
9696
gzip = %x{which gzip}
9797
gzip.chomp!
9898
%x{#{gzip} -f #{omf}}
@@ -234,56 +234,56 @@ def prepare_installation
234234
RbConfig::CONFIG['bindir'] = "/usr/bin"
235235
end
236236

237-
# Here we only set $operatingsystem if we have opted to check for prereqs.
237+
# Here we only set $osname if we have opted to check for prereqs.
238238
# Otherwise facter won't be guaranteed to be present.
239239
if InstallOptions.check_prereqs
240240
check_prereqs
241-
$operatingsystem = Facter.value :operatingsystem
241+
$osname = Facter.value('os.name')
242242
end
243243

244244
if not InstallOptions.configdir.nil?
245245
configdir = InstallOptions.configdir
246-
elsif $operatingsystem == "windows"
246+
elsif $osname == "windows"
247247
configdir = File.join(ENV['ALLUSERSPROFILE'], "PuppetLabs", "puppet", "etc")
248248
else
249249
configdir = "/etc/puppetlabs/puppet"
250250
end
251251

252252
if not InstallOptions.codedir.nil?
253253
codedir = InstallOptions.codedir
254-
elsif $operatingsystem == "windows"
254+
elsif $osname == "windows"
255255
codedir = File.join(ENV['ALLUSERSPROFILE'], "PuppetLabs", "code")
256256
else
257257
codedir = "/etc/puppetlabs/code"
258258
end
259259

260260
if not InstallOptions.vardir.nil?
261261
vardir = InstallOptions.vardir
262-
elsif $operatingsystem == "windows"
262+
elsif $osname == "windows"
263263
vardir = File.join(ENV['ALLUSERSPROFILE'], "PuppetLabs", "puppet", "cache")
264264
else
265265
vardir = "/opt/puppetlabs/puppet/cache"
266266
end
267267

268268
if not InstallOptions.publicdir.nil?
269269
publicdir = InstallOptions.publicdir
270-
elsif $operatingsystem == "windows"
270+
elsif $osname == "windows"
271271
publicdir = File.join(ENV['ALLUSERSPROFILE'], "PuppetLabs", "puppet", "public")
272272
else
273273
publicdir = "/opt/puppetlabs/puppet/public"
274274
end
275275

276276
if not InstallOptions.rundir.nil?
277277
rundir = InstallOptions.rundir
278-
elsif $operatingsystem == "windows"
278+
elsif $osname == "windows"
279279
rundir = File.join(ENV['ALLUSERSPROFILE'], "PuppetLabs", "puppet", "var", "run")
280280
else
281281
rundir = "/var/run/puppetlabs"
282282
end
283283

284284
if not InstallOptions.logdir.nil?
285285
logdir = InstallOptions.logdir
286-
elsif $operatingsystem == "windows"
286+
elsif $osname == "windows"
287287
logdir = File.join(ENV['ALLUSERSPROFILE'], "PuppetLabs", "puppet", "var", "log")
288288
else
289289
logdir = "/var/log/puppetlabs/puppet"
@@ -298,7 +298,7 @@ def prepare_installation
298298
if not InstallOptions.localedir.nil?
299299
localedir = InstallOptions.localedir
300300
else
301-
if $operatingsystem == "windows"
301+
if $osname == "windows"
302302
localedir = File.join(ENV['PROGRAMFILES'], "Puppet Labs", "Puppet", "puppet", "share", "locale")
303303
else
304304
localedir = "/opt/puppetlabs/puppet/share/locale"
@@ -376,7 +376,7 @@ def prepare_installation
376376
# by stripping the drive letter, but only if the basedir is not empty.
377377
#
378378
def join(basedir, dir)
379-
return "#{basedir}#{dir[2..-1]}" if $operatingsystem == "windows" and basedir.length > 0 and dir.length > 2
379+
return "#{basedir}#{dir[2..-1]}" if $osname == "windows" and basedir.length > 0 and dir.length > 2
380380

381381
"#{basedir}#{dir}"
382382
end
@@ -398,7 +398,7 @@ def build_rdoc(files)
398398

399399
def build_ri(files)
400400
return unless $haverdoc
401-
return if $operatingsystem == "windows"
401+
return if $osname == "windows"
402402
begin
403403
ri = RDoc::RDoc.new
404404
#ri.document(["--ri-site", "--merge"] + files)
@@ -427,14 +427,14 @@ def install_binfile(from, op_file, target)
427427

428428
File.open(from) do |ip|
429429
File.open(tmp_file.path, "w") do |op|
430-
op.puts "#!#{ruby}" unless $operatingsystem == "windows"
430+
op.puts "#!#{ruby}" unless $osname == "windows"
431431
contents = ip.readlines
432432
contents.shift if contents[0] =~ /^#!/
433433
op.write contents.join
434434
end
435435
end
436436

437-
if $operatingsystem == "windows" && InstallOptions.batch_files
437+
if $osname == "windows" && InstallOptions.batch_files
438438
installed_wrapper = false
439439

440440
unless File.extname(from) =~ /\.(cmd|bat)/
@@ -484,16 +484,16 @@ def install_binfile(from, op_file, target)
484484

485485
prepare_installation
486486

487-
if $operatingsystem == "windows"
487+
if $osname == "windows"
488488
windows_bins = glob(%w{ext/windows/*bat})
489489
end
490490

491491
#build_rdoc(rdoc) if InstallOptions.rdoc
492492
#build_ri(ri) if InstallOptions.ri
493493
do_configs(configs, InstallOptions.config_dir) if InstallOptions.configs
494494
do_bins(bins, InstallOptions.bin_dir)
495-
do_bins(windows_bins, InstallOptions.bin_dir, 'ext/windows/') if $operatingsystem == "windows" && InstallOptions.batch_files
495+
do_bins(windows_bins, InstallOptions.bin_dir, 'ext/windows/') if $osname == "windows" && InstallOptions.batch_files
496496
do_libs(libs)
497497
do_locales(locales)
498-
do_man(man) unless $operatingsystem == "windows"
498+
do_man(man) unless $osname == "windows"
499499
end

lib/puppet/confiner.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ module Puppet::Confiner
1616
# * `:any` => an array of expressions that will be ORed together
1717
#
1818
# @example
19-
# confine :operatingsystem => [:redhat, :fedora]
19+
# confine 'os.name' => [:redhat, :fedora]
2020
# confine :true { ... }
2121
#
2222
# @param hash [Hash<{Symbol => Object}>] hash of confines

lib/puppet/file_serving/mount/file.rb

+4-4
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
class Puppet::FileServing::Mount::File < Puppet::FileServing::Mount
44
def self.localmap
55
@localmap ||= {
6-
"h" => Puppet.runtime[:facter].value("hostname"),
6+
"h" => Puppet.runtime[:facter].value('networking.hostname'),
77
"H" => [
8-
Puppet.runtime[:facter].value("hostname"),
9-
Puppet.runtime[:facter].value("domain")
8+
Puppet.runtime[:facter].value('networking.hostname'),
9+
Puppet.runtime[:facter].value('networking.domain')
1010
].join("."),
11-
"d" => Puppet.runtime[:facter].value("domain")
11+
"d" => Puppet.runtime[:facter].value('networking.domain')
1212
}
1313
end
1414

lib/puppet/provider/exec/windows.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
Puppet::Type.type(:exec).provide :windows, :parent => Puppet::Provider::Exec do
44

5-
confine :operatingsystem => :windows
6-
defaultfor :operatingsystem => :windows
5+
confine 'os.name' => :windows
6+
defaultfor 'os.name' => :windows
77

88
desc <<-'EOT'
99
Execute external binaries on Windows systems. As with the `posix`

lib/puppet/provider/file/windows.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Puppet::Type.type(:file).provide :windows do
22
desc "Uses Microsoft Windows functionality to manage file ownership and permissions."
33

4-
confine :operatingsystem => :windows
4+
confine 'os.name' => :windows
55
has_feature :manages_symlinks if Puppet.features.manages_symlinks?
66

77
include Puppet::Util::Warnings

lib/puppet/provider/group/aix.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
desc "Group management for AIX."
77

88
# This will the default provider for this platform
9-
defaultfor :operatingsystem => :aix
10-
confine :operatingsystem => :aix
9+
defaultfor 'os.name' => :aix
10+
confine 'os.name' => :aix
1111

1212
# Commands that manage the element
1313
commands :list => "/usr/sbin/lsgroup"

lib/puppet/provider/group/directoryservice.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
"
77

88
commands :dscl => "/usr/bin/dscl"
9-
confine :operatingsystem => :darwin
10-
defaultfor :operatingsystem => :darwin
9+
confine 'os.name' => :darwin
10+
defaultfor 'os.name' => :darwin
1111
has_feature :manages_members
1212

1313
def members_insync?(current, should)

lib/puppet/provider/group/groupadd.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
commands :add => "groupadd", :delete => "groupdel", :modify => "groupmod"
1111

12-
has_feature :system_groups unless %w{HP-UX Solaris}.include? Puppet.runtime[:facter].value(:operatingsystem)
12+
has_feature :system_groups unless %w{HP-UX Solaris}.include? Puppet.runtime[:facter].value('os.name')
1313

1414
verify :gid, _("GID must be an integer") do |value|
1515
value.is_a? Integer

lib/puppet/provider/group/pw.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
commands :pw => "pw"
77
has_features :manages_members
88

9-
defaultfor :operatingsystem => [:freebsd, :dragonfly]
10-
confine :operatingsystem => [:freebsd, :dragonfly]
9+
defaultfor 'os.name' => [:freebsd, :dragonfly]
10+
confine 'os.name' => [:freebsd, :dragonfly]
1111

1212
options :members, :flag => "-M", :method => :mem
1313

lib/puppet/provider/group/windows_adsi.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
desc "Local group management for Windows. Group members can be both users and groups.
55
Additionally, local groups can contain domain users."
66

7-
defaultfor :operatingsystem => :windows
8-
confine :operatingsystem => :windows
7+
defaultfor 'os.name' => :windows
8+
confine 'os.name' => :windows
99

1010
has_features :manages_members
1111

lib/puppet/provider/nameservice/directoryservice.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ class << self
1818
commands :dscl => "/usr/bin/dscl"
1919
commands :dseditgroup => "/usr/sbin/dseditgroup"
2020
commands :sw_vers => "/usr/bin/sw_vers"
21-
confine :operatingsystem => :darwin
21+
confine 'os.name' => :darwin
2222
confine :feature => :cfpropertylist
23-
defaultfor :operatingsystem => :darwin
23+
defaultfor 'os.name' => :darwin
2424

2525
# There is no generalized mechanism for provider cache management, but we can
2626
# use post_resource_eval, which will be run for each suitable provider at the

lib/puppet/provider/package/aix.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
# AIX supports versionable packages with and without a NIM server
2525
has_feature :versionable
2626

27-
confine :operatingsystem => [ :aix ]
28-
defaultfor :operatingsystem => :aix
27+
confine 'os.name' => [ :aix ]
28+
defaultfor 'os.name' => :aix
2929

3030
attr_accessor :latest_info
3131

lib/puppet/provider/package/appdmg.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
Puppet::Type.type(:package).provide(:appdmg, :parent => Puppet::Provider::Package) do
1818
desc "Package management which copies application bundles to a target."
1919

20-
confine :operatingsystem => :darwin
20+
confine 'os.name' => :darwin
2121
confine :feature => :cfpropertylist
2222

2323
commands :hdiutil => "/usr/bin/hdiutil"

lib/puppet/provider/package/apple.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
automatically add the `.pkg` extension, so leave that off when specifying
99
the package name."
1010

11-
confine :operatingsystem => :darwin
11+
confine 'os.name' => :darwin
1212
commands :installer => "/usr/sbin/installer"
1313

1414
def self.instances

lib/puppet/provider/package/apt.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
commands :aptmark => "/usr/bin/apt-mark"
2020
commands :preseed => "/usr/bin/debconf-set-selections"
2121

22-
defaultfor :osfamily => :debian
22+
defaultfor 'os.family' => :debian
2323

2424
ENV['DEBIAN_FRONTEND'] = "noninteractive"
2525

lib/puppet/provider/package/blastwave.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
pkgget = "pkg-get"
55
pkgget = "/opt/csw/bin/pkg-get" if FileTest.executable?("/opt/csw/bin/pkg-get")
66

7-
confine :osfamily => :solaris
7+
confine 'os.family' => :solaris
88

99
commands :pkgget => pkgget
1010

0 commit comments

Comments
 (0)