Skip to content

Commit 67e81b6

Browse files
authored
Merge pull request #637 from mhashizume/MODULES-11361/main/legacy-facts
(MODULES-11361) Updates legacy facts
2 parents 12ea70d + c536213 commit 67e81b6

29 files changed

+452
-280
lines changed

.fixtures.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ fixtures:
88
ref: "2.4.0"
99
apt:
1010
repo: "puppetlabs/apt"
11-
ref: "7.4.2"
11+
ref: "7.7.1"
1212
translate:
1313
repo: "puppetlabs/translate"
1414
ref: "1.2.0"

acceptance/helpers.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ def new_puppet_testing_environment
180180
def install_puppet_agent_module_on(host, environment)
181181
on(host, puppet('module', 'install', 'puppetlabs-stdlib', '--version', '5.1.0', '--environment', environment), { acceptable_exit_codes: [0] })
182182
on(host, puppet('module', 'install', 'puppetlabs-inifile', '--version', '2.4.0', '--environment', environment), { acceptable_exit_codes: [0] })
183-
on(host, puppet('module', 'install', 'puppetlabs-apt', '--version', '6.0.0', '--environment', environment), { acceptable_exit_codes: [0] })
183+
on(host, puppet('module', 'install', 'puppetlabs-apt', '--version', '7.7.1', '--environment', environment), { acceptable_exit_codes: [0] })
184184

185185
install_dev_puppet_module_on(host,
186186
source: File.join(File.dirname(__FILE__), '..'),

manifests/init.pp

+9-9
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@
9999
# This parameter is constrained to managing only a predetermined set of configuration
100100
# settings, e.g. runinterval.
101101
class puppet_agent (
102-
$arch = $::architecture,
102+
$arch = $facts['os']['architecture'],
103103
$collection = $::puppet_agent::params::collection,
104104
$is_pe = $::puppet_agent::params::_is_pe,
105105
$manage_pki_dir = true,
@@ -139,15 +139,15 @@
139139
fail('The puppet_agent module does not support pre-Puppet 4 upgrades.')
140140
}
141141

142-
if $package_version == 'latest' and $::osfamily =~ /^(?i:windows|solaris|aix|darwin)$/ {
143-
fail("Setting package_version to 'latest' is not supported on ${::osfamily.capitalize()}")
142+
if $package_version == 'latest' and $facts['os']['family'] =~ /^(?i:windows|solaris|aix|darwin)$/ {
143+
fail("Setting package_version to 'latest' is not supported on ${$facts['os']['family'].capitalize()}")
144144
}
145145

146146
if $source != undef and $absolute_source != undef {
147147
fail('Only one of $source and $absolute_source can be set')
148148
}
149149

150-
if $::osfamily == 'windows' and $install_dir != undef {
150+
if $facts['os']['family'] == 'windows' and $install_dir != undef {
151151
validate_absolute_path($install_dir)
152152
}
153153

@@ -159,7 +159,7 @@
159159
# In this code-path, $package_version != undef AND we are not on a PE infrastructure
160160
# node since $::pe_server_version is not defined
161161

162-
if $::architecture == 'x86' and $arch == 'x64' {
162+
if $facts['os']['architecture'] == 'x86' and $arch == 'x64' {
163163
fail('Unable to install x64 on a x86 system')
164164
}
165165

@@ -171,7 +171,7 @@
171171
$master_or_package_version = $package_version
172172
}
173173

174-
if $::osfamily == 'redhat' {
174+
if $facts['os']['family'] == 'redhat' {
175175
if $master_or_package_version !~ /^\d+\.\d+\.\d+.*$|^latest$|^present$/ {
176176
fail("invalid version ${master_or_package_version} requested")
177177
}
@@ -184,7 +184,7 @@
184184
# Strip git sha from dev builds
185185
if $master_or_package_version =~ /.g/ {
186186
$_expected_package_version = split($master_or_package_version, /[.-]g.*/)[0]
187-
} elsif $::osfamily == 'redhat' {
187+
} elsif $facts['os']['family'] == 'redhat' {
188188
$_expected_package_version = $master_or_package_version.match(/^\d+\.\d+\.\d+|^latest$|^present$/)[0]
189189
} else {
190190
$_expected_package_version = $master_or_package_version
@@ -209,7 +209,7 @@
209209
}
210210
}
211211

212-
if $::operatingsystem == 'Solaris' and $::operatingsystemmajrelease == '11' {
212+
if $facts['os']['name'] == 'Solaris' and $facts['os']['release']['major'] == '11' {
213213
# Strip letters from development builds. Unique to Solaris 11 packaging.
214214
$_version_without_letters = regsubst($master_or_package_version, '[a-zA-Z]', '', 'G')
215215
$_version_without_orphan_dashes = regsubst($_version_without_letters, '(^-|-$)', '', 'G')
@@ -236,7 +236,7 @@
236236
# - On Windows, services are handled by the puppet-agent MSI packages themselves.
237237
# ...but outside of PE, on other platforms, we must make sure the services are restarted. We do that with the
238238
# ::puppet_agent::service class. Make sure it's applied after the install process finishes if needed:
239-
if $::osfamily != 'windows' and (!$is_pe or versioncmp($::clientversion, '4.0.0') < 0) {
239+
if $facts['os']['family'] != 'windows' and (!$is_pe or versioncmp($::clientversion, '4.0.0') < 0) {
240240
Class['puppet_agent::configure']
241241
~> contain('puppet_agent::service')
242242
}

manifests/install.pp

+6-6
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@
1717
# Solaris, MacOS, Windows platforms will require more than just a package
1818
# resource to install correctly. These will call to other classes that
1919
# define how the installations work.
20-
if $::operatingsystem == 'Solaris' {
20+
if $facts['os']['name'] == 'Solaris' {
2121
class { 'puppet_agent::install::solaris':
2222
package_version => $package_version,
2323
install_options => $install_options,
2424
}
2525
contain '::puppet_agent::install::solaris'
26-
} elsif $::operatingsystem == 'Darwin' {
26+
} elsif $facts['os']['name'] == 'Darwin' {
2727
# Prevent re-running the script install
2828
if $puppet_agent::aio_upgrade_required {
2929
class { 'puppet_agent::install::darwin':
@@ -32,7 +32,7 @@
3232
}
3333
contain '::puppet_agent::install::darwin'
3434
}
35-
} elsif $::osfamily == 'windows' {
35+
} elsif $facts['os']['family'] == 'windows' {
3636
# Prevent re-running the batch install
3737
if ($puppet_agent::aio_upgrade_required) or ($puppet_agent::aio_downgrade_required){
3838
class { 'puppet_agent::install::windows':
@@ -41,7 +41,7 @@
4141
}
4242
contain '::puppet_agent::install::windows'
4343
}
44-
} elsif $::osfamily == 'suse' {
44+
} elsif $facts['os']['family'] == 'suse' {
4545
# Prevent re-running the batch install
4646
if ($package_version =~ /^latest$|^present$/) or ($puppet_agent::aio_upgrade_required) or ($puppet_agent::aio_downgrade_required){
4747
class { 'puppet_agent::install::suse':
@@ -51,13 +51,13 @@
5151
contain '::puppet_agent::install::suse'
5252
}
5353
} else {
54-
if $::operatingsystem == 'AIX' {
54+
if $facts['os']['name'] == 'AIX' {
5555
# AIX installations always use RPM directly since no there isn't any default package manager for rpms
5656
$_package_version = $package_version
5757
$_install_options = concat(['--ignoreos'],$install_options)
5858
$_provider = 'rpm'
5959
$_source = "${::puppet_agent::params::local_packages_dir}/${::puppet_agent::prepare::package::package_file_name}"
60-
} elsif $::osfamily == 'Debian' {
60+
} elsif $facts['os']['family'] == 'Debian' {
6161
$_install_options = $install_options
6262
if $::puppet_agent::absolute_source {
6363
# absolute_source means we use dpkg on debian based platforms

manifests/install/solaris.pp

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
$install_options = [],
1010
){
1111
assert_private()
12-
if $::operatingsystemmajrelease == '10' {
12+
if $facts['os']['release']['major'] == '10' {
1313
$_unzipped_package_name = regsubst($::puppet_agent::prepare::package::package_file_name, '\.gz$', '')
1414
$install_script = 'solaris_install.sh.erb'
1515

manifests/install/suse.pp

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
){
1111
assert_private()
1212

13-
if ($::puppet_agent::absolute_source) or ($::operatingsystemmajrelease == '11' and $::puppet_agent::is_pe) {
13+
if ($::puppet_agent::absolute_source) or ($facts['os']['release']['major'] == '11' and $::puppet_agent::is_pe) {
1414
$_provider = 'rpm'
1515
$_source = "${::puppet_agent::params::local_packages_dir}/${::puppet_agent::prepare::package::package_file_name}"
1616

manifests/install/windows.pp

+5-5
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@
7575
}
7676

7777
exec { 'prerequisites_check.ps1':
78-
command => "${::system32}\\WindowsPowerShell\\v1.0\\powershell.exe \
78+
command => "${facts['os']['windows']['system32']}\\WindowsPowerShell\\v1.0\\powershell.exe \
7979
-ExecutionPolicy Bypass \
8080
-NoProfile \
8181
-NoLogo \
@@ -88,7 +88,7 @@
8888
# The powershell execution uses -Command and not -File because -File will interpolate the quotes
8989
# in a context like cmd.exe: https://docs.microsoft.com/en-us/powershell/scripting/components/console/powershell.exe-command-line-help?view=powershell-6#-file--
9090
# Because of this it's much cleaner to use -Command and use single quotes for each powershell param
91-
command => "${::system32}\\cmd.exe /S /c start /b ${::system32}\\WindowsPowerShell\\v1.0\\powershell.exe \
91+
command => "${facts['os']['windows']['system32']}\\cmd.exe /S /c start /b ${facts['os']['windows']['system32']}\\WindowsPowerShell\\v1.0\\powershell.exe \
9292
-ExecutionPolicy Bypass \
9393
-NoProfile \
9494
-NoLogo \
@@ -104,7 +104,7 @@
104104
${_move_dll_workaround} \
105105
${_pxp_agent_wait} \
106106
${_puppet_run_wait}",
107-
unless => "${::system32}\\WindowsPowerShell\\v1.0\\powershell.exe \
107+
unless => "${facts['os']['windows']['system32']}\\WindowsPowerShell\\v1.0\\powershell.exe \
108108
-ExecutionPolicy Bypass \
109109
-NoProfile \
110110
-NoLogo \
@@ -124,8 +124,8 @@
124124

125125
# PUP-5480/PE-15037 Cache dir loses inheritable SYSTEM perms
126126
exec { 'fix inheritable SYSTEM perms':
127-
command => "${::system32}\\icacls.exe \"${::puppet_client_datadir}\" /grant \"SYSTEM:(OI)(CI)(F)\"",
128-
unless => "${::system32}\\cmd.exe /c ${::system32}\\icacls.exe \"${::puppet_client_datadir}\" | findstr \"SYSTEM:(OI)(CI)(F)\"",
127+
command => "${facts['os']['windows']['system32']}\\icacls.exe \"${::puppet_client_datadir}\" /grant \"SYSTEM:(OI)(CI)(F)\"",
128+
unless => "${facts['os']['windows']['system32']}\\cmd.exe /c ${facts['os']['windows']['system32']}\\icacls.exe \"${::puppet_client_datadir}\" | findstr \"SYSTEM:(OI)(CI)(F)\"",
129129
require => Exec['install_puppet.ps1'],
130130
}
131131
}

manifests/osfamily/aix.pp

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
class puppet_agent::osfamily::aix{
22
assert_private()
33

4-
if $::operatingsystem != 'AIX' {
5-
fail("${::operatingsystem} not supported")
4+
if $facts['os']['name'] != 'AIX' {
5+
fail("${facts['os']['name']} not supported")
66
}
77

88
if $::puppet_agent::is_pe != true {

manifests/osfamily/darwin.pp

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
class puppet_agent::osfamily::darwin{
22
assert_private()
33

4-
if $::macosx_productversion_major =~ /^10\./ {
5-
$productversion_major = $::macosx_productversion_major
4+
if $facts['os']['version']['major'] =~ /^10\./ {
5+
$productversion_major = $facts['os']['version']['major']
66
} else {
7-
$productversion_array = split($::macosx_productversion_major, '[.]')
7+
$productversion_array = split($facts['os']['version']['major'], '[.]')
88
$productversion_major = $productversion_array[0]
99
}
1010

manifests/osfamily/redhat.pp

+6-6
Original file line numberDiff line numberDiff line change
@@ -11,27 +11,27 @@
1111
}
1212
contain puppet_agent::prepare::package
1313
} else {
14-
case $::operatingsystem {
14+
case $facts['os']['name'] {
1515
'Fedora': {
16-
$platform_and_version = "fedora/${::operatingsystemmajrelease}"
16+
$platform_and_version = "fedora/${facts['os']['release']['major']}"
1717
}
1818
'Amazon': {
19-
if ("${::operatingsystemmajrelease}" == '2') {
19+
if ("${facts['os']['release']['major']}" == '2') {
2020
$amz_el_version = '7'
2121
} else {
2222
$amz_el_version = '6'
2323
}
2424
$platform_and_version = "el/${amz_el_version}"
2525
}
2626
default: {
27-
$platform_and_version = "el/${::operatingsystemmajrelease}"
27+
$platform_and_version = "el/${facts['os']['release']['major']}"
2828
}
2929
}
3030
if ($::puppet_agent::is_pe and (!$::puppet_agent::use_alternate_sources)) {
3131
$pe_server_version = pe_build_version()
3232
# Treat Amazon Linux just like Enterprise Linux
33-
$pe_repo_dir = ($::operatingsystem == 'Amazon') ? {
34-
true => "el-${amz_el_version}-${::architecture}",
33+
$pe_repo_dir = ($facts['os']['name'] == 'Amazon') ? {
34+
true => "el-${amz_el_version}-${facts['os']['architecture']}",
3535
default => $::platform_tag,
3636
}
3737
if $::puppet_agent::source {

manifests/osfamily/solaris.pp

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
class puppet_agent::osfamily::solaris{
22
assert_private()
33

4-
if $::operatingsystem != 'Solaris' {
5-
fail("${::operatingsystem} not supported")
4+
if $facts['os']['name'] != 'Solaris' {
5+
fail("${facts['os']['name']} not supported")
66
}
77

88
if $::puppet_agent::is_pe != true {
@@ -25,7 +25,7 @@
2525
default => 'i386',
2626
}
2727

28-
case $::operatingsystemmajrelease {
28+
case $facts['os']['release']['major'] {
2929
'10': {
3030
$package_file_name = "${::puppet_agent::package_name}-${::puppet_agent::prepare::package_version}-1.${pkg_arch}.pkg.gz"
3131
if $::puppet_agent::absolute_source {
@@ -70,7 +70,7 @@
7070

7171
$pkgrepo_dir = '/etc/puppetlabs/installer/solaris.repo'
7272
$publisher = 'puppetlabs.com'
73-
$arch = $::architecture ? {
73+
$arch = $facts['os']['architecture'] ? {
7474
/^sun4[uv]$/ => 'sparc',
7575
default => 'i386',
7676
}
@@ -121,7 +121,7 @@
121121
}
122122
}
123123
default: {
124-
fail("${::operatingsystem} ${::operatingsystemmajrelease} not supported")
124+
fail("${facts['os']['name']} ${facts['os']['release']['major']} not supported")
125125
}
126126
}
127127
}

manifests/osfamily/suse.pp

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
class puppet_agent::osfamily::suse{
22
assert_private()
33

4-
if $::operatingsystem != 'SLES' {
5-
fail("${::operatingsystem} not supported")
4+
if $facts['os']['name'] != 'SLES' {
5+
fail("${facts['os']['name']} not supported")
66
}
77

88
if $::puppet_agent::absolute_source {
@@ -19,7 +19,7 @@
1919
$pe_server_version = pe_build_version()
2020

2121
# SLES 11 in PE can no longer install agents from pe_repo
22-
if $::operatingsystemmajrelease == '11' {
22+
if $facts['os']['release']['major'] == '11' {
2323
if $::puppet_agent::source {
2424
$source = "${::puppet_agent::source}/packages/${pe_server_version}/${::platform_tag}"
2525
} elsif $::puppet_agent::alternate_pe_source {
@@ -48,13 +48,13 @@
4848
}
4949
} else {
5050
if $::puppet_agent::collection == 'PC1' {
51-
$source = "${::puppet_agent::yum_source}/sles/${::operatingsystemmajrelease}/${::puppet_agent::collection}/${::puppet_agent::arch}"
51+
$source = "${::puppet_agent::yum_source}/sles/${facts['os']['release']['major']}/${::puppet_agent::collection}/${::puppet_agent::arch}"
5252
} else {
53-
$source = "${::puppet_agent::yum_source}/${::puppet_agent::collection}/sles/${::operatingsystemmajrelease}/${::puppet_agent::arch}"
53+
$source = "${::puppet_agent::yum_source}/${::puppet_agent::collection}/sles/${facts['os']['release']['major']}/${::puppet_agent::arch}"
5454
}
5555
}
5656

57-
case $::operatingsystemmajrelease {
57+
case $facts['os']['release']['major'] {
5858
'11', '12', '15': {
5959
# Import the GPG key
6060
$legacy_keyname = 'GPG-KEY-puppet'
@@ -122,7 +122,7 @@
122122
logoutput => 'on_failure',
123123
}
124124

125-
unless $::operatingsystemmajrelease == '11' and $::puppet_agent::is_pe {
125+
unless $facts['os']['release']['major'] == '11' and $::puppet_agent::is_pe {
126126
if getvar('::puppet_agent::manage_repo') == true {
127127
# Set up a zypper repository by creating a .repo file which mimics a ini file
128128
$repo_file = '/etc/zypp/repos.d/pc_repo.repo'
@@ -178,7 +178,7 @@
178178
}
179179
}
180180
default: {
181-
fail("${::operatingsystem} ${::operatingsystemmajrelease} not supported")
181+
fail("${facts['os']['name']} ${facts['os']['release']['major']} not supported")
182182
}
183183
}
184184
}

manifests/params.pp

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,17 @@
33
# This class is meant to be called from puppet_agent
44
# It sets variables according to platform.
55
#
6-
class puppet_agent::params{
6+
class puppet_agent::params {
77
# Which services should be started after the upgrade process?
8-
if ($::osfamily == 'Solaris' and $::operatingsystemmajrelease == '11') {
8+
if ($facts['os']['family'] == 'Solaris' and $facts['os']['release']['major'] == '11') {
99
# Solaris 11 is a special case; it uses a custom script.
1010
$service_names = []
1111
} else {
1212
# Mcollective will be removed from this list in the service manifest if
1313
# the puppet version is >= 6.0.0
1414
$service_names = ['puppet', 'mcollective']
1515
}
16-
if $::osfamily == 'windows' {
16+
if $facts['os']['family'] == 'windows' {
1717
$local_puppet_dir = windows_native_path("${::puppet_agent_appdata}/Puppetlabs")
1818
$local_packages_dir = windows_native_path("${local_puppet_dir}/packages")
1919

0 commit comments

Comments
 (0)