Skip to content

Commit

Permalink
Revert "Merge pull request #8492 from GabrielNagy/PUP-10853/remove-le…
Browse files Browse the repository at this point in the history
…gacy-facts"

This reverts commit 8660b32, reversing
changes made to c6412ea.

This also sneakily reverts e972610 by
switching back to using legacy facts.

When/If we decide to reintroduce this functionality, it should be enough
to revert this revert.
  • Loading branch information
GabrielNagy committed Mar 10, 2021
1 parent a91b4d7 commit fae6138
Show file tree
Hide file tree
Showing 146 changed files with 494 additions and 493 deletions.
2 changes: 1 addition & 1 deletion .gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -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<facter>, [">= 4.0.0", "< 5"])
s.add_runtime_dependency(%q<facter>, [">= 2.4.0", "< 5"])
s.add_runtime_dependency(%q<hiera>, [">= 3.2.1", "< 4"])
s.add_runtime_dependency(%q<semantic_puppet>, "~> 1.0")
s.add_runtime_dependency(%q<fast_gettext>, "~> 1.1")
Expand Down
2 changes: 1 addition & 1 deletion acceptance/lib/puppet/acceptance/agent_fqdn_utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion acceptance/tests/aix/nim_package_provider.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion acceptance/tests/catalog_with_binary_data.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand Down
2 changes: 1 addition & 1 deletion acceptance/tests/direct_puppet/supports_utf8.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
2 changes: 1 addition & 1 deletion acceptance/tests/language/binary_data_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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}/ } },
]

Expand Down
2 changes: 1 addition & 1 deletion acceptance/tests/language/sensitive_data_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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}/}]},

]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions acceptance/tests/lookup/merge_strategies.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
16 changes: 8 additions & 8 deletions acceptance/tests/parser_functions/hiera_in_templates.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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],
}
}
",
Expand Down Expand Up @@ -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',
Expand All @@ -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',
Expand All @@ -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',
Expand All @@ -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',
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion acceptance/tests/reports/corrective_change_new_resource.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
2 changes: 1 addition & 1 deletion acceptance/tests/reports/corrective_change_via_puppet.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion acceptance/tests/resource/service/service_enable_linux.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
16 changes: 8 additions & 8 deletions acceptance/tests/ssl/certificate_extensions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,29 +11,29 @@
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])
end
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}",
}
Expand Down Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion acceptance/tests/ticket_15560_managehome.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion acceptance/tests/windows/QA-506_windows_exit_codes_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion ext/project_data.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
4 changes: 2 additions & 2 deletions install.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
end

PREREQS = %w{openssl facter cgi hiera}
MIN_FACTER_VERSION = 4.0
MIN_FACTER_VERSION = 1.5

InstallOptions = OpenStruct.new

Expand Down Expand Up @@ -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?
Expand Down
2 changes: 1 addition & 1 deletion lib/puppet/confiner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions lib/puppet/file_serving/mount/file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
10 changes: 5 additions & 5 deletions lib/puppet/indirector/catalog/compiler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions lib/puppet/provider/exec/windows.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
2 changes: 1 addition & 1 deletion lib/puppet/provider/file/windows.rb
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions lib/puppet/provider/group/aix.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions lib/puppet/provider/group/directoryservice.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading

0 comments on commit fae6138

Please sign in to comment.