Skip to content

Commit 9e6b462

Browse files
committed
add version defaults for Debian, Ubuntu and RedHat (clones)
As discussed before there is an issue with the nginx_version. If the nginx package is not yet installed on a system the fact `nginx_version` is not set. In that case the hard coded default value of `1.16.0` is used. This change will add a default version for some operating systems via hiera data. This avoid the need to run puppet twice to get the correct configuration generated.
1 parent 071c48d commit 9e6b462

File tree

9 files changed

+46
-4
lines changed

9 files changed

+46
-4
lines changed

data/common.yaml

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
---
2+
3+
{}

data/os/Debian/11.yaml

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
---
2+
3+
nginx::nginx_version: '1.18.0'

data/os/Debian/12.yaml

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
---
2+
3+
nginx::nginx_version: '1.22.1'

data/os/RedHat/8.yaml

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
---
2+
3+
nginx::nginx_version: '1.14.1'

data/os/RedHat/9.yaml

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
---
2+
3+
nginx::nginx_version: '1.20.1'

data/os/Ubuntu/20.04.yaml

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
---
2+
3+
nginx::nginx_version: '1.18.0'

data/os/Ubuntu/22.04.yaml

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
---
2+
3+
nginx::nginx_version: '1.18.0'

hiera.yaml

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
version: 5
3+
4+
defaults: # Used for any hierarchy level that omits these keys.
5+
datadir: data # This path is relative to hiera.yaml's directory.
6+
data_hash: yaml_data # Use the built-in YAML backend.
7+
8+
hierarchy:
9+
- name: "osfamily/major release"
10+
paths:
11+
# Used to distinguish between Debian and Ubuntu
12+
- "os/%{facts.os.name}/%{facts.os.release.major}.yaml"
13+
- "os/%{facts.os.family}/%{facts.os.release.major}.yaml"
14+
# Used for Solaris
15+
- "os/%{facts.os.family}/%{facts.kernelrelease}.yaml"
16+
- name: "osfamily"
17+
paths:
18+
- "os/%{facts.os.name}.yaml"
19+
- "os/%{facts.os.family}.yaml"
20+
- name: 'common'
21+
path: 'common.yaml'

spec/defines/resource_server_spec.rb

+4-4
Original file line numberDiff line numberDiff line change
@@ -688,19 +688,19 @@
688688
end
689689

690690
context 'with fact nginx_version=1.14.1' do
691-
let(:facts) { facts.merge(nginx_version: '1.14.1') }
691+
let(:pre_condition) { 'class {"nginx": nginx_version => "1.14.1"}' }
692692

693693
it { is_expected.to contain_concat__fragment("#{title}-ssl-header").with_content(%r{ ssl on;}) }
694694
end
695695

696696
context 'with fact nginx_version=1.15.1' do
697-
let(:facts) { facts.merge(nginx_version: '1.15.1') }
697+
let(:pre_condition) { 'class {"nginx": nginx_version => "1.15.1"}' }
698698

699699
it { is_expected.to contain_concat__fragment("#{title}-ssl-header").without_content(%r{ ssl on;}) }
700700
end
701701

702702
context 'http2 on with fact nginx_version=1.25.1' do
703-
let(:facts) { facts.merge(nginx_version: '1.25.1') }
703+
let(:pre_condition) { 'class {"nginx": nginx_version => "1.25.1"}' }
704704
let :params do
705705
default_params.merge(
706706
http2: 'on',
@@ -714,7 +714,7 @@
714714
end
715715

716716
context 'with fact nginx_version=1.25.1' do
717-
let(:facts) { facts.merge(nginx_version: '1.25.1') }
717+
let(:pre_condition) { 'class {"nginx": nginx_version => "1.25.1"}' }
718718

719719
it { is_expected.to contain_concat__fragment("#{title}-ssl-header").with_content(%r{^\s+http2\s+off;}) }
720720
end

0 commit comments

Comments
 (0)