Add missing changes for mediawiki upgrades

This commit is contained in:
Basti 2020-09-05 23:43:28 +02:00
parent 7af26d6ad3
commit b7e2a72369
Signed by untrusted user: basti
GPG Key ID: 9F88009D31D99C72
61 changed files with 1179 additions and 2252 deletions

View File

@ -9,8 +9,8 @@ cookbook 'redis',
git: 'https://github.com/phlipper/chef-redis.git',
ref: 'v0.5.6'
cookbook 'postfix', '= 5.0.2'
cookbook 'php', '~> 6.1.1'
cookbook 'composer', '~> 2.6.1'
cookbook 'php', '~> 8.0.0'
cookbook 'composer', '~> 2.7.0'
cookbook 'poise-ruby-build', '~> 1.1.0'
cookbook 'application', '~> 5.2.0'
cookbook 'application_javascript', '~> 1.0.0'
@ -28,15 +28,15 @@ cookbook 'nginx', '= 9.0.0'
# Remove when cookbooks stop depending on it, the build_essential resource is
# part of Chef 14 (https://docs.chef.io/resource_build_essential.html)
cookbook 'build-essential', '~> 8.2.1'
cookbook 'mysql', '~> 8.5.1'
cookbook 'mysql', '~> 8.7.3'
# cookbook 'postgresql', '= 7.1.8'
cookbook 'apt', '~> 7.3.0'
cookbook 'git', '>= 6.0.0'
cookbook 'git', '~> 10.0.0'
cookbook 'hostsfile', '= 2.4.5'
cookbook 'ohai', '~> 5.2.5'
cookbook 'nodejs', '~> 5.0.0'
cookbook 'timezone_iii', '= 1.0.4'
cookbook 'ark', '>= 3.1.0'
cookbook 'ark', '>= 5.0.0'
cookbook 'logrotate', '= 2.2.0'
cookbook 'openssl', '~> 8.5.5'
cookbook 'ntp', '= 3.4.0'

View File

@ -4,14 +4,14 @@ DEPENDENCIES
application_git (= 1.1.0)
application_javascript (~> 1.0.0)
apt (~> 7.3.0)
ark (>= 3.1.0)
ark (>= 5.0.0)
build-essential (~> 8.2.1)
chef-sugar (= 3.3.0)
compat_resource (= 12.19.0)
composer (~> 2.6.1)
composer (~> 2.7.0)
elasticsearch (= 4.2.0)
firewall (~> 2.6.3)
git (>= 6.0.0)
git (~> 10.0.0)
golang (~> 4.1.0)
homebrew (= 3.0.0)
hostname (= 0.4.2)
@ -27,13 +27,13 @@ DEPENDENCIES
git: https://github.com/67P/mediawiki-cookbook.git
revision: 78641e53635ba6cbd4a2a51fd597adb8fef1e8ad
ref: nginx
mysql (~> 8.5.1)
mysql (~> 8.7.3)
nginx (= 9.0.0)
nodejs (~> 5.0.0)
ntp (= 3.4.0)
ohai (~> 5.2.5)
openssl (~> 8.5.5)
php (~> 6.1.1)
php (~> 8.0.0)
poise (~> 2.8.2)
poise-archive (~> 1.5.0)
poise-javascript
@ -74,7 +74,7 @@ GRAPH
seven_zip (>= 0.0.0)
chef-sugar (3.3.0)
compat_resource (12.19.0)
composer (2.6.1)
composer (2.7.0)
apt (>= 0.0.0)
php (>= 0.0.0)
windows (>= 0.0.0)
@ -108,7 +108,7 @@ GRAPH
php (>= 0.0.0)
mingw (2.1.0)
seven_zip (>= 0.0.0)
mysql (8.5.1)
mysql (8.7.3)
nginx (9.0.0)
build-essential (>= 5.0)
ohai (>= 4.1.0)
@ -119,8 +119,7 @@ GRAPH
ntp (3.4.0)
ohai (5.2.5)
openssl (8.5.5)
php (6.1.1)
build-essential (>= 5.0)
php (8.0.0)
yum-epel (>= 0.0.0)
poise (2.8.2)
poise-archive (1.5.0)

View File

@ -159,7 +159,7 @@ end
## License and Authors
Author: David Joos <development@davidjoos.com>
Copyright: 2016, David Joos
Copyright: 2016-2017, David Joos
Author: David Joos <david.joos@escapestudios.com>
Author: Escape Studios Development <dev@escapestudios.com>

View File

@ -14,7 +14,7 @@ if node['platform'] == 'windows'
default['composer']['global_install']['install_dir'] = 'C:\\Program\ Files\\Composer'
default['composer']['global_install']['bin_dir'] = 'C:\\ProgramData\\Composer'
else
default['composer']['url'] = 'http://getcomposer.org/composer.phar'
default['composer']['url'] = 'http://getcomposer.org/composer-stable.phar'
default['composer']['install_dir'] = '/usr/local/bin'
default['composer']['bin'] = "#{node['composer']['install_dir']}/composer"
default['composer']['install_globally'] = true
@ -27,3 +27,4 @@ end
default['composer']['global_configs'] = {}
default['composer']['home_dir'] = nil
default['composer']['php_recipe'] = 'php::default'
default['composer']['self_update_channel'] = nil

File diff suppressed because one or more lines are too long

View File

@ -4,9 +4,10 @@ maintainer_email 'development@davidjoos.com'
license 'MIT'
description 'Installs/Configures Composer'
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version '2.6.1'
version '2.7.0'
chef_version '>= 0.10.0' if respond_to?(:chef_version)
%w(debian ubuntu redhat centos fedora scientific amazon windows).each do |os|
%w[debian ubuntu redhat centos fedora scientific amazon windows].each do |os|
supports os
end

View File

@ -13,17 +13,14 @@ end
action :install do
install_global_install
new_resource.updated_by_last_action(true)
end
action :remove do
install_global_remove
new_resource.updated_by_last_action(true)
end
action :update do
install_global_update
new_resource.updated_by_last_action(true)
end
def install_global_install

View File

@ -13,7 +13,6 @@ end
action :install do
make_execute 'install'
new_resource.updated_by_last_action(true)
end
action :require do
@ -22,12 +21,10 @@ end
action :update do
make_execute 'update'
new_resource.updated_by_last_action(true)
end
action :dump_autoload do
make_execute 'dump-autoload'
new_resource.updated_by_last_action(true)
end
action :remove do

View File

@ -10,9 +10,9 @@ include_recipe node['composer']['php_recipe']
if node['platform'] == 'windows'
windows_package 'Composer - PHP Dependency Manager' do
source node['composer']['url']
options %w(
options %w[
/VERYSILENT
).join(' ')
].join(' ')
end
install_dir = "#{node['composer']['install_dir'].tr('/', '\\')}\\bin"

View File

@ -7,9 +7,15 @@
include_recipe 'composer::install'
channel = if node['composer']['self_update_channel'].nil?
''
else
" --#{node['composer']['self_update_channel']}"
end
execute 'composer-self_update' do
cwd node['composer']['install_dir']
command 'composer self-update'
command 'composer self-update' + channel
environment 'COMPOSER_HOME' => Composer.home_dir(node)
action :run
ignore_failure true

View File

@ -17,8 +17,3 @@ attribute :quiet, :kind_of => [TrueClass, FalseClass], :default => true
attribute :optimize_autoloader, :kind_of => [TrueClass, FalseClass], :default => false
attribute :prefer_dist, :kind_of => [TrueClass, FalseClass], :default => false
attribute :prefer_source, :kind_of => [TrueClass, FalseClass], :default => false
def initialize(*args)
super
@action = :install
end

View File

@ -22,8 +22,3 @@ attribute :user, :kind_of => String, :default => 'root'
attribute :group, :kind_of => String, :default => 'root'
attribute :umask, :kind_of => [String, Integer], :default => '0002'
attribute :environment, :kind_of => Hash, :default => {}
def initialize(*args)
super
@action = :install
end

View File

@ -12,8 +12,7 @@
"dependencies": {
"apache2": ">= 0.0.0",
"php": ">= 0.0.0",
"nginx": ">= 0.0.0",
"php-fpm": ">= 0.0.0"
"nginx": ">= 0.0.0"
},
"providing": {

View File

@ -8,7 +8,6 @@ version '0.5.0'
depends 'apache2'
depends 'php'
depends 'nginx'
depends 'php-fpm'
attribute 'mediawiki/version',
:display_name => "Mediawiki version",

View File

@ -3,30 +3,11 @@
# Recipe:: nginx
#
node.default['php-fpm']['pools'] = []
node.override['php-fpm']['package_name'] = "php-fpm"
node.override['php-fpm']['service_name'] = "php7.2-fpm"
node.override['php-fpm']['conf_dir'] = "/etc/php/7.2/fpm/conf.d"
node.override['php-fpm']['pool_conf_dir'] = "/etc/php/7.2/fpm/pool.d"
node.override['php-fpm']['conf_file'] = "/etc/php/7.2/fpm/php-fpm.conf"
include_recipe "php-fpm"
include_recipe 'php-fpm::repository' unless node['php-fpm']['skip_repository_install']
include_recipe "php-fpm::install"
php_fpm_pool "www" do
enable false
end
php_fpm_pool "mediawiki" do
listen "127.0.0.1:9002"
user node['nginx']['user']
group node['nginx']['group']
listen_owner node['nginx']['user']
listen_group node['nginx']['group']
php_options node['mediawiki']['php_options']
start_servers 5
enable true
additional_config node['mediawiki']['php_options']
end
include_recipe "nginx"

View File

@ -1 +0,0 @@
~FC005

View File

@ -1,24 +1,84 @@
# mysql Cookbook CHANGELOG
# Changelog
This file is used to list changes made in each version of the mysql cookbook.
All notable changes to this project will be documented in this file.
## 8.5.1 (2017-08-23)
## 8.7.3 - 2020-07-22
- restore resource_name in mysql_service for Chef Infra Client < 16
- resolved cookstyle error: libraries/mysql_client_installation_package.rb:8:5 warning: `ChefDeprecations/ResourceUsesOnlyResourceName`
- resolved cookstyle error: libraries/mysql_client_installation_package.rb:9:1 convention: `Layout/IndentationConsistency`
- resolved cookstyle error: libraries/mysql_client_installation_package.rb:9:1 convention: `Layout/IndentationWidth`
- resolved cookstyle error: libraries/mysql_client_installation_package.rb:9:3 convention: `Layout/IndentationWidth`
- resolved cookstyle error: libraries/mysql_client_installation_package.rb:9:9 convention: `Layout/IndentationConsistency`
- resolved cookstyle error: libraries/mysql_server_installation_package.rb:4:5 warning: `ChefDeprecations/ResourceUsesOnlyResourceName`
- resolved cookstyle error: libraries/mysql_server_installation_package.rb:5:1 convention: `Layout/IndentationConsistency`
- resolved cookstyle error: libraries/mysql_server_installation_package.rb:5:1 convention: `Layout/IndentationWidth`
- resolved cookstyle error: libraries/mysql_server_installation_package.rb:5:3 convention: `Layout/IndentationWidth`
- resolved cookstyle error: libraries/mysql_server_installation_package.rb:5:9 convention: `Layout/IndentationConsistency`
- resolved cookstyle error: libraries/mysql_service_manager_systemd.rb:3:5 warning: `ChefDeprecations/ResourceUsesOnlyResourceName`
- resolved cookstyle error: libraries/mysql_service_manager_systemd.rb:4:1 convention: `Layout/IndentationConsistency`
- resolved cookstyle error: libraries/mysql_service_manager_systemd.rb:4:1 convention: `Layout/IndentationWidth`
- resolved cookstyle error: libraries/mysql_service_manager_systemd.rb:4:3 convention: `Layout/IndentationWidth`
- resolved cookstyle error: libraries/mysql_service_manager_systemd.rb:4:9 convention: `Layout/IndentationConsistency`
- resolved cookstyle error: libraries/mysql_service_manager_sysvinit.rb:3:5 warning: `ChefDeprecations/ResourceUsesOnlyResourceName`
- resolved cookstyle error: libraries/mysql_service_manager_sysvinit.rb:4:1 convention: `Layout/IndentationConsistency`
- resolved cookstyle error: libraries/mysql_service_manager_sysvinit.rb:4:1 convention: `Layout/IndentationWidth`
- resolved cookstyle error: libraries/mysql_service_manager_sysvinit.rb:4:3 convention: `Layout/IndentationWidth`
- resolved cookstyle error: libraries/mysql_service_manager_sysvinit.rb:4:9 convention: `Layout/IndentationConsistency`
- resolved cookstyle error: libraries/mysql_service_manager_upstart.rb:3:5 warning: `ChefDeprecations/ResourceUsesOnlyResourceName`
- resolved cookstyle error: libraries/mysql_service_manager_upstart.rb:4:1 convention: `Layout/IndentationConsistency`
- resolved cookstyle error: libraries/mysql_service_manager_upstart.rb:4:1 convention: `Layout/IndentationWidth`
- resolved cookstyle error: libraries/mysql_service_manager_upstart.rb:4:3 convention: `Layout/IndentationWidth`
- resolved cookstyle error: libraries/mysql_service_manager_upstart.rb:4:9 convention: `Layout/IndentationConsistency`
## 8.7.2 - 2020-06-02
- resolved cookstyle error: libraries/mysql_service.rb:4:5 warning: `ChefDeprecations/ResourceUsesOnlyResourceName`
## 8.7.1 - 2020-05-20
- resolved cookstyle error: spec/mysql_client_installation_package_spec.rb:7:46 warning: `ChefDeprecations/DeprecatedChefSpecPlatform`
- resolved cookstyle error: spec/mysql_server_installation_package_spec.rb:7:46 warning: `ChefDeprecations/DeprecatedChefSpecPlatform`
## 8.7.0 - 2020-05-05
- migration to Github Actions
- Ability to include "none" as an installation method in mysql_service
- resolved cookstyle error: libraries/helpers.rb:57:48 refactor: `ChefStyle/UnnecessaryOSCheck`
- resolved cookstyle error: libraries/helpers.rb:58:41 refactor: `ChefStyle/UnnecessaryOSCheck`
## [8.6.0] - 2019-12-03
- Fix the failing linting tests
- Add mysql57 support for Amazon Linux AMI
- Fix installation and testing on Ubuntu 18.04 bionic, EL7, Fedora and Opensuse
- Ensure compatibility with mysql 5.7 on Ubtuntu 16.04
- Add apparmor profile for ubuntu 16.04
- Allow instance with 'mysql' as name
- Add a helper for Ubuntu 18.04
- Remove support for Debian 7
- Remove ChefSpec matchers
- Set apparmor tmp_dir permissions on directory itself
- Run latest cookstyle
- Circleci, Yaml and markdown lint updates
## [8.5.1] - 2017-08-23
- Fix the remainder of the namespace collision deprecation warnings
- Remove the class_eval in the action class as this causes issues with some releases of Chef 12
## 8.5.0 (2017-08-23)
## [8.5.0] - 2017-08-23
- Require Chef 12.7+ since 12.5/12.6 has custom resource action_class issues
- Resolve several Chef 14 deprecation warnings
## 8.4.0 (2017-05-30)
## [8.4.0] - 2017-05-30
- Fix client/server install on Amazon Linux and add testing
- Remove support for Ubuntu Precise since it's EOL
- Add Amazon Linux testing
## 8.3.1 (2017-04-04)
## [8.3.1] - 2017-04-04
- Fix an ignoring of 'cookbook' attribute by 'mysql_config' resource
- Remove unused helper method
@ -26,21 +86,24 @@ This file is used to list changes made in each version of the mysql cookbook.
- Switch to Delivery Local and rename the docked config
- Remove mention of the EOL opensuse 13.x in the readme
## 8.3.0 (2017-03-20)
## [8.3.0] - 2017-03-20
- Refactor mysql_service_manager_upstart.rb to eliminate use of cloned resource
## 8.2.0 (2016-12-03)
## [8.2.0] - 2016-12-03
- Include client development packages on RHEL/SUSE platforms
## 8.1.1 (2016-10-31)
## [8.1.1] - 2016-10-31
- Fixing CVE-2016-6662 - Reverting execure bit on mysql config
## 8.1.0 (2016-10-29)
## [8.1.0] - 2016-10-29
- Drop hardcoded, specific package version logic that broke many users
## 8.0.4 (2016-09-26)
## [8.0.4] - 2016-09-26
- Bump debian version
- Updated packages for 12.04 and 14.04 too
- Add chef_version metadata
@ -48,19 +111,22 @@ This file is used to list changes made in each version of the mysql cookbook.
- Add selinux to the Berksfile for testing
- Make sure yum repos are setup in local Test Kitchen
## 8.0.3 (2016-09-14)
## [8.0.3] - 2016-09-14
- [GH-390] Fix #390 incorrect escaping of initial_root_password
- Updated package versions for Ubuntu 16.04
- Testing updates
# v8.0.2 (2016-08-25)
## [8.0.2] - 2016-08-25
- Various bug fixed and updates to package version strings
# v8.0.1 (2016-07-20)
## [8.0.1] - 2016-07-20
- Fixed a regression in the mysql_client resource where the action was changed from create to install in the 8.0 release
- Added oracle, opensuse, and opensuseleap as supported platforms in the metadata
# v8.0.0 (2016-07-11)
## [8.0.0] - 2016-07-11
- Converting from LWRP to custom resources
- Removing yum-mysql and other dependencies.
@ -71,26 +137,26 @@ This file is used to list changes made in each version of the mysql cookbook.
- Renaming "replication" test suite to "smoke"
- Moving to Inspec
## v7.2.0 (2016-06-30)
## [7.2.0] - 2016-06-30
- Support openeSUSE leap
- Support Fedora 24
## v7.1.2 (2016-06-30)
## [7.1.2] - 2016-06-30
- Avoid deprecation warnings on the upcoming Chef 12.12 release
## v7.1.1 (2016-06-03)
## [7.1.1] - 2016-06-03
- Fix apparmor blocking writes to non-default tmp_dirs
- Updated apparmor config to allow read & write to sock.lock file
- Use cookstyle instead of Rubocop directly
## v7.1.0 (2016-05-11)
## [7.1.0] - 2016-05-11
- Added support for Ubuntu 16.04
## v7.0.0 (2016-04-19)
## [7.0.0] - 2016-04-19
- Removed support for legacy distros: Ubuntu 10.04/13.04/14.10/15.04, Fedora 20/21, OmniOS r151006, opensuse 11.3/12.0
- Added support for Fedora 23, suse 13.X, and Ubuntu 16.04
@ -100,161 +166,161 @@ This file is used to list changes made in each version of the mysql cookbook.
- Added Travis CI Test Kitchen testing on Fedora 22/23 and removed Fedora 21
- Updated the platforms used in the specs
## v6.1.3 (2016-03-14)
## [6.1.3] - 2016-03-14
- Added support for Ubuntu 15.10
- Added support for Amazon Linux 2016-03
- Updated Kitchen testing configs
## v6.1.2 (2015-10-05)
## [6.1.2] - 2015-10-05
- Added support for Amazon Linux 2015.09
## v6.1.1 (2015-09-24)
## [6.1.1] - 2015-09-24
- Completing ChefSpec matchers
## v6.1.0 (2015-07-17)
## [6.1.0] - 2015-07-17
- Adding tunables for tmp_dir, error_log, and pid_file
- Adding mysqld_options hash interface for main my.cnf template
## v6.0.31 (2015-07-13)
## [6.0.31] - 2015-07-13
- Reverting create_stop_system_service checks
## v6.0.30 (2015-07-13)
## [6.0.30] - 2015-07-13
- Ubuntu 15.04 support
- Check for scripts and unit files during create_stop_system_service
## v6.0.29 (2015-07-12)
## [6.0.29] - 2015-07-12
- Patch to allow blank root password
- Adding package information for Suse 12.0
## v6.0.28 (2015-07-10)
## [6.0.28] - 2015-07-10
- Fixes for 12.4.x
## v6.0.27 (2015-07-09)
## [6.0.27] - 2015-07-09
- Allowing integer value for port number
## v6.0.26 (2015-07-07)
## [6.0.26] - 2015-07-07
- Reverting breaking changes introduced in 6.0.25
## v6.0.25 (2015-07-06)
## [6.0.25] - 2015-07-06
- Fixes for 12.4.1
## v6.0.24 (2015-06-27)
## [6.0.24] - 2015-06-27
- 341 - Changing default GRANT for root from '%' to 'localhost' and '127.0.0.1'
## v6.0.23 (2015-06-21)
## [6.0.23] - 2015-06-21
- 354 Better handling of long MySQL startup times
## v6.0.22 (2015-05-07)
## [6.0.22] - 2015-05-07
- Debian 8 (Jessie) support
## v6.0.21 (2015-04-08)
## [6.0.21] - 2015-04-08
- Fix to Upstart prestart script when using custom socket
- Adding --explicit_defaults_for_timestamp mysql_install_db_cmd for
- 5.6 and above
## v6.0.20 (2015-03-27)
## [6.0.20] - 2015-03-27
- 318 - Fixing Upstart pre-start script to handle custom socket paths
## v6.0.19 (2015-03-25)
## [6.0.19] - 2015-03-25
- Adding support for Amazon Linux 2015.03
## v6.0.18 (2015-03-24)
## [6.0.18] - 2015-03-24
- Adding support for 5.6 and 5.7 packages from dotdeb repos on Debian 7
## v6.0.17 (2015-03-13)
## [6.0.17] - 2015-03-13
- Updated for MySQL 5.7.6.
- Handing removal of mysql_install_db and mysqld_safe
## v6.0.16 (2015-03-10)
## [6.0.16] - 2015-03-10
- Moved --defaults-file as first option to mysql_install_db_script
## v6.0.15 (2015-02-26)
## [6.0.15] - 2015-02-26
- Updating docker detection fix to pass specs
## v6.0.14 (2015-02-26)
## [6.0.14] - 2015-02-26
- Fixed debian system service :disable action. Now survives reboot
- Fixing centos-7 instance :enable action. Now survives
- Not applying Apparmor policy if running in a Docker container
## v6.0.13 (2015-02-15)
## [6.0.13] - 2015-02-15
- Adding support for special characters in initial_root_password
- Fixing failure status bug in sysvinit script
## v6.0.12 (2015-02-30)
## [6.0.12] - 2015-02-30
- No changes. Released a 6.0.11 that was identical to 6.0.10.
- Git before coffee.
## v6.0.11 (2015-02-30)
## [6.0.11] - 2015-02-30
- Adding support for configurable socket files
## v6.0.10 (2015-01-19)
## [6.0.10] - 2015-01-19
- Fix #282 - Fixing up data_dir template variable
## v6.0.9 (2015-01-19)
## [6.0.9] - 2015-01-19
- Fix #282 - undefined method `parsed_data_dir' bug
## v6.0.8 (2015-01-19)
## [6.0.8] - 2015-01-19
- Refactoring helper methods out of resource classes
## v6.0.7 (2015-01-14)
## [6.0.7] - 2015-01-14
- Fixing timing issue with Upstart provider :restart and :reload
- actions where service returns before being available
## v6.0.6 (2014-12-26)
## [6.0.6] - 2014-12-26
- Fixing subtle bug where MysqlCookbook::Helper methods were polluting Chef::Resource
## v6.0.5 (2014-12-25)
## [6.0.5] - 2014-12-25
- Using 'include_recipe' instead of 'recipe_eval' in LWRP
- Fixing type checking on package_name attribute in mysql_client resource.
## v6.0.4 (2014-12-21)
## [6.0.4] - 2014-12-21
- Suggest available versions if current is not available for current platform.
## v6.0.3 (2014-12-17)
## [6.0.3] - 2014-12-17
- Adding bind_address parameter to mysql_service resource
## v6.0.2 (2014-12-17)
## [6.0.2] - 2014-12-17
- Fixing sysvinit provider to survive reboots
## v6.0.1 (2014-12-16)
## [6.0.1] - 2014-12-16
- Fixing Upstart template to survive reboots
## v6.0.0 (2014-12-15)
## [6.0.0] - 2014-12-15
- Major version update
- Cookbook now provides LWRPs instead of recipes
@ -269,11 +335,11 @@ This file is used to list changes made in each version of the mysql cookbook.
- Refactored acceptance tests
- Temporarily dropped FreeBSD support
## v5.6.1 (2014-10-29)
## [5.6.1] - 2014-10-29
- Use Gem::Version instead of Chef::Version
## v5.6.0 (2014-10-29)
## [5.6.0] - 2014-10-29
- Changing default charset to utf8
- Quoting passwords in debian.cnf.erb
@ -282,45 +348,45 @@ This file is used to list changes made in each version of the mysql cookbook.
- Only hide passwords from STDOUT via "sensitive true" in chef-client higher than 11.14
- Updating test harness
## v5.5.4 (2014-10-07)
## [5.5.4] - 2014-10-07
- Adding sensitive flag to execute resources to protect passwords from logs
## v5.5.3 (2014-09-24)
## [5.5.3] - 2014-09-24
- Reverting back to Upstart on Ubuntu 14.04
## v5.5.2 (2014-09-8)
## [5.5.2] - 2014-09-8
- Reverting commit that broke Debian pass_string
## v5.5.1 (2014-09-2)
## [5.5.1] - 2014-09-2
- Switching Ubuntu service provider to use SysVinit instead of Upstart
## v5.5.0 (2014-08-27)
## [5.5.0] - 2014-08-27
- Adding package version and action parameters to mysql_service resource
- Fixing Debian pass_string
## v5.4.4 (2014-08-27)
## [5.4.4] - 2014-08-27
- Changing module namespace to MysqlCookbook
## v5.4.3 (2014-08-25)
## [5.4.3] - 2014-08-25
- More refactoring. Moving helper function bits into resource parsed_parameters
## v5.4.2 (2014-08-25)
## [5.4.2] - 2014-08-25
- Moving provider local variables into definitions for RHEL provider
## v5.4.1 (2014-08-25)
## [5.4.1] - 2014-08-25
- Refactoring resources into the LWRP style with parsed parameters
- Moving provider local variables into definitions
## v5.4.0 (2014-08-25)
## [5.4.0] - 2014-08-25
- 212 - support for centos-7 (mysql55 and mysql56)
- Adding (untested) Debian-6 support
@ -330,119 +396,119 @@ This file is used to list changes made in each version of the mysql cookbook.
- Appeasing AppArmor
- Reducing duplication in client provider
## v5.3.6 (2014-06-18)
## [5.3.6] - 2014-06-18
- Fixing pid path location. Updating tests to include real RHEL
## v5.3.4 (2014-06-16)
## [5.3.4] - 2014-06-16
- Fixing specs for Amazon Linux server package names
## v5.3.2 (2014-06-16)
## [5.3.2] - 2014-06-16
- Fixing Amazon Linux support
## v5.3.0 (2014-06-11)
## [5.3.0] - 2014-06-11
- 189 - Fix server_repl_password description
- 191 - Adding support for server55 and server56 on el-6
- 193 - Fix syntax in mysql_service example
- 199 - Adding Suse support
## v5.2.12 (2014-05-19)
## [5.2.12] - 2014-05-19
PR #192 - recipes/server.rb should honor parameter node['mysql']['version']
## v5.2.10 (2014-05-15)
## [5.2.10] - 2014-05-15
- COOK-4394 - restore freebsd support
## v5.2.8 (2014-05-15)
## [5.2.8] - 2014-05-15
- [COOK-4653] - Missing mySQL 5.6 support for Ubuntu 14.04
## v5.2.6 (2014-05-07)
## [5.2.6] - 2014-05-07
- [COOK-4625] - Fix password resource parameter consumption on Debian and Ubuntu
- Fix up typos and version numbers in PLATFORMS.md
- Fix up specs from COOK-4613 changes
## v5.2.4 (2014-05-02)
## [5.2.4] - 2014-05-02
- [COOK-4613] - Fix permissions on mysql data_dir to allow global access to mysql.sock
## v5.2.2 (2014-04-24)
## [5.2.2] - 2014-04-24
- [COOK-4564] - Using positive tests for datadir move
## v5.2.0 (2014-04-22)
## [5.2.0] - 2014-04-22
- [COOK-4551] - power grants.sql from resource parameters
## v5.1.12 (2014-04-21)
## [5.1.12] - 2014-04-21
- [COOK-4554] - Support for Debian Sid
## v5.1.10 (2014-04-21)
## [5.1.10] - 2014-04-21
- [COOK-4565] Support for Ubuntu 14.04
- [COOK-4565] Adding Specs and TK platform
- Removing non-LTS 13.10 specs and TK platform
## v5.1.8 (2014-04-12)
## [5.1.8] - 2014-04-12
Adding Ubuntu 13.04 to Platforminfo
## v5.1.6 (2014-04-11)
## [5.1.6] - 2014-04-11
- [COOK-4548] - Add template[/etc/mysql/debian.cnf] to Ubuntu provider
## v5.1.4 (2014-04-11)
## [5.1.4] - 2014-04-11
- [COOK-4547] - Shellescape server_root_password
## v5.1.2 (2014-04-09)
## [5.1.2] - 2014-04-09
- [COOK-4519] - Fix error in run_dir for Ubuntu
- [COOK-4531] - Fix pid and run_dir for Debian
## v5.1.0 (2014-04-08)
## [5.1.0] - 2014-04-08
[COOK-4523] - Allow for both :restart and :reload
## v5.0.6 (2014-04-07)
## [5.0.6] - 2014-04-07
- [COOK-4519] - Updating specs to reflect pid file change on Ubuntu
## v5.0.4 (2014-04-07)
## [5.0.4] - 2014-04-07
- [COOK-4519] - Fix path to pid file on Ubuntu
## v5.0.2 (2014-04-01)
## [5.0.2] - 2014-04-01
- Moving server_deprecated into recipes directory
## v5.0.0 (2014-03-31)
## [5.0.0] - 2014-03-31
- Rewriting as a library cookbook
- Exposing mysql_service and mysql_client resources
- User now needs to supply configuration
- Moving attribute driven recipe to server-deprecated
## v4.1.2 (2014-02-28)
## [4.1.2] - 2014-02-28
- [COOK-4349] - Fix invalid platform check
- [COOK-4184] - Better handling of Ubuntu upstart service
- [COOK-2100] - Changing innodb_log_file_size tunable results in inability to start MySQL
## v4.1.1 (2014-02-25)
## [4.1.1] - 2014-02-25
- **[COOK-2966] - Address foodcritic failures'
- **[COOK-4182] - Template parse failure in /etc/init/mysql.conf (data_dir)'
- **[COOK-4198] - Added missing tunable'
- **[COOK-4206] - create root@127.0.0.1, as well as root@localhost'
## v4.0.20 (2014-01-18)
## [4.0.20] - 2014-01-18
- [COOK-3931] - MySQL Server Recipe Regression for Non-LTS Ubuntu Versions
- [COOK-3945] - MySQL cookbook fails on Ubuntu 13.04/13.10
@ -452,11 +518,11 @@ Adding Ubuntu 13.04 to Platforminfo
- [COOK-4001] - Pull request: Fixes for broken mysql::server on Debian
- [COOK-4071] - Mysql cookbook doesn't work on debian 7.2
## v4.0.14
## [4.0.14]
Fixing style cops
## v4.0.12
## [4.0.12]
### Bug
@ -466,25 +532,25 @@ Fixing style cops
- **[COOK-3801](https://tickets.chef.io/browse/COOK-3801)** - Add innodb_adaptive_flushing_method and innodb_adaptive_checkpoint
## v4.0.10
## [4.0.10]
fixing metadata version error. locking to 3.0
## v4.0.8
## [4.0.8]
Locking yum dependency to '< 3'
## v4.0.6
## [4.0.6]
# Bug
### Bug
- [COOK-3943] Notifying service restart on grants update
## v4.0.4
## [4.0.4]
[COOK-3952] - Adding 'recursive true' to directory resources
## v4.0.2
## [4.0.2]
### BUGS
@ -492,7 +558,7 @@ Locking yum dependency to '< 3'
- Fixing bug where unprivileged users cannot connect over a local socket. Adding integration test.
- Fixing bug in mysql_grants_cmd generation
## v4.0.0
## [4.0.0]
- [COOK-3928] Heavily refactoring for readability. Moving platform implementation into separate recipes
- Moving integration tests from minitest to serverspec, removing "improper" tests
@ -503,23 +569,23 @@ Locking yum dependency to '< 3'
- [COOK-3807] - Don't use execute[assign-root-password] on Debian and Ubuntu
- [COOK-3881] - Fixing /etc being owned by mysql user
## v3.0.12
## [3.0.12]
### Bug
- **[COOK-3752](https://tickets.chef.io/browse/COOK-3752)** - mysql service fails to start in mysql::server recipe
## v3.0.10
## [3.0.10]
- Fix a failed release attempt for v3.0.8
## v3.0.8
## [3.0.8]
### Bug
- **[COOK-3749](https://tickets.chef.io/browse/COOK-3749)** - Fix a regression with Chef 11-specific features
## v3.0.6
## [3.0.6]
### Bug
@ -536,7 +602,7 @@ Locking yum dependency to '< 3'
- **[COOK-3498](https://tickets.chef.io/browse/COOK-3498)** - Add support for replicate_* variables in my.cnf
## v3.0.4
## [3.0.4]
### Bug
@ -546,7 +612,7 @@ Locking yum dependency to '< 3'
- **[COOK-3134](https://tickets.chef.io/browse/COOK-3134)** - Fix Chef 11 support
- **[COOK-2318](https://tickets.chef.io/browse/COOK-2318)** - Remove redundant `if` block around `node.mysql.tunable.log_bin`
## v3.0.2
## [3.0.2]
### Bug
@ -558,7 +624,7 @@ Locking yum dependency to '< 3'
- [COOK-2102]: `innodb_flush_log_at_trx_commit` value is incorrectly set based on CPU count
## v3.0.0
## [3.0.0]
**Note** This is a backwards incompatible version with previous versions of the cookbook. Tickets that introduce incompatibility are COOK-2615 and COOK-2617.
@ -580,11 +646,11 @@ Locking yum dependency to '< 3'
- [COOK-2618] - myisam-recover not using attribute value
- [COOK-2617] - open-files is a duplicate of open-files-limit
## v2.1.2
## [2.1.2]
- [COOK-2172] - Mysql cookbook duplicates `binlog_format` configuration
## v2.1.0
## [2.1.0]
- [COOK-1669] - Using platform("ubuntu") in default attributes always returns true
- [COOK-1694] - Added additional my.cnf fields and reorganized cookbook to avoid race conditions with mysql startup and sql script execution
@ -592,13 +658,13 @@ Locking yum dependency to '< 3'
- [COOK-1929] - Update msyql server attributes file because setting attributes without specifying a precedence is deprecated
- [COOK-1999] - Add read_only tunable useful for replication slave servers
## v2.0.2
## [2.0.2]
- [COOK-1967] - mysql: trailing comma in server.rb platform family
## v2.0.0
## [2.0.0]
**Important note for this release**
### Important note for this release
Under Chef Solo, you must set the node attributes for the root, debian and repl passwords or the run will completely fail. See COOK-1737 for background on this.
@ -613,9 +679,9 @@ Under Chef Solo, you must set the node attributes for the root, debian and repl
- [COOK-1769] - link to database recipe in mysql README goes to old chef/cookbooks repo instead of chef-cookbook organization
- [COOK-1963] - use `platform_family`
## v1.3.0
## [1.3.0]
**Important note for this release**
### Important note for this release
This version no longer installs Ruby bindings in the client recipe by default. Use the ruby recipe if you'd like the RubyGem. If you'd like packages from your distribution, use them in your application's specific cookbook/recipe, or modify the client packages attribute. This resolves the following tickets:
@ -637,7 +703,7 @@ The following issues are also addressed in this release.
- [COOK-934] - remove deprecated mysql/libraries/database.rb, use the database cookbook instead.
- [COOK-1475] - fix restart on config change
## v1.2.6
## [1.2.6]
- [COOK-1113] - Use an attribute to determine if upstart is used
- [COOK-1121] - Add support for Windows
@ -645,47 +711,47 @@ The following issues are also addressed in this release.
- [COOK-1151] - Fix server_ec2 handling /var/lib/mysql bind mount
- [COOK-1321] - Document setting password attributes for solo
## v1.2.4
## [1.2.4]
- [COOK-992] - fix FATAL nameerror
- [COOK-827] - `mysql:server_ec2` recipe can't mount `data_dir`
- [COOK-945] - FreeBSD support
## v1.2.2
## [1.2.2]
- [COOK-826] mysql::server recipe doesn't quote password string
- [COOK-834] Add 'scientific' and 'amazon' platforms to mysql cookbook
## v1.2.1
## [1.2.1]
- [COOK-644] Mysql client cookbook 'package missing' error message is confusing
- [COOK-645] RHEL6/CentOS6 - mysql cookbook contains 'skip-federated' directive which is unsupported on MySQL 5.1
## v1.2.0
## [1.2.0]
- [COOK-684] remove mysql_database LWRP
## v1.0.8
## [1.0.8]
- [COOK-633] ensure "cloud" attribute is available
## v1.0.7
## [1.0.7]
- [COOK-614] expose all mysql tunable settings in config
- [COOK-617] bind to private IP if available
## v1.0.6
## [1.0.6]
- [COOK-605] install mysql-client package on ubuntu/debian
## v1.0.5
## [1.0.5]
- [COOK-465] allow optional remote root connections to mysql
- [COOK-455] improve platform version handling
- externalize conf_dir attribute for easier cross platform support
- change datadir attribute to data_dir for consistency
## v1.0.4
## [1.0.4]
- fix regressions on debian platform
- [COOK-578] wrap root password in quotes

View File

@ -1,2 +1,4 @@
# Contributing
Please refer to
https://github.com/chef-cookbooks/community_cookbook_documentation/blob/master/CONTRIBUTING.MD
[https://github.com/chef-cookbooks/community_cookbook_documentation/blob/master/CONTRIBUTING.MD](https://github.com/chef-cookbooks/community_cookbook_documentation/blob/master/CONTRIBUTING.MD)

View File

@ -1,6 +1,10 @@
# MySQL Cookbook
[![Build Status](https://travis-ci.org/chef-cookbooks/mysql.svg?branch=master)](https://travis-ci.org/chef-cookbooks/mysql) [![Cookbook Version](https://img.shields.io/cookbook/v/mysql.svg)](https://supermarket.chef.io/cookbooks/mysql)
[![Cookbook Version](https://img.shields.io/cookbook/v/mysql.svg)](https://supermarket.chef.io/cookbooks/mysql)
[![Build Status](https://img.shields.io/circleci/project/github/sous-chefs/mysql/master.svg)](https://circleci.com/gh/sous-chefs/mysql)
[![OpenCollective](https://opencollective.com/sous-chefs/backers/badge.svg)](#backers)
[![OpenCollective](https://opencollective.com/sous-chefs/sponsors/badge.svg)](#sponsors)
[![License](https://img.shields.io/badge/License-Apache%202.0-green.svg)](https://opensource.org/licenses/Apache-2.0)
The MySQL Cookbook is a library cookbook that provides resource primitives (LWRPs) for use in recipes. It is designed to be a reference example for creating highly reusable cross-platform cookbooks.
@ -8,6 +12,10 @@ The MySQL Cookbook is a library cookbook that provides resource primitives (LWRP
This cookbook is concerned with the "MySQL Community Server", particularly those shipped with F/OSS Unix and Linux distributions. It does not address forks or value-added repackaged MySQL distributions like MariaDB or Percona.
## Maintainers
This cookbook is maintained by the Sous Chefs. The Sous Chefs are a community of Chef cookbook maintainers working together to maintain important cookbooks. If youd like to know more please visit [sous-chefs.org](https://sous-chefs.org/) or come chat with us on the Chef Community Slack in [#sous-chefs](https://chefcommunity.slack.com/messages/C2V7B88SF).
## Requirements
- Chef 12.7 or higher
@ -18,27 +26,15 @@ This cookbook is concerned with the "MySQL Community Server", particularly those
The following platforms have been tested with Test Kitchen:
```
|----------------+-----+-----+-----+-----|
| | 5.1 | 5.5 | 5.6 | 5.7 |
|----------------+-----+-----+-----+-----|
| debian-7 | | X | | |
|----------------+-----+-----+-----+-----|
| OS | 5.1 | 5.5 | 5.6 | 5.7 |
|----------------|-----|-----|-----|-----|
| debian-8 | | X | | |
|----------------+-----+-----+-----+-----|
| ubuntu-14.04 | | X | X | |
|----------------+-----+-----+-----+-----|
| ubuntu-16.04 | | | | X |
|----------------+-----+-----+-----+-----|
| centos-6 | X | X | X | X |
|----------------+-----+-----+-----+-----|
| centos-7 | | X | X | X |
|----------------+-----+-----+-----+-----|
| fedora | | | X | X |
|----------------+-----+-----+-----+-----|
| openSUSE Leap | | | X | |
|----------------+-----+-----+-----+-----|
```
## Cookbook Dependencies
@ -65,9 +61,11 @@ end
The service name on the OS is `mysql-foo`. You can manually start and stop it with `service mysql-foo start` and `service mysql-foo stop`.
If you use `default` as the name the service name will be `mysql` instead of `mysql-default`.
The configuration file is at `/etc/mysql-foo/my.cnf`. It contains the minimum options to get the service running. It looks like this.
```
```toml
# Chef generated my.cnf for instance mysql-foo
[client]
@ -104,12 +102,13 @@ end
mysql_config 'foo' do
source 'my_extra_settings.erb'
instance 'foo'
notifies :restart, 'mysql_service[foo]'
action :create
end
```
You are responsible for providing `my_extra_settings.erb` in your own cookbook's templates folder.
You are responsible for providing `my_extra_settings.erb` in your own cookbook's templates folder. The name of the mysql service instance must be provided in mysql config as this defaults to 'default'.
## Connecting with the mysql CLI command
@ -156,7 +155,6 @@ Please note that when using `notifies` or `subscribes`, the resource to referenc
- `error_log` - Tunable location of the error_log
- `initial_root_password` - allows the user to specify the initial root password for mysql when initializing new databases. This can be set explicitly in a recipe, driven from a node attribute, or from data_bags. When omitted, it defaults to `ilikerandompasswords`. Please be sure to change it.
- `instance` - A string to identify the MySQL service. By convention, to allow for multiple instances of the `mysql_service`, directories and files on disk are named `mysql-<instance_name>`. Defaults to the resource name.
- `package_action` - Defaults to `:install`.
- `package_name` - Defaults to a value looked up in an internal map.
- `package_version` - Specific version of the package to install,passed onto the underlying package manager. Defaults to `nil`.
- `bind_address` - determines the listen IP address for the mysqld service. When omitted, it will be determined by MySQL. If the address is "regular" IPv4/IPv6address (e.g 127.0.0.1 or ::1), the server accepts TCP/IP connections only for that particular address. If the address is "0.0.0.0" (IPv4) or "::" (IPv6), the server accepts TCP/IP connections on all IPv4 or IPv6 interfaces.
@ -166,17 +164,17 @@ Please note that when using `notifies` or `subscribes`, the resource to referenc
- `run_user` - The name of the system user the `mysql_service` should run as. Defaults to 'mysql'.
- `pid_file` - Tunable location of the pid file.
- `socket` - determines where to write the socket file for the `mysql_service` instance. Useful when configuring clients on the same machine to talk over socket and skip the networking stack. Defaults to a calculated value based on platform and instance name.
- `tmp_dir` - Tunable location of the tmp_dir
- `tmp_dir` - Tunable location of the tmp_dir.
- `version` - allows the user to select from the versions available for the platform, where applicable. When omitted, it will install the default MySQL version for the target platform. Available version numbers are `5.0`, `5.1`, `5.5`, `5.6`, and `5.7`, depending on platform.
#### Actions
- `:create` - Configures everything but the underlying operating system service.
- `:delete` - Removes everything but the package and data_dir.
- `:start` - Starts the underlying operating system service
- `:stop`- Stops the underlying operating system service
- `:restart` - Restarts the underlying operating system service
- `:reload` - Reloads the underlying operating system service
- `:start` - Starts the underlying operating system service.
- `:stop`- Stops the underlying operating system service.
- `:restart` - Restarts the underlying operating system service.
- `:reload` - Reloads the underlying operating system service.
#### Providers
@ -353,7 +351,7 @@ Use multiple `mysql_service` instances to test a replication setup. This particu
## Frequently Asked Questions
### How do I run this behind my firewall?
### How do I run this behind my firewall
On Linux, the `mysql_service` resource uses the platform's underlying package manager to install software. For this to work behind firewalls, you'll need to either:
@ -395,30 +393,35 @@ Or to connect over the network, use something like this: connect over the networ
These network or socket ssettings can also be put in you $HOME/.my.cnf, if preferred.
### What about MariaDB, Percona, etc.
### What about MariaDB, Percona, etc
MySQL forks are purposefully out of scope for this cookbook. This is mostly to reduce the testing matrix to a manageable size. Cookbooks for these technologies can easily be created by copying and adapting this cookbook. However, there will be differences.
Package repository locations, package version names, software major version numbers, supported platform matrices, and the availability of software such as XtraDB and Galera are the main reasons that creating multiple cookbooks to make sense.
## Maintainers
There are existing cookbooks to carter for these forks, check them out on the supermarket
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/)
## Contributors
## License
This project exists thanks to all the people who [contribute.](https://opencollective.com/sous-chefs/contributors.svg?width=890&button=false)
```text
Copyright:: 2009-2017 Chef Software, Inc
### Backers
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
Thank you to all our backers!
http://www.apache.org/licenses/LICENSE-2.0
![https://opencollective.com/sous-chefs#backers](https://opencollective.com/sous-chefs/backers.svg?width=600&avatarHeight=40)
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.
```
### Sponsors
Support this project by becoming a sponsor. Your logo will show up here with a link to your website.
![https://opencollective.com/sous-chefs/sponsor/0/website](https://opencollective.com/sous-chefs/sponsor/0/avatar.svg?avatarHeight=100)
![https://opencollective.com/sous-chefs/sponsor/1/website](https://opencollective.com/sous-chefs/sponsor/1/avatar.svg?avatarHeight=100)
![https://opencollective.com/sous-chefs/sponsor/2/website](https://opencollective.com/sous-chefs/sponsor/2/avatar.svg?avatarHeight=100)
![https://opencollective.com/sous-chefs/sponsor/3/website](https://opencollective.com/sous-chefs/sponsor/3/avatar.svg?avatarHeight=100)
![https://opencollective.com/sous-chefs/sponsor/4/website](https://opencollective.com/sous-chefs/sponsor/4/avatar.svg?avatarHeight=100)
![https://opencollective.com/sous-chefs/sponsor/5/website](https://opencollective.com/sous-chefs/sponsor/5/avatar.svg?avatarHeight=100)
![https://opencollective.com/sous-chefs/sponsor/6/website](https://opencollective.com/sous-chefs/sponsor/6/avatar.svg?avatarHeight=100)
![https://opencollective.com/sous-chefs/sponsor/7/website](https://opencollective.com/sous-chefs/sponsor/7/avatar.svg?avatarHeight=100)
![https://opencollective.com/sous-chefs/sponsor/8/website](https://opencollective.com/sous-chefs/sponsor/8/avatar.svg?avatarHeight=100)
![https://opencollective.com/sous-chefs/sponsor/9/website](https://opencollective.com/sous-chefs/sponsor/9/avatar.svg?avatarHeight=100)

View File

@ -12,8 +12,13 @@ module MysqlCookbook
false
end
def wheezy?
return true if node['platform'] == 'debian' && node['platform_version'].to_i == 7
def fedora?
return true if node['platform_family'] == 'fedora'
false
end
def suse?
return true if node['platform_family'] == 'suse'
false
end
@ -38,14 +43,19 @@ module MysqlCookbook
false
end
def bionic?
return true if node['platform'] == 'ubuntu' && node['platform_version'] == '18.04'
false
end
def defaults_file
"#{etc_dir}/my.cnf"
end
def default_data_dir
return "/var/lib/#{mysql_name}" if node['os'] == 'linux'
return "/opt/local/lib/#{mysql_name}" if node['os'] == 'solaris2'
return "/var/db/#{mysql_name}" if node['os'] == 'freebsd'
return "/opt/local/lib/#{mysql_name}" if platform_family?('solaris2')
return "/var/db/#{mysql_name}" if platform_family?('freebsd')
end
def default_error_log
@ -58,22 +68,22 @@ module MysqlCookbook
def default_major_version
# rhelish
return '5.1' if el6?
return '5.6' if el6?
return '5.6' if el7?
return '5.6' if node['platform'] == 'amazon'
# debian
return '5.5' if wheezy?
return '5.5' if jessie?
# ubuntu
return '5.5' if trusty?
return '5.7' if xenial?
return '5.7' if bionic?
# misc
return '5.6' if node['platform'] == 'freebsd'
return '5.6' if node['platform'] == 'fedora'
return '5.6' if node['platform_family'] == 'suse'
return '5.7' if fedora?
return '5.6' if suse?
end
def major_from_full(v)
@ -81,7 +91,11 @@ module MysqlCookbook
end
def mysql_name
"mysql-#{instance}"
if instance == 'default'
'mysql'
else
"mysql-#{instance}"
end
end
def default_socket_file
@ -89,20 +103,23 @@ module MysqlCookbook
end
def default_client_package_name
return ['mysql', 'mysql-devel'] if major_version == '5.1' && el6?
return %w(mysql mysql-devel) if major_version == '5.1' && el6?
return %w(mysql mysql-devel) if el7?
return ['mysql55', 'mysql55-devel.x86_64'] if major_version == '5.5' && node['platform'] == 'amazon'
return ['mysql56', 'mysql56-devel.x86_64'] if major_version == '5.6' && node['platform'] == 'amazon'
return ['mysql57', 'mysql57-devel.x86_64'] if major_version == '5.7' && node['platform'] == 'amazon'
return ['mysql-client-5.5', 'libmysqlclient-dev'] if major_version == '5.5' && node['platform_family'] == 'debian'
return ['mysql-client-5.6', 'libmysqlclient-dev'] if major_version == '5.6' && node['platform_family'] == 'debian'
return ['mysql-client-5.7', 'libmysqlclient-dev'] if major_version == '5.7' && node['platform_family'] == 'debian'
return 'mysql-community-server-client' if major_version == '5.6' && node['platform_family'] == 'suse'
['mysql-community-client', 'mysql-community-devel']
%w(mysql-community-client mysql-community-devel)
end
def default_server_package_name
return 'mysql-server' if major_version == '5.1' && el6?
return 'mysql55-server' if major_version == '5.5' && node['platform'] == 'amazon'
return 'mysql56-server' if major_version == '5.6' && node['platform'] == 'amazon'
return 'mysql57-server' if major_version == '5.7' && node['platform'] == 'amazon'
return 'mysql-server-5.5' if major_version == '5.5' && node['platform_family'] == 'debian'
return 'mysql-server-5.6' if major_version == '5.6' && node['platform_family'] == 'debian'
return 'mysql-server-5.7' if major_version == '5.7' && node['platform_family'] == 'debian'
@ -189,7 +206,6 @@ module MysqlCookbook
set -e
rm -rf /tmp/#{mysql_name}
mkdir /tmp/#{mysql_name}
cat > /tmp/#{mysql_name}/my.sql <<-'EOSQL'
UPDATE mysql.user SET #{password_column_name}=PASSWORD('#{sql_escaped_password}')#{password_expired} WHERE user = 'root';
DELETE FROM mysql.user WHERE USER LIKE '';
@ -198,15 +214,24 @@ FLUSH PRIVILEGES;
DELETE FROM mysql.db WHERE db LIKE 'test%';
DROP DATABASE IF EXISTS test ;
EOSQL
#{db_init}
#{record_init}
while [ ! -f #{pid_file} ] ; do sleep 1 ; done
kill `cat #{pid_file}`
while [ -f #{pid_file} ] ; do sleep 1 ; done
rm -rf /tmp/#{mysql_name}
EOS
EOS
end
def wait_for_init
cmd = <<-EOS
while [ ! -f #{pid_file} ] ; do sleep 1 ; done
kill `cat #{pid_file}`
while [ -f #{pid_file} ] ; do sleep 1 ; done
rm -rf /tmp/#{mysql_name}
EOS
cmd = '' if v57plus
cmd
end
def password_column_name
@ -256,12 +281,26 @@ EOSQL
def mysqld_bin
return "#{prefix_dir}/libexec/mysqld" if node['platform_family'] == 'smartos'
return "#{base_dir}/bin/mysqld" if node['platform_family'] == 'omnios'
return '/usr/sbin/mysqld' if node['platform_family'] == 'fedora' && v56plus
return '/usr/libexec/mysqld' if node['platform_family'] == 'fedora'
return '/usr/sbin/mysqld' if fedora? && v56plus
return '/usr/libexec/mysqld' if fedora?
return 'mysqld' if scl_package?
"#{prefix_dir}/usr/sbin/mysqld"
end
def mysql_systemd_start_pre
return '/usr/bin/mysqld_pre_systemd' if v57plus && (el7? || fedora?)
return '/usr/bin/mysql-systemd-start pre' if node['platform_family'] == 'rhel'
return '/usr/lib/mysql/mysql-systemd-helper install' if suse?
'/usr/share/mysql/mysql-systemd-start pre'
end
def mysql_systemd
return "/usr/libexec/#{mysql_name}-wait-ready $MAINPID" if v57plus && (el7? || fedora?)
return '/usr/bin/mysql-systemd-start' if node['platform_family'] == 'rhel'
return '/usr/share/mysql/mysql-systemd-start' if v57plus
"/usr/libexec/#{mysql_name}-wait-ready $MAINPID"
end
def mysqld_initialize_cmd
cmd = mysqld_bin
cmd << " --defaults-file=#{etc_dir}/my.cnf"

View File

@ -1,71 +0,0 @@
if defined?(ChefSpec)
ChefSpec.define_matcher :mysql_config
ChefSpec.define_matcher :mysql_service
ChefSpec.define_matcher :mysql_client
# mysql_client_client_installation_package
def install_mysql_client_installation_package(resource_name)
ChefSpec::Matchers::ResourceMatcher.new(:mysql_client_installation_package, :create, resource_name)
end
def remove_mysql_client_installation_package(resource_name)
ChefSpec::Matchers::ResourceMatcher.new(:mysql_client_installation_package, :remove, resource_name)
end
# mysql_server_server_installation_package
def install_mysql_server_installation_package(resource_name)
ChefSpec::Matchers::ResourceMatcher.new(:mysql_server_installation_package, :install, resource_name)
end
def remove_mysql_server_installation_package(resource_name)
ChefSpec::Matchers::ResourceMatcher.new(:mysql_server_installation_package, :remove, resource_name)
end
#####
# old
#####
# client
def create_mysql_client(resource_name)
ChefSpec::Matchers::ResourceMatcher.new(:mysql_client, :create, resource_name)
end
def delete_mysql_client(resource_name)
ChefSpec::Matchers::ResourceMatcher.new(:mysql_client, :delete, resource_name)
end
# mysql_config
def create_mysql_config(resource_name)
ChefSpec::Matchers::ResourceMatcher.new(:mysql_config, :create, resource_name)
end
def delete_mysql_config(resource_name)
ChefSpec::Matchers::ResourceMatcher.new(:mysql_config, :delete, resource_name)
end
# service
def create_mysql_service(resource_name)
ChefSpec::Matchers::ResourceMatcher.new(:mysql_service, :create, resource_name)
end
def delete_mysql_service(resource_name)
ChefSpec::Matchers::ResourceMatcher.new(:mysql_service, :delete, resource_name)
end
def start_mysql_service(resource_name)
ChefSpec::Matchers::ResourceMatcher.new(:mysql_service, :start, resource_name)
end
def stop_mysql_service(resource_name)
ChefSpec::Matchers::ResourceMatcher.new(:mysql_service, :stop, resource_name)
end
def restart_mysql_service(resource_name)
ChefSpec::Matchers::ResourceMatcher.new(:mysql_service, :restart, resource_name)
end
def reload_mysql_service(resource_name)
ChefSpec::Matchers::ResourceMatcher.new(:mysql_service, :reload, resource_name)
end
end

View File

@ -3,9 +3,6 @@ module MysqlCookbook
require_relative 'helpers'
# All resources are composites
def whyrun_supported?
true
end
################
# Type Constants

View File

@ -4,14 +4,15 @@ module MysqlCookbook
require_relative 'helpers'
include MysqlCookbook::HelpersBase
# Resource properties
# Resource:: properties
resource_name :mysql_client_installation_package
provides :mysql_client_installation_package
provides :mysql_client_installation, os: 'linux'
provides :mysql_client, os: 'linux'
property :package_name, [String, Array], default: lazy { default_client_package_name }, desired_state: false
property :package_options, [String, nil], desired_state: false
property :package_version, [String, nil], default: nil, desired_state: false
property :package_version, [String, nil], desired_state: false
# Actions
action :create do

View File

@ -1,6 +1,7 @@
module MysqlCookbook
class MysqlConfig < MysqlBase
resource_name :mysql_config
provides :mysql_config
property :config_name, String, name_property: true, desired_state: false
property :cookbook, String, desired_state: false
@ -14,8 +15,6 @@ module MysqlCookbook
require_relative 'helpers'
include MysqlCookbook::HelpersBase
provides :mysql_config
action :create do
# hax because group property
g = Chef::Resource::Group.new(new_resource.group, run_context)

View File

@ -1,12 +1,13 @@
module MysqlCookbook
class MysqlServerInstallationPackage < MysqlBase
# Resource properties
# Resource:: properties
resource_name :mysql_server_installation_package
provides :mysql_server_installation_package
provides :mysql_server_installation, os: 'linux'
property :package_name, String, default: lazy { default_server_package_name }, desired_state: false
property :package_options, [String, nil], desired_state: false
property :package_version, [String, nil], default: nil, desired_state: false
property :package_version, [String, nil], desired_state: false
# helper methods
require_relative 'helpers'

View File

@ -2,9 +2,10 @@ module MysqlCookbook
require_relative 'mysql_service_base'
class MysqlService < MysqlServiceBase
resource_name :mysql_service
provides :mysql_service
# installation type and service_manager
property :install_method, %w(package auto), default: 'auto', desired_state: false
property :install_method, %w(package auto none), default: 'auto', desired_state: false
property :service_manager, %w(sysvinit upstart systemd auto), default: 'auto', desired_state: false
# mysql_server_installation
@ -12,7 +13,7 @@ module MysqlCookbook
property :major_version, String, default: lazy { major_from_full(version) }, desired_state: false
property :package_name, String, default: lazy { default_package_name }, desired_state: false
property :package_options, [String, nil], desired_state: false
property :package_version, [String, nil], default: nil, desired_state: false
property :package_version, [String, nil], desired_state: false
################
# Helper Methods

View File

@ -41,6 +41,7 @@ module MysqlCookbook
# setting up multiple services.
file "#{prefix_dir}/etc/mysql/my.cnf" do
action :delete
not_if { node['init_package'] == 'systemd' }
end
file "#{prefix_dir}/etc/my.cnf" do
@ -55,20 +56,14 @@ module MysqlCookbook
end
# Support directories
directory etc_dir do
owner new_resource.run_user
group new_resource.run_group
mode '0750'
recursive true
action :create
end
directory new_resource.include_dir do
owner new_resource.run_user
group new_resource.run_group
mode '0750'
recursive true
action :create
[etc_dir, new_resource.include_dir, log_dir, new_resource.data_dir].each do |dir|
directory dir do
owner new_resource.run_user
group new_resource.run_group
mode '0750'
recursive true
action :create
end
end
directory run_dir do
@ -79,22 +74,6 @@ module MysqlCookbook
action :create
end
directory log_dir do
owner new_resource.run_user
group new_resource.run_group
mode '0750'
recursive true
action :create
end
directory new_resource.data_dir do
owner new_resource.run_user
group new_resource.run_group
mode '0750'
recursive true
action :create
end
# Main configuration file
template "#{etc_dir}/my.cnf" do
source 'my.cnf.erb'
@ -171,7 +150,7 @@ module MysqlCookbook
template '/etc/apparmor.d/usr.sbin.mysqld' do
cookbook 'mysql'
source 'apparmor/usr.sbin.mysqld.erb'
source "apparmor/#{node['platform']}-#{node['platform_version']}/usr.sbin.mysqld.erb"
owner 'root'
group 'root'
mode '0644'

View File

@ -1,6 +1,7 @@
module MysqlCookbook
class MysqlServiceManagerSystemd < MysqlServiceBase
resource_name :mysql_service_manager_systemd
provides :mysql_service_manager_systemd
provides :mysql_service_manager, os: 'linux' do |_node|
Chef::Platform::ServiceHelpers.service_resource_providers.include?(:systemd)
@ -48,7 +49,9 @@ module MysqlCookbook
config: new_resource,
etc_dir: etc_dir,
base_dir: base_dir,
mysqld_bin: mysqld_bin
mysqld_bin: mysqld_bin,
mysql_systemd_start_pre: mysql_systemd_start_pre,
mysql_systemd: mysql_systemd
)
cookbook 'mysql'
notifies :run, "execute[#{new_resource.instance} systemctl daemon-reload]", :immediately

View File

@ -1,6 +1,7 @@
module MysqlCookbook
class MysqlServiceManagerSysvinit < MysqlServiceBase
resource_name :mysql_service_manager_sysvinit
provides :mysql_service_manager_sysvinit
provides :mysql_service_manager, os: 'linux'

View File

@ -1,6 +1,7 @@
module MysqlCookbook
class MysqlServiceManagerUpstart < MysqlServiceBase
resource_name :mysql_service_manager_upstart
provides :mysql_service_manager_upstart
provides :mysql_service_manager, platform_family: 'debian' do |_node|
Chef::Platform::ServiceHelpers.service_resource_providers.include?(:upstart) &&

View File

@ -1 +1 @@
{"name":"mysql","version":"8.5.1","description":"Provides mysql_service, mysql_config, and mysql_client resources","long_description":"","maintainer":"Chef Software, Inc.","maintainer_email":"cookbooks@chef.io","license":"Apache-2.0","platforms":{"redhat":">= 6.0","centos":">= 6.0","scientific":">= 6.0","oracle":">= 6.0","amazon":">= 0.0.0","fedora":">= 0.0.0","debian":">= 7.0","ubuntu":">= 12.04","opensuse":">= 13.0","opensuseleap":">= 0.0.0","suse":">= 12.0"},"dependencies":{},"recommendations":{},"suggestions":{},"conflicting":{},"providing":{},"replacing":{},"attributes":{},"groupings":{},"recipes":{},"source_url":"https://github.com/chef-cookbooks/mysql","issues_url":"https://github.com/chef-cookbooks/mysql/issues","chef_version":[[">= 12.7"]],"ohai_version":[]}
{"name":"mysql","version":"8.7.3","description":"Provides mysql_service, mysql_config, and mysql_client resources","long_description":"","maintainer":"Sous Chefs","maintainer_email":"help@sous-chefs.org","license":"Apache-2.0","platforms":{"redhat":">= 6.0","centos":">= 6.0","scientific":">= 6.0","oracle":">= 6.0","amazon":">= 0.0.0","fedora":">= 0.0.0","debian":">= 7.0","ubuntu":">= 14.04","opensuseleap":">= 0.0.0","suse":">= 12.0"},"dependencies":{},"recommendations":{},"suggestions":{},"conflicting":{},"providing":{},"replacing":{},"attributes":{},"groupings":{},"recipes":{},"source_url":"https://github.com/sous-chefs/mysql","issues_url":"https://github.com/sous-chefs/mysql/issues","chef_version":[[">= 12.7"]],"ohai_version":[]}

View File

@ -11,4 +11,5 @@
<%= @config.socket_file %> rw,
/tmp/<%= @mysql_name %>/ r,
/tmp/<%= @mysql_name %>/my.sql r,
<%= @config.tmp_dir %>/ rw,
<%= @config.tmp_dir %>/* rw,

View File

@ -1,47 +0,0 @@
# vim:syntax=apparmor
# Last Modified: Tue Jun 19 17:37:30 2007
#include <tunables/global>
/usr/sbin/mysqld {
#include <abstractions/base>
#include <abstractions/nameservice>
#include <abstractions/user-tmp>
#include <abstractions/mysql>
#include <abstractions/winbind>
capability dac_override,
capability sys_resource,
capability setgid,
capability setuid,
network tcp,
/etc/hosts.allow r,
/etc/hosts.deny r,
/etc/mysql/*.pem r,
/etc/mysql/conf.d/ r,
/etc/mysql/conf.d/* r,
/etc/mysql/*.cnf r,
/usr/lib/mysql/plugin/ r,
/usr/lib/mysql/plugin/*.so* mr,
/usr/sbin/mysqld mr,
/usr/share/mysql/** r,
/var/log/mysql.log rw,
/var/log/mysql.err rw,
/var/lib/mysql/ r,
/var/lib/mysql/** rwk,
/var/log/mysql/ r,
/var/log/mysql/* rw,
/var/run/mysqld/mysqld.pid rw,
/var/run/mysqld/mysqld.sock w,
/var/run/mysqld/mysqld.sock.lock rw,
/run/mysqld/mysqld.pid rw,
/run/mysqld/mysqld.sock w,
/run/mysqld/mysqld.sock.lock rw,
/sys/devices/system/cpu/ r,
# Site-specific additions and overrides. See local/README for details.
#include <local/usr.sbin.mysqld>
}

View File

@ -7,10 +7,15 @@ After=network.target
Type=simple
User=<%= @config.run_user %>
Group=<%= @config.run_group %>
PermissionsStartOnly=true
ExecStartPre=<%= @mysql_systemd_start_pre %>
ExecStart=<%= @mysqld_bin %> --defaults-file=<%= @etc_dir %>/my.cnf --basedir=<%= @base_dir %>
ExecStartPost=/usr/libexec/mysql-<%= @config.instance %>-wait-ready $MAINPID
ExecStartPost=<%= @mysql_systemd %>
TimeoutSec=300
PrivateTmp=true
Restart=on-failure
RuntimeDirectory=mysqld
RuntimeDirectoryMode=755
[Install]
WantedBy=multi-user.target

View File

@ -1 +0,0 @@
~FC015

View File

@ -1,142 +0,0 @@
[![Build Status](https://travis-ci.org/yevgenko/cookbook-php-fpm.svg?branch=master)](https://travis-ci.org/yevgenko/cookbook-php-fpm)
# Description
Installs and configures PHP-FPM (FastCGI Process Manager), an alternative PHP FastCGI implementation with some additional features useful for sites of any size, especially busier sites. It's like the `unicorn` of the PHP world dawg.
# Requirements
## Platform
- Debian, Ubuntu
- CentOS, Red Hat, Fedora
- Amazon Linux
## Cookbooks
- none
## Chef
- 12.14 or later
# Description
Creates a PHP-FPM configuration file at the path specified. Meant to be deployed with a service init scheme/supervisor such as runit. Please see the `application::php-fpm` recipe for a complete working example. In depth information about PHP-FPM's configuration values can be [found in the PHP-FPM documentation](http://php.net/manual/en/install.fpm.configuration.php).
# Usage
Simply include the recipe where you want PHP-FPM installed. Default pool **www** will be created. To disable pool creation set default['php-fpm']['pools'] to false.
To customize settings and pools you can override default attributes.
## Usage in roles:
```ruby
name "php-fpm"
description "php fpm role"
run_list "recipe[php-fpm]"
override_attributes "php-fpm" => {
"pools" => {
"default" => {
:enable => true
},
"www" => {
:enable => "true",
:cookbook => "another-cookbook",
:process_manager => "dynamic",
:max_requests => 5000,
:php_options => { 'php_admin_flag[log_errors]' => 'on', 'php_admin_value[memory_limit]' => '32M' }
}
}
}
```
# Creating pools in recipes
## Create PHP-FPM pool named 'www' with default settings:
```ruby
php_fpm_pool "www"
```
## Create PHP-FPM pool named 'www' with custom settings:
```ruby
php_fpm_pool "www" do
cookbook "another-cookbook" # get template from another cookbook
process_manager "dynamic"
max_requests 5000
php_options 'php_admin_flag[log_errors]' => 'on', 'php_admin_value[memory_limit]' => '32M'
end
```
## Delete PHP-FPM pool named 'www':
```ruby
php_fpm_pool "www" do
enable false
end
```
# Development
## Requirements
- [Docker](https://www.docker.com/)
## Setup
To get all dependencies:
```
bundle install
```
## Test
To see available platforms:
```
bundle exec rake -T
```
To test particular platform:
```
bundle exec rake kitchen:default-ubuntu-1604
```
To test all platforms:
```
bundle exec rake kitchen:all
```
## Publishing (maintainers only!)
Bump version in metadata.rb, commit and push to master!
```
bundle exec rake publish
```
as a result new tag will be created and pushed to github as well as new version will be published on <https://supermarket.chef.io>
# Contributing
Please do not bump version when proposing a change, no other rules ;)
# License and Author
Author:: Seth Chisamore ([schisamo@chef.io](mailto:schisamo@chef.io))
Copyright:: 2011-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.

View File

@ -1,71 +0,0 @@
case node['platform_family']
when 'rhel', 'fedora'
user = 'apache'
group = 'apache'
conf_dir = '/etc/php.d'
pool_conf_dir = '/etc/php-fpm.d'
conf_file = '/etc/php-fpm.conf'
error_log = '/var/log/php-fpm/error.log'
pid = '/var/run/php-fpm/php-fpm.pid'
else
user = 'www-data'
group = 'www-data'
if platform?('ubuntu') && node['platform_version'].to_f >= 16.04
php_conf_dir = '/etc/php/7.0'
php_fpm_name = 'php7.0-fpm'
else
php_conf_dir = '/etc/php5'
php_fpm_name = 'php5-fpm'
end
conf_dir = "#{php_conf_dir}/fpm/conf.d"
pool_conf_dir = "#{php_conf_dir}/fpm/pool.d"
conf_file = "#{php_conf_dir}/fpm/php-fpm.conf"
error_log = "/var/log/#{php_fpm_name}.log"
pid = "/var/run/#{php_fpm_name}.pid"
end
default['php-fpm']['user'] = user
default['php-fpm']['group'] = group
default['php-fpm']['conf_dir'] = conf_dir
default['php-fpm']['pool_conf_dir'] = pool_conf_dir
default['php-fpm']['conf_file'] = conf_file
default['php-fpm']['pid'] = pid
default['php-fpm']['log_dir'] = '/var/log/php-fpm'
default['php-fpm']['error_log'] = error_log
default['php-fpm']['log_level'] = 'notice'
default['php-fpm']['emergency_restart_threshold'] = 0
default['php-fpm']['emergency_restart_interval'] = 0
default['php-fpm']['process_control_timeout'] = 0
default['php-fpm']['process_manager'] = 'ondemand'
default['php-fpm']['max_children'] = 50
default['php-fpm']['start_servers'] = 5
default['php-fpm']['min_spare_servers'] = 5
default['php-fpm']['max_spare_servers'] = 35
default['php-fpm']['max_requests'] = 0
default['php-fpm']['request_terminate_timeout'] = 0
default['php-fpm']['catch_workers_output'] = 'no'
default['php-fpm']['security_limit_extensions'] = '.php'
default['php-fpm']['listen_mode'] = '0660'
default['php-fpm']['listen'] = '/var/run/php-fpm-%{pool_name}.sock'
default['php-fpm']['pools'] = {
'www' => {
enable: true,
},
}
default['php-fpm']['skip_repository_install'] = false
default['php-fpm']['installation_action'] = :install
default['php-fpm']['version'] = nil
case node['platform_family']
when 'rhel'
default['php-fpm']['yum_url'] = 'http://rpms.famillecollet.com/enterprise/$releasever/remi/$basearch/'
default['php-fpm']['yum_mirrorlist'] = 'http://rpms.famillecollet.com/enterprise/$releasever/remi/mirror'
when 'fedora'
default['php-fpm']['skip_repository_install'] = true
end
default['php-fpm']['dotdeb_repository']['uri'] = 'http://packages.dotdeb.org'
default['php-fpm']['dotdeb_repository']['key'] = 'http://www.dotdeb.org/dotdeb.gpg'
default['php-fpm']['dotdeb-php53_repository']['uri'] = 'http://php53.dotdeb.org'

View File

@ -1,65 +0,0 @@
#
# Cookbook Name:: php-fpm
# Definition:: php_fpm_pool
#
# Copyright 2008-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.
#
define :php_fpm_pool, template: 'pool.conf.erb', enable: true do
pool_name = params[:name]
conf_file = "#{node['php-fpm']['pool_conf_dir']}/#{pool_name}.conf"
if params[:enable]
template conf_file do
only_if "test -d #{node['php-fpm']['pool_conf_dir']} || mkdir -p #{node['php-fpm']['pool_conf_dir']}"
source params[:template]
owner 'root'
group 'root'
mode '0644'
cookbook params[:cookbook] || 'php-fpm'
variables(
pool_name: pool_name,
listen: params[:listen] || node['php-fpm']['listen'].gsub(/%{pool_name}/, pool_name),
listen_owner: params[:listen_owner] || node['php-fpm']['listen_owner'] || node['php-fpm']['user'],
listen_group: params[:listen_group] || node['php-fpm']['listen_group'] || node['php-fpm']['group'],
listen_mode: params[:listen_mode] || node['php-fpm']['listen_mode'],
allowed_clients: params[:allowed_clients],
user: params[:user] || node['php-fpm']['user'],
group: params[:group] || node['php-fpm']['group'],
process_manager: params[:process_manager] || node['php-fpm']['process_manager'],
max_children: params[:max_children] || node['php-fpm']['max_children'],
start_servers: params[:start_servers] || node['php-fpm']['start_servers'],
min_spare_servers: params[:min_spare_servers] || node['php-fpm']['min_spare_servers'],
max_spare_servers: params[:max_spare_servers] || node['php-fpm']['max_spare_servers'],
max_requests: params[:max_requests] || node['php-fpm']['max_requests'],
catch_workers_output: params[:catch_workers_output] || node['php-fpm']['catch_workers_output'],
security_limit_extensions: params[:security_limit_extensions] || node['php-fpm']['security_limit_extensions'],
access_log: params[:access_log] || false,
slowlog: params[:slowlog] || false,
request_slowlog_timeout: params[:request_slowlog_timeout] || false,
php_options: params[:php_options] || {},
request_terminate_timeout: params[:request_terminate_timeout] || node['php-fpm']['request_terminate_timeout'],
params: params
)
notifies :restart, 'service[php-fpm]'
end
else
cookbook_file conf_file do
action :delete
notifies :restart, 'service[php-fpm]'
end
end
end

View File

@ -1 +0,0 @@
{"name":"php-fpm","version":"0.8.0","description":"Installs/Configures php-fpm","long_description":"[![Build Status](https://travis-ci.org/yevgenko/cookbook-php-fpm.svg?branch=master)](https://travis-ci.org/yevgenko/cookbook-php-fpm)\n\n# Description\n\nInstalls and configures PHP-FPM (FastCGI Process Manager), an alternative PHP FastCGI implementation with some additional features useful for sites of any size, especially busier sites. It's like the `unicorn` of the PHP world dawg.\n\n# Requirements\n\n## Platform\n\n- Debian, Ubuntu\n- CentOS, Red Hat, Fedora\n- Amazon Linux\n\n## Cookbooks\n\n- none\n\n## Chef\n\n- 12.14 or later\n\n# Description\n\nCreates a PHP-FPM configuration file at the path specified. Meant to be deployed with a service init scheme/supervisor such as runit. Please see the `application::php-fpm` recipe for a complete working example. In depth information about PHP-FPM's configuration values can be [found in the PHP-FPM documentation](http://php.net/manual/en/install.fpm.configuration.php).\n\n# Usage\n\nSimply include the recipe where you want PHP-FPM installed. Default pool **www** will be created. To disable pool creation set default['php-fpm']['pools'] to false.\n\nTo customize settings and pools you can override default attributes.\n\n## Usage in roles:\n\n```ruby\nname \"php-fpm\"\ndescription \"php fpm role\"\nrun_list \"recipe[php-fpm]\"\noverride_attributes \"php-fpm\" => {\n \"pools\" => {\n \"default\" => {\n :enable => true\n },\n \"www\" => {\n :enable => \"true\",\n :cookbook => \"another-cookbook\",\n :process_manager => \"dynamic\",\n :max_requests => 5000,\n :php_options => { 'php_admin_flag[log_errors]' => 'on', 'php_admin_value[memory_limit]' => '32M' }\n }\n }\n}\n```\n\n# Creating pools in recipes\n\n## Create PHP-FPM pool named 'www' with default settings:\n\n```ruby\nphp_fpm_pool \"www\"\n```\n\n## Create PHP-FPM pool named 'www' with custom settings:\n\n```ruby\nphp_fpm_pool \"www\" do\n cookbook \"another-cookbook\" # get template from another cookbook\n process_manager \"dynamic\"\n max_requests 5000\n php_options 'php_admin_flag[log_errors]' => 'on', 'php_admin_value[memory_limit]' => '32M'\nend\n```\n\n## Delete PHP-FPM pool named 'www':\n\n```ruby\nphp_fpm_pool \"www\" do\n enable false\nend\n```\n\n# Development\n\n## Requirements\n\n- [Docker](https://www.docker.com/)\n\n## Setup\n\nTo get all dependencies:\n\n```\nbundle install\n```\n\n## Test\n\nTo see available platforms:\n\n```\nbundle exec rake -T\n```\n\nTo test particular platform:\n\n```\nbundle exec rake kitchen:default-ubuntu-1604\n```\n\nTo test all platforms:\n\n```\nbundle exec rake kitchen:all\n```\n\n## Publishing (maintainers only!)\n\nBump version in metadata.rb, commit and push to master!\n\n```\nbundle exec rake publish\n```\n\nas a result new tag will be created and pushed to github as well as new version will be published on <https://supermarket.chef.io>\n\n# Contributing\n\nPlease do not bump version when proposing a change, no other rules ;)\n\n# License and Author\n\nAuthor:: Seth Chisamore ([schisamo@chef.io](mailto:schisamo@chef.io))\n\nCopyright:: 2011-2017, Chef Software, Inc\n\nLicensed 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\n\n```\nhttp://www.apache.org/licenses/LICENSE-2.0\n```\n\nUnless 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.\n","maintainer":"Chef Software, Inc.","maintainer_email":"cookbooks@chef.io","license":"Apache-2.0","platforms":{"debian":">= 0.0.0","ubuntu":">= 0.0.0","centos":">= 0.0.0","redhat":">= 0.0.0","fedora":">= 0.0.0","amazon":">= 0.0.0","oracle":">= 0.0.0","scientific":">= 0.0.0"},"dependencies":{},"recommendations":{},"suggestions":{},"conflicting":{},"providing":{},"replacing":{},"attributes":{},"groupings":{},"recipes":{},"source_url":"https://github.com/yevgenko/cookbook-php-fpm","issues_url":"https://github.com/yevgenko/cookbook-php-fpm/issues","chef_version":[[">= 12.14"]],"ohai_version":[]}

View File

@ -1,43 +0,0 @@
#
# Author:: Seth Chisamore (<schisamo@chef.io>)
# Cookbook Name:: php-fpm
# Recipe:: package
#
# Copyright 2011-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.
#
template node['php-fpm']['conf_file'] do
source 'php-fpm.conf.erb'
mode 00644
owner 'root'
group 'root'
notifies :restart, 'service[php-fpm]'
end
if node['php-fpm']['pools']
node['php-fpm']['pools'].each do |pool|
if pool.is_a?(Array)
pool_name = pool[0]
pool = pool[1]
else
pool_name = pool[:name]
end
php_fpm_pool pool_name do
pool.each do |k, v|
params[k.to_sym] = v
end
end
end
end

View File

@ -1,22 +0,0 @@
#
# Author:: Seth Chisamore (<schisamo@opscode.com>)
# Cookbook Name:: php-fpm
# Recipe:: default
#
# Copyright 2011-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.
#
include_recipe 'php-fpm::install'
include_recipe 'php-fpm::configure'

View File

@ -1,59 +0,0 @@
#
# Author:: Seth Chisamore (<schisamo@opscode.com>)
# Cookbook Name:: php-fpm
# Recipe:: package
#
# Copyright 2011-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.
#
include_recipe 'php-fpm::repository' unless node['php-fpm']['skip_repository_install']
php_fpm_package_name = if node['php-fpm']['package_name'].nil?
if platform_family?('rhel', 'fedora')
'php-fpm'
elsif platform?('ubuntu') && node['platform_version'].to_f >= 16.04
'php7.0-fpm'
else
'php5-fpm'
end
else
node['php-fpm']['package_name']
end
package php_fpm_package_name do
action node['php-fpm']['installation_action']
version node['php-fpm']['version'] if node['php-fpm']['version']
end
php_fpm_service_name = if node['php-fpm']['service_name'].nil?
php_fpm_package_name
else
node['php-fpm']['service_name']
end
service_provider = nil
# this is actually already done in chef, but is kept here for older chef releases
if platform?('ubuntu') && node['platform_version'].to_f.between?(13.10, 14.10)
service_provider = ::Chef::Provider::Service::Upstart
end
directory node['php-fpm']['log_dir']
service 'php-fpm' do
provider service_provider if service_provider
service_name php_fpm_service_name
supports start: true, stop: true, restart: true, reload: true
action [:enable, :start]
end

View File

@ -1,54 +0,0 @@
#
# Author:: Seth Chisamore (<schisamo@opscode.com>)
# Cookbook Name:: php-fpm
# Recipe:: package
#
# Copyright 2011-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']
when 'debian'
# Configure Dotdeb repos
# TODO: move this to it's own 'dotdeb' cookbook?
# http://www.dotdeb.org/instructions/
if node['platform_version'].to_f >= 8.0
apt_repository 'dotdeb' do
uri node['php-fpm']['dotdeb_repository']['uri']
distribution 'jessie'
components ['all']
key node['php-fpm']['dotdeb_repository']['key']
action :add
end
elsif node['platform_version'].to_f >= 7.0
apt_repository 'dotdeb' do
uri node['php-fpm']['dotdeb_repository']['uri']
distribution 'wheezy'
components ['all']
key node['php-fpm']['dotdeb_repository']['key']
action :add
end
end
when 'amazon', 'fedora', 'centos', 'redhat', 'scientific', 'oracle'
unless platform?('centos', 'redhat') && node['platform_version'].to_f >= 6.4 # ~FC024
yum_repository 'remi' do
description 'Remi'
url node['php-fpm']['yum_url']
mirrorlist node['php-fpm']['yum_mirrorlist']
gpgkey 'http://rpms.famillecollet.com/RPM-GPG-KEY-remi'
action :add
end
end
end

View File

@ -1,3 +0,0 @@
include_recipe 'php-fpm::default'
package 'net-tools'

View File

@ -1,60 +0,0 @@
;;;;;;;;;;;;;;;;;;;;;
; FPM Configuration ;
;;;;;;;;;;;;;;;;;;;;;
; All relative paths in this configuration file are relative to PHP's install
; prefix.
; Include one or more files. If glob(3) exists, it is used to include a bunch of
; files from a glob(3) pattern. This directive can be used everywhere in the
; file.
include = <%= "#{node['php-fpm']['pool_conf_dir']}/*.conf" %>
;;;;;;;;;;;;;;;;;;
; Global Options ;
;;;;;;;;;;;;;;;;;;
[global]
; Pid file
; Default Value: none
pid = <%= node['php-fpm']['pid'] %>
; Error log file
; Default Value: /var/log/php-fpm.log
error_log = <%= node['php-fpm']['error_log'] %>
; Log level
; Possible Values: alert, error, warning, notice, debug
; Default Value: notice
log_level = <%= node['php-fpm']['log_level'] %>
; If this number of child processes exit with SIGSEGV or SIGBUS within the time
; interval set by emergency_restart_interval then FPM will restart. A value
; of '0' means 'Off'.
; Default Value: 0
emergency_restart_threshold = <%= node['php-fpm']['emergency_restart_threshold'] %>
; Interval of time used by emergency_restart_interval to determine when
; a graceful restart will be initiated. This can be useful to work around
; accidental corruptions in an accelerator's shared memory.
; Available Units: s(econds), m(inutes), h(ours), or d(ays)
; Default Unit: seconds
; Default Value: 0
emergency_restart_interval = <%= node['php-fpm']['emergency_restart_interval'] %>
; Time limit for child processes to wait for a reaction on signals from master.
; Available units: s(econds), m(inutes), h(ours), or d(ays)
; Default Unit: seconds
; Default Value: 0
process_control_timeout = <%= node['php-fpm']['process_control_timeout'] %>
; Send FPM to background. Set to 'no' to keep FPM in foreground for debugging.
; Default Value: yes
daemonize = yes
;;;;;;;;;;;;;;;;;;;;
; Pool Definitions ;
;;;;;;;;;;;;;;;;;;;;
; See <%= "#{node['php-fpm']['pool_conf_dir']}/*.conf" %>

View File

@ -1,424 +0,0 @@
; Start a new pool named '<%= @pool_name %>'.
; the variable $pool can we used in any directive and will be replaced by the
; pool name ('<%= @pool_name %>' here)
[<%= @pool_name %>]
; Per pool prefix
; It only applies on the following directives:
; - 'slowlog'
; - 'listen' (unixsocket)
; - 'chroot'
; - 'chdir'
; - 'php_values'
; - 'php_admin_values'
; When not set, the global prefix (or /usr) applies instead.
; Note: This directive can also be relative to the global prefix.
; Default Value: none
;prefix = /path/to/pools/$pool
; Unix user/group of processes
; Note: The user is mandatory. If the group is not set, the default user's group
; will be used.
user = <%= @user %>
group = <%= @group %>
; The address on which to accept FastCGI requests.
; Valid syntaxes are:
; 'ip.add.re.ss:port' - to listen on a TCP socket to a specific address on
; a specific port;
; 'port' - to listen on a TCP socket to all addresses on a
; specific port;
; '/path/to/unix/socket' - to listen on a unix socket.
; Note: This value is mandatory.
listen = <%= @listen %>
; Set listen(2) backlog.
; Default Value: 128 (-1 on FreeBSD and OpenBSD)
;listen.backlog = 128
; Set permissions for unix socket, if one is used. In Linux, read/write
; permissions must be set in order to allow connections from a web server. Many
; BSD-derived systems allow connections regardless of permissions.
; Default Values: user and group are set as the running user
; mode is set to 0666
;listen.owner = nobody
<% unless @listen_owner.nil? %>
listen.owner = <%= @listen_owner %>
<% end %>
;listen.group = nobody
<% unless @listen_group.nil? %>
listen.group = <%= @listen_group %>
<% end %>
listen.mode = <%= @listen_mode %>
; List of ipv4 addresses of FastCGI clients which are allowed to connect.
; Equivalent to the FCGI_WEB_SERVER_ADDRS environment variable in the original
; PHP FCGI (5.2.2+). Makes sense only with a tcp listening socket. Each address
; must be separated by a comma. If this value is left blank, connections will be
; accepted from any ip address.
; Default Value: any
listen.allowed_clients = <%= @allowed_clients ? ([@allowed_clients].flatten.join(',')) : "127.0.0.1" %>
; Specify the nice(2) priority to apply to the pool processes (only if set)
; The value can vary from -19 (highest priority) to 20 (lower priority)
; Note: - It will only work if the FPM master process is launched as root
; - The pool processes will inherit the master process priority
; unless it specified otherwise
; Default Value: no set
; priority = -19
; Choose how the process manager will control the number of child processes.
; Possible Values:
; static - a fixed number (pm.max_children) of child processes;
; dynamic - the number of child processes are set dynamically based on the
; following directives. With this process management, there will be
; always at least 1 children.
; pm.max_children - the maximum number of children that can
; be alive at the same time.
; pm.start_servers - the number of children created on startup.
; pm.min_spare_servers - the minimum number of children in 'idle'
; state (waiting to process). If the number
; of 'idle' processes is less than this
; number then some children will be created.
; pm.max_spare_servers - the maximum number of children in 'idle'
; state (waiting to process). If the number
; of 'idle' processes is greater than this
; number then some children will be killed.
; ondemand - no children are created at startup. Children will be forked when
; new requests will connect. The following parameter are used:
; pm.max_children - the maximum number of children that
; can be alive at the same time.
; pm.process_idle_timeout - The number of seconds after which
; an idle process will be killed.
; Note: This value is mandatory.
pm = <%= @process_manager %>
; The number of child processes to be created when pm is set to 'static' and the
; maximum number of child processes when pm is set to 'dynamic' or 'ondemand'.
; This value sets the limit on the number of simultaneous requests that will be
; served. Equivalent to the ApacheMaxClients directive with mpm_prefork.
; Equivalent to the PHP_FCGI_CHILDREN environment variable in the original PHP
; CGI. The below defaults are based on a server without much resources. Don't
; forget to tweak pm.* to fit your needs.
; Note: Used when pm is set to 'static', 'dynamic' or 'ondemand'
; Note: This value is mandatory.
pm.max_children = <%= @max_children %>
<% if @process_manager == "dynamic" %>
; The number of child processes created on startup.
; Note: Used only when pm is set to 'dynamic'
; Default Value: min_spare_servers + (max_spare_servers - min_spare_servers) / 2
<% if @start_servers %>
pm.start_servers = <%= @start_servers %>
<% end %>
; The desired minimum number of idle server processes.
; Note: Used only when pm is set to 'dynamic'
; Note: Mandatory when pm is set to 'dynamic'
pm.min_spare_servers = <%= @min_spare_servers %>
; The desired maximum number of idle server processes.
; Note: Used only when pm is set to 'dynamic'
; Note: Mandatory when pm is set to 'dynamic'
pm.max_spare_servers = <%= @max_spare_servers %>
<% end %>
<% if @process_manager == "ondemand" %>
; The number of seconds after which an idle process will be killed.
; Note: Used only when pm is set to 'ondemand'
; Default Value: 10s
;pm.process_idle_timeout = 10s;
<% end %>
; The number of requests each child process should execute before respawning.
; This can be useful to work around memory leaks in 3rd party libraries. For
; endless request processing specify '0'. Equivalent to PHP_FCGI_MAX_REQUESTS.
; Default Value: 0
pm.max_requests = <%= @max_requests %>
; The URI to view the FPM status page. If this value is not set, no URI will be
; recognized as a status page. It shows the following informations:
; pool - the name of the pool;
; process manager - static, dynamic or ondemand;
; start time - the date and time FPM has started;
; start since - number of seconds since FPM has started;
; accepted conn - the number of request accepted by the pool;
; listen queue - the number of request in the queue of pending
; connections (see backlog in listen(2));
; max listen queue - the maximum number of requests in the queue
; of pending connections since FPM has started;
; listen queue len - the size of the socket queue of pending connections;
; idle processes - the number of idle processes;
; active processes - the number of active processes;
; total processes - the number of idle + active processes;
; max active processes - the maximum number of active processes since FPM
; has started;
; max children reached - number of times, the process limit has been reached,
; when pm tries to start more children (works only for
; pm 'dynamic' and 'ondemand');
; Value are updated in real time.
; Example output:
; pool: www
; process manager: static
; start time: 01/Jul/2011:17:53:49 +0200
; start since: 62636
; accepted conn: 190460
; listen queue: 0
; max listen queue: 1
; listen queue len: 42
; idle processes: 4
; active processes: 11
; total processes: 15
; max active processes: 12
; max children reached: 0
;
; By default the status page output is formatted as text/plain. Passing either
; 'html', 'xml' or 'json' in the query string will return the corresponding
; output syntax. Example:
; http://www.foo.bar/status
; http://www.foo.bar/status?json
; http://www.foo.bar/status?html
; http://www.foo.bar/status?xml
;
; By default the status page only outputs short status. Passing 'full' in the
; query string will also return status for each pool process.
; Example:
; http://www.foo.bar/status?full
; http://www.foo.bar/status?json&full
; http://www.foo.bar/status?html&full
; http://www.foo.bar/status?xml&full
; The Full status returns for each process:
; pid - the PID of the process;
; state - the state of the process (Idle, Running, ...);
; start time - the date and time the process has started;
; start since - the number of seconds since the process has started;
; requests - the number of requests the process has served;
; request duration - the duration in ms of the requests;
; request method - the request method (GET, POST, ...);
; request URI - the request URI with the query string;
; content length - the content length of the request (only with POST);
; user - the user (PHP_AUTH_USER) (or '-' if not set);
; script - the main script called (or '-' if not set);
; last request cpu - the %cpu the last request consumed
; it's always 0 if the process is not in Idle state
; because CPU calculation is done when the request
; processing has terminated;
; last request memory - the max amount of memory the last request consumed
; it's always 0 if the process is not in Idle state
; because memory calculation is done when the request
; processing has terminated;
; If the process is in Idle state, then informations are related to the
; last request the process has served. Otherwise informations are related to
; the current request being served.
; Example output:
; ************************
; pid: 31330
; state: Running
; start time: 01/Jul/2011:17:53:49 +0200
; start since: 63087
; requests: 12808
; request duration: 1250261
; request method: GET
; request URI: /test_mem.php?N=10000
; content length: 0
; user: -
; script: /home/fat/web/docs/php/test_mem.php
; last request cpu: 0.00
; last request memory: 0
;
; Note: There is a real-time FPM status monitoring sample web page available
; It's available in: ${prefix}/share/fpm/status.html
;
; Note: The value must start with a leading slash (/). The value can be
; anything, but it may not be a good idea to use the .php extension or it
; may conflict with a real PHP file.
; Default Value: not set
;pm.status_path = /status
; The ping URI to call the monitoring page of FPM. If this value is not set, no
; URI will be recognized as a ping page. This could be used to test from outside
; that FPM is alive and responding, or to
; - create a graph of FPM availability (rrd or such);
; - remove a server from a group if it is not responding (load balancing);
; - trigger alerts for the operating team (24/7).
; Note: The value must start with a leading slash (/). The value can be
; anything, but it may not be a good idea to use the .php extension or it
; may conflict with a real PHP file.
; Default Value: not set
;ping.path = /ping
; This directive may be used to customize the response of a ping request. The
; response is formatted as text/plain with a 200 response code.
; Default Value: pong
;ping.response = pong
; The access log file
; Default: not set
<% if @access_log %>
access.log = <%= node['php-fpm']['log_dir'] %>/$pool.access.log
<% end %>
; The access log format.
; The following syntax is allowed
; %%: the '%' character
; %C: %CPU used by the request
; it can accept the following format:
; - %{user}C for user CPU only
; - %{system}C for system CPU only
; - %{total}C for user + system CPU (default)
; %d: time taken to serve the request
; it can accept the following format:
; - %{seconds}d (default)
; - %{miliseconds}d
; - %{mili}d
; - %{microseconds}d
; - %{micro}d
; %e: an environment variable (same as $_ENV or $_SERVER)
; it must be associated with embraces to specify the name of the env
; variable. Some exemples:
; - server specifics like: %{REQUEST_METHOD}e or %{SERVER_PROTOCOL}e
; - HTTP headers like: %{HTTP_HOST}e or %{HTTP_USER_AGENT}e
; %f: script filename
; %l: content-length of the request (for POST request only)
; %m: request method
; %M: peak of memory allocated by PHP
; it can accept the following format:
; - %{bytes}M (default)
; - %{kilobytes}M
; - %{kilo}M
; - %{megabytes}M
; - %{mega}M
; %n: pool name
; %o: output header
; it must be associated with embraces to specify the name of the header:
; - %{Content-Type}o
; - %{X-Powered-By}o
; - %{Transfert-Encoding}o
; - ....
; %p: PID of the child that serviced the request
; %P: PID of the parent of the child that serviced the request
; %q: the query string
; %Q: the '?' character if query string exists
; %r: the request URI (without the query string, see %q and %Q)
; %R: remote IP address
; %s: status (response code)
; %t: server time the request was received
; it can accept a strftime(3) format:
; %d/%b/%Y:%H:%M:%S %z (default)
; %T: time the log has been written (the request has finished)
; it can accept a strftime(3) format:
; %d/%b/%Y:%H:%M:%S %z (default)
; %u: remote user
;
; Default: "%R - %u %t \"%m %r\" %s"
;access.format = "%R - %u %t \"%m %r%Q%q\" %s %f %{mili}d %{kilo}M %C%%"
; The log file for slow requests
; Default Value: not set
; Note: slowlog is mandatory if request_slowlog_timeout is set
<% if @slowlog %>
slowlog = <%= @slowlog %>
<% else %>
;slowlog = log/$pool.log.slow
<% end %>
; The timeout for serving a single request after which a PHP backtrace will be
; dumped to the 'slowlog' file. A value of '0s' means 'off'.
; Available units: s(econds)(default), m(inutes), h(ours), or d(ays)
; Default Value: 0
<% if @request_slowlog_timeout %>
request_slowlog_timeout = <%=@request_slowlog_timeout %>
<% else %>
;request_slowlog_timeout = 0
<% end %>
; The timeout for serving a single request after which the worker process will
; be killed. This option should be used when the 'max_execution_time' ini option
; does not stop script execution for some reason. A value of '0' means 'off'.
; Available units: s(econds)(default), m(inutes), h(ours), or d(ays)
; Default Value: 0
request_terminate_timeout = <%=@request_terminate_timeout %>
; Set open file descriptor rlimit.
; Default Value: system defined value
;rlimit_files = 1024
; Set max core size rlimit.
; Possible Values: 'unlimited' or an integer greater or equal to 0
; Default Value: system defined value
;rlimit_core = 0
; Chroot to this directory at the start. This value must be defined as an
; absolute path. When this value is not set, chroot is not used.
; Note: you can prefix with '$prefix' to chroot to the pool prefix or one
; of its subdirectories. If the pool prefix is not set, the global prefix
; will be used instead.
; Note: chrooting is a great security feature and should be used whenever
; possible. However, all PHP paths will be relative to the chroot
; (error_log, sessions.save_path, ...).
; Default Value: not set
;chroot =
; Chdir to this directory at the start.
; Note: relative path can be used.
; Default Value: current directory or / when chroot
;chdir = /
; Redirect worker stdout and stderr into main error log. If not set, stdout and
; stderr will be redirected to /dev/null according to FastCGI specs.
; Note: on highloaded environement, this can cause some delay in the page
; process time (several ms).
; Default Value: no
catch_workers_output = <%= @catch_workers_output %>
<% if node['platform'] != 'ubuntu' && node['platform_version'] != '10.04' %>
; Limits the extensions of the main script FPM will allow to parse. This can
; prevent configuration mistakes on the web server side. You should only limit
; FPM to .php extensions to prevent malicious users to use other extensions to
; exectute php code.
; Note: set an empty value to allow all extensions.
; Default Value: .php
;security.limit_extensions = .php .php3 .php4 .php5
security.limit_extensions = <%=@security_limit_extensions %>
<% end %>
; Pass environment variables like LD_LIBRARY_PATH. All $VARIABLEs are taken from
; the current environment.
; Default Value: clean env
;env[HOSTNAME] = $HOSTNAME
;env[PATH] = /usr/local/bin:/usr/bin:/bin
;env[TMP] = /tmp
;env[TMPDIR] = /tmp
;env[TEMP] = /tmp
; Additional php.ini defines, specific to this pool of workers. These settings
; overwrite the values previously defined in the php.ini. The directives are the
; same as the PHP SAPI:
; php_value/php_flag - you can set classic ini defines which can
; be overwritten from PHP call 'ini_set'.
; php_admin_value/php_admin_flag - these directives won't be overwritten by
; PHP call 'ini_set'
; For php_*flag, valid values are on, off, 1, 0, true, false, yes or no.
; Defining 'extension' will load the corresponding shared extension from
; extension_dir. Defining 'disable_functions' or 'disable_classes' will not
; overwrite previously defined php.ini values, but will append the new value
; instead.
; Note: path INI options can be relative and will be expanded with the prefix
; (pool, global or /usr)
; Default Value: nothing is defined by default except the values in php.ini and
; specified at startup with the -d argument
;php_admin_value[sendmail_path] = /usr/sbin/sendmail -t -i -f www@my.domain.com
;php_flag[display_errors] = off
;php_admin_value[error_log] = /var/log/fpm-php.www.log
;php_admin_flag[log_errors] = on
;php_admin_value[memory_limit] = 32M
<% @php_options.each do |name,value| %>
<%= "#{name} = #{value}" %>
<% end %>

View File

@ -1,6 +1,38 @@
# php Cookbook CHANGELOG
# PHP Cookbook CHANGELOG
This file is used to list changes made in each version of the php cookbook.
This file is used to list changes made in each version of the PHP cookbook.
## 8.0.0 (2020-07-09)
- Drop support for:
- Debian 8
- Ubuntu < 16.04
- Amazon Linux 1
- Set default PHP version to 7.2.x
- Update Ubuntu 18.04 support to source build PHP 7.2
- Update attributes for Debian 10
- Add support for Ubuntu 20.04
- Only symlink GMP on Ubuntu 16.04 to aid source builds
- Drop support for installing from source on Debian 9
## 7.2.0 (2020-06-19)
- Include extension priority on the specified format to the extension file
## 7.1.0 (2020-05-05)
- Split out resource documentation into the documentation folder
- Run cookstyle 0.75.1
- Fix dependency problem with installing php from source on ubuntu 18.04
- Simplify platform checks
- Remove unused long_description metadata from metadata.rb
- Migrated to Github Actions for testing
- Adding control of php-fpm php.ini with specific attribute
## 7.0.0 (2019-08-07)
- *Drop support for Chef 13* so we don't need to require build essentials
- Sync php.ini template with php.ini-production from php-7.2.18
## 6.1.1 (2018-08-07)
@ -42,7 +74,7 @@ This release removes the previous recipes in this cookbook for setting up variou
- 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
- 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

View File

@ -1,2 +1,4 @@
# Contributing
Please refer to
https://github.com/chef-cookbooks/community_cookbook_documentation/blob/master/CONTRIBUTING.MD
[https://github.com/chef-cookbooks/community_cookbook_documentation/blob/master/CONTRIBUTING.MD](https://github.com/chef-cookbooks/community_cookbook_documentation/blob/master/CONTRIBUTING.MD)

View File

@ -1,9 +1,17 @@
# 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)
[![Cookbook Version](https://img.shields.io/cookbook/v/php.svg)](https://supermarket.chef.io/cookbooks/php)
[![Build Status](https://img.shields.io/circleci/project/github/sous-chefs/php/master.svg)](https://circleci.com/gh/sous-chefs/php)
[![OpenCollective](https://opencollective.com/sous-chefs/backers/badge.svg)](#backers)
[![OpenCollective](https://opencollective.com/sous-chefs/sponsors/badge.svg)](#sponsors)
[![License](https://img.shields.io/badge/License-Apache%202.0-green.svg)](https://opensource.org/licenses/Apache-2.0)
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.
## Maintainers
This cookbook is maintained by the Sous Chefs. The Sous Chefs are a community of Chef cookbook maintainers working together to maintain important cookbooks. If youd like to know more please visit [sous-chefs.org](https://sous-chefs.org/) or come chat with us on the Chef Community Slack in [#sous-chefs](https://chefcommunity.slack.com/messages/C2V7B88SF).
## Requirements
### Platforms
@ -14,18 +22,14 @@ It installs and configures PHP and the PEAR package management system. Also incl
### Chef
- Chef 12.7+
### Cookbooks
- build-essential
- Chef 14+
## 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']`
- `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:
@ -36,175 +40,9 @@ The file also contains the following attribute types:
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
```
- [php_pear](https://github.com/sous-chefs/php/tree/master/documentation/php_pear.md)
- [php_pear_channel](https://github.com/sous-chefs/php/tree/master/documentation/php_pear_channel.md)
- [php_fpm_pool](https://github.com/sous-chefs/php/tree/master/documentation/php_fpm_pool.md)
## Recipes
@ -220,11 +58,13 @@ This recipe installs PHP from packages.
This recipe installs PHP from source.
*Note:* Debian 9 is not supported for building 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:
### Role example
```ruby
name 'php'
@ -239,25 +79,27 @@ run_list(
)
```
## Maintainers
## Contributors
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/)
This project exists thanks to all the people who [contribute.](https://opencollective.com/sous-chefs/contributors.svg?width=890&button=false)
## License
### Backers
**Copyright:** 2011-2018, Chef Software, Inc.
**Copyright:** 2018, Oracle and/or its affiliates. All rights reserved
Thank you to all our backers!
```
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
![https://opencollective.com/sous-chefs#backers](https://opencollective.com/sous-chefs/backers.svg?width=600&avatarHeight=40)
http://www.apache.org/licenses/LICENSE-2.0
### Sponsors
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.
```
Support this project by becoming a sponsor. Your logo will show up here with a link to your website.
![https://opencollective.com/sous-chefs/sponsor/0/website](https://opencollective.com/sous-chefs/sponsor/0/avatar.svg?avatarHeight=100)
![https://opencollective.com/sous-chefs/sponsor/1/website](https://opencollective.com/sous-chefs/sponsor/1/avatar.svg?avatarHeight=100)
![https://opencollective.com/sous-chefs/sponsor/2/website](https://opencollective.com/sous-chefs/sponsor/2/avatar.svg?avatarHeight=100)
![https://opencollective.com/sous-chefs/sponsor/3/website](https://opencollective.com/sous-chefs/sponsor/3/avatar.svg?avatarHeight=100)
![https://opencollective.com/sous-chefs/sponsor/4/website](https://opencollective.com/sous-chefs/sponsor/4/avatar.svg?avatarHeight=100)
![https://opencollective.com/sous-chefs/sponsor/5/website](https://opencollective.com/sous-chefs/sponsor/5/avatar.svg?avatarHeight=100)
![https://opencollective.com/sous-chefs/sponsor/6/website](https://opencollective.com/sous-chefs/sponsor/6/avatar.svg?avatarHeight=100)
![https://opencollective.com/sous-chefs/sponsor/7/website](https://opencollective.com/sous-chefs/sponsor/7/avatar.svg?avatarHeight=100)
![https://opencollective.com/sous-chefs/sponsor/8/website](https://opencollective.com/sous-chefs/sponsor/8/avatar.svg?avatarHeight=100)
![https://opencollective.com/sous-chefs/sponsor/9/website](https://opencollective.com/sous-chefs/sponsor/9/avatar.svg?avatarHeight=100)

View File

@ -18,13 +18,14 @@
#
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']['version'] = '7.2.31'
default['php']['pear'] = '/usr/bin/pear'
default['php']['pear_setup'] = true
@ -33,20 +34,23 @@ default['php']['pear_channels'] = [
'pecl.php.net',
]
default['php']['url'] = 'http://us1.php.net/get'
default['php']['checksum'] = '8bc7d93e4c840df11e3d9855dcad15c1b7134e8acf0cf3b90b932baea2d0bde2'
default['php']['url'] = 'https://www.php.net/distributions'
default['php']['checksum'] = '796837831ccebf00dc15921ed327cfbac59177da41b33044d9a6c7134cdd250c' # checksum of the .tar.gz files
default['php']['prefix_dir'] = '/usr/local'
default['php']['enable_mod'] = '/usr/sbin/php5enmod'
default['php']['disable_mod'] = '/usr/sbin/php5dismod'
default['php']['enable_mod'] = '/usr/sbin/phpenmod'
default['php']['disable_mod'] = '/usr/sbin/phpdismod'
default['php']['ini']['template'] = 'php.ini.erb'
default['php']['ini']['cookbook'] = 'php'
default['php']['fpm_socket'] = '/var/run/php5-fpm.sock'
default['php']['fpm_socket'] = '/var/run/php7.2-fpm.sock'
default['php']['fpm_conf_dir'] = nil
default['php']['fpm_ini_control'] = false
case node['platform_family']
when 'rhel', 'fedora', 'amazon'
when 'rhel', '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'
@ -54,21 +58,14 @@ 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 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)
default['php']['fpm_package'] = 'php-fpm'
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']['src_deps'] = if platform?('amazon') || node['platform_version'].to_i < 8
%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)
else # redhat does not name their packages with version on RHEL 6+
%w(bzip2-devel libc-client-devel curl-devel freetype-devel gmp-devel libjpeg-devel krb5-devel libmcrypt-devel libpng-devel openssl-devel libxml2-devel libxslt-devel zlib-devel mhash-devel)
end
default['php']['packages'] = %w(php php-devel php-cli php-pear)
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'
@ -79,86 +76,73 @@ when 'rhel', 'fedora', 'amazon'
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']['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 libjpeg-dev libkrb5-dev libmcrypt-dev libpng-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']['disable_mod'] = '/usr/sbin/phpdismod'
default['php']['enable_mod'] = '/usr/sbin/phpenmod'
default['php']['fpm_default_conf'] = '/etc/php/7.0/fpm/pool.d/www.conf'
default['php']['fpm_conf_dir'] = '/etc/php/7.0/fpm'
default['php']['ext_conf_dir'] = '/etc/php/7.0/mods-available'
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_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'
if platform?('debian') && node['platform_version'].to_i >= 10
default['php']['version'] = '7.3.19'
default['php']['checksum'] = '809126b46d62a1a06c2d5a0f9d7ba61aba40e165f24d2d185396d0f9646d3280'
default['php']['conf_dir'] = '/etc/php/7.3/cli'
default['php']['src_deps'] = %w(libbz2-dev libc-client2007e-dev libcurl4-gnutls-dev libfreetype6-dev libgmp3-dev libjpeg62-turbo-dev libkrb5-dev libmcrypt-dev libpng-dev libssl-dev pkg-config libxml2-dev file re2c libzip-dev)
# Debian >= 10 drops versions from the package names
default['php']['packages'] = %w(php-cgi php php-dev php-cli php-pear)
default['php']['fpm_package'] = 'php7.3-fpm'
default['php']['fpm_pooldir'] = '/etc/php/7.3/fpm/pool.d'
default['php']['fpm_service'] = 'php7.3-fpm'
default['php']['fpm_socket'] = '/var/run/php/php7.3-fpm.sock'
default['php']['fpm_default_conf'] = '/etc/php/7.3/fpm/pool.d/www.conf'
default['php']['fpm_conf_dir'] = '/etc/php/7.3/fpm'
default['php']['ext_conf_dir'] = '/etc/php/7.3/mods-available'
elsif platform?('ubuntu') && node['platform_version'].to_f == 18.04
default['php']['version'] = '7.2.31'
default['php']['checksum'] = '796837831ccebf00dc15921ed327cfbac59177da41b33044d9a6c7134cdd250c'
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']['src_deps'] = %w(libbz2-dev libc-client2007e-dev libcurl4-gnutls-dev libfreetype6-dev libgmp3-dev libjpeg62-dev libkrb5-dev libmcrypt-dev libpng-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']['fpm_conf_dir'] = '/etc/php/7.2/fpm'
default['php']['ext_conf_dir'] = '/etc/php/7.2/mods-available'
elsif platform?('ubuntu') && node['platform_version'].to_f >= 20.04
default['php']['version'] = '7.4.7'
default['php']['checksum'] = 'a554a510190e726ebe7157fb00b4aceabdb50c679430510a3b93cbf5d7546e44'
default['php']['conf_dir'] = '/etc/php/7.4/cli'
default['php']['src_deps'] = %w(libbz2-dev libc-client2007e-dev libcurl4-gnutls-dev libfreetype6-dev libgmp3-dev libjpeg62-dev libkrb5-dev libmcrypt-dev libpng-dev libssl-dev pkg-config libxml2-dev libsqlite3-dev libonig-dev)
# Ubuntu >= 20.04 drops versions from the package names
default['php']['packages'] = %w(php-cgi php php-dev php-cli php-pear)
default['php']['fpm_package'] = 'php7.4-fpm'
default['php']['fpm_pooldir'] = '/etc/php/7.4/fpm/pool.d'
default['php']['fpm_service'] = 'php7.4-fpm'
default['php']['fpm_socket'] = '/var/run/php/php7.4-fpm.sock'
default['php']['fpm_default_conf'] = '/etc/php/7.4/fpm/pool.d/www.conf'
default['php']['fpm_conf_dir'] = '/etc/php/7.4/fpm'
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'
default['php']['ext_conf_dir'] = '/etc/php/7.4/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']['src_recompile'] = false
default['php']['configure_options'] = %W(--prefix=#{node['php']['prefix_dir']}
--with-libdir=#{lib_dir}
--with-config-file-path=#{node['php']['conf_dir']}

File diff suppressed because one or more lines are too long

View File

@ -18,6 +18,26 @@
# limitations under the License.
#
if node['php']['fpm_ini_control']
service node['php']['fpm_service'] do
action :enable
end
template "#{node['php']['fpm_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'])
notifies :restart, "service[#{node['php']['fpm_service']}]"
not_if { node['php']['fpm_conf_dir'].nil? }
end
end
template "#{node['php']['conf_dir']}/php.ini" do
source node['php']['ini']['template']
cookbook node['php']['ini']['cookbook']

View File

@ -19,16 +19,8 @@
# 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
package node['php']['packages'] do
options node['php']['package_options']
end
include_recipe 'php::ini'

View File

@ -18,34 +18,6 @@
# 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.default['php']['src_recompile'] = true
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
include_recipe 'php::source'

View File

@ -18,20 +18,41 @@
# limitations under the License.
#
configure_options = node['php']['configure_options'].join(' ')
if platform?('debian') && node['platform_version'].to_i == 9
Chef::Log.fatal 'Debian 9 is not supported when building from source'
end
build_essential 'install compilation tools'
include_recipe 'yum-epel' if node['platform_family'] == 'rhel'
version = node['php']['version']
configure_options = node['php']['configure_options'].join(' ')
ext_dir_prefix = node['php']['ext_dir'] ? "EXTENSION_DIR=#{node['php']['ext_dir']}" : ''
php_exists = if node['php']['src_recompile']
false
else
"$(which #{node['php']['bin']}) --version | grep #{version}"
end
build_essential
include_recipe 'yum-epel' if platform_family?('rhel', 'amazon')
package node['php']['src_deps']
version = node['php']['version']
log "php_exists == #{php_exists}"
remote_file "#{Chef::Config[:file_cache_path]}/php-#{version}.tar.gz" do
source "#{node['php']['url']}/php-#{version}.tar.gz/from/this/mirror"
source "#{node['php']['url']}/php-#{version}.tar.gz"
checksum node['php']['checksum']
mode '0644'
not_if "$(which #{node['php']['bin']}) --version | grep #{version}"
action :create_if_missing
not_if php_exists
notifies :run, 'execute[un-pack php]', :immediately
end
execute 'un-pack php' do
cwd Chef::Config[:file_cache_path]
command "tar -zxf php-#{version}.tar.gz"
creates "#{Chef::Config[:file_cache_path]}/php-#{version}"
action :nothing
end
if node['php']['ext_dir']
@ -41,26 +62,31 @@ if node['php']['ext_dir']
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.
# PHP is unable to find the GMP library on Ubuntu 16.04
# This symlink brings the file inside of the included 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 }
only_if { platform?('ubuntu') && node['platform_version'].to_f == 16.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}"
execute 'clean build' do
cwd "#{Chef::Config[:file_cache_path]}/php-#{version}"
command 'make clean'
only_if { node['php']['src_recompile'] }
end
execute 'configure php' do
cwd "#{Chef::Config[:file_cache_path]}/php-#{version}"
command "#{ext_dir_prefix} ./configure #{configure_options}"
not_if php_exists
end
execute 'build and install php' do
cwd "#{Chef::Config[:file_cache_path]}/php-#{version}"
command "make -j #{node['cpu']['total']} && make install"
not_if php_exists
end
directory node['php']['conf_dir'] do

View File

@ -19,14 +19,14 @@
#
property :package_name, String, name_property: true
property :version, [String, nil], default: nil
property :version, [String, 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
property :priority, [String, nil]
def current_installed_version(new_resource)
version_check_cmd = "#{new_resource.binary} -d"
@ -69,6 +69,8 @@ load_current_value do |new_resource|
end
action :install do
build_essential
# 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
@ -87,6 +89,8 @@ end
# reinstall is just an install that always fires
action :reinstall do
build_essential
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}"
@ -214,7 +218,14 @@ action_class do
def get_extension_files(name)
files = []
p = shell_out("#{new_resource.binary} list-files #{name}")
# use appropriate binary when listing pecl packages
list_binary = if new_resource.channel == 'pecl.php.net'
node['php']['pecl']
else
new_resource.binary
end
p = shell_out("#{list_binary} list-files #{name}")
p.stdout.each_line.grep(/^src\s+.*\.so$/i).each do |line|
files << line.split[1]
end
@ -231,7 +242,11 @@ action_class do
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
if (new_resource.binary.include? 'pecl') || (new_resource.channel == 'pecl.php.net')
true
else
false
end
elsif grep_for_version(shell_out(node['php']['pecl'] + search_args).stdout, new_resource.package_name)
true
else
@ -276,5 +291,10 @@ action_class do
)
action action
end
execute "#{node['php']['enable_mod']} #{name}" do
creates "#{node['php']['conf_dir']}/conf.d/#{name}"
only_if { platform_family? 'debian' }
end
end
end

View File

@ -22,9 +22,6 @@
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?

View File

@ -1,4 +1,7 @@
; configuration for php <%= @name %> module
<% if @priority %>
; priority=<%= @priority %>
<% end -%>
<% @extensions.each do |filepath, zend| -%>
<%= 'zend_' if zend %>extension=<%= filepath %>
<% end -%>

File diff suppressed because it is too large Load Diff

View File

@ -8,7 +8,7 @@
"automatic": {
"fqdn": "wiki-1",
"os": "linux",
"os_version": "5.4.0-42-generic",
"os_version": "5.4.0-45-generic",
"hostname": "wiki-1",
"ipaddress": "192.168.122.26",
"roles": [
@ -41,19 +41,7 @@
"php::ini",
"composer::global_configs",
"mediawiki::default",
"mediawiki::database",
"kosmos-nginx::default",
"nginx::default",
"nginx::package",
"nginx::ohai_plugin",
"nginx::repo",
"nginx::commons",
"nginx::commons_dir",
"nginx::commons_script",
"nginx::commons_conf",
"mediawiki::nginx",
"backup::default",
"logrotate::default"
"mediawiki::database"
],
"platform": "ubuntu",
"platform_version": "20.04",

View File

@ -45,11 +45,6 @@ mediawiki_credentials = data_bag_item('credentials', 'mediawiki')
node.override['mediawiki']['db']['root_password'] = mysql_credentials["root_password"]
node.override['mediawiki']['db']['pass'] = mediawiki_credentials["db_pass"]
# Fix bug in php cookbook
if platform?('ubuntu') && node[:platform_version].to_f == 14.04
node.override['php']['ext_conf_dir'] = '/etc/php5/mods-available'
end
directory "#{node['mediawiki']['webdir']}/skins/common/images" do
owner node['nginx']['user']
group node['nginx']['group']
@ -98,8 +93,7 @@ nginx_site server_name do
action :enable
end
# TODO
# nginx_certbot_site server_name
nginx_certbot_site server_name
#
# Extensions