Update the mediawiki cookbook and upstream cookbooks

Compatibility with Chef 14
This commit is contained in:
Greg Karékinian
2019-04-08 11:20:12 +02:00
parent 6e3e8cde1b
commit 777b85c2ab
312 changed files with 5603 additions and 14219 deletions

View File

@@ -2,6 +2,71 @@
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

View File

@@ -1,15 +0,0 @@
<!-- This is a generated file. Please do not edit directly -->
# Maintainers
This file lists how this cookbook project is maintained. When making changes to the system, this file tells you who needs to review your patch - you need a review from an existing maintainer for the cookbook to provide a :+1: on your pull request. Additionally, you need to not receive a veto from a Lieutenant or the Project Lead.
Check out [How Cookbooks are Maintained](https://github.com/chef-cookbooks/community_cookbook_documentation/blob/master/CONTRIBUTING.MD) for details on the process and how to become a maintainer or the project lead.
# Project Maintainer
* [Tim Smith](https://github.com/tas50)
# Maintainers
* [Jennifer Davis](https://github.com/sigje)
* [Tim Smith](https://github.com/tas50)
* [Thom May](https://github.com/thommay)

View File

@@ -19,23 +19,22 @@ It installs and configures PHP and the PEAR package management system. Also incl
### Cookbooks
- build-essential
- xml
- mysql
## 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']` = Name of the pear executable to use, default `pear`.
- `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
## Resource/Provider
## Resources
This cookbook includes LWRPs for managing:
This cookbook includes resources for managing:
- PEAR channels
- PEAR/PECL packages
@@ -46,16 +45,16 @@ This cookbook includes LWRPs for managing:
#### 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
- `: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
#### Attribute Parameters
#### Properties
- channel_name: name attribute. The name of the channel to discover
- channel_xml: the channel.xml file of the channel you are adding
- pear: pear binary, default: pear
- `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
@@ -67,10 +66,10 @@ 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
source 'http://pear.symfony-project.com/channel.xml'
mode '0644'
end
php_pear_channel "symfony" do
php_pear_channel 'symfony' do
channel_xml "#{Chef::Config[:file_cache_path]}/symfony-channel.xml"
action :add
end
@@ -88,77 +87,84 @@ 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 LWRP is clever enough to abstract away the small differences and can be used for managing either. This LWRP also creates the proper module .ini file for each PECL extension at the correct location for each supported platform.
[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
- `:purge`: Purge a pear package (this usually entails removing configuration files as well as the package itself). With pear packages this behaves the same as `:remove`
- `: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
#### Attribute Parameters
#### 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.
- `preferred_state`: PEAR by default installs stable packages only, this allows you to install pear packages in a devel, alpha or beta state
- `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.
- o`ptions`: Add additional options to the underlying pear package command
- `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
php_pear 'XML_RPC' do
action :upgrade
end
# install a specific version
php_pear "XML_RPC" do
version "1.5.4"
php_pear 'XML_RPC' do
version '1.5.4'
action :install
end
# install the mongodb pecl
php_pear "mongo" do
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
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
php_pear 'apc' do
action :install
directives(:shm_size => 128, :enable_cli => 1)
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
hc = php_pear_channel 'pear.horde.org' do
action :discover
end
php_pear "Horde_Url" do
preferred_state "beta"
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
sc = php_pear_channel 'pear.symfony-project.com' do
action :discover
end
php_pear "YAML" do
php_pear 'YAML' do
channel sc.channel_name
action :install
end
@@ -195,7 +201,7 @@ More info: <http://php.net/manual/en/install.fpm.php>
```ruby
# Install a FPM pool named "default"
php_fpm_pool "default" do
php_fpm_pool 'default' do
action :install
end
```
@@ -214,37 +220,6 @@ This recipe installs PHP from packages.
This recipe installs PHP from source.
## Deprecated Recipes
The following recipes are deprecated and will be removed from a future version of this cookbook.
- `module_apc`
- `module_apcu`
- `module_curl`
- `module_fileinfo`
- `module_fpdf`
- `module_gd`
- `module_imap`
- `module_ldap`
- `module_memcache`
- `module_mysql`
- `module_pgsql`
- `module_sqlite3`
The installation of the php modules in these recipes can now be accomplished by installing from a native package or via the new php_pear LWRP. For example, the functionality of the `module_memcache` recipe can be enabled in the following ways:
```ruby
# using apt
package "php5-memcache" do
action :install
end
# using pear LWRP
php_pear "memcache" do
action :install
end
```
## 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:
@@ -252,23 +227,26 @@ Simply include the `php` recipe where ever you would like php installed. To inst
### Role example:
```ruby
name "php"
description "Install php from source"
name 'php'
description 'Install php from source'
override_attributes(
"php" => {
"install_method" => "source"
'php' => {
'install_method' => 'source',
}
)
run_list(
"recipe[php]"
'recipe[php]'
)
```
## License & Authors
## Maintainers
**Author:** Cookbook Engineering Team ([cookbooks@chef.io](mailto:cookbooks@chef.io))
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/)
**Copyright:** 2008-2017, Chef Software, Inc.
## 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");

View File

@@ -2,7 +2,7 @@
# Cookbook:: php
# Attributes:: default
#
# Copyright:: 2011-2017, Chef Software, Inc.
# 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.
@@ -22,11 +22,17 @@ default['php']['install_method'] = 'package'
default['php']['directives'] = {}
default['php']['bin'] = 'php'
default['php']['pear'] = 'pear'
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'
@@ -36,14 +42,7 @@ 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'
default['php']['curl']['package'] = 'php5-curl'
default['php']['apc']['package'] = 'php5-apc'
default['php']['apcu']['package'] = 'php5-apcu'
default['php']['gd']['package'] = 'php5-gd'
default['php']['ldap']['package'] = 'php5-ldap'
default['php']['pgsql']['package'] = 'php5-pgsql'
default['php']['sqlite']['package'] = 'php5-sqlite3'
default['php']['fpm_socket'] = '/var/run/php5-fpm.sock'
case node['platform_family']
when 'rhel', 'fedora', 'amazon'
@@ -55,16 +54,21 @@ when 'rhel', 'fedora', 'amazon'
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
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)
default['php']['packages'] = %w(php56 php56-devel php-pear)
default['php']['fpm_package'] = 'php56-fpm'
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 mhash-devel)
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']['mysql']['package'] = 'php-mysql'
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'
@@ -77,9 +81,8 @@ when 'rhel', 'fedora', 'amazon'
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)
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']['mysql']['package'] = 'php5-mysql'
default['php']['fpm_package'] = 'php5-fpm'
default['php']['fpm_pooldir'] = '/etc/php5/fpm/pool.d'
default['php']['fpm_user'] = 'www-data'
@@ -88,31 +91,41 @@ when 'debian'
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 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)
default['php']['packages'] = %w(php7.0-cgi php7.0 php7.0-dev php7.0-cli php-pear)
default['php']['mysql']['package'] = 'php7.0-mysql'
default['php']['curl']['package'] = 'php7.0-curl'
default['php']['apc']['package'] = 'php-apc'
default['php']['apcu']['package'] = 'php-apcu'
default['php']['gd']['package'] = 'php7.0-gd'
default['php']['ldap']['package'] = 'php7.0-ldap'
default['php']['pgsql']['package'] = 'php7.0-pgsql'
default['php']['sqlite']['package'] = 'php7.0-sqlite3'
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'
when 13.04..15.10
default['php']['ext_conf_dir'] = '/etc/php5/mods-available'
end
@@ -124,13 +137,16 @@ when 'debian'
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)
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)
default['php']['mysql']['package'] = 'php5-mysql'
lib_dir = node['kernel']['machine'] =~ /x86_64/ ? 'lib64' : 'lib'
when 'freebsd'
default['php']['conf_dir'] = '/usr/local/etc'
@@ -141,15 +157,6 @@ when 'freebsd'
default['php']['fpm_listen_user'] = 'www'
default['php']['fpm_listen_group'] = 'www'
default['php']['packages'] = %w( php56 pear )
default['php']['mysql']['package'] = 'php56-mysqli'
else
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)
default['php']['fpm_user'] = 'www-data'
default['php']['fpm_group'] = 'www-data'
default['php']['packages'] = %w(php5-cgi php5 php5-dev php5-cli php-pear)
default['php']['mysql']['package'] = 'php5-mysql'
end
default['php']['configure_options'] = %W(--prefix=#{node['php']['prefix_dir']}
@@ -179,13 +186,5 @@ default['php']['configure_options'] = %W(--prefix=#{node['php']['prefix_dir']}
--enable-sockets
--enable-soap
--with-xmlrpc
--with-libevent-dir
--with-mcrypt
--enable-mbstring
--with-t1lib
--with-mysql
--with-mysqli=/usr/bin/mysql_config
--with-mysql-sock
--with-sqlite3
--with-pdo-mysql
--with-pdo-sqlite)
--enable-mbstring)

View File

@@ -1,48 +0,0 @@
if defined?(ChefSpec)
ChefSpec.define_matcher :php_pear
def install_php_pear(resource_name)
ChefSpec::Matchers::ResourceMatcher.new(:php_pear, :install, resource_name)
end
def remove_php_pear(resource_name)
ChefSpec::Matchers::ResourceMatcher.new(:php_pear, :remove, resource_name)
end
def upgrade_php_pear(resource_name)
ChefSpec::Matchers::ResourceMatcher.new(:php_pear, :upgrade, resource_name)
end
def purge_php_pear(resource_name)
ChefSpec::Matchers::ResourceMatcher.new(:php_pear, :purge, resource_name)
end
def purge_php_pear(resource_name)
ChefSpec::Matchers::ResourceMatcher.new(:php_pear, :option, resource_name)
end
ChefSpec.define_matcher :php_pear_channel
def discover_php_pear_channel(resource_name)
ChefSpec::Matchers::ResourceMatcher.new(:php_pear_channel, :discover, resource_name)
end
def remove_php_pear_channel(resource_name)
ChefSpec::Matchers::ResourceMatcher.new(:php_pear_channel, :remove, resource_name)
end
def update_php_pear_channel(resource_name)
ChefSpec::Matchers::ResourceMatcher.new(:php_pear_channel, :update, resource_name)
end
def add_php_pear_channel(resource_name)
ChefSpec::Matchers::ResourceMatcher.new(:php_pear_channel, :add, resource_name)
end
ChefSpec.define_matcher :php_fpm_pool
def install_php_fpm_pool(resource_name)
ChefSpec::Matchers::ResourceMatcher.new(:php_fpm_pool, :install, resource_name)
end
def uninstall_php_fpm_pool(resource_name)
ChefSpec::Matchers::ResourceMatcher.new(:php_fpm_pool, :uninstall, resource_name)
end
end

File diff suppressed because one or more lines are too long

View File

@@ -1,304 +0,0 @@
#
# Author:: Seth Chisamore <schisamo@chef.io>
# Cookbook:: php
# Provider:: pear_package
#
# Copyright:: 2011-2017, 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.
#
use_inline_resources
require 'chef/mixin/shell_out'
require 'chef/mixin/language'
include Chef::Mixin::ShellOut
# the logic in all action methods mirror that of
# the Chef::Provider::Package which will make
# refactoring into core chef easy
use_inline_resources
def whyrun_supported?
true
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
# If it's not installed at all or an upgrade, install it
if install_version || @current_resource.version.nil?
description = "install package #{@new_resource} #{install_version}"
converge_by(description) do
info_output = "Installing #{@new_resource}"
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
action :upgrade do
if @current_resource.version != candidate_version
orig_version = @current_resource.version || 'uninstalled'
description = "upgrade package #{@new_resource} version from #{orig_version} to #{candidate_version}"
converge_by(description) do
Chef::Log.info("Upgrading #{@new_resource} version from #{orig_version} to #{candidate_version}")
upgrade_package(@new_resource.package_name, candidate_version)
end
end
end
action :remove do
if removing_package?
description = "remove package #{@new_resource}"
converge_by(description) do
Chef::Log.info("Removing #{@new_resource}")
remove_package(@current_resource.package_name, @new_resource.version)
end
end
end
action :purge do
if removing_package?
description = "purge package #{@new_resource}"
converge_by(description) do
Chef::Log.info("Purging #{@new_resource}")
purge_package(@current_resource.package_name, @new_resource.version)
end
end
end
def removing_package?
if @current_resource.version.nil?
false # nothing to remove
elsif @new_resource.version.nil?
true # remove any version of a package
elsif @new_resource.version == @current_resource.version
true # remove the version we have
else
false # we don't have the version we want to remove
end
end
def expand_options(options)
options ? " #{options}" : ''
end
# these methods are the required overrides of
# a provider that extends from Chef::Provider::Package
# so refactoring into core Chef should be easy
def load_current_resource
@current_resource = new_resource.class.new(new_resource.name)
@current_resource.package_name(@new_resource.package_name)
@bin = node['php']['pear']
if pecl?
Chef::Log.debug("#{@new_resource} smells like a pecl...installing package in Pecl mode.")
@bin = node['php']['pecl']
end
Chef::Log.debug("#{@current_resource}: Installed version: #{current_installed_version} Candidate version: #{candidate_version}")
unless current_installed_version.nil?
@current_resource.version(current_installed_version)
Chef::Log.debug("Current version is #{@current_resource.version}") if @current_resource.version
end
@current_resource
end
def current_installed_version
@current_installed_version ||= begin
version_check_cmd = "#{@bin} -d "
version_check_cmd << " preferred_state=#{can_haz(@new_resource, 'preferred_state')}"
version_check_cmd << " list#{expand_channel(can_haz(@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
end
def candidate_version
@candidate_version ||= begin
candidate_version_cmd = "#{@bin} -d "
candidate_version_cmd << "preferred_state=#{can_haz(@new_resource, 'preferred_state')}"
candidate_version_cmd << " search#{expand_channel(can_haz(@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
end
def install_package(name, version)
command = "printf \"\r\" | #{@bin} -d"
command << " preferred_state=#{can_haz(@new_resource, 'preferred_state')}"
command << " install -a#{expand_options(@new_resource.options)}"
command << " #{prefix_channel(can_haz(@new_resource, 'channel'))}#{name}"
command << "-#{version}" if version && !version.empty?
pear_shell_out(command)
manage_pecl_ini(name, :create, can_haz(@new_resource, 'directives'), can_haz(@new_resource, 'zend_extensions')) if pecl?
enable_package(name)
end
def upgrade_package(name, version)
command = "printf \"\r\" | #{@bin} -d"
command << " preferred_state=#{can_haz(@new_resource, 'preferred_state')}"
command << " upgrade -a#{expand_options(@new_resource.options)}"
command << " #{prefix_channel(can_haz(@new_resource, 'channel'))}#{name}"
command << "-#{version}" if version && !version.empty?
pear_shell_out(command)
manage_pecl_ini(name, :create, can_haz(@new_resource, 'directives'), can_haz(@new_resource, 'zend_extensions')) if pecl?
enable_package(name)
end
def remove_package(name, version)
command = "#{@bin} uninstall"
command << " #{expand_options(@new_resource.options)}"
command << " #{prefix_channel(can_haz(@new_resource, 'channel'))}#{name}"
command << "-#{version}" if version && !version.empty?
pear_shell_out(command)
disable_package(name)
manage_pecl_ini(name, :delete, 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 purge_package(name, version)
remove_package(name, version)
end
def expand_channel(channel)
channel ? " -c #{channel}" : ''
end
def prefix_channel(channel)
channel ? "#{channel}/" : ''
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("#{@bin} list-files #{name}")
p.stdout.each_line.grep(/^src\s+.*\.so$/i).each do |line|
files << line.split[1]
end
files
end
def manage_pecl_ini(name, action, directives, zend_extensions)
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)
action action
end
end
def grep_for_version(stdout, package)
v = 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
v = m.split(/\s+/)[1].strip
v = if v.split(%r{/\//})[0] =~ /.\./
# 1.1.4/(1.1.4 stable)
v.split(%r{/\//})[0]
else
# -n/a-/(1.0.0beta1 beta)
v.split(%r{/(.*)\/\((.*)/}).last.split(/\s/)[0]
end
end
v
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=#{can_haz(@new_resource, 'preferred_state')}"
search_args << " search#{expand_channel(can_haz(@new_resource, 'channel'))} #{@new_resource.package_name}"
if grep_for_version(shell_out(node['php']['pear'] + 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
# TODO: remove when provider is moved into Chef core
# this allows PhpPear to work with Chef::Resource::Package
def can_haz(resource, attribute_name)
resource.respond_to?(attribute_name) ? resource.send(attribute_name) : nil
end

View File

@@ -4,7 +4,7 @@
# Cookbook:: php
# Recipe:: default
#
# Copyright:: 2009-2017, Chef Software, Inc.
# 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.
@@ -22,12 +22,12 @@
include_recipe "php::#{node['php']['install_method']}"
# update the main channels
php_pear_channel 'pear.php.net' do
action :update
end
php_pear_channel 'pecl.php.net' do
action :update
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

@@ -3,7 +3,7 @@
# Cookbook:: php
# Recipe:: ini
#
# Copyright:: 2011-2017, Chef Software, Inc.
# 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.

View File

@@ -1,32 +0,0 @@
#
# Author:: Joshua Timberman (<joshua@chef.io>)
# Author:: Seth Chisamore (<schisamo@chef.io>)
# Cookbook:: php
# Recipe:: module_apc
#
# Copyright:: 2009-2017, 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.
#
case node['platform_family']
when 'rhel', 'fedora', 'amazon'
package %w(httpd-devel pcre pcre-devel)
php_pear 'APC' do
action :install
directives(shm_size: '128M', enable_cli: 0)
end
when 'debian'
package node['php']['apc']['package']
end

View File

@@ -1,32 +0,0 @@
#
# Author:: Joshua Timberman (<joshua@chef.io>)
# Author:: Seth Chisamore (<schisamo@chef.io>)
# Cookbook:: php
# Recipe:: module_apc
#
# Copyright:: 2009-2017, 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.
#
case node['platform_family']
when 'rhel', 'fedora', 'amazon'
package %w(httpd-devel pcre pcre-devel)
php_pear 'APCu' do
action :install
directives(shm_size: '128M', enable_cli: 0)
end
when 'debian'
package node['php']['apcu']['package']
end

View File

@@ -1,25 +0,0 @@
#
# Author:: Joshua Timberman (<joshua@chef.io>)
# Author:: Seth Chisamore (<schisamo@chef.io>)
# Cookbook:: php
# Recipe:: module_curl
#
# Copyright:: 2009-2017, 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.
#
package node['php']['curl']['package'] do
action :install
only_if { platform_family?('debian') } # centos php compiled with curl
end

View File

@@ -1,35 +0,0 @@
#
# Author:: Joshua Timberman (<joshua@chef.io>)
# Author:: Seth Chisamore (<schisamo@chef.io>)
# Cookbook:: php
# Recipe:: module_fpdf
#
# Copyright:: 2009-2017, 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.
#
case node['platform_family']
when 'rhel', 'fedora', 'amazon'
pearhub_chan = php_pear_channel 'pearhub.org' do
action :discover
end
php_pear 'FPDF' do
channel pearhub_chan.channel_name
action :install
end
when 'debian'
package 'php-fpdf' do
action :install
end
end

View File

@@ -1,34 +0,0 @@
#
# Author:: Joshua Timberman (<joshua@chef.io>)
# Author:: Seth Chisamore (<schisamo@chef.io>)
# Cookbook:: php
# Recipe:: module_gd
#
# Copyright:: 2009-2017, 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.
#
pkg = value_for_platform(
%w(centos redhat scientific fedora amazon oracle) => {
'default' => 'php-gd',
},
'freebsd' => {
'default' => 'php56-gd',
},
'default' => node['php']['gd']['package']
)
package pkg do
action :install
end

View File

@@ -1,28 +0,0 @@
#
# Author:: Artur Melo (<artur.melo@beubi.com>)
# Cookbook:: php
# Recipe:: module_imap
#
# 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.
#
pkg = value_for_platform(
%w(centos redhat scientific fedora amazon oracle) => {
'default' => 'php-imap',
},
'default' => 'php5-imap'
)
package pkg do
action :install
end

View File

@@ -1,31 +0,0 @@
#
# Author:: Joshua Timberman (<joshua@chef.io>)
# Author:: Seth Chisamore (<schisamo@chef.io>)
# Cookbook:: php
# Recipe:: module_ldap
#
# Copyright:: 2009-2017, 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.
#
pkg = value_for_platform(
%w(centos redhat scientific fedora amazon oracle) => {
'default' => 'php-ldap',
},
'default' => node['php']['ldap']['package']
)
package pkg do
action :install
end

View File

@@ -1,31 +0,0 @@
#
# Author:: Joshua Timberman (<joshua@chef.io>)
# Author:: Seth Chisamore (<schisamo@chef.io>)
# Cookbook:: php
# Recipe:: module_memcache
#
# Copyright:: 2009-2017, 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.
#
case node['platform_family']
when 'rhel', 'fedora', 'amazon'
package 'zlib-devel'
php_pear 'memcache' do
action :install
end
when 'debian'
package 'php5-memcache'
end

View File

@@ -1,24 +0,0 @@
#
# Author:: Joshua Timberman (<joshua@chef.io>)
# Author:: Seth Chisamore (<schisamo@chef.io>)
# Cookbook:: php
# Recipe:: module_mysql
#
# Copyright:: 2009-2017, 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.
#
package node['php']['mysql']['package'] do
action :install
end

View File

@@ -1,31 +0,0 @@
#
# Author:: Joshua Timberman (<joshua@chef.io>)
# Author:: Seth Chisamore (<schisamo@chef.io>)
# Cookbook:: php
# Recipe:: module_pgsql
#
# Copyright:: 2009-2017, 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.
#
pkg = value_for_platform(
%w(centos redhat scientific fedora amazon oracle) => {
'default' => 'php-pgsql',
},
'default' => node['php']['pgsql']['package']
)
package pkg do
action :install
end

View File

@@ -1,25 +0,0 @@
#
# Author:: Joshua Timberman (<joshua@chef.io>)
# Author:: Seth Chisamore (<schisamo@chef.io>)
# Cookbook:: php
# Recipe:: module_sqlite3
#
# Copyright:: 2009-2017, 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.
#
package node['php']['sqlite']['package'] do
action :install
only_if { platform_family?('debian') } # already there in centos, --with-pdo-sqlite=shared
end

View File

@@ -4,7 +4,7 @@
# Cookbook:: php
# Recipe:: package
#
# Copyright:: 2013-2017, Chef Software, Inc.
# 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.

View File

@@ -3,7 +3,7 @@
# Cookbook:: php
# Recipe:: recompile
#
# Copyright:: 2014-2017, David Kinzer
# 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.

View File

@@ -3,7 +3,7 @@
# Cookbook:: php
# Recipe:: source
#
# Copyright:: 2011-2017, Chef Software, Inc.
# 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.
@@ -20,15 +20,9 @@
configure_options = node['php']['configure_options'].join(' ')
include_recipe 'build-essential'
include_recipe 'xml'
build_essential 'install compilation tools'
include_recipe 'yum-epel' if node['platform_family'] == 'rhel'
mysql_client 'default' do
action :create
only_if { configure_options =~ /mysql/ }
end
package node['php']['src_deps']
version = node['php']['version']

View File

@@ -3,7 +3,7 @@
# Cookbook:: php
# Resource:: fpm_pool
#
# Copyright:: 2015-2017, Chef Software, Inc <legal@chef.io>
# 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.

View File

@@ -1,9 +1,9 @@
#
# Author:: Seth Chisamore <schisamo@chef.io>
# Cookbook:: php
# Resource:: pear_package
# Resource:: pear
#
# Copyright:: 2011-2016, Chef Software, Inc <legal@chef.io>
# 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.
@@ -18,21 +18,263 @@
# limitations under the License.
#
default_action :install
actions :install, :upgrade, :remove, :purge
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
state_attrs :channel,
:directives,
:options,
:package_name,
:preferred_state,
:version,
:zend_extensions
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
attribute :package_name, kind_of: String, name_attribute: true
attribute :version, default: nil
attribute :channel, kind_of: String
attribute :options, kind_of: String
attribute :directives, kind_of: Hash, default: {}
attribute :zend_extensions, kind_of: Array, default: []
attribute :preferred_state, default: 'stable'
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

@@ -4,7 +4,7 @@
# Cookbook:: php
# Resource:: pear_channel
#
# Copyright:: 2011-2017, Chef Software, Inc <legal@chef.io>
# 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.
@@ -19,9 +19,9 @@
# limitations under the License.
#
property :channel_xml, kind_of: String
property :channel_name, kind_of: String, name_property: true
property :pear, kind_of: String, default: lazy { node['php']['pear'] }
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
@@ -29,7 +29,7 @@ property :pear, kind_of: String, default: lazy { node['php']['pear'] }
action :discover do
unless exists?
Chef::Log.info("Discovering pear channel #{new_resource}")
execute "#{new_resource.pear} channel-discover #{new_resource.channel_name}" do
execute "#{new_resource.binary} channel-discover #{new_resource.channel_name}" do
action :run
end
end
@@ -38,28 +38,17 @@ end
action :add do
unless exists?
Chef::Log.info("Adding pear channel #{new_resource} from #{new_resource.channel_xml}")
execute "#{new_resource.pear} channel-add #{new_resource.channel_xml}" do
execute "#{new_resource.binary} channel-add #{new_resource.channel_xml}" do
action :run
end
end
end
action :update do
if exists?
update_needed = false
begin
update_needed = true if shell_out("#{new_resource.pear} 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}")
update_needed = true
end
if update_needed
description = "update pear channel #{new_resource}"
converge_by(description) do
Chef::Log.info("Updating pear channel #{new_resource}")
shell_out!("#{new_resource.pear} channel-update #{new_resource.channel_name}")
end
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
@@ -67,15 +56,32 @@ end
action :remove do
if exists?
Chef::Log.info("Deleting pear channel #{new_resource}")
execute "#{new_resource.pear} channel-delete #{new_resource.channel_name}" do
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.pear} channel-info #{new_resource.channel_name}")
shell_out!("#{new_resource.binary} channel-info #{new_resource.channel_name}")
true
rescue Mixlib::ShellOut::ShellCommandFailed
false

View File

@@ -91,11 +91,6 @@
; Please see the actual settings later in the document for more details as to why
; we recommend these changes in PHP's behavior.
; allow_call_time_pass_reference
; Default Value: On
; Development Value: Off
; Production Value: Off
; display_errors
; Default Value: On
; Development Value: On
@@ -233,10 +228,6 @@ asp_tags = Off
; http://php.net/precision
precision = 14
; Enforce year 2000 compliance (will cause problems with non-compliant browsers)
; http://php.net/y2k-compliance
y2k_compliance = On
; Output buffering is a mechanism for controlling how much output data
; (excluding headers and cookies) PHP should keep internally before pushing that
; data to the client. If your application's output exceeds this setting, PHP
@@ -319,20 +310,6 @@ unserialize_callback_func =
; are decoded with unserialize, the data will remain the same.
serialize_precision = 100
; This directive allows you to enable and disable warnings which PHP will issue
; if you pass a value by reference at function call time. Passing values by
; reference at function call time is a deprecated feature which will be removed
; from PHP at some point in the near future. The acceptable method for passing a
; value by reference to a function is by declaring the reference in the functions
; definition, not at call time. This directive does not disable this feature, it
; only determines whether PHP will warn you about it or not. These warnings
; should enabled in development environments only.
; Default Value: On (Suppress warnings)
; Development Value: Off (Issue warnings)
; Production Value: Off (Issue warnings)
; http://php.net/allow-call-time-pass-reference
allow_call_time_pass_reference = Off
; Safe Mode
; http://php.net/safe-mode
safe_mode = Off

View File

@@ -91,11 +91,6 @@
; Please see the actual settings later in the document for more details as to why
; we recommend these changes in PHP's behavior.
; allow_call_time_pass_reference
; Default Value: On
; Development Value: Off
; Production Value: Off
; display_errors
; Default Value: On
; Development Value: On
@@ -233,10 +228,6 @@ asp_tags = Off
; http://php.net/precision
precision = 14
; Enforce year 2000 compliance (will cause problems with non-compliant browsers)
; http://php.net/y2k-compliance
y2k_compliance = On
; Output buffering is a mechanism for controlling how much output data
; (excluding headers and cookies) PHP should keep internally before pushing that
; data to the client. If your application's output exceeds this setting, PHP
@@ -319,20 +310,6 @@ unserialize_callback_func =
; are decoded with unserialize, the data will remain the same.
serialize_precision = 100
; This directive allows you to enable and disable warnings which PHP will issue
; if you pass a value by reference at function call time. Passing values by
; reference at function call time is a deprecated feature which will be removed
; from PHP at some point in the near future. The acceptable method for passing a
; value by reference to a function is by declaring the reference in the functions
; definition, not at call time. This directive does not disable this feature, it
; only determines whether PHP will warn you about it or not. These warnings
; should enabled in development environments only.
; Default Value: On (Suppress warnings)
; Development Value: Off (Issue warnings)
; Production Value: Off (Issue warnings)
; http://php.net/allow-call-time-pass-reference
allow_call_time_pass_reference = Off
; Safe Mode
; http://php.net/safe-mode
safe_mode = Off

View File

@@ -91,11 +91,6 @@
; Please see the actual settings later in the document for more details as to why
; we recommend these changes in PHP's behavior.
; allow_call_time_pass_reference
; Default Value: On
; Development Value: Off
; Production Value: Off
; display_errors
; Default Value: On
; Development Value: On
@@ -233,10 +228,6 @@ asp_tags = Off
; http://php.net/precision
precision = 14
; Enforce year 2000 compliance (will cause problems with non-compliant browsers)
; http://php.net/y2k-compliance
y2k_compliance = On
; Output buffering is a mechanism for controlling how much output data
; (excluding headers and cookies) PHP should keep internally before pushing that
; data to the client. If your application's output exceeds this setting, PHP
@@ -319,20 +310,6 @@ unserialize_callback_func =
; are decoded with unserialize, the data will remain the same.
serialize_precision = 100
; This directive allows you to enable and disable warnings which PHP will issue
; if you pass a value by reference at function call time. Passing values by
; reference at function call time is a deprecated feature which will be removed
; from PHP at some point in the near future. The acceptable method for passing a
; value by reference to a function is by declaring the reference in the functions
; definition, not at call time. This directive does not disable this feature, it
; only determines whether PHP will warn you about it or not. These warnings
; should enabled in development environments only.
; Default Value: On (Suppress warnings)
; Development Value: Off (Issue warnings)
; Production Value: Off (Issue warnings)
; http://php.net/allow-call-time-pass-reference
allow_call_time_pass_reference = Off
; Safe Mode
; http://php.net/safe-mode
safe_mode = Off