Skip to content

Commit

Permalink
Merge pull request #1607 from silug/legacy_facts
Browse files Browse the repository at this point in the history
Fix use of legacy facts
  • Loading branch information
bastelfreak authored Jul 15, 2024
2 parents f6e3c3f + 349a2c7 commit ba429c5
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ define web::nginx_ssl_with_redirect (
$www_root = "${full_web_path}/${name}/",
$location_cfg_append = undef,
) {
nginx::resource::server { "${name}.${::domain}":
nginx::resource::server { "${name}.${facts['networking']['domain']}":
ensure => present,
www_root => "${full_web_path}/${name}/",
location_cfg_append => {
Expand All @@ -361,7 +361,7 @@ define web::nginx_ssl_with_redirect (
$tmp_www_root = $www_root
}
nginx::resource::server { "${name}.${::domain} ${name}":
nginx::resource::server { "${name}.${facts['networking']['domain']} ${name}":
ensure => present,
listen_port => 443,
www_root => $tmp_www_root,
Expand All @@ -379,7 +379,7 @@ define web::nginx_ssl_with_redirect (
ensure => present,
ssl => true,
ssl_only => true,
server => "${name}.${::domain} ${name}",
server => "${name}.${facts['networking']['domain']} ${name}",
www_root => "${full_web_path}/${name}/",
location => '~ \.php$',
index_files => ['index.php', 'index.html', 'index.htm'],
Expand Down
2 changes: 1 addition & 1 deletion lib/facter/nginx_version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Facter.add(:nginx_version) do
confine { Facter.value(:kernel) != 'windows' }
confine { Facter.value(:operatingsystem) != 'nexus' }
confine { Facter.value(:os)['name'] != 'nexus' }
setcode do
if Facter::Util::Resolution.which('nginx') || Facter::Util::Resolution.which('openresty')
nginx_version_command = Facter::Util::Resolution.which('nginx') ? 'nginx -v 2>&1' : 'openresty -v 2>&1'
Expand Down
2 changes: 1 addition & 1 deletion manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@
}
}
default: {
## For cases not covered in $::osfamily
## For cases not covered in $facts['os']['family']
case $facts['os']['name'] {
default: { $_module_os_overrides = {} }
}
Expand Down
20 changes: 10 additions & 10 deletions spec/classes/nginx_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,14 @@
context 'nginx::package' do
it { is_expected.to compile.with_all_deps }

case facts[:osfamily]
case facts[:os]['family']
when 'RedHat'
context 'using defaults' do
it { is_expected.to contain_package('nginx') }

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

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

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

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

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

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

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

it 'installs specified version exactly' do
Expand Down Expand Up @@ -158,7 +158,7 @@

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

it do
is_expected.to contain_apt__source('nginx').with(
'location' => "https://nginx.org/packages/mainline/#{facts[:operatingsystem].downcase}"
'location' => "https://nginx.org/packages/mainline/#{facts[:os]['name'].downcase}"
)
end
end
Expand Down Expand Up @@ -358,7 +358,7 @@
end
end

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

Expand Down

0 comments on commit ba429c5

Please sign in to comment.