Skip to content

Commit

Permalink
Use include postgresql::server in zabbix::database
Browse files Browse the repository at this point in the history
This is safe to do because it can be called even after an explicit class
statement. The following code is legal.

    class { 'postgresql::server':
    }
    include postgresql::server

It could make a difference for a remote database, but due to the usage
of postgresql::server::pg_hba_rule that was already invalid.

The explicit require is also not needed, since postgresql::server::db
already does this where needed.

The end result is that the module is easier to use.
  • Loading branch information
ekohl committed Nov 6, 2023
1 parent 391fc94 commit 2b17195
Show file tree
Hide file tree
Showing 11 changed files with 9 additions and 22 deletions.
4 changes: 0 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,6 @@ node 'zabbix.example.com' {
}
include apache::mod::php

class { 'postgresql::server': }

class { 'zabbix':
zabbix_url => 'zabbix.example.com',
}
Expand Down Expand Up @@ -215,8 +213,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 Down
3 changes: 2 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
2 changes: 0 additions & 2 deletions spec/acceptance/server_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ class { 'postgresql::globals':
manage_dnf_module => $facts['os']['release']['major'] == '8',
version => '13',
}
-> class { 'postgresql::server': }
-> class { 'zabbix::database': }
-> class { 'zabbix::server': }
EOS
Expand Down Expand Up @@ -73,7 +72,6 @@ class { 'postgresql::globals':
manage_dnf_module => $facts['os']['release']['major'] == '8',
version => '13',
}
-> class { 'postgresql::server': }
-> class { 'zabbix::database': }
-> class { 'zabbix::server':
zabbix_version => "#{zabbix_version}"
Expand Down
3 changes: 1 addition & 2 deletions spec/acceptance/zabbix_application_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ class { 'postgresql::globals':
manage_dnf_module => $facts['os']['release']['major'] == '8',
version => '13',
}
-> class { 'postgresql::server': }
class { 'zabbix':
zabbix_version => "#{zabbix_version}",
Expand All @@ -42,7 +41,7 @@ class { 'zabbix':
zabbix_api_pass => 'zabbix',
apache_use_ssl => false,
manage_resources => true,
require => [ Class['postgresql::server'], Class['apache'], ],
require => Class['apache'],
}
EOS
Expand Down
3 changes: 1 addition & 2 deletions spec/acceptance/zabbix_host_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ class { 'postgresql::globals':
manage_dnf_module => $facts['os']['release']['major'] == '8',
version => '13',
}
-> class { 'postgresql::server': }
class { 'zabbix':
zabbix_version => "#{zabbix_version}",
Expand All @@ -51,7 +50,7 @@ class { 'zabbix':
zabbix_api_pass => 'zabbix',
apache_use_ssl => false,
manage_resources => true,
require => [ Class['postgresql::server'], Class['apache'], ],
require => Class['apache'],
}
EOS

Expand Down
3 changes: 1 addition & 2 deletions spec/acceptance/zabbix_hostgroup_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ class { 'postgresql::globals':
manage_dnf_module => $facts['os']['release']['major'] == '8',
version => '13',
}
-> class { 'postgresql::server': }
class { 'zabbix':
zabbix_version => "#{zabbix_version}",
Expand All @@ -35,7 +34,7 @@ class { 'zabbix':
zabbix_api_pass => 'zabbix',
apache_use_ssl => false,
manage_resources => true,
require => [ Class['postgresql::server'], Class['apache'], ],
require => Class['apache'],
}
EOS

Expand Down
3 changes: 1 addition & 2 deletions spec/acceptance/zabbix_proxy_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ class { 'postgresql::globals':
manage_dnf_module => $facts['os']['release']['major'] == '8',
version => '13',
}
-> class { 'postgresql::server': }
class { 'zabbix':
zabbix_version => "#{zabbix_version}",
Expand All @@ -36,7 +35,7 @@ class { 'zabbix':
zabbix_api_pass => 'zabbix',
apache_use_ssl => false,
manage_resources => true,
require => [ Class['postgresql::server'], Class['apache'], ],
require => Class['apache'],
}
EOS

Expand Down
3 changes: 1 addition & 2 deletions spec/acceptance/zabbix_template_host_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ class { 'postgresql::globals':
manage_dnf_module => $facts['os']['release']['major'] == '8',
version => '13',
}
-> class { 'postgresql::server': }
class { 'zabbix':
zabbix_version => "#{zabbix_version}",
Expand All @@ -44,7 +43,7 @@ class { 'zabbix':
zabbix_api_pass => 'zabbix',
apache_use_ssl => false,
manage_resources => true,
require => [ Class['postgresql::server'], Class['apache'], ],
require => Class['apache'],
}
EOS

Expand Down
3 changes: 1 addition & 2 deletions spec/acceptance/zabbix_template_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ class { 'postgresql::globals':
manage_dnf_module => $facts['os']['release']['major'] == '8',
version => '13',
}
-> class { 'postgresql::server': }
class { 'zabbix':
zabbix_version => "#{zabbix_version}",
Expand All @@ -35,7 +34,7 @@ class { 'zabbix':
zabbix_api_pass => 'zabbix',
apache_use_ssl => false,
manage_resources => true,
require => [ Class['postgresql::server'], Class['apache'], ],
require => Class['apache'],
}
EOS

Expand Down
1 change: 0 additions & 1 deletion spec/classes/database_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

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':
Expand Down
3 changes: 1 addition & 2 deletions spec/classes/proxy_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@
end
else
let :pre_condition do
"include 'postgresql::server'
include 'mysql::server'"
"include 'mysql::server'"
end
let :params do
{
Expand Down

0 comments on commit 2b17195

Please sign in to comment.