Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better Hiera compatibility #905

Merged
merged 4 commits into from
Nov 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,6 @@ node 'zabbix.example.com' {
class { 'apache':
mpm_module => 'prefork',
}
include apache::mod::php

class { 'postgresql::server': }

class { 'zabbix':
zabbix_url => 'zabbix.example.com',
Expand All @@ -152,9 +149,6 @@ node 'zabbix.example.com' {
class { 'apache':
mpm_module => 'prefork',
}
include apache::mod::php

class { 'mysql::server': }

class { 'zabbix':
zabbix_url => 'zabbix.example.com',
Expand Down Expand Up @@ -215,8 +209,6 @@ Like the zabbix-server, the zabbix-proxy can also be used in 2 ways:
The following is an example for using the PostgreSQL as database:
```ruby
node 'proxy.example.com' {
class { 'postgresql::server': }

class { 'zabbix::database':
database_type => 'postgresql',
}
Expand All @@ -231,8 +223,6 @@ node 'proxy.example.com' {
When you want to make use of an MySQL database as backend:
```ruby
node 'proxy.example.com' {
class { 'mysql::server': }

class { 'zabbix::database':
database_type => 'mysql',
}
Expand Down
1 change: 0 additions & 1 deletion REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -4936,7 +4936,6 @@ node 'wdpuppet02.dj-wasabi.local' {
class { 'apache':
mpm_module => 'prefork',
}
class { 'apache::mod::php': }
class { 'zabbix::web':
zabbix_url => 'zabbix.dj-wasabi.nl',
zabbix_server => 'wdpuppet03.dj-wasabi.local',
Expand Down
4 changes: 3 additions & 1 deletion manifests/database.pp
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,13 @@
case $database_type {
'postgresql': {
# This is the PostgreSQL part.

include postgresql::server
# Create the postgres database.
postgresql::server::db { $database_name:
user => $database_user,
owner => $database_user,
password => postgresql::postgresql_password($database_user, $database_password),
require => Class['postgresql::server'],
tablespace => $database_tablespace,
}

Expand Down Expand Up @@ -145,6 +146,7 @@
}
'mysql': {
# This is the MySQL part.
include mysql::server

# First we check what kind of zabbix component it is. We have to use clear names
# as it may be confusing when you need to fill in the zabbix-proxy name into the
Expand Down
3 changes: 2 additions & 1 deletion manifests/web.pp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@
# class { 'apache':
# mpm_module => 'prefork',
# }
# class { 'apache::mod::php': }
# class { 'zabbix::web':
# zabbix_url => 'zabbix.dj-wasabi.nl',
# zabbix_server => 'wdpuppet03.dj-wasabi.local',
Expand Down Expand Up @@ -343,6 +342,8 @@
}
}
else {
include apache::mod::php

$apache_vhost_custom_fragment = "
php_value max_execution_time ${apache_php_max_execution_time}
php_value memory_limit ${apache_php_memory_limit}
Expand Down
7 changes: 7 additions & 0 deletions spec/acceptance/hieradata/common.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
apache::mpm_module: 'prefork'

postgresql::globals::encoding: 'UTF-8'
postgresql::globals::locale: 'en_US.UTF-8'
postgresql::globals::manage_package_repo: true
postgresql::globals::version: '13'
3 changes: 3 additions & 0 deletions spec/acceptance/hieradata/os/RedHat/8.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
postgresql::globals::manage_dnf_module: true
postgresql::globals::manage_package_repo: false
20 changes: 2 additions & 18 deletions spec/acceptance/server_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,7 @@

# this will actually deploy apache + postgres + zabbix-server + zabbix-web
pp = <<-EOS
class { 'postgresql::globals':
encoding => 'UTF-8',
locale => 'en_US.UTF-8',
manage_package_repo => $facts['os']['release']['major'] != '8',
manage_dnf_module => $facts['os']['release']['major'] == '8',
version => '13',
}
-> class { 'postgresql::server': }
-> class { 'zabbix::database': }
class { 'zabbix::database': }
-> class { 'zabbix::server': }
EOS

Expand Down Expand Up @@ -66,15 +58,7 @@ class { 'postgresql::globals':

# this will actually deploy apache + postgres + zabbix-server + zabbix-web
pp = <<-EOS
class { 'postgresql::globals':
encoding => 'UTF-8',
locale => 'en_US.UTF-8',
manage_package_repo => $facts['os']['release']['major'] != '8',
manage_dnf_module => $facts['os']['release']['major'] == '8',
version => '13',
}
-> class { 'postgresql::server': }
-> class { 'zabbix::database': }
class { 'zabbix::database': }
-> class { 'zabbix::server':
zabbix_version => "#{zabbix_version}"
}
Expand Down
15 changes: 0 additions & 15 deletions spec/acceptance/zabbix_application_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,28 +21,13 @@
# This will deploy a running Zabbix setup (server, web, db) which we can
# use for custom type tests
pp1 = <<-EOS
class { 'apache':
mpm_module => 'prefork',
}
if $facts['os']['family'] != 'RedHat' {
include apache::mod::php
}
class { 'postgresql::globals':
locale => 'en_US.UTF-8',
manage_package_repo => $facts['os']['release']['major'] != '8',
manage_dnf_module => $facts['os']['release']['major'] == '8',
version => '13',
}
-> class { 'postgresql::server': }

class { 'zabbix':
zabbix_version => "#{zabbix_version}",
zabbix_url => 'localhost',
zabbix_api_user => 'Admin',
zabbix_api_pass => 'zabbix',
apache_use_ssl => false,
manage_resources => true,
require => [ Class['postgresql::server'], Class['apache'], ],
}

EOS
Expand Down
15 changes: 0 additions & 15 deletions spec/acceptance/zabbix_host_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,28 +30,13 @@
end

pp1 = <<-EOS
class { 'apache':
mpm_module => 'prefork',
}
if $facts['os']['family'] != 'RedHat' {
include apache::mod::php
}
class { 'postgresql::globals':
locale => 'en_US.UTF-8',
manage_package_repo => $facts['os']['release']['major'] != '8',
manage_dnf_module => $facts['os']['release']['major'] == '8',
version => '13',
}
-> class { 'postgresql::server': }

class { 'zabbix':
zabbix_version => "#{zabbix_version}",
zabbix_url => 'localhost',
zabbix_api_user => 'Admin',
zabbix_api_pass => 'zabbix',
apache_use_ssl => false,
manage_resources => true,
require => [ Class['postgresql::server'], Class['apache'], ],
}
EOS

Expand Down
15 changes: 0 additions & 15 deletions spec/acceptance/zabbix_hostgroup_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,28 +14,13 @@
# This will deploy a running Zabbix setup (server, web, db) which we can
# use for custom type tests
pp1 = <<-EOS
class { 'apache':
mpm_module => 'prefork',
}
if $facts['os']['family'] != 'RedHat' {
include apache::mod::php
}
class { 'postgresql::globals':
locale => 'en_US.UTF-8',
manage_package_repo => $facts['os']['release']['major'] != '8',
manage_dnf_module => $facts['os']['release']['major'] == '8',
version => '13',
}
-> class { 'postgresql::server': }

class { 'zabbix':
zabbix_version => "#{zabbix_version}",
zabbix_url => 'localhost',
zabbix_api_user => 'Admin',
zabbix_api_pass => 'zabbix',
apache_use_ssl => false,
manage_resources => true,
require => [ Class['postgresql::server'], Class['apache'], ],
}
EOS

Expand Down
15 changes: 0 additions & 15 deletions spec/acceptance/zabbix_proxy_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,28 +15,13 @@
# This will deploy a running Zabbix setup (server, web, db) which we can
# use for custom type tests
pp1 = <<-EOS
class { 'apache':
mpm_module => 'prefork',
}
if $facts['os']['family'] != 'RedHat' {
include apache::mod::php
}
class { 'postgresql::globals':
locale => 'en_US.UTF-8',
manage_package_repo => $facts['os']['release']['major'] != '8',
manage_dnf_module => $facts['os']['release']['major'] == '8',
version => '13',
}
-> class { 'postgresql::server': }

class { 'zabbix':
zabbix_version => "#{zabbix_version}",
zabbix_url => 'localhost',
zabbix_api_user => 'Admin',
zabbix_api_pass => 'zabbix',
apache_use_ssl => false,
manage_resources => true,
require => [ Class['postgresql::server'], Class['apache'], ],
}
EOS

Expand Down
15 changes: 0 additions & 15 deletions spec/acceptance/zabbix_template_host_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,28 +23,13 @@
# This will deploy a running Zabbix setup (server, web, db) which we can
# use for custom type tests
pp1 = <<-EOS
class { 'apache':
mpm_module => 'prefork',
}
if $facts['os']['family'] != 'RedHat' {
include apache::mod::php
}
class { 'postgresql::globals':
locale => 'en_US.UTF-8',
manage_package_repo => $facts['os']['release']['major'] != '8',
manage_dnf_module => $facts['os']['release']['major'] == '8',
version => '13',
}
-> class { 'postgresql::server': }

class { 'zabbix':
zabbix_version => "#{zabbix_version}",
zabbix_url => 'localhost',
zabbix_api_user => 'Admin',
zabbix_api_pass => 'zabbix',
apache_use_ssl => false,
manage_resources => true,
require => [ Class['postgresql::server'], Class['apache'], ],
}
EOS

Expand Down
15 changes: 0 additions & 15 deletions spec/acceptance/zabbix_template_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,28 +14,13 @@
# This will deploy a running Zabbix setup (server, web, db) which we can
# use for custom type tests
pp1 = <<-EOS
class { 'apache':
mpm_module => 'prefork',
}
if $facts['os']['family'] != 'RedHat' {
include apache::mod::php
}
class { 'postgresql::globals':
locale => 'en_US.UTF-8',
manage_package_repo => $facts['os']['release']['major'] != '8',
manage_dnf_module => $facts['os']['release']['major'] == '8',
version => '13',
}
-> class { 'postgresql::server': }

class { 'zabbix':
zabbix_version => "#{zabbix_version}",
zabbix_url => 'localhost',
zabbix_api_user => 'Admin',
zabbix_api_pass => 'zabbix',
apache_use_ssl => false,
manage_resources => true,
require => [ Class['postgresql::server'], Class['apache'], ],
}
EOS

Expand Down
4 changes: 0 additions & 4 deletions spec/classes/database_mysql_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@
'rspec.puppet.com'
end

let :pre_condition do
"include 'mysql::server'"
end

on_supported_os(baseline_os_hash).each do |os, facts|
next if facts[:os]['name'] == 'windows'

Expand Down
2 changes: 0 additions & 2 deletions spec/classes/database_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,12 @@

let :pre_condition do
<<-EOS
include 'postgresql::server'
if $facts['os']['family'] == 'Gentoo' {
# We don't need the package to be installed as its the same for the server.
class { 'mysql::client':
package_manage => false,
}
}
include 'mysql::server'
EOS
end

Expand Down
8 changes: 0 additions & 8 deletions spec/classes/proxy_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,6 @@
it { is_expected.not_to compile }
end
else
let :pre_condition do
"include 'postgresql::server'
include 'mysql::server'"
end
let :params do
{
zabbix_server_host: '192.168.1.1',
Expand Down Expand Up @@ -133,10 +129,6 @@
}
end

let(:pre_condition) do
"include 'mysql::server'"
end

it { is_expected.to contain_class('zabbix::database::mysql').with_zabbix_type('proxy') }
it { is_expected.to contain_class('zabbix::database::mysql').with_zabbix_version(zabbix_version) }
it { is_expected.to contain_class('zabbix::database::mysql').with_database_name('zabbix_proxy') }
Expand Down
10 changes: 10 additions & 0 deletions spec/classes/web_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,16 @@
}
end

let :pre_condition do
<<~PUPPET
if $facts['os']['family'] != 'RedHat' {
class { 'apache':
mpm_module => 'prefork',
}
}
PUPPET
end

on_supported_os(baseline_os_hash).each do |os, facts|
supported_versions.each do |zabbix_version|
next if facts[:os]['name'] == 'windows'
Expand Down