Skip to content

Commit

Permalink
Update cookbook to use newer resource driven php cookbook (#674)
Browse files Browse the repository at this point in the history
- Remove EOL platforms and other platform updates
- Add initial support for Ubuntu 24.04 (requires apache2 cookbook updates)

Signed-off-by: Lance Albertson <[email protected]>
  • Loading branch information
ramereth authored Jul 2, 2024
1 parent 404a7d6 commit a38ea9d
Show file tree
Hide file tree
Showing 15 changed files with 44 additions and 92 deletions.
6 changes: 2 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,11 @@ jobs:
matrix:
os:
- "almalinux-8"
- "centos-7"
- "centos-stream-8"
- "debian-10"
- "debian-11"
- "debian-12"
- "rockylinux-8"
- "ubuntu-1804"
- "ubuntu-2004"
- "ubuntu-2204"
suite:
- "nginx"
- "pagerduty"
Expand Down
7 changes: 4 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ This file is used to list changes made in each version of the nagios cookbook.

## Unreleased

Standardise files with files in sous-chefs/repo-management

Standardise files with files in sous-chefs/repo-management
- Standardise files with files in sous-chefs/repo-management
- Update cookbook to use newer resource driven php cookbook
- Remove EOL platforms and other platform updates
- Add initial support for Ubuntu 24.04 (requires apache2 cookbook updates)

## 11.3.2 - *2024-05-02*

Expand Down
3 changes: 1 addition & 2 deletions attributes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,7 @@
default['nagios']['server']['nginx_dispatch']['type'] = 'both'
default['nagios']['server']['nginx_dispatch']['packages'] = nagios_nginx_dispatch_packages
default['nagios']['server']['nginx_dispatch']['services'] = nagios_nginx_dispatch_services
default['nagios']['server']['nginx_dispatch']['cgi_url'] = 'unix:/var/run/fcgiwrap.socket'
default['nagios']['server']['nginx_dispatch']['php_url'] = "unix:#{node['php']['fpm_socket']}"
default['nagios']['server']['nginx_dispatch']['cgi_url'] = 'unix:/var/run/fcgiwrap.socket'
default['nagios']['php_gd_package'] = nagios_php_gd_package
default['nagios']['server']['stop_apache'] = false
default['nagios']['server']['normalize_hostname'] = false
Expand Down
6 changes: 3 additions & 3 deletions kitchen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ verifier:

platforms:
- name: almalinux-8
- name: centos-7
- name: centos-stream-8
- name: debian-10
- name: debian-11
- name: debian-12
- name: rockylinux-8
- name: ubuntu-18.04
- name: ubuntu-20.04
- name: ubuntu-22.04
- name: ubuntu-24.04

suites:
- name: server_package
Expand Down
28 changes: 12 additions & 16 deletions libraries/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,7 @@ def nagios_vname
elsif platform?('debian')
'nagios4'
elsif platform?('ubuntu')
if node['platform_version'].to_f < 20.04
'nagios3'
else
'nagios4'
end
'nagios4'
end
end

Expand All @@ -22,28 +18,28 @@ def nagios_packages
elsif platform?('debian')
%w(nagios4 nagios-nrpe-plugin nagios-images)
elsif platform?('ubuntu')
if node['platform_version'].to_f < 20.04
%w(nagios3 nagios-nrpe-plugin nagios-images)
else
%w(nagios4 nagios-nrpe-plugin nagios-images)
end
%w(nagios4 nagios-nrpe-plugin nagios-images)
end
end

def nagios_php_gd_package
if platform_family?('rhel')
'php-gd'
elsif platform?('debian')
if node['platform_version'].to_i < 11
'php7.3-gd'
else
case node['platform_version'].to_i
when 11
'php7.4-gd'
else
'php8.2-gd'
end
elsif platform?('ubuntu')
if node['platform_version'].to_f < 20.04
'php7.2-gd'
else
case node['platform_version'].to_f
when 20.04
'php7.4-gd'
when 22.04
'php8.1-gd'
else
'php8.3-gd'
end
end
end
Expand Down
12 changes: 6 additions & 6 deletions metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
depends 'apache2', '>= 9.0'
depends 'nginx', '>= 11.2'
depends 'nrpe'
depends 'php', '>= 7.2'
depends 'php', '>= 10.0'
depends 'yum-epel'
depends 'zap', '>= 0.6.0'

suports 'centos', '>= 7.0'
supports 'oracle', '>= 7.0'
supports 'redhat', '>= 7.0'
supports 'debian', '>= 10.0'
supports 'ubuntu', '>= 18.04'
suports 'centos', '>= 8.0'
supports 'oracle', '>= 8.0'
supports 'redhat', '>= 8.0'
supports 'debian', '>= 11.0'
supports 'ubuntu', '>= 20.04'
2 changes: 1 addition & 1 deletion recipes/apache.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

node.default['nagios']['server']['web_server'] = 'apache'

include_recipe 'php'
php_install 'php'

apache2_install 'nagios' do
listen node['nagios']['enable_ssl'] ? %w(80 443) : %w(80)
Expand Down
4 changes: 2 additions & 2 deletions recipes/nginx.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
notifies :restart, 'nginx_service[nagios]', :delayed
end

include_recipe 'php'
php_install 'nagios'

php_fpm_pool 'nagios' do
user nagios_nginx_user
Expand Down Expand Up @@ -72,7 +72,7 @@
log_dir: node['nagios']['log_dir'],
nagios_url: node['nagios']['url'],
nginx_dispatch_cgi_url: node['nagios']['server']['nginx_dispatch']['cgi_url'],
nginx_dispatch_php_url: node['nagios']['server']['nginx_dispatch']['php_url'],
nginx_dispatch_php_url: "unix:#{php_fpm_socket}",
php: %w(php both).include?(dispatch_type),
public_domain: node['public_domain'] || node['domain'],
server_name: node['nagios']['server']['name'],
Expand Down
3 changes: 2 additions & 1 deletion recipes/server_source.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@

# Package pre-reqs
build_essential 'install compilation tools'
include_recipe 'php::default'

php_install 'nagios'

package node['nagios']['php_gd_package']

Expand Down
4 changes: 1 addition & 3 deletions spec/source_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@
expect(chef_run).to include_recipe('nagios::server_source')
end

it 'should include the php::default recipe' do
expect(chef_run).to include_recipe('php::default')
end
it { expect(chef_run).to install_php_install 'nagios' }

it 'should install the php-gd package' do
expect(chef_run).to install_package('php7.4-gd')
Expand Down
6 changes: 1 addition & 5 deletions test/smoke/default/nagios_website.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,7 @@
elsif os.name == 'debian'
"#{wget_cmd}/cgi-bin/nagios4"
elsif os.name == 'ubuntu'
if os.release.to_f < 20.04
"#{wget_cmd}/cgi-bin/nagios3"
else
"#{wget_cmd}/cgi-bin/nagios4"
end
"#{wget_cmd}/cgi-bin/nagios4"
end

control 'nagios-website-01' do
Expand Down
6 changes: 1 addition & 5 deletions test/smoke/default/server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,7 @@
elsif os.name == 'debian'
'nagios4'
elsif os.name == 'ubuntu'
if os.release.to_f < 20.04
'nagios3'
else
'nagios4'
end
'nagios4'
end

if %w(redhat).include?(os[:family])
Expand Down
19 changes: 4 additions & 15 deletions test/smoke/pagerduty/default_test.rb
Original file line number Diff line number Diff line change
@@ -1,14 +1,3 @@
vname =
if os.name == 'debian'
'nagios4'
elsif os.name == 'ubuntu'
if os.release.to_f < 20.04
'nagios3'
else
'nagios4'
end
end

if os.redhat?
apache_bin = 'httpd'
config_cgi_path = 'nagios/cgi-bin/config.cgi'
Expand All @@ -17,10 +6,10 @@
service_name = 'nagios'
else
apache_bin = 'apache2'
config_cgi_path = "cgi-bin/#{vname}/config.cgi"
path_config_dir = "/etc/#{vname}/conf.d"
path_conf_dir = "/etc/#{vname}"
service_name = vname
config_cgi_path = 'cgi-bin/nagios4/config.cgi'
path_config_dir = '/etc/nagios4/conf.d'
path_conf_dir = '/etc/nagios4'
service_name = 'nagios4'
end

# Test Nagios Config
Expand Down
17 changes: 3 additions & 14 deletions test/smoke/pagerduty/pagerduty_test.rb
Original file line number Diff line number Diff line change
@@ -1,24 +1,13 @@
vname =
if os.name == 'debian'
'nagios4'
elsif os.name == 'ubuntu'
if os.release.to_f < 20.04
'nagios3'
else
'nagios4'
end
end

if os.redhat?
command_file = '/var/log/nagios/rw/nagios.cmd'
pagerduty_cgi_dir = '/usr/lib64/nagios/cgi-bin'
path_config_dir = '/etc/nagios/conf.d'
perl_cgi_package = 'perl-CGI'
plugin_dir = '/usr/lib64/nagios/plugins'
else
command_file = "/var/lib/#{vname}/rw/nagios.cmd"
pagerduty_cgi_dir = "/usr/lib/cgi-bin/#{vname}"
path_config_dir = "/etc/#{vname}/conf.d"
command_file = '/var/lib/nagios4/rw/nagios.cmd'
pagerduty_cgi_dir = '/usr/lib/cgi-bin/nagios4'
path_config_dir = '/etc/nagios4/conf.d'
perl_cgi_package = 'libcgi-pm-perl'
plugin_dir = '/usr/lib/nagios/plugins'
end
Expand Down
13 changes: 1 addition & 12 deletions test/smoke/swappable_config/default_test.rb
Original file line number Diff line number Diff line change
@@ -1,18 +1,7 @@
vname =
if os.name == 'debian'
'nagios4'
elsif os.name == 'ubuntu'
if os.release.to_f < 20.04
'nagios3'
else
'nagios4'
end
end

path_conf_dir = if os.redhat?
'/etc/nagios'
else
"/etc/#{vname}"
'/etc/nagios4'
end

describe file("#{path_conf_dir}/nagios.cfg") do
Expand Down

0 comments on commit a38ea9d

Please sign in to comment.