Skip to content

Commit ba429c5

Browse files
authored
Merge pull request #1607 from silug/legacy_facts
Fix use of legacy facts
2 parents f6e3c3f + 349a2c7 commit ba429c5

File tree

4 files changed

+15
-15
lines changed

4 files changed

+15
-15
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ define web::nginx_ssl_with_redirect (
347347
$www_root = "${full_web_path}/${name}/",
348348
$location_cfg_append = undef,
349349
) {
350-
nginx::resource::server { "${name}.${::domain}":
350+
nginx::resource::server { "${name}.${facts['networking']['domain']}":
351351
ensure => present,
352352
www_root => "${full_web_path}/${name}/",
353353
location_cfg_append => {
@@ -361,7 +361,7 @@ define web::nginx_ssl_with_redirect (
361361
$tmp_www_root = $www_root
362362
}
363363
364-
nginx::resource::server { "${name}.${::domain} ${name}":
364+
nginx::resource::server { "${name}.${facts['networking']['domain']} ${name}":
365365
ensure => present,
366366
listen_port => 443,
367367
www_root => $tmp_www_root,
@@ -379,7 +379,7 @@ define web::nginx_ssl_with_redirect (
379379
ensure => present,
380380
ssl => true,
381381
ssl_only => true,
382-
server => "${name}.${::domain} ${name}",
382+
server => "${name}.${facts['networking']['domain']} ${name}",
383383
www_root => "${full_web_path}/${name}/",
384384
location => '~ \.php$',
385385
index_files => ['index.php', 'index.html', 'index.htm'],

lib/facter/nginx_version.rb

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

33
Facter.add(:nginx_version) do
44
confine { Facter.value(:kernel) != 'windows' }
5-
confine { Facter.value(:operatingsystem) != 'nexus' }
5+
confine { Facter.value(:os)['name'] != 'nexus' }
66
setcode do
77
if Facter::Util::Resolution.which('nginx') || Facter::Util::Resolution.which('openresty')
88
nginx_version_command = Facter::Util::Resolution.which('nginx') ? 'nginx -v 2>&1' : 'openresty -v 2>&1'

manifests/params.pp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@
185185
}
186186
}
187187
default: {
188-
## For cases not covered in $::osfamily
188+
## For cases not covered in $facts['os']['family']
189189
case $facts['os']['name'] {
190190
default: { $_module_os_overrides = {} }
191191
}

spec/classes/nginx_spec.rb

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,14 @@
4141
context 'nginx::package' do
4242
it { is_expected.to compile.with_all_deps }
4343

44-
case facts[:osfamily]
44+
case facts[:os]['family']
4545
when 'RedHat'
4646
context 'using defaults' do
4747
it { is_expected.to contain_package('nginx') }
4848

4949
it do
5050
is_expected.to contain_yumrepo('nginx-release').with(
51-
'baseurl' => "https://nginx.org/packages/#{%w[CentOS VirtuozzoLinux OracleLinux].include?(facts[:operatingsystem]) ? 'centos' : 'rhel'}/#{facts[:operatingsystemmajrelease]}/$basearch/",
51+
'baseurl' => "https://nginx.org/packages/#{%w[CentOS VirtuozzoLinux OracleLinux].include?(facts[:os]['name']) ? 'centos' : 'rhel'}/#{facts[:os]['release']['major']}/$basearch/",
5252
'descr' => 'nginx repo',
5353
'enabled' => '1',
5454
'gpgcheck' => '1',
@@ -74,7 +74,7 @@
7474

7575
it do
7676
is_expected.to contain_yumrepo('nginx-release').with(
77-
'baseurl' => "https://nginx.org/packages/#{%w[CentOS VirtuozzoLinux OracleLinux].include?(facts[:operatingsystem]) ? 'centos' : 'rhel'}/#{facts[:operatingsystemmajrelease]}/$basearch/",
77+
'baseurl' => "https://nginx.org/packages/#{%w[CentOS VirtuozzoLinux OracleLinux].include?(facts[:os]['name']) ? 'centos' : 'rhel'}/#{facts[:os]['release']['major']}/$basearch/",
7878
'descr' => 'nginx repo',
7979
'enabled' => '1',
8080
'gpgcheck' => '1',
@@ -91,7 +91,7 @@
9191

9292
it do
9393
is_expected.to contain_yumrepo('nginx-release').with(
94-
'baseurl' => "https://nginx.org/packages/mainline/#{%w[CentOS VirtuozzoLinux OracleLinux].include?(facts[:operatingsystem]) ? 'centos' : 'rhel'}/#{facts[:operatingsystemmajrelease]}/$basearch/"
94+
'baseurl' => "https://nginx.org/packages/mainline/#{%w[CentOS VirtuozzoLinux OracleLinux].include?(facts[:os]['name']) ? 'centos' : 'rhel'}/#{facts[:os]['release']['major']}/$basearch/"
9595
)
9696
end
9797

@@ -105,12 +105,12 @@
105105
it { is_expected.to contain_yumrepo('passenger').that_comes_before('Package[nginx]') }
106106
end
107107

108-
context 'package_source => passenger', unless: facts[:operatingsystemmajrelease] == '8' do
108+
context 'package_source => passenger', unless: facts[:os]['release']['major'] == '8' do
109109
let(:params) { { package_source: 'passenger' } }
110110

111111
it do
112112
is_expected.to contain_yumrepo('passenger').with(
113-
'baseurl' => "https://oss-binaries.phusionpassenger.com/yum/passenger/el/#{facts[:operatingsystemmajrelease]}/$basearch",
113+
'baseurl' => "https://oss-binaries.phusionpassenger.com/yum/passenger/el/#{facts[:os]['release']['major']}/$basearch",
114114
'gpgcheck' => '0',
115115
'repo_gpgcheck' => '1',
116116
'gpgkey' => 'https://oss-binaries.phusionpassenger.com/auto-software-signing-gpg-key.txt'
@@ -128,7 +128,7 @@
128128
it { is_expected.to contain_package('passenger').with('ensure' => 'installed') }
129129
end
130130

131-
describe 'installs the requested passenger package version', unless: facts[:operatingsystemmajrelease] == '8' do
131+
describe 'installs the requested passenger package version', unless: facts[:os]['release']['major'] == '8' do
132132
let(:params) { { package_source: 'passenger', passenger_package_ensure: '4.1.0-1.el9' } }
133133

134134
it 'installs specified version exactly' do
@@ -158,7 +158,7 @@
158158

159159
it do
160160
is_expected.to contain_apt__source('nginx').with(
161-
'location' => "https://nginx.org/packages/#{facts[:operatingsystem].downcase}",
161+
'location' => "https://nginx.org/packages/#{facts[:os]['name'].downcase}",
162162
'repos' => 'nginx',
163163
'key' => { 'id' => '573BFD6B3D8FBC641079A6ABABF5BD827BD9BF62' }
164164
)
@@ -180,7 +180,7 @@
180180

181181
it do
182182
is_expected.to contain_apt__source('nginx').with(
183-
'location' => "https://nginx.org/packages/mainline/#{facts[:operatingsystem].downcase}"
183+
'location' => "https://nginx.org/packages/mainline/#{facts[:os]['name'].downcase}"
184184
)
185185
end
186186
end
@@ -358,7 +358,7 @@
358358
end
359359
end
360360

361-
case facts[:osfamily]
361+
case facts[:os]['family']
362362
when 'RedHat'
363363
it { is_expected.to contain_file('/etc/nginx/nginx.conf').with_content %r{^user nginx;} }
364364

0 commit comments

Comments
 (0)