Vendor the external cookbooks

Knife-Zero doesn't include Berkshelf support, so vendoring everything in
the repo is convenient again
This commit is contained in:
Greg Karékinian
2019-10-13 19:17:42 +02:00
parent f4bfe31ac1
commit a32f34b408
1245 changed files with 100630 additions and 0 deletions

338
cookbooks/php/CHANGELOG.md Normal file
View File

@@ -0,0 +1,338 @@
# php Cookbook CHANGELOG
This file is used to list changes made in each version of the php cookbook.
## 6.1.1 (2018-08-07)
- Pass in missing argument to manage_pecl_ini method when trying to remove a module
## 6.1.0 (2018-07-24)
- Allow default recipe to skip pear channel configuration
## 6.0.0 (2018-04-16)
### Breaking Change
This release removes the previous recipes in this cookbook for setting up various PEAR extensions. These should now be setup using the php_pear module directly and not done by adding various recipes / manipulating attributes
### Other Changes
- Use the build_essential resource directly so we can call this from Chef itself on Chef 14
- Add specs for additional platforms
- Move the helpers back into the resources which makes them easier to ship in Chef later
- Break out logic in the channel resource into a helper
- Add support for Amazon Linux 2
## 5.1.0 (2018-04-05)
- Don't eval the action_class
- use php pear binary property in all recipes
- Remove incorrect not_if in the php_pear resource
- More testing updates
- Initial support for Ubuntu 18.04
## 5.0.0 (2018-02-15)
- Simplify this cookbook to remove the dependency on mysql cookbook, and remove the database dependencies in the recipes and attributes. This will allow folks who are using the mysql cookbook to be able to upgrade as needed (or pin to earlier versions). As this is a big change, pin to an earlier version if you need the mysql support that was previously available in this cookbook. Future versions may contain a resource that allows for recompiling php with the necessary extensions.
- Usage of `node['php']['pear']` in the php_pear resource has been replaced with a new 'binary' property for specifying the path to the binary
- Added a new `priority` property to the php_pear resource
## 4.6.0 (2018-02-07)
- Converted the php_pear resource to a custom resource
- Moved all helper logic out of the resource and into its own helper library file
- Fix source install on Ubuntu by making sure we have xml2-config package
- Remove options that are no longer recognised by the php installer when installing from source
- Remove matchers as we no longer require them with a modern ChefDK
## 4.5.0 (2017-07-11)
- Add reinstall chefspec matcher
- Switch from maintainers files to a simple readme section
- Remove allow_call_time_pass_reference and y2k_compliance config on Debian/Ubuntu as no supported PHP version supports it
- Initial Debian 9 support
## 4.4.0 (2017-06-27)
- Add a reinstall action to php_pear
- Added additional specs for package installs on different platforms
## 4.3.0 (2017-06-27)
- Remove fallback default php attributes that were used if we were on an unsupported platform. If we don't know the platform we don't support it and we should fail until we add proper support
- Add a few attributes needed for fpm support on opensuse. This is a work in progress to get full PHP support on opensuse
- Install xml deps and avoid using xml cookbook since it's been deprecated
- Expand the php_pear testing
- Remove double logging and log the correct package name in php_pear resource
- Cleanup readme example codes, improve formatting and remove references to LWRPs as they are just resources now
## 4.2.0 (2017-05-30)
- Make sure package intalls, php-fpm, and source installs work on Amazon linux
- Avoid symlink warning in the converges
- Simplify the package install logic
- Rename the inspec test to match the suite name so it actually runs
- Test on FreeBSD 11 / Amazon Linux
- Install 5.6.30 by default on source installs
## 4.1.0 (2017-05-30)
- Remove class_eval usage and require Chef 12.7+
## 4.0.0 (2017-04-20)
- Fix pear_channel resource to not fail on Chef 12.5 and 12.6
- Remove support for RHEL 5 as it is now EOL
- Resolve Amazon Linux failures on Chef 13
- Convert fpm_pool to a custom resource
- Fix php_pear failures on Chef 13
- Remove non-functional support for Windows
- Remove redundant Ubuntu version checks in the php_pear provider
- Expand testing to test all of the resources
## 3.1.1 (2017-04-20)
- Use the cookbook attribute as the default value of pear_channel pear property to provide better platform support
## 3.1.0 (2017-04-10)
- Use multi-package installs on supported platform_family(rhel debian suse amazon)
- Use a SPDX standardized license string in the metadata
- Update specs for the new Fauxhai data
## 3.0.0 (2017-03-27)
- Converted pear_channel LWRP into custom resource
- Removed use of pear node attribute from pear_channel resource
- Fix cookstyle issue with missing line on metadata.rb
- Clean up kitchen.dokken.yml file to eliminate duplication of testing suites.
- Eliminate duplicated resource from test cookbook that is in the default recipe.
- Rename php-test to standard cookbook testing cookbook of "test"
- Remove EOL ubuntu platform logic
**NOTE** Windows package installation is currently broken.
## 2.2.1 (2017-02-21)
- Fix double definition of ['php']['packages'] for rhel.
## 2.2.0 (2016-12-12)
- Use multipackage for installs to speed up chef runs
- Use all CPUs when building from source
- Remove need for apt/yum in testing
- Add opensuse to the metadata
- Migrate to inspec for integration testing
## 2.1.1 (2016-09-15)
- Fix recompile un-pack php creates
- Resolve cookstyle warnings
## 2.1.0 (2016-09-14)
- Fix source php version check
- Require Chef 12.1 not 12.0
## 2.0.0 (2016-09-07)
- Require Chef 12+
- Remove the dependency on the Windows cookbook which isn't necessary with Chef 12+
## 1.10.1 (2016-08-30)
- [fix] bug fixes related with Ubuntu 16.04 and PHP 7 support
- adding validator to listen attribute
- Fix node.foo.bar warnings
## v1.10.0 (2016-07-27)
- PR #167 Preventing user specified pool of www from being deleted at the end of the chef run on the first install
- PR #122 Add recipe for php module_imap
- PR #172 Fix uninstall action for resource php_fpm_pool
## v1.9.0 (2016-05-12)
Special thanks to @ThatGerber for getting the PR for this release together
- Added support for Ubuntu 16.04 and PHP 7
- Added support for different listen user/groups with FPM
- Cleaned up resource notification in the pear_channel provider to simplify code
- Fixed Ubuntu 14.04+ not being able to find the GMP library
## v1.8.0 (2016-02-25)
- Bumped the source install default version from 5.5.9 to 5.6.13
- Added a chefignore file to limit the files uploaded to the Chef server
- Added source_url and issues_url to the metadata.rb
- Added additional Chefspec matchers
- Added a Chef standard rubocop.yml file and resolved warnings
- Added serverspec for integration testing
- Remove legacy cloud Test Kitchen configs
- Added testing in Travis CI with kitchen-docker
- Added additional test suites to the Test Kitchen config
- Updated contributing and testing documentation
- Updated testing gem dependencies to the latest
- Added maintainers.md and maintainers.toml files
- Remove gitter chat from the readme
- Add cookbook version badge to the readme
- Added Fedora as a supported platform in the readme
- Add missing cookbook dependencies to the readme
## v1.7.2 (2015-8-24)
- Correct spelling in fpm_pool_start_servers (was servres)
## v1.7.1 (2015-8-17)
- Correct permissions on ext_conf_dir folder (644 -> 755)
## v1.7.0 (2015-7-31)
- NOTICE - This version changes the way the ['php']['directives'] is placed into configuration files. Quotes are no longer automatically placed around these aditional directives. Please take care when rolling out this version.
- Allow additional PHP FPM config
- Add recipe to recompile PHP from source
- Move source dependencies to attributes file
- Misc bug fixes
## v1.6.0 (2015-7-6)
- Added ChefSpec matchers
- Added basic PHP-FPM Support (Pre-Release)
- Added support for FreeBSD
- Updated cookbook to use MySQL 6.0 cookbook
- Update cookbook to use php5enmod on supported platforms
- Allow users to override php-mysql package
## v1.5.0 (2014-10-06)
- Adding package_options attribute, utilizing in package resource
## v1.4.6 (2014-03-19)
- [COOK-4436] - Test this cookbook, not yum. Also test Fedora 20.
- [COOK-4427] - Add oracle as supported operating system
## v1.4.4 (2014-03-12)
- [COOK-4393] - Fix convergence bug in source install
## v1.4.2 (2014-02-27)
[COOK-4300] - Simplified and fixed pear/pecl logic. [Fixes #56 / #57]
## v1.4.0 (2014-02-27)
[COOK-3639] - Allow users to specify php.ini source template
## v1.3.14 (2014-02-21)
### Bug
- **[COOK-4186](https://tickets.opscode.com/browse/COOK-4186)** - Upgrade_package concatenates an empty version string when version is not set or is empty.
## v1.3.12 (2014-01-28)
Fix github issue 'Cannot find a resource for preferred_state'
## v1.3.10
Fixing my stove
## v1.3.8
Version bump to ensure artifact sanity
## v1.3.6
Version bump for toolchain
## v1.3.4
Adding platform_family check to include_recipe in source.rb
## v1.3.2
Fixing style cops. Updating test harness
## v1.3.0
### Bug
- **[COOK-3479](https://tickets.opscode.com/browse/COOK-3479)** - Added Windows support to PHP
- **[COOK-2909](https://tickets.opscode.com/browse/COOK-2909)** - Warnings about Chef::Exceptions::ShellCommandFailed is deprecated
## v1.2.6
### Bug
- **[COOK-3628](https://tickets.opscode.com/browse/COOK-3628)** - Fix PHP download URL
- **[COOK-3568](https://tickets.opscode.com/browse/COOK-3568)** - Fix Test Kitchen tests
- **[COOK-3402](https://tickets.opscode.com/browse/COOK-3402)** - When the `ext_dir` setting is present, configure php properly for the source recipe
- **[COOK-2926](https://tickets.opscode.com/browse/COOK-2926)** - Fix pear package detection when installing specific version
## v1.2.4
### Improvement
- **[COOK-3047](https://tickets.opscode.com/browse/COOK-3047)** - Sort directives in `php.ini`
- **[COOK-2928](https://tickets.opscode.com/browse/COOK-2928)** - Abstract `php.ini` directives into variables
### Bug
- **[COOK-2378](https://tickets.opscode.com/browse/COOK-2378)** - Fix `php_pear` for libevent
## v1.2.2
### Bug
- [COOK-3050]: `lib_dir` declared in wrong place for redhat
- [COOK-3102]: remove fileinfo recipe from php cookbook
### Improvement
- [COOK-3101]: use a method to abstract range of "el 5" versions in php recipes
## v1.2.0
### Improvement
- [COOK-2516]: Better support for SUSE distribution for php cookbook
- [COOK-3035]: update php::source to install 5.4.15 by default
### Bug
- [COOK-2463]: PHP PEAR Provider Installs Most Recent Version, Without Respect to Preferred State
- [COOK-2514]: php_pear: does not handle more exotic version strings
## v1.1.8
- [COOK-1998] - Enable override of PHP packages in attributes
## v1.1.6
- [COOK-2324] - adds Oracle linux support
## v1.1.4
- [COOK-2106] - `php_pear` cannot find available packages
## v1.1.2
- [COOK-1803] - use better regexp to match package name
- [COOK-1926] - support Amazon linux
## v1.1.0
- [COOK-543] - php.ini template should be configurable
- [COOK-1067] - support for PECL zend extensions
- [COOK-1193] - update package names for EPEL 6
- [COOK-1348] - rescue Mixlib::ShellOut::ShellCommandFailed (chef 0.10.10)
- [COOK-1465] - fix pear extension template
## v1.0.2
- [COOK-993] Add mhash-devel to centos php source libs
- [COOK-989] - bump version of php to 5.3.10
- Also download the .tar.gz instead of .tar.bz2 as bzip2 may not be in the base OS (e.g., CentOS 6 minimal)

View File

@@ -0,0 +1,2 @@
Please refer to
https://github.com/chef-cookbooks/community_cookbook_documentation/blob/master/CONTRIBUTING.MD

263
cookbooks/php/README.md Normal file
View File

@@ -0,0 +1,263 @@
# php Cookbook
[![Build Status](https://travis-ci.org/chef-cookbooks/php.svg?branch=master)](http://travis-ci.org/chef-cookbooks/php) [![Cookbook Version](https://img.shields.io/cookbook/v/php.svg)](https://supermarket.chef.io/cookbooks/php)
It installs and configures PHP and the PEAR package management system. Also includes resources for managing PEAR (and PECL) packages, PECL channels, and PHP-FPM pools.
## Requirements
### Platforms
- Debian, Ubuntu
- CentOS, Red Hat, Oracle, Scientific, Amazon Linux
- Fedora
### Chef
- Chef 12.7+
### Cookbooks
- build-essential
## Attributes
- `node['php']['install_method']` = method to install php with, default `package`.
- `node['php']['directives']` = Hash of directives and values to append to `php.ini`, default `{}`.
- `node['php']['pear_setup']` = Boolean value to determine whether to set up pear repositories. Default: `true`
- `node['php']['pear_channels']` = List of external pear channels to add if `node['php']['pear_setup]` is true. Default: `['pear.php.net', 'pecl.php.net']`
The file also contains the following attribute types:
- platform specific locations and settings.
- source installation settings
## Resources
This cookbook includes resources for managing:
- PEAR channels
- PEAR/PECL packages
### `php_pear_channel`
[PEAR Channels](http://pear.php.net/manual/en/guide.users.commandline.channels.php) are alternative sources for PEAR packages. This resource provides and easy way to manage these channels.
#### Actions
- `:discover`: Initialize a channel from its server.
- `:add`: Add a channel to the channel list, usually only used to add private channels. Public channels are usually added using the `:discover` action
- `:update`: Update an existing channel
- `:remove`: Remove a channel from the List
#### Properties
- `channel_name`: name attribute. The name of the channel to discover
- `channel_xml`: the channel.xml file of the channel you are adding
- `binary`: pear binary, default: pear
#### Examples
```ruby
# discover the horde channel
php_pear_channel "pear.horde.org" do
action :discover
end
# download xml then add the symfony channel
remote_file "#{Chef::Config[:file_cache_path]}/symfony-channel.xml" do
source 'http://pear.symfony-project.com/channel.xml'
mode '0644'
end
php_pear_channel 'symfony' do
channel_xml "#{Chef::Config[:file_cache_path]}/symfony-channel.xml"
action :add
end
# update the main pear channel
php_pear_channel 'pear.php.net' do
action :update
end
# update the main pecl channel
php_pear_channel 'pecl.php.net' do
action :update
end
```
### `php_pear`
[PEAR](http://pear.php.net/) is a framework and distribution system for reusable PHP components. [PECL](http://pecl.php.net/) is a repository for PHP Extensions. PECL contains C extensions for compiling into PHP. As C programs, PECL extensions run more efficiently than PEAR packages. PEARs and PECLs use the same packaging and distribution system. As such this resource is clever enough to abstract away the small differences and can be used for managing either. This resource also creates the proper module .ini file for each PECL extension at the correct location for each supported platform.
#### Actions
- `:install`: Install a pear package - if version is provided, install that specific version
- `:upgrade`: Upgrade a pear package - if version is provided, upgrade to that specific version
- `:remove`: Remove a pear package
- `:reinstall`: Force install of the package even if the same version is already installed. Note: This will converge on every Chef run and is probably not what you want.
- `:purge`: An alias for remove as the two behave the same in pear
#### Properties
- `package_name`: name attribute. The name of the pear package to install
- `version`: the version of the pear package to install/upgrade. If no version is given latest is assumed.
- `channel`:
- `options`: Add additional options to the underlying pear package command
- `directives`: extra extension directives (settings) for a pecl. on most platforms these usually get rendered into the extension's .ini file
- `zend_extensions`: extension filenames which should be loaded with zend_extension.
- `preferred_state`: PEAR by default installs stable packages only, this allows you to install pear packages in a devel, alpha or beta state
- `binary`: The pear binary to use, by default pear, can be overridden if the binary is not called pear, e.g. pear7
#### Examples
```ruby
# upgrade a pear
php_pear 'XML_RPC' do
action :upgrade
end
# install a specific version
php_pear 'XML_RPC' do
version '1.5.4'
action :install
end
# install the mongodb pecl
php_pear 'Install mongo but use a different resource name' do
package_name 'mongo'
action :install
end
# install the xdebug pecl
php_pear 'xdebug' do
# Specify that xdebug.so must be loaded as a zend extension
zend_extensions ['xdebug.so']
action :install
end
# install apc pecl with directives
php_pear 'apc' do
action :install
directives(shm_size: 128, enable_cli: 1)
end
# install using the pear-7 binary
php_pear 'apc' do
action :install
binary 'pear7'
end
# install the beta version of Horde_Url
# from the horde channel
hc = php_pear_channel 'pear.horde.org' do
action :discover
end
php_pear 'Horde_Url' do
preferred_state 'beta'
channel hc.channel_name
action :install
end
# install the YAML pear from the symfony project
sc = php_pear_channel 'pear.symfony-project.com' do
action :discover
end
php_pear 'YAML' do
channel sc.channel_name
action :install
end
```
### `php_fpm_pool`
Installs the `php-fpm` package appropriate for your distro (if using packages) and configures a FPM pool for you. Currently only supported in Debian-family operating systems and CentOS 7 (or at least tested with such, YMMV if you are using source).
Please consider FPM functionally pre-release, and test it thoroughly in your environment before using it in production
More info: <http://php.net/manual/en/install.fpm.php>
#### Actions
- `:install`: Installs the FPM pool (default).
- `:uninstall`: Removes the FPM pool.
#### Attribute Parameters
- `pool_name`: name attribute. The name of the FPM pool.
- `listen`: The listen address. Default: `/var/run/php5-fpm.sock`
- `user`: The user to run the FPM under. Default should be the webserver user for your distro.
- `group`: The group to run the FPM under. Default should be the webserver group for your distro.
- `process_manager`: Process manager to use - see <http://php.net/manual/en/install.fpm.configuration.php>. Default: `dynamic`
- `max_children`: Max children to scale to. Default: 5
- `start_servers`: Number of servers to start the pool with. Default: 2
- `min_spare_servers`: Minimum number of servers to have as spares. Default: 1
- `max_spare_servers`: Maximum number of servers to have as spares. Default: 3
- `chdir`: The startup working directory of the pool. Default: `/`
- `additional_config`: Additional parameters in JSON. Default: {}
#### Examples
```ruby
# Install a FPM pool named "default"
php_fpm_pool 'default' do
action :install
end
```
## Recipes
### default
Include the default recipe in a run list, to get `php`. By default `php` is installed from packages but this can be changed by using the `install_method` attribute.
### package
This recipe installs PHP from packages.
### source
This recipe installs PHP from source.
## Usage
Simply include the `php` recipe where ever you would like php installed. To install from source override the `node['php']['install_method']` attribute with in a role or wrapper cookbook:
### Role example:
```ruby
name 'php'
description 'Install php from source'
override_attributes(
'php' => {
'install_method' => 'source',
}
)
run_list(
'recipe[php]'
)
```
## Maintainers
This cookbook is maintained by Chef's Community Cookbook Engineering team. Our goal is to improve cookbook quality and to aid the community in contributing to cookbooks. To learn more about our team, process, and design goals see our [team documentation](https://github.com/chef-cookbooks/community_cookbook_documentation/blob/master/COOKBOOK_TEAM.MD). To learn more about contributing to cookbooks like this see our [contributing documentation](https://github.com/chef-cookbooks/community_cookbook_documentation/blob/master/CONTRIBUTING.MD), or if you have general questions about this cookbook come chat with us in #cookbok-engineering on the [Chef Community Slack](http://community-slack.chef.io/)
## License
**Copyright:** 2011-2018, Chef Software, Inc.
**Copyright:** 2018, Oracle and/or its affiliates. All rights reserved
```
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
```

View File

@@ -0,0 +1,190 @@
#
# Cookbook:: php
# Attributes:: default
#
# Copyright:: 2011-2018, Chef Software, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
lib_dir = 'lib'
default['php']['install_method'] = 'package'
default['php']['directives'] = {}
default['php']['bin'] = 'php'
default['php']['pecl'] = 'pecl'
default['php']['version'] = '5.6.30'
default['php']['pear'] = '/usr/bin/pear'
default['php']['pear_setup'] = true
default['php']['pear_channels'] = [
'pear.php.net',
'pecl.php.net',
]
default['php']['url'] = 'http://us1.php.net/get'
default['php']['checksum'] = '8bc7d93e4c840df11e3d9855dcad15c1b7134e8acf0cf3b90b932baea2d0bde2'
default['php']['prefix_dir'] = '/usr/local'
default['php']['enable_mod'] = '/usr/sbin/php5enmod'
default['php']['disable_mod'] = '/usr/sbin/php5dismod'
default['php']['ini']['template'] = 'php.ini.erb'
default['php']['ini']['cookbook'] = 'php'
default['php']['fpm_socket'] = '/var/run/php5-fpm.sock'
case node['platform_family']
when 'rhel', 'fedora', 'amazon'
lib_dir = node['kernel']['machine'] =~ /x86_64/ ? 'lib64' : 'lib'
default['php']['conf_dir'] = '/etc'
default['php']['ext_conf_dir'] = '/etc/php.d'
default['php']['fpm_user'] = 'nobody'
default['php']['fpm_group'] = 'nobody'
default['php']['fpm_listen_user'] = 'nobody'
default['php']['fpm_listen_group'] = 'nobody'
default['php']['ext_dir'] = "/usr/#{lib_dir}/php/modules"
if node['platform'] == 'amazon' # amazon names their packages with versions on 201X amazon
default['php']['src_deps'] = %w(bzip2-devel libc-client-devel curl-devel freetype-devel gmp-devel libjpeg-devel krb5-devel libmcrypt-devel libpng-devel openssl-devel t1lib-devel libxml2-devel libxslt-devel zlib-devel)
if node['platform_version'].to_i == 2
default['php']['packages'] = %w(php php-devel php-pear)
default['php']['fpm_package'] = 'php-fpm'
else
default['php']['packages'] = %w(php56 php56-devel php-pear)
default['php']['fpm_package'] = 'php56-fpm'
end
else # redhat does not name their packages with version on RHEL 6+
default['php']['src_deps'] = %w(bzip2-devel libc-client-devel curl-devel freetype-devel gmp-devel libjpeg-devel krb5-devel libmcrypt-devel libpng-devel openssl-devel t1lib-devel libxml2-devel libxslt-devel zlib-devel mhash-devel)
default['php']['packages'] = %w(php php-devel php-cli php-pear)
default['php']['fpm_package'] = 'php-fpm'
end
default['php']['fpm_pooldir'] = '/etc/php-fpm.d'
default['php']['fpm_default_conf'] = '/etc/php-fpm.d/www.conf'
default['php']['fpm_service'] = 'php-fpm'
if node['php']['install_method'] == 'package'
default['php']['fpm_user'] = 'apache'
default['php']['fpm_group'] = 'apache'
default['php']['fpm_listen_user'] = 'apache'
default['php']['fpm_listen_group'] = 'apache'
end
when 'debian'
default['php']['conf_dir'] = '/etc/php5/cli'
default['php']['ext_conf_dir'] = '/etc/php5/conf.d'
default['php']['src_deps'] = %w(libbz2-dev libc-client2007e-dev libcurl4-gnutls-dev libfreetype6-dev libgmp3-dev libjpeg62-dev libkrb5-dev libmcrypt-dev libpng12-dev libssl-dev libt1-dev libxml2-dev libxslt-dev zlib1g-dev)
default['php']['packages'] = %w(php5-cgi php5 php5-dev php5-cli php-pear)
default['php']['fpm_package'] = 'php5-fpm'
default['php']['fpm_pooldir'] = '/etc/php5/fpm/pool.d'
default['php']['fpm_user'] = 'www-data'
default['php']['fpm_group'] = 'www-data'
default['php']['fpm_listen_user'] = 'www-data'
default['php']['fpm_listen_group'] = 'www-data'
default['php']['fpm_service'] = 'php5-fpm'
default['php']['fpm_default_conf'] = '/etc/php5/fpm/pool.d/www.conf'
if (platform?('debian') && node['platform_version'].to_i >= 9) ||
(platform?('ubuntu') && node['platform_version'].to_f == 16.04)
default['php']['version'] = '7.0.4'
default['php']['checksum'] = 'f6cdac2fd37da0ac0bbcee0187d74b3719c2f83973dfe883d5cde81c356fe0a8'
default['php']['conf_dir'] = '/etc/php/7.0/cli'
default['php']['src_deps'] = %w(libbz2-dev libc-client2007e-dev libcurl4-gnutls-dev libfreetype6-dev libgmp3-dev libjpeg62-dev libkrb5-dev libmcrypt-dev libpng12-dev libssl-dev pkg-config libxml2-dev)
default['php']['packages'] = %w(php7.0-cgi php7.0 php7.0-dev php7.0-cli php-pear)
default['php']['fpm_package'] = 'php7.0-fpm'
default['php']['fpm_pooldir'] = '/etc/php/7.0/fpm/pool.d'
default['php']['fpm_service'] = 'php7.0-fpm'
default['php']['fpm_socket'] = '/var/run/php/php7.0-fpm.sock'
default['php']['fpm_default_conf'] = '/etc/php/7.0/fpm/pool.d/www.conf'
default['php']['enable_mod'] = '/usr/sbin/phpenmod'
default['php']['disable_mod'] = '/usr/sbin/phpdismod'
default['php']['ext_conf_dir'] = '/etc/php/7.0/mods-available'
elsif platform?('ubuntu') && node['platform_version'].to_f >= 18.04
default['php']['version'] = '7.0.4'
default['php']['checksum'] = 'f6cdac2fd37da0ac0bbcee0187d74b3719c2f83973dfe883d5cde81c356fe0a8'
default['php']['conf_dir'] = '/etc/php/7.2/cli'
default['php']['src_deps'] = %w(libbz2-dev libc-client2007e-dev libcurl4-gnutls-dev libfreetype6-dev libgmp3-dev libjpeg62-dev libkrb5-dev libmcrypt-dev libpng12-dev libssl-dev pkg-config libxml2-dev)
default['php']['packages'] = %w(php7.2-cgi php7.2 php7.2-dev php7.2-cli php-pear)
default['php']['fpm_package'] = 'php7.2-fpm'
default['php']['fpm_pooldir'] = '/etc/php/7.2/fpm/pool.d'
default['php']['fpm_service'] = 'php7.2-fpm'
default['php']['fpm_socket'] = '/var/run/php/php7.2-fpm.sock'
default['php']['fpm_default_conf'] = '/etc/php/7.2/fpm/pool.d/www.conf'
default['php']['enable_mod'] = '/usr/sbin/phpenmod'
default['php']['disable_mod'] = '/usr/sbin/phpdismod'
default['php']['ext_conf_dir'] = '/etc/php/7.2/mods-available'
end
case node['platform']
when 'ubuntu'
case node['platform_version'].to_f
when 13.04..15.10
default['php']['ext_conf_dir'] = '/etc/php5/mods-available'
end
when 'debian'
if node['platform_version'].to_i == 8
default['php']['ext_conf_dir'] = '/etc/php5/mods-available'
end
end
when 'suse'
default['php']['conf_dir'] = '/etc/php5/cli'
default['php']['ext_conf_dir'] = '/etc/php5/conf.d'
default['php']['src_deps'] = %w(libbz2-dev libc-client2007e-dev libcurl4-gnutls-dev libfreetype6-dev libgmp3-dev libjpeg62-dev libkrb5-dev libmcrypt-dev libpng12-dev libssl-dev libt1-dev libxml2-devel libxslt-devel zlib-devel)
default['php']['fpm_default_conf'] = '/etc/php-fpm.d/www.conf'
default['php']['fpm_pooldir'] = '/etc/php5/fpm'
default['php']['fpm_service'] = 'php-fpm'
default['php']['fpm_package'] = 'php5-fpm'
default['php']['fpm_user'] = 'wwwrun'
default['php']['fpm_group'] = 'www'
default['php']['fpm_listen_user'] = 'wwwrun'
default['php']['fpm_listen_group'] = 'www'
default['php']['packages'] = %w(apache2-mod_php5 php5-pear)
lib_dir = node['kernel']['machine'] =~ /x86_64/ ? 'lib64' : 'lib'
when 'freebsd'
default['php']['conf_dir'] = '/usr/local/etc'
default['php']['ext_conf_dir'] = '/usr/local/etc/php'
default['php']['src_deps'] = %w(libbz2-dev libc-client2007e-dev libcurl4-gnutls-dev libfreetype6-dev libgmp3-dev libjpeg62-dev libkrb5-dev libmcrypt-dev libpng12-dev libssl-dev libt1-dev)
default['php']['fpm_user'] = 'www'
default['php']['fpm_group'] = 'www'
default['php']['fpm_listen_user'] = 'www'
default['php']['fpm_listen_group'] = 'www'
default['php']['packages'] = %w( php56 pear )
end
default['php']['configure_options'] = %W(--prefix=#{node['php']['prefix_dir']}
--with-libdir=#{lib_dir}
--with-config-file-path=#{node['php']['conf_dir']}
--with-config-file-scan-dir=#{node['php']['ext_conf_dir']}
--with-pear
--enable-fpm
--with-fpm-user=#{node['php']['fpm_user']}
--with-fpm-group=#{node['php']['fpm_group']}
--with-zlib
--with-openssl
--with-kerberos
--with-bz2
--with-curl
--enable-ftp
--enable-zip
--enable-exif
--with-gd
--enable-gd-native-ttf
--with-gettext
--with-gmp
--with-mhash
--with-iconv
--with-imap
--with-imap-ssl
--enable-sockets
--enable-soap
--with-xmlrpc
--with-mcrypt
--enable-mbstring)

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,33 @@
#
# Author:: Joshua Timberman (<joshua@chef.io>)
# Author:: Seth Chisamore (<schisamo@chef.io>)
# Cookbook:: php
# Recipe:: default
#
# Copyright:: 2009-2018, Chef Software, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
include_recipe "php::#{node['php']['install_method']}"
# update the main channels
node['php']['pear_channels'].each do |channel|
php_pear_channel channel do
binary node['php']['pear']
action :update
only_if { node['php']['pear_setup'] }
end
end
include_recipe 'php::ini'

View File

@@ -0,0 +1,29 @@
#
# Author:: Christo De Lange (<opscode@dldinternet.com>)
# Cookbook:: php
# Recipe:: ini
#
# Copyright:: 2011-2018, Chef Software, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
template "#{node['php']['conf_dir']}/php.ini" do
source node['php']['ini']['template']
cookbook node['php']['ini']['cookbook']
owner 'root'
group node['root_group']
mode '0644'
manage_symlink_source true
variables(directives: node['php']['directives'])
end

View File

@@ -0,0 +1,34 @@
#
# Author:: Seth Chisamore (<schisamo@chef.io>)
# Author:: Lucas Hansen (<lucash@chef.io>)
# Cookbook:: php
# Recipe:: package
#
# Copyright:: 2013-2018, Chef Software, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
if platform_family?('rhel', 'debian', 'amazon', 'suse')
package node['php']['packages'] do
options node['php']['package_options']
end
else
node['php']['packages'].each do |pkg|
package pkg do
options node['php']['package_options']
end
end
end
include_recipe 'php::ini'

View File

@@ -0,0 +1,51 @@
#
# Author:: David Kinzer (<dtkinzer@gmail.com>)
# Cookbook:: php
# Recipe:: recompile
#
# Copyright:: 2014-2018, David Kinzer
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
version = node['php']['version']
configure_options = node['php']['configure_options'].join(' ')
ext_dir_prefix = node['php']['ext_dir'] ? "EXTENSION_DIR=#{node['php']['ext_dir']}" : ''
node['php']['src_deps'].each do |pkg|
package pkg do
action 'install'
end
end
remote_file "#{Chef::Config[:file_cache_path]}/php-#{version}.tar.gz" do
source "#{node['php']['url']}/php-#{version}.tar.gz/from/this/mirror"
checksum node['php']['checksum']
mode '0644'
action 'create_if_missing'
end
bash 'un-pack php' do
cwd Chef::Config[:file_cache_path]
code "tar -zxf php-#{version}.tar.gz"
creates "#{Chef::Config[:file_cache_path]}/php-#{version}"
end
bash 're-build php' do
cwd "#{Chef::Config[:file_cache_path]}/php-#{version}"
code <<-EOF
(make clean)
(#{ext_dir_prefix} ./configure #{configure_options})
(make -j #{node['cpu']['total']} && make install)
EOF
end

View File

@@ -0,0 +1,80 @@
#
# Author:: Seth Chisamore (<schisamo@chef.io>)
# Cookbook:: php
# Recipe:: source
#
# Copyright:: 2011-2018, Chef Software, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
configure_options = node['php']['configure_options'].join(' ')
build_essential 'install compilation tools'
include_recipe 'yum-epel' if node['platform_family'] == 'rhel'
package node['php']['src_deps']
version = node['php']['version']
remote_file "#{Chef::Config[:file_cache_path]}/php-#{version}.tar.gz" do
source "#{node['php']['url']}/php-#{version}.tar.gz/from/this/mirror"
checksum node['php']['checksum']
mode '0644'
not_if "$(which #{node['php']['bin']}) --version | grep #{version}"
end
if node['php']['ext_dir']
directory node['php']['ext_dir'] do
owner 'root'
group 'root'
mode '0755'
recursive true
end
ext_dir_prefix = "EXTENSION_DIR=#{node['php']['ext_dir']}"
else
ext_dir_prefix = ''
end
# PHP is unable to find the GMP library in 16.04. The symlink brings the file
# inside of the include libraries.
link '/usr/include/gmp.h' do
to '/usr/include/x86_64-linux-gnu/gmp.h'
only_if { node['platform_family'] == 'debian' && node['platform_version'].to_f >= 14.04 }
end
bash 'build php' do
cwd Chef::Config[:file_cache_path]
code <<-EOF
tar -zxf php-#{version}.tar.gz
(cd php-#{version} && #{ext_dir_prefix} ./configure #{configure_options})
(cd php-#{version} && make -j #{node['cpu']['total']} && make install)
EOF
not_if "$(which #{node['php']['bin']}) --version | grep #{version}"
end
directory node['php']['conf_dir'] do
owner 'root'
group 'root'
mode '0755'
recursive true
end
directory node['php']['ext_conf_dir'] do
owner 'root'
group 'root'
mode '0755'
recursive true
end
include_recipe 'php::ini'

View File

@@ -0,0 +1,97 @@
#
# Author:: Chris Marchesi <cmarchesi@paybyphone.com>
# Cookbook:: php
# Resource:: fpm_pool
#
# Copyright:: 2015-2018, Chef Software, Inc <legal@chef.io>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
property :pool_name, String, name_property: true
property :listen, String, default: lazy { node['php']['fpm_socket'] }
property :user, String, default: lazy { node['php']['fpm_user'] }
property :group, String, default: lazy { node['php']['fpm_group'] }
property :listen_user, String, default: lazy { node['php']['fpm_listen_user'] }
property :listen_group, String, default: lazy { node['php']['fpm_listen_group'] }
property :process_manager, String, default: 'dynamic'
property :max_children, Integer, default: 5
property :start_servers, Integer, default: 2
property :min_spare_servers, Integer, default: 1
property :max_spare_servers, Integer, default: 3
property :chdir, String, default: '/'
property :additional_config, Hash, default: {}
action :install do
# Ensure the FPM pacakge is installed, and the service is registered
install_fpm_package
register_fpm_service
# I wanted to have this as a function in itself, but doing this seems to
# break testing suites?
template "#{node['php']['fpm_pooldir']}/#{new_resource.pool_name}.conf" do
source 'fpm-pool.conf.erb'
action :create
cookbook 'php'
variables(
fpm_pool_name: new_resource.pool_name,
fpm_pool_user: new_resource.user,
fpm_pool_group: new_resource.group,
fpm_pool_listen: new_resource.listen,
fpm_pool_listen_user: new_resource.listen_user,
fpm_pool_listen_group: new_resource.listen_group,
fpm_pool_manager: new_resource.process_manager,
fpm_pool_max_children: new_resource.max_children,
fpm_pool_start_servers: new_resource.start_servers,
fpm_pool_min_spare_servers: new_resource.min_spare_servers,
fpm_pool_max_spare_servers: new_resource.max_spare_servers,
fpm_pool_chdir: new_resource.chdir,
fpm_pool_additional_config: new_resource.additional_config
)
notifies :restart, "service[#{node['php']['fpm_service']}]"
end
end
action :uninstall do
# Ensure the FPM pacakge is installed, and the service is registered
register_fpm_service
# Delete the FPM pool.
file "#{node['php']['fpm_pooldir']}/#{new_resource.pool_name}.conf" do
action :delete
end
end
action_class do
def install_fpm_package
# Install the FPM pacakge for this platform, if it's available
# Fail the run if it's an unsupported OS (FPM pacakge name not populated)
# also, this is skipped for source
return if node['php']['install_method'] == 'source'
raise 'PHP-FPM package not found (you probably have an unsupported distro)' if node['php']['fpm_package'].nil?
file node['php']['fpm_default_conf'] do
action :nothing
end
package node['php']['fpm_package'] do
action :install
notifies :delete, "file[#{node['php']['fpm_default_conf']}]", :immediately
end
end
def register_fpm_service
service node['php']['fpm_service'] do
action :enable
end
end
end

View File

@@ -0,0 +1,280 @@
#
# Author:: Seth Chisamore <schisamo@chef.io>
# Cookbook:: php
# Resource:: pear
#
# Copyright:: 2011-2018, Chef Software, Inc <legal@chef.io>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
property :package_name, String, name_property: true
property :version, [String, nil], default: nil
property :channel, String
property :options, String
property :directives, Hash, default: {}
property :zend_extensions, Array, default: []
property :preferred_state, String, default: 'stable'
property :binary, String, default: 'pear'
property :priority, [String, nil], default: nil
def current_installed_version(new_resource)
version_check_cmd = "#{new_resource.binary} -d"
version_check_cmd << " preferred_state=#{new_resource.preferred_state}"
version_check_cmd << " list#{expand_channel(new_resource.channel)}"
p = shell_out(version_check_cmd)
response = nil
response = grep_for_version(p.stdout, new_resource.package_name) if p.stdout =~ /\.?Installed packages/i
response
end
def expand_channel(channel)
channel ? " -c #{channel}" : ''
end
def grep_for_version(stdout, package)
version = nil
stdout.split(/\n/).grep(/^#{package}\s/i).each do |m|
# XML_RPC 1.5.4 stable
# mongo 1.1.4/(1.1.4 stable) 1.1.4 MongoDB database driver
# Horde_Url -n/a-/(1.0.0beta1 beta) Horde Url class
# Horde_Url 1.0.0beta1 (beta) 1.0.0beta1 Horde Url class
version = m.split(/\s+/)[1].strip
version = if version.split(%r{/\//})[0] =~ /.\./
# 1.1.4/(1.1.4 stable)
version.split(%r{/\//})[0]
else
# -n/a-/(1.0.0beta1 beta)
version.split(%r{/(.*)\/\((.*)/}).last.split(/\s/)[0]
end
end
version
end
load_current_value do |new_resource|
unless current_installed_version(new_resource).nil?
version(current_installed_version(new_resource))
Chef::Log.debug("Current version is #{version}") if version
end
end
action :install do
# If we specified a version, and it's not the current version, move to the specified version
install_version = new_resource.version unless new_resource.version.nil? || new_resource.version == current_resource.version
# 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
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?
Chef::Log.info(info_output)
install_package(new_resource.package_name, install_version)
end
end
end
# reinstall is just an install that always fires
action :reinstall do
install_version = new_resource.version unless new_resource.version.nil?
converge_by("reinstall 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?
Chef::Log.info(info_output)
install_package(new_resource.package_name, install_version, force: true)
end
end
action :upgrade do
if current_resource.version != candidate_version
orig_version = @current_resource.version || 'uninstalled'
description = "upgrade package #{new_resource.package_name} version from #{orig_version} to #{candidate_version}"
converge_by(description) do
upgrade_package(new_resource.package_name, candidate_version)
end
end
end
action :remove do
if removing_package?
converge_by("remove package #{new_resource.package_name}") do
remove_package(@current_resource.package_name, new_resource.version)
end
end
end
action :purge do
if removing_package?
converge_by("purge package #{new_resource.package_name}") do
remove_package(@current_resource.package_name, new_resource.version)
end
end
end
action_class do
def expand_options(options)
options ? " #{options}" : ''
end
def candidate_version
candidate_version_cmd = "#{new_resource.binary} -d "
candidate_version_cmd << "preferred_state=#{new_resource.preferred_state}"
candidate_version_cmd << " search#{expand_channel(new_resource.channel)}"
candidate_version_cmd << " #{new_resource.package_name}"
p = shell_out(candidate_version_cmd)
response = nil
response = grep_for_version(p.stdout, new_resource.package_name) if p.stdout =~ /\.?Matched packages/i
response
end
def install_package(name, version, **opts)
command = "printf \"\r\" | #{new_resource.binary} -d"
command << " preferred_state=#{new_resource.preferred_state}"
command << " install -a#{expand_options(new_resource.options)}"
command << ' -f' if opts[:force] # allows us to force a reinstall
command << " #{prefix_channel(new_resource.channel)}#{name}"
command << "-#{version}" if version && !version.empty?
pear_shell_out(command)
manage_pecl_ini(name, :create, new_resource.directives, new_resource.zend_extensions, new_resource.priority) if pecl?
enable_package(name)
end
def upgrade_package(name, version)
command = "printf \"\r\" | #{new_resource.binary} -d"
command << " preferred_state=#{new_resource.preferred_state}"
command << " upgrade -a#{expand_options(new_resource.options)}"
command << " #{prefix_channel(new_resource.channel)}#{name}"
command << "-#{version}" if version && !version.empty?
pear_shell_out(command)
manage_pecl_ini(name, :create, new_resource.directives, new_resource.zend_extensions, new_resource.priority) if pecl?
enable_package(name)
end
def remove_package(name, version)
command = "#{new_resource.binary} uninstall"
command << " #{expand_options(new_resource.options)}"
command << " #{prefix_channel(new_resource.channel)}#{name}"
command << "-#{version}" if version && !version.empty?
pear_shell_out(command)
disable_package(name)
manage_pecl_ini(name, :delete, nil, nil, nil) if pecl?
end
def enable_package(name)
execute "#{node['php']['enable_mod']} #{name}" do
only_if { platform?('ubuntu') && ::File.exist?(node['php']['enable_mod']) }
end
end
def disable_package(name)
execute "#{node['php']['disable_mod']} #{name}" do
only_if { platform?('ubuntu') && ::File.exist?(node['php']['disable_mod']) }
end
end
def pear_shell_out(command)
p = shell_out!(command)
# pear/pecl commands return a 0 on failures...we'll grep for it
p.invalid! if p.stdout.split('\n').last =~ /^ERROR:.+/i
p
end
def prefix_channel(channel)
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
end
def extension_dir
@extension_dir ||= begin
# Consider using "pecl config-get ext_dir". It is more cross-platform.
# p = shell_out("php-config --extension-dir")
p = shell_out("#{node['php']['pecl']} config-get ext_dir")
p.stdout.strip
end
end
def get_extension_files(name)
files = []
p = shell_out("#{new_resource.binary} list-files #{name}")
p.stdout.each_line.grep(/^src\s+.*\.so$/i).each do |line|
files << line.split[1]
end
files
end
def pecl?
@pecl ||=
begin
# search as a pear first since most 3rd party channels will report pears as pecls!
search_args = ''
search_args << " -d preferred_state=#{new_resource.preferred_state}"
search_args << " search#{expand_channel(new_resource.channel)} #{new_resource.package_name}"
if grep_for_version(shell_out(new_resource.binary + search_args).stdout, new_resource.package_name)
false
elsif grep_for_version(shell_out(node['php']['pecl'] + search_args).stdout, new_resource.package_name)
true
else
raise "Package #{new_resource.package_name} not found in either PEAR or PECL."
end
end
end
def manage_pecl_ini(name, action, directives, zend_extensions, priority)
ext_prefix = extension_dir
ext_prefix << ::File::SEPARATOR if ext_prefix[-1].chr != ::File::SEPARATOR
files = get_extension_files(name)
extensions = Hash[
files.map do |filepath|
rel_file = filepath.clone
rel_file.slice! ext_prefix if rel_file.start_with? ext_prefix
zend = zend_extensions.include?(rel_file)
[(zend ? filepath : rel_file), zend]
end
]
directory node['php']['ext_conf_dir'] do
owner 'root'
group 'root'
mode '0755'
recursive true
end
template "#{node['php']['ext_conf_dir']}/#{name}.ini" do
source 'extension.ini.erb'
cookbook 'php'
owner 'root'
group 'root'
mode '0644'
variables(
name: name,
extensions: extensions,
directives: directives,
priority: priority
)
action action
end
end
end

View File

@@ -0,0 +1,89 @@
#
# Author:: Seth Chisamore <schisamo@chef.io>
# Author:: Jennifer Davis <sigje@chef.io>
# Cookbook:: php
# Resource:: pear_channel
#
# Copyright:: 2011-2018, Chef Software, Inc <legal@chef.io>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
property :channel_xml, String
property :channel_name, String, name_property: true
property :binary, String, default: 'pear'
# TODO: add authenticated channel support!
# property :username, :kind_of => String
# property :password, :kind_of => String
action :discover do
unless exists?
Chef::Log.info("Discovering pear channel #{new_resource}")
execute "#{new_resource.binary} channel-discover #{new_resource.channel_name}" do
action :run
end
end
end
action :add do
unless exists?
Chef::Log.info("Adding pear channel #{new_resource} from #{new_resource.channel_xml}")
execute "#{new_resource.binary} channel-add #{new_resource.channel_xml}" do
action :run
end
end
end
action :update do
if exists? && update_needed?
converge_by("update pear channel #{new_resource}") do
Chef::Log.info("Updating pear channel #{new_resource}")
shell_out!("#{new_resource.binary} channel-update #{new_resource.channel_name}")
end
end
end
action :remove do
if exists?
Chef::Log.info("Deleting pear channel #{new_resource}")
execute "#{new_resource.binary} channel-delete #{new_resource.channel_name}" do
action :run
end
end
end
action_class do
# determine if the channel needs to be updated by searching for a bogus package
# in that channel and looking for the text prompting the user to update the channel
# in the CLI output
# @return [Boolean] does the channel need to be updated
def update_needed?
begin
return true if shell_out("#{new_resource.binary} search -c #{new_resource.channel_name} NNNNNN").stdout =~ /channel-update/
rescue Chef::Exceptions::CommandTimeout
# CentOS can hang on 'pear search' if a channel needs updating
Chef::Log.info("Timed out checking if channel-update needed...forcing update of pear channel #{new_resource.channel_name}")
return true
end
false
end
# run pear channel-info to see if the channel has been setup or not
# @return [Boolean] does the channel exist locally
def exists?
shell_out!("#{new_resource.binary} channel-info #{new_resource.channel_name}")
true
rescue Mixlib::ShellOut::ShellCommandFailed
false
end
end

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,7 @@
; configuration for php <%= @name %> module
<% @extensions.each do |filepath, zend| -%>
<%= 'zend_' if zend %>extension=<%= filepath %>
<% end -%>
<% @directives.each do |k,v| -%>
<%= "#{@name}.#{k}=#{v}" %>
<% end -%>

View File

@@ -0,0 +1,15 @@
[<%= @fpm_pool_name %>]
user = <%= @fpm_pool_user %>
group = <%= @fpm_pool_group %>
listen = <%= @fpm_pool_listen %>
listen.owner = <%= @fpm_pool_listen_user %>
listen.group = <%= @fpm_pool_listen_group %>
pm = <%= @fpm_pool_manager %>
pm.max_children = <%= @fpm_pool_max_children %>
pm.start_servers = <%= @fpm_pool_start_servers %>
pm.min_spare_servers = <%= @fpm_pool_min_spare_servers %>
pm.max_spare_servers = <%= @fpm_pool_max_spare_servers %>
chdir = <%= @fpm_pool_chdir %>
<% @fpm_pool_additional_config.each do |key, value| %>
<%= key %> = <%= value %>
<% end %>

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff