Skip to content

refactor: modernize apache2 custom resources#862

Merged
damacus merged 10 commits intomainfrom
refactor/modernize-custom-resources
Mar 17, 2026
Merged

refactor: modernize apache2 custom resources#862
damacus merged 10 commits intomainfrom
refactor/modernize-custom-resources

Conversation

@damacus
Copy link
Member

@damacus damacus commented Mar 14, 2026

Modernize apache2 cookbook resources to follow current Chef custom resource patterns.

Changes

Boilerplate (previous session)

  • Added # frozen_string_literal: true to all 39 resource files, helpers, and spec files
  • Added explicit provides :apache2_<name> to all resources

Phase 2 — Missing action_class blocks

  • Added action_class do include Apache2::Cookbook::Helpers end to conf.rb, mod_php.rb, mod_userdir.rb, mod_wsgi.rb

Phase 3 — Resource partial

  • Created resources/_partial/_common.rb with shared root_group and template_cookbook properties
  • Updated conf.rb, config.rb, default_site.rb, install.rb, mod.rb to use '_partial/_common'

Phase 4 — Missing ChefSpec tests

  • Added spec/resources/service_spec.rb — covers start/stop/restart/reload/enable/disable actions
  • Added spec/resources/site_spec.rb — covers enable/disable with helper stubs

Phase 5 — Documentation

  • Added documentation for 27 previously undocumented mod resources

Phase 6 — Lint

  • Applied cookstyle autocorrect for UnnecessaryPlatformCaseStatement in helpers.rb

Verification

  • chef exec rspec: 308 examples, 0 failures
  • cookstyle: 106 files, no offenses

@damacus damacus requested a review from a team as a code owner March 14, 2026 14:17
damacus added 7 commits March 15, 2026 23:10
- Add amazon platform family to apache_mod_wsgi_package and apache_mod_wsgi_filename helpers
- Update mod_auth_cas devel packages from pcre to pcre2 for v1.2 compatibility
- Add Debian 13 PHP 8.4 filename support (libphp8.4.so)
- Add mod_php_spec.rb tests for PHP helper functions
- Update mod_wsgi_spec.rb and mod_auth_cas_spec.rb tests
- Remove CI exclusions for amazonlinux-2023/mod-wsgi, ubuntu-2404/php,
  opensuse-leap-15/mod-auth-cas, opensuse-leap-15/mod-wsgi, debian-13/php

Fixes #815, #816, #817, #818, #819
- Create resources/_partial/_common.rb with root_group and template_cookbook

- Update conf.rb, config.rb, default_site.rb, install.rb, mod.rb to use partial
…dir, mod_wsgi

- conf.rb, mod_php.rb, mod_userdir.rb, mod_wsgi.rb were missing action_class do...end

- Each now explicitly includes Apache2::Cookbook::Helpers
- spec/resources/service_spec.rb: covers start/stop/restart/reload/enable/disable actions

- spec/resources/site_spec.rb: covers enable/disable with helper stubs
@damacus damacus force-pushed the refactor/modernize-custom-resources branch from 8c3ad53 to cf8c832 Compare March 16, 2026 09:13
damacus added 2 commits March 16, 2026 09:22
Wrap bare URLs in angle brackets and use minimal table column widths

to satisfy markdownlint rules.
Six test recipes were missing apt_update before apache2_install, causing

apt-get failures in Dokken containers with stale package caches.
@damacus damacus self-assigned this Mar 16, 2026
@damacus damacus force-pushed the refactor/modernize-custom-resources branch from c4bd6ee to 3bef534 Compare March 16, 2026 12:46
RHEL 7 is EOL. Simplify helpers by removing version guards. Replace

commented-out mod_ssl spec with a working test.
@damacus damacus force-pushed the refactor/modernize-custom-resources branch from 3bef534 to 2aca9d6 Compare March 16, 2026 12:52
@github-actions
Copy link

Slowest examples

Top 10 slowest examples (3.27 seconds, 14.37% of total time)
Example Description Time in seconds
spec/resources/mod_spec.rb:252 apache2_install mod_cgid outputs template correctly 0.50741
spec/resources/service_spec.rb:58 apache2_service action :enable is expected to enable service "apache2" 0.50563
spec/resources/mod_auth_cas_spec.rb:57 apache2_mod_auth_cas ubuntu is expected to render file "/etc/apache2/mods-available/auth_cas.conf" 0.49758
spec/libraries/log_spec.rb:61 #default_access_log with amazon family is expected to write log "access.log" 0.30844
spec/libraries/pid_file_spec.rb:35 #apache_pid_file with arch is expected to write log "/var/run/httpd/httpd.pid" 0.27567
spec/resources/module_spec.rb:46 apache2_install mod_proxy with custom configuration Installs mod_proxy with custom configuration 0.24434
spec/resources/mod_auth_cas_spec.rb:57 apache2_mod_auth_cas ubuntu is expected to render file "/etc/apache2/mods-available/auth_cas.conf" 0.23962
spec/libraries/default_modules_spec.rb:45 #default_modules systemd freebsd is expected to write log "status, alias, auth_basic, authn_core, authn_file, authz_core, authz_groupfile, authz_host, authz_user, autoindex, deflate, dir, env, mime, negotiation, setenvif, log_config, logio, unixd" 0.23342
spec/resources/conf_spec.rb:43 apache2_install install an apache2_module with default properties Creates the charset template 0.23036
spec/resources/conf_spec.rb:28 apache2_install install an apache2_module with default properties Creates the security template 0.22989

@damacus damacus merged commit 2b74512 into main Mar 17, 2026
149 checks passed
@damacus damacus deleted the refactor/modernize-custom-resources branch March 17, 2026 10:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants