Update cookbooks for Ubuntu 16.04 TLS

This commit is contained in:
Greg Karékinian
2017-03-31 19:20:00 +02:00
parent 6430d71006
commit 8923d0d7ef
219 changed files with 2770 additions and 11511 deletions

View File

@@ -1,9 +1,9 @@
#
# Author:: Chris Marchesi <cmarchesi@paybyphone.com>
# Cookbook Name:: php
# Cookbook:: php
# Provider:: fpm_pool
#
# Copyright:: 2015, Opscode, Inc <legal@opscode.com>
# Copyright:: 2015-2016, Chef Software, Inc <legal@chef.io>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -18,6 +18,8 @@
# limitations under the License.
#
use_inline_resources
def whyrun_supported?
true
end
@@ -28,16 +30,15 @@ def install_fpm_package
# also, this is skipped for source
return if node['php']['install_method'] == 'source'
if node['php']['fpm_package'].nil?
raise 'PHP-FPM package not found (you probably have an unsupported distro)'
else
file node['php']['fpm_default_conf'] do
action :nothing
end
package node['php']['fpm_package'] do
action :install
notifies :delete, "file[#{node['php']['fpm_default_conf']}]"
end
raise 'PHP-FPM package not found (you probably have an unsupported distro)' if node['php']['fpm_package'].nil?
file node['php']['fpm_default_conf'] do
action :nothing
end
package node['php']['fpm_package'] do
action :install
notifies :delete, "file[#{node['php']['fpm_default_conf']}]", :immediately
end
end
@@ -57,20 +58,22 @@ action :install do
source 'fpm-pool.conf.erb'
action :create
cookbook 'php'
variables ({
:fpm_pool_name => new_resource.pool_name,
:fpm_pool_user => new_resource.user,
:fpm_pool_group => new_resource.group,
:fpm_pool_listen => new_resource.listen,
:fpm_pool_manager => new_resource.process_manager,
:fpm_pool_max_children => new_resource.max_children,
:fpm_pool_start_servers => new_resource.start_servers,
:fpm_pool_min_spare_servers => new_resource.min_spare_servers,
:fpm_pool_max_spare_servers => new_resource.max_spare_servers,
:fpm_pool_chdir => new_resource.chdir,
:fpm_pool_additional_config => new_resource.additional_config
})
notifies :restart, "service[#{node['php']['fpm_package']}]"
variables(
fpm_pool_name: new_resource.pool_name,
fpm_pool_user: new_resource.user,
fpm_pool_group: new_resource.group,
fpm_pool_listen: new_resource.listen,
fpm_pool_listen_user: new_resource.listen_user,
fpm_pool_listen_group: new_resource.listen_group,
fpm_pool_manager: new_resource.process_manager,
fpm_pool_max_children: new_resource.max_children,
fpm_pool_start_servers: new_resource.start_servers,
fpm_pool_min_spare_servers: new_resource.min_spare_servers,
fpm_pool_max_spare_servers: new_resource.max_spare_servers,
fpm_pool_chdir: new_resource.chdir,
fpm_pool_additional_config: new_resource.additional_config
)
notifies :restart, "service[#{node['php']['fpm_service']}]"
end
new_resource.updated_by_last_action(t.updated_by_last_action?)
end
@@ -79,7 +82,7 @@ action :uninstall do
# Ensure the FPM pacakge is installed, and the service is registered
register_fpm_service
# Delete the FPM pool.
f = file "#{node['php']['fpm_pooldir']}/#{new_resource.pool_name}" do
f = file "#{node['php']['fpm_pooldir']}/#{new_resource.pool_name}.conf" do
action :delete
end
new_resource.updated_by_last_action(f.updated_by_last_action?)

View File

@@ -1,9 +1,9 @@
#
# Author:: Seth Chisamore <schisamo@getchef.com>
# Cookbook Name:: php
# Author:: Seth Chisamore <schisamo@chef.io>
# Cookbook:: php
# Provider:: pear_package
#
# Copyright:: 2011, Opscode, Inc <legal@getchef.com>
# Copyright:: 2011-2016, Chef Software, Inc <legal@chef.io>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -18,6 +18,8 @@
# limitations under the License.
#
use_inline_resources
require 'chef/mixin/shell_out'
require 'chef/mixin/language'
include Chef::Mixin::ShellOut
@@ -26,6 +28,8 @@ include Chef::Mixin::ShellOut
# the Chef::Provider::Package which will make
# refactoring into core chef easy
use_inline_resources
def whyrun_supported?
true
end
@@ -41,7 +45,7 @@ action :install do
info_output = "Installing #{@new_resource}"
info_output << " version #{install_version}" if install_version && !install_version.empty?
Chef::Log.info(info_output)
status = install_package(@new_resource.package_name, install_version)
install_package(@new_resource.package_name, install_version)
end
end
end
@@ -52,7 +56,7 @@ action :upgrade do
description = "upgrade package #{@new_resource} version from #{orig_version} to #{candidate_version}"
converge_by(description) do
Chef::Log.info("Upgrading #{@new_resource} version from #{orig_version} to #{candidate_version}")
status = upgrade_package(@new_resource.package_name, candidate_version)
upgrade_package(@new_resource.package_name, candidate_version)
end
end
end
@@ -172,14 +176,14 @@ def remove_package(name, version)
end
def enable_package(name)
execute "/usr/sbin/php5enmod #{name}" do
only_if { platform?('ubuntu') && node['platform_version'].to_f >= 12.04 && ::File.exist?('/usr/sbin/php5enmod') }
execute "#{node['php']['enable_mod']} #{name}" do
only_if { platform?('ubuntu') && node['platform_version'].to_f >= 12.04 && ::File.exist?(node['php']['enable_mod']) }
end
end
def disable_package(name)
execute "/usr/sbin/php5dismod #{name}" do
only_if { platform?('ubuntu') && node['platform_version'].to_f >= 12.04 && ::File.exist?('/usr/sbin/php5dismod') }
execute "#{node['php']['disable_mod']} #{name}" do
only_if { platform?('ubuntu') && node['platform_version'].to_f >= 12.04 && ::File.exist?(node['php']['disable_mod']) }
end
end
@@ -202,7 +206,7 @@ def prefix_channel(channel)
channel ? "#{channel}/" : ''
end
def get_extension_dir
def extension_dir
@extension_dir ||= begin
# Consider using "pecl config-get ext_dir". It is more cross-platform.
# p = shell_out("php-config --extension-dir")
@@ -223,7 +227,7 @@ def get_extension_files(name)
end
def manage_pecl_ini(name, action, directives, zend_extensions)
ext_prefix = get_extension_dir
ext_prefix = extension_dir
ext_prefix << ::File::SEPARATOR if ext_prefix[-1].chr != ::File::SEPARATOR
files = get_extension_files(name)
@@ -237,7 +241,7 @@ def manage_pecl_ini(name, action, directives, zend_extensions)
end
]
directory "#{node['php']['ext_conf_dir']}" do
directory node['php']['ext_conf_dir'] do
owner 'root'
group 'root'
mode '0755'
@@ -250,7 +254,7 @@ def manage_pecl_ini(name, action, directives, zend_extensions)
owner 'root'
group 'root'
mode '0644'
variables(:name => name, :extensions => extensions, :directives => directives)
variables(name: name, extensions: extensions, directives: directives)
action action
end
end
@@ -264,13 +268,13 @@ def grep_for_version(stdout, package)
# Horde_Url -n/a-/(1.0.0beta1 beta) Horde Url class
# Horde_Url 1.0.0beta1 (beta) 1.0.0beta1 Horde Url class
v = m.split(/\s+/)[1].strip
if v.split(/\//)[0] =~ /.\./
# 1.1.4/(1.1.4 stable)
v = v.split(/\//)[0]
else
# -n/a-/(1.0.0beta1 beta)
v = v.split(/(.*)\/\((.*)/).last.split(/\s/)[0]
end
v = if v.split(%r{/\//})[0] =~ /.\./
# 1.1.4/(1.1.4 stable)
v.split(%r{/\//})[0]
else
# -n/a-/(1.0.0beta1 beta)
v.split(%r{/(.*)\/\((.*)/}).last.split(/\s/)[0]
end
end
v
end
@@ -288,7 +292,7 @@ def pecl?
elsif grep_for_version(shell_out(node['php']['pecl'] + search_args).stdout, @new_resource.package_name)
true
else
fail "Package #{@new_resource.package_name} not found in either PEAR or PECL."
raise "Package #{@new_resource.package_name} not found in either PEAR or PECL."
end
end
end

View File

@@ -1,91 +0,0 @@
#
# Author:: Seth Chisamore <schisamo@getchef.com>
# Cookbook Name:: php
# Provider:: pear_channel
#
# Copyright:: 2011, Opscode, Inc <legal@getchef.com>
#
# 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.
#
# http://pear.php.net/manual/en/guide.users.commandline.channels.php
require 'chef/mixin/shell_out'
require 'chef/mixin/language'
include Chef::Mixin::ShellOut
def whyrun_supported?
true
end
action :discover do
unless exists?
Chef::Log.info("Discovering pear channel #{@new_resource}")
execute "#{node['php']['pear']} channel-discover #{@new_resource.channel_name}" do
action :run
end
end
end
action :add do
unless exists?
Chef::Log.info("Adding pear channel #{@new_resource} from #{@new_resource.channel_xml}")
execute "#{node['php']['pear']} channel-add #{@new_resource.channel_xml}" do
action :run
end
end
end
action :update do
if exists?
update_needed = false
begin
updated_needed = true if shell_out("#{node['php']['pear']} search -c #{@new_resource.channel_name} NNNNNN").stdout =~ /channel-update/
rescue Chef::Exceptions::CommandTimeout
# CentOS can hang on 'pear search' if a channel needs updating
Chef::Log.info("Timed out checking if channel-update needed...forcing update of pear channel #{@new_resource}")
update_needed = true
end
if update_needed
description = "update pear channel #{@new_resource}"
converge_by(description) do
Chef::Log.info("Updating pear channel #{@new_resource}")
shell_out!("#{node['php']['pear']} channel-update #{@new_resource.channel_name}")
end
end
end
end
action :remove do
if exists?
Chef::Log.info("Deleting pear channel #{@new_resource}")
execute "#{node['php']['pear']} channel-delete #{@new_resource.channel_name}" do
action :run
end
end
end
def load_current_resource
@current_resource = Chef::Resource::PhpPearChannel.new(@new_resource.name)
@current_resource.channel_name(@new_resource.channel_name)
@current_resource
end
private
def exists?
shell_out!("#{node['php']['pear']} channel-info #{@current_resource.channel_name}")
true
rescue Mixlib::ShellOut::ShellCommandFailed
false
end