Skip to content
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: 5 additions & 5 deletions .github/copilot-instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@
- `libraries/` - Library helpers to assist with the cookbook. May contain multiple files depending on complexity of the cookbook.
- `templates/` - ERB templates that may be used in the cookbook
- `files/` - files that may be used in the cookbook
- `metadata.rb`, `Berksfile` - Cookbook metadata and dependencies
- `metadata.rb`, `Policyfile.rb` - Cookbook metadata and dependencies

## Build and Test System

### Environment Setup
**MANDATORY:** Install Chef Workstation first - provides chef, berks, cookstyle, kitchen tools.
**MANDATORY:** Install Chef Workstation first - provides chef, cookstyle, kitchen tools.

### Essential Commands (strict order)
```bash
berks install # Install dependencies (always first)
chef install Policyfile.rb # Install dependencies (always first)
cookstyle # Ruby/Chef linting
yamllint . # YAML linting
markdownlint-cli2 '**/*.md' # Markdown linting
Expand All @@ -42,7 +42,7 @@ chef exec rspec # Unit tests (ChefSpec)
- **Full CI Runtime:** 30+ minutes for complete matrix

### Common Issues and Solutions
- **Always run `berks install` first** - most failures are dependency-related
- **Always run `chef install Policyfile.rb` first** - most failures are dependency-related
- **Docker must be running** for kitchen tests
- **Chef Workstation required** - no workarounds, no alternatives
- **Test data bags needed** (optional for some cookbooks) in `test/integration/data_bags/` for convergence
Expand Down Expand Up @@ -88,7 +88,7 @@ These instructions are validated for Sous Chefs cookbooks. **Do not search for b

**Error Resolution Checklist:**
1. Verify Chef Workstation installation
2. Confirm `berks install` completed successfully
2. Confirm `chef install Policyfile.rb` completed successfully
3. Ensure Docker is running for integration tests
4. Check for missing test data dependencies

Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ jobs:
- almalinux-8
- almalinux-9
- centos-stream-9
- debian-11
- debian-12
- fedora-latest
- rockylinux-8
Expand All @@ -38,6 +37,11 @@ jobs:
- resource
- resource-community
- resource-peclchannel
exclude:
- os: fedora-latest
suite: resource-community
- os: ubuntu-2004
suite: resource-community
fail-fast: false

steps:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/copilot-setup-steps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ jobs:
uses: actions/checkout@v7
- name: Install Chef
uses: actionshub/chef-install@main
- name: Install cookbooks
run: berks install
- name: Install Policyfile dependencies
run: chef install Policyfile.rb
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ doc/
rdoc

# chef infra stuff
Berksfile.lock
.kitchen
kitchen.local.yml
vendor/
Expand Down
11 changes: 11 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Agent Notes

## Policyfile Integration Limits

The `resource-community` suite exercises external community package repositories, not only this cookbook's resources. Keep the suite matrix aligned with package availability:

* Fedora is excluded from `resource-community` because the Remi Fedora repository does not provide the `php8.2`, `php8.2-cgi`, `php8.2-cli`, `php8.2-dev`, and `php8.2-xml` package set used by the test recipe.
* Ubuntu 20.04 is excluded from `resource-community` because the Ondrej PHP PPA no longer provides the PHP 8.2 package set for focal.
* EL9 `resource-community` uses the legacy `yum-remi-chef::remi` recipe, which still configures only older Remi GPG keys. The test recipe adds the current Remi signing key set so package verification can follow upstream key rotation.
* Fedora `resource` and `resource-peclchannel` remain supported. `php_pear` installs explicit compiler packages on Fedora instead of using `build_essential`, because Dokken Fedora images can request an unavailable host-matching `kernel-devel` package.
* Fedora skips the PECL `sync` fixture because `sync` 1.1.3 does not compile against Fedora latest's PHP 8.5 headers. Keep the channel and PEAR package checks enabled there.
7 changes: 0 additions & 7 deletions Berksfile

This file was deleted.

19 changes: 19 additions & 0 deletions Policyfile.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# frozen_string_literal: true

name 'php'

run_list 'test::default'

cookbook 'php', path: '.'
cookbook 'apt', git: 'https://github.com/sous-chefs/apt.git', branch: 'main'
cookbook 'ondrej_ppa_ubuntu', git: 'https://github.com/MelonSmasher/ondrej_ppa_ubuntu.git', branch: 'master'
cookbook 'test', path: './test/cookbooks/test'
cookbook 'yum', git: 'https://github.com/sous-chefs/yum.git', branch: 'main'
cookbook 'yum-epel', git: 'https://github.com/sous-chefs/yum-epel.git', tag: '5.0.9'
cookbook 'yum-remi-chef', '>= 5.0.1', git: 'https://github.com/sous-chefs/yum-remi-chef.git', tag: '5.0.1'

Dir.children('./test/cookbooks/test/recipes').grep(/\.rb\z/).sort.each do |recipe|
recipe_name = File.basename(recipe, '.rb')

named_run_list recipe_name.to_sym, "test::#{recipe_name}"
end
2 changes: 1 addition & 1 deletion UPGRADING.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ Installing from community repos is no longer built in to the cookbook. The `php_

## Source Install

Installing from source is no longer built in to the cookbook. Users should manage installation from source on their own. The original recipe can be referenced [here](https://github.com/sous-chefs/php/blob/9.2.16/recipes/source.rb) to help with the switch.
Installing from source is no longer built in to the cookbook. Users should manage installation from source on their own. The [original source install recipe](https://github.com/sous-chefs/php/blob/9.2.16/recipes/source.rb) can help with the switch.

## .ini Configuration

Expand Down
7 changes: 0 additions & 7 deletions chefignore
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,6 @@ test/*
*/.hg/*
*/.svn/*

# Berkshelf #
#############
Berksfile
Berksfile.lock
cookbooks/*
tmp

# Bundler #
###########
vendor/*
Expand Down
28 changes: 14 additions & 14 deletions documentation/php_fpm_pool.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,20 @@ More info: <https://www.php.net/manual/en/install.fpm.php>

## Properties

| Name | Type | Default | Description |
| ------------------- | --------------- | ------------------------------------ | ------------------------------------------------------------------------------------- |
| `pool_name` | `String` | The name of the FPM pool | |
| `listen` | `String` | `/var/run/php<version>-fpm.sock` (RHEL & Amazon) or `/var/run/php/php<version>-fpm.sock` (Debian) | The listen address |
| `user` | `String` | The webserver user for your distro. | The user to run the FPM under |
| `group` | `String` | The webserver group for your distro. | The group to run the FPM under |
| `process_manager` | `String` | `dynamic` | Process manager to use - see <https://www.php.net/manual/en/install.fpm.configuration.php> |
| `max_children` | `Integer` | `5` | Max children to scale to |
| `start_servers` | `Integer` | `2` | Number of servers to start the pool with |
| `min_spare_servers` | `Integer` | `1` | Minimum number of servers to have as spares |
| `max_spare_servers` | `Integer` | `3` | Maximum number of servers to have as spares |
| `chdir` | `String` | `/` | The startup working directory of the pool |
| `additional_config` | `Hash` | `{}` | Additional parameters in JSON |
| `fpm_ini_control` | `[true, false]` | `false` | Whether to add a new `php.ini` file for FPM |
| Name | Type | Default | Description |
| ------------------- | --------------- | ------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- |
| `pool_name` | `String` | The name of the FPM pool | |
| `listen` | `String` | `/var/run/php<version>-fpm.sock` (RHEL & Amazon) or `/var/run/php/php<version>-fpm.sock` (Debian) | The listen address |
| `user` | `String` | The webserver user for your distro. | The user to run the FPM under |
| `group` | `String` | The webserver group for your distro. | The group to run the FPM under |
| `process_manager` | `String` | `dynamic` | Process mgr - see <https://www.php.net/manual/en/install.fpm.configuration.php> |
| `max_children` | `Integer` | `5` | Max children to scale to |
| `start_servers` | `Integer` | `2` | Number of servers to start the pool with |
| `min_spare_servers` | `Integer` | `1` | Minimum number of servers to have as spares |
| `max_spare_servers` | `Integer` | `3` | Maximum number of servers to have as spares |
| `chdir` | `String` | `/` | The startup working directory of the pool |
| `additional_config` | `Hash` | `{}` | Additional parameters in JSON |
| `fpm_ini_control` | `[true, false]` | `false` | Whether to add a new `php.ini` file for FPM |

## Examples

Expand Down
19 changes: 10 additions & 9 deletions documentation/php_install.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,16 @@ By default, installs the `php` packages appropriate for your platform and adds a

## Properties

| Name | Type | Default | Description |
| ------------------- | ---------------- | ----------------------------------------------------- | ----------------------------------------------------------- |
| `packages` | `String` | Platform-specific - see `libraries/helpers.rb` | Packages to install |
| `options` | `[String, Array]` | | Installation options (see Chef `package` resource) |
| `conf_dir` | `String` | Platform-specific - see `libraries/helpers.rb` | Directory to place the `php.ini` file under |
| `ini_template` | `String` | `php.ini.erb` (see `templates/<distro>/php.ini.rb`) | Template to use to create the `php.ini` file |
| `ini_cookbook` | `String` | `php` (this cookbook) | Cookbook where the template is located |
| `directives` | `Hash` | `{}` | Directive-value pairs to add to the `php.ini` file |
| `ext_dir` | `String` | Platform-specific - see `libraries/helpers.rb` | Directory in which the loadable extensions (modules) reside |
| Name | Type | Default |
| -------------- | ----------------- | --------------------------------------------------- |
| -------------- | ----------------- | --------------------------------------------------- |
| `packages` | `String` | Platform-specific - see `libraries/helpers.rb` |
| `options` | `[String, Array]` | |
| `conf_dir` | `String` | Platform-specific - see `libraries/helpers.rb` |
| `ini_template` | `String` | `php.ini.erb` (see `templates/<distro>/php.ini.rb`) |
| `ini_cookbook` | `String` | `php` (this cookbook) |
| `directives` | `Hash` | `{}` |
| `ext_dir` | `String` | Platform-specific - see `libraries/helpers.rb` |

## Examples

Expand Down
4 changes: 3 additions & 1 deletion kitchen.dokken.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ driver:
chef_version: <%= ENV['CHEF_VERSION'] || 'current' %>

transport: { name: dokken }
provisioner: { name: dokken }
provisioner:
name: dokken
policyfile: Policyfile.rb

platforms:
- name: almalinux-8
Expand Down
2 changes: 2 additions & 0 deletions kitchen.exec.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
---
driver: { name: exec }
transport: { name: exec }
provisioner:
policyfile: Policyfile.rb

platforms:
- name: macos-latest
Expand Down
4 changes: 2 additions & 2 deletions kitchen.global.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
provisioner:
name: chef_infra
name: policyfile_zero
product_name: chef
product_version: <%= ENV['CHEF_VERSION'] || 'latest' %>
channel: stable
Expand All @@ -10,6 +10,7 @@ provisioner:
multiple_converge: <%= ENV['MULTIPLE_CONVERGE'] || 2 %>
deprecations_as_errors: true
log_level: <%= ENV['CHEF_LOG_LEVEL'] || 'auto' %>
policyfile: Policyfile.rb

verifier:
name: inspec
Expand All @@ -19,7 +20,6 @@ platforms:
- name: almalinux-9
- name: amazonlinux-2023
- name: centos-stream-9
- name: debian-11
- name: debian-12
- name: fedora-latest
- name: opensuse-leap-15
Expand Down
18 changes: 10 additions & 8 deletions kitchen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ driver:
name: vagrant

provisioner:
name: chef_infra
name: policyfile_zero
product_name: chef
chef_license: accept-no-persist
enforce_idempotency: true
multiple_converge: 2
deprecations_as_errors: true
policyfile: Policyfile.rb

verifier:
name: inspec
Expand All @@ -18,7 +19,6 @@ platforms:
- name: almalinux-9
- name: amazonlinux-2023
- name: centos-stream-9
- name: debian-11
- name: debian-12
- name: fedora-latest
- name: rockylinux-8
Expand All @@ -29,17 +29,19 @@ platforms:

suites:
- name: resource
run_list:
- recipe[test::default]
provisioner:
named_run_list: default
- name: resource_community
run_list:
- recipe[test::community]
provisioner:
named_run_list: community
excludes:
- ubuntu-18.04
- ubuntu-20.04
- amazonlinux-2023
- fedora-latest
- name: resource_peclchannel
run_list:
- recipe[test::default]
provisioner:
named_run_list: default
attributes:
pecl_method: channel
verifier:
Expand Down
9 changes: 4 additions & 5 deletions resources/fpm_pool.rb
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,12 @@ def install_fpm_package

raise 'PHP-FPM package not found (you probably have an unsupported distro)' if new_resource.fpm_package.nil?

file new_resource.default_conf do
action :nothing
end

package new_resource.fpm_package do
action :install
notifies :delete, "file[#{new_resource.default_conf}]", :immediately
end

file new_resource.default_conf do
action :delete
end
end

Expand Down
27 changes: 15 additions & 12 deletions resources/pear.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,17 +76,14 @@ def grep_for_version(stdout, package)
end

action :install do
build_essential
install_build_dependencies

# If we specified a version, and it's not the current version, move to the specified version
unless new_resource.version.nil? || new_resource.version == current_resource.version
install_version = new_resource.version
end
# Check if the version we want is already installed
versions_match = candidate_version == current_installed_version(new_resource)

# If it's not installed at all or an upgrade, install it
if install_version || new_resource.version.nil? && !versions_match
if install_version || new_resource.version.nil? && current_resource.version.nil?
converge_by("install package #{new_resource.package_name} #{install_version}") do
info_output = "Installing #{new_resource.package_name}"
info_output << " version #{install_version}" if install_version && !install_version.empty?
Expand All @@ -98,7 +95,7 @@ def grep_for_version(stdout, package)

# reinstall is just an install that always fires
action :reinstall do
build_essential
install_build_dependencies

install_version = new_resource.version unless new_resource.version.nil?
converge_by("reinstall package #{new_resource.package_name} #{install_version}") do
Expand Down Expand Up @@ -136,6 +133,16 @@ def grep_for_version(stdout, package)
end

action_class do
def install_build_dependencies
if platform?('fedora')
package 'Install PEAR build dependencies' do
package_name %w(autoconf bison ca-certificates flex gcc gcc-c++ gettext make m4 ncurses-devel patch)
end
else
build_essential
end
end

def expand_options(options)
options ? " #{options}" : ''
end
Expand Down Expand Up @@ -219,11 +226,7 @@ def prefix_channel(channel)
end

def removing_package?
if new_resource.version.nil?
true # remove any version of a package
else
new_resource.version == @current_resource.version # we don't have the version we want to remove
end
new_resource.version.nil? || new_resource.version == @current_resource.version
end

def extension_dir
Expand Down Expand Up @@ -273,7 +276,7 @@ def pecl?

def manage_pecl_ini(name, action, directives, zend_extensions, priority)
ext_prefix = extension_dir
ext_prefix << ::File::SEPARATOR if ext_prefix.last.chr != ::File::SEPARATOR
ext_prefix << ::File::SEPARATOR unless ext_prefix.end_with?(::File::SEPARATOR)

files = get_extension_files(name)

Expand Down
2 changes: 1 addition & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
require 'chefspec'
require 'chefspec/berkshelf'
require 'chefspec/policyfile'

RSpec.configure do |config|
config.color = true # Use color in STDOUT
Expand Down
Loading
Loading