Skip to content

Commit

Permalink
add version defaults for Debian, Ubuntu and RedHat (clones)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
TheMeier committed Oct 22, 2024
1 parent 071c48d commit 9e6b462
Show file tree
Hide file tree
Showing 9 changed files with 46 additions and 4 deletions.
3 changes: 3 additions & 0 deletions data/common.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---

{}
3 changes: 3 additions & 0 deletions data/os/Debian/11.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---

nginx::nginx_version: '1.18.0'
3 changes: 3 additions & 0 deletions data/os/Debian/12.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---

nginx::nginx_version: '1.22.1'
3 changes: 3 additions & 0 deletions data/os/RedHat/8.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---

nginx::nginx_version: '1.14.1'
3 changes: 3 additions & 0 deletions data/os/RedHat/9.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---

nginx::nginx_version: '1.20.1'
3 changes: 3 additions & 0 deletions data/os/Ubuntu/20.04.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---

nginx::nginx_version: '1.18.0'
3 changes: 3 additions & 0 deletions data/os/Ubuntu/22.04.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---

nginx::nginx_version: '1.18.0'
21 changes: 21 additions & 0 deletions hiera.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
version: 5

defaults: # Used for any hierarchy level that omits these keys.
datadir: data # This path is relative to hiera.yaml's directory.
data_hash: yaml_data # Use the built-in YAML backend.

hierarchy:
- name: "osfamily/major release"
paths:
# Used to distinguish between Debian and Ubuntu
- "os/%{facts.os.name}/%{facts.os.release.major}.yaml"
- "os/%{facts.os.family}/%{facts.os.release.major}.yaml"
# Used for Solaris
- "os/%{facts.os.family}/%{facts.kernelrelease}.yaml"
- name: "osfamily"
paths:
- "os/%{facts.os.name}.yaml"
- "os/%{facts.os.family}.yaml"
- name: 'common'
path: 'common.yaml'
8 changes: 4 additions & 4 deletions spec/defines/resource_server_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -688,19 +688,19 @@
end

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

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

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

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

context 'http2 on with fact nginx_version=1.25.1' do
let(:facts) { facts.merge(nginx_version: '1.25.1') }
let(:pre_condition) { 'class {"nginx": nginx_version => "1.25.1"}' }
let :params do
default_params.merge(
http2: 'on',
Expand All @@ -714,7 +714,7 @@
end

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

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

0 comments on commit 9e6b462

Please sign in to comment.