Skip to content

Commit 4328a2f

Browse files
committed
(PUP-10853) Remove usage of legacy networking facts
Use structured facts instead of legacy networking facts. The following mapping applies: fqdn => networking.fqdn domain => networking.domain hostname => networking.hostname ipaddress => networking.ip ipaddress6 => networking.ip6 Change `processorcount` to `processors.count`.
1 parent dbedb68 commit 4328a2f

File tree

18 files changed

+50
-50
lines changed

18 files changed

+50
-50
lines changed

acceptance/lib/puppet/acceptance/agent_fqdn_utils.rb

Lines changed: 1 addition & 1 deletion
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/catalog_with_binary_data.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
manifest = <<-MANIFEST
3535
class #{test_num}(
3636
) {
37-
\$test_path = \$::fqdn ? #{agent_tmp_dirs}
37+
\$test_path = \$facts['networking']['fqdn'] ? #{agent_tmp_dirs}
3838
file { '#{test_num}':
3939
path => "\$test_path/#{test_num}",
4040
content => file('#{test_num}/binary_data'),

acceptance/tests/direct_puppet/supports_utf8.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
file { '#{environmentpath}/#{tmp_environment}/manifests/site.pp':
3535
ensure => file,
3636
content => '
37-
\$test_path = \$::fqdn ? #{tmp_file}
37+
\$test_path = \$facts['networking']['fqdn'] ? #{tmp_file}
3838
file { \$test_path:
3939
content => @(UTF8)
4040
#{file_contents}

acceptance/tests/loader/autoload_from_resource_type_decl.rb

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

acceptance/tests/parser_functions/hiera_in_templates.rb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ def create_environment(osfamilies, tmp_dirs)
100100
\\$msgs = hiera_array('message')
101101
notify {\\$msgs:}
102102
class {'#{@module_name}':
103-
result_dir => hiera('result_dir')[\\$::hostname],
103+
result_dir => hiera('result_dir')[\\$facts['networking']['hostname']],
104104
}
105105
}
106106
",
@@ -188,7 +188,7 @@ class #{@module_name} (
188188
file { "#{moduledir}/manifests/mod_default.pp":
189189
content => "
190190
class #{@module_name}::mod_default {
191-
\\$result_dir = hiera('result_dir')[\\$::hostname]
191+
\\$result_dir = hiera('result_dir')[\\$facts['networking']['hostname']]
192192
notify{\\"module mod_default invoked.\\\\n\\":}
193193
file {\\\"\\\${result_dir}/mod_default\\\":
194194
ensure => 'file',
@@ -202,7 +202,7 @@ class #{@module_name}::mod_default {
202202
file { "#{moduledir}/manifests/mod_osfamily.pp":
203203
content => "
204204
class #{@module_name}::mod_osfamily {
205-
\\$result_dir = hiera('result_dir')[\\$::hostname]
205+
\\$result_dir = hiera('result_dir')[\\$facts['networking']['hostname']]
206206
notify{\\"module mod_osfamily invoked.\\\\n\\":}
207207
file {\\\"\\\${result_dir}/mod_osfamily\\\":
208208
ensure => 'file',
@@ -216,7 +216,7 @@ class #{@module_name}::mod_osfamily {
216216
file { "#{moduledir}/manifests/mod_production.pp":
217217
content => "
218218
class #{@module_name}::mod_production {
219-
\\$result_dir = hiera('result_dir')[\\$::hostname]
219+
\\$result_dir = hiera('result_dir')[\\$facts['networking']['hostname']]
220220
notify{\\"module mod_production invoked.\\\\n\\":}
221221
file {\\\"\\\${result_dir}/mod_production\\\":
222222
ensure => 'file',
@@ -230,7 +230,7 @@ class #{@module_name}::mod_production {
230230
file { "#{moduledir}/manifests/mod_fqdn.pp":
231231
content => "
232232
class #{@module_name}::mod_fqdn {
233-
\\$result_dir = hiera('result_dir')[\\$::hostname]
233+
\\$result_dir = hiera('result_dir')[\\$facts['networking']['hostname']]
234234
notify{\\"module mod_fqdn invoked.\\\\n\\":}
235235
file {\\\"\\\${result_dir}/mod_fqdn\\\":
236236
ensure => 'file',
@@ -282,7 +282,7 @@ def find_tmp_dirs
282282
tmp_dirs = ""
283283
host_to_result_dir = {}
284284
agents.each do |agent|
285-
h = on(agent, facter("hostname")).stdout.chomp
285+
h = on(agent, facter('networking.hostname')).stdout.chomp
286286
t = agent.tmpdir("#{@module_name}_results")
287287
tmp_dirs += " #{h}: '#{t}'\n"
288288
host_to_result_dir[h] = t
@@ -304,7 +304,7 @@ def find_tmp_dirs
304304
env_manifest = create_environment(find_osfamilies, tmp_dirs)
305305
apply_manifest_on(master, env_manifest, :catch_failures => true)
306306
agents.each do |agent|
307-
resultdir = host_to_result_dir[on(agent, facter("hostname")).stdout.chomp]
307+
resultdir = host_to_result_dir[on(agent, facter('networking.hostname')).stdout.chomp]
308308
step "Applying catalog to agent: #{agent}. result files in #{resultdir}"
309309
on(
310310
agent,

acceptance/tests/reports/corrective_change_new_resource.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
file { '#{environmentpath}/#{tmp_environment}/manifests/site.pp':
3737
ensure => file,
3838
content => '
39-
\$test_path = \$::fqdn ? #{tmp_file}
39+
\$test_path = \$facts['networking']['fqdn'] ? #{tmp_file}
4040
file { \$test_path:
4141
content => @(UTF8)
4242
#{file_contents}

acceptance/tests/reports/corrective_change_outside_puppet.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
file { '#{environmentpath}/#{tmp_environment}/manifests/site.pp':
3838
ensure => file,
3939
content => '
40-
\$test_path = \$::fqdn ? #{tmp_file}
40+
\$test_path = \$facts['networking']['fqdn'] ? #{tmp_file}
4141
file { \$test_path:
4242
content => @(UTF8)
4343
#{file_contents}

acceptance/tests/reports/corrective_change_via_puppet.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def create_manifest_for_file_resource(file_resource, file_contents, environment_
3939
file { '#{environmentpath}/#{environment_name}/manifests/site.pp':
4040
ensure => file,
4141
content => '
42-
\$test_path = \$::fqdn ? #{file_resource}
42+
\$test_path = \$facts['networking']['fqdn'] ? #{file_resource}
4343
file { \$test_path:
4444
content => @(UTF8)
4545
#{file_contents}

acceptance/tests/resource/file/ticket_6448_file_with_utf8_source.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949

5050
step 'create a site.pp on master containing a unicode file resource' do
5151
site_pp_contents = <<-SITE_PP
52-
\$test_path = \$::fqdn ? #{agent_tmp_dirs}
52+
\$test_path = \$facts['networking']['fqdn'] ? #{agent_tmp_dirs}
5353
file { "\$test_path/\uff72\uff67\u30d5\u30eb":
5454
ensure => present,
5555
source => "puppet:///modules/utf8_file_module/\u9759\u7684",

acceptance/tests/ssl/certificate_extensions.rb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,29 +11,29 @@
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"
19-
master_config = {
19+
server_config = {
2020
'main' => { 'server' => fqdn },
21-
'master' => { 'dns_alt_names' => "puppet,#{hostname},#{fqdn}" }
21+
'server' => { 'dns_alt_names' => "puppet,#{hostname},#{fqdn}" }
2222
}
2323

24-
with_puppet_running_on(master, master_config) do
24+
with_puppet_running_on(master, server_config) do
2525
on(master,
2626
"puppetserver ca clean --certname #{agent_certnames.join(',')}",
2727
:acceptable_exit_codes => [0,24])
2828
end
2929
end
3030

3131
environments_dir = get_test_file_path(master, "environments")
32-
master_config = {
32+
server_config = {
3333
'main' => {
3434
'environmentpath' => environments_dir,
3535
},
36-
'master' => {
36+
'server' => {
3737
'autosign' => true,
3838
'dns_alt_names' => "puppet,#{hostname},#{fqdn}",
3939
}
@@ -74,7 +74,7 @@
7474
}
7575
MANIFEST
7676

77-
with_puppet_running_on(master, master_config) do
77+
with_puppet_running_on(master, server_config) do
7878
agents.each do |agent|
7979
next if agent == master
8080

0 commit comments

Comments
 (0)