Update cookbooks and add wordpress cookbook

This commit is contained in:
Greg Karékinian
2016-02-19 18:09:49 +01:00
parent 9ba973e3ac
commit 820b0ab3f8
606 changed files with 22421 additions and 14084 deletions

View File

@@ -0,0 +1,86 @@
#
# Author:: Chris Marchesi <cmarchesi@paybyphone.com>
# Cookbook Name:: php
# Provider:: fpm_pool
#
# Copyright:: 2015, Opscode, Inc <legal@opscode.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.
#
def whyrun_supported?
true
end
def install_fpm_package
# Install the FPM pacakge for this platform, if it's available
# Fail the run if it's an unsupported OS (FPM pacakge name not populated)
# also, this is skipped for source
return if node['php']['install_method'] == 'source'
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
end
end
def register_fpm_service
service node['php']['fpm_service'] do
action :enable
end
end
action :install do
# Ensure the FPM pacakge is installed, and the service is registered
install_fpm_package
register_fpm_service
# I wanted to have this as a function in itself, but doing this seems to
# break testing suites?
t = template "#{node['php']['fpm_pooldir']}/#{new_resource.pool_name}.conf" do
source 'fpm-pool.conf.erb'
action :create
cookbook 'php'
variables ({
:fpm_pool_name => new_resource.pool_name,
:fpm_pool_user => new_resource.user,
:fpm_pool_group => new_resource.group,
:fpm_pool_listen => new_resource.listen,
:fpm_pool_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']}]"
end
new_resource.updated_by_last_action(t.updated_by_last_action?)
end
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
action :delete
end
new_resource.updated_by_last_action(f.updated_by_last_action?)
end

View File

@@ -1,9 +1,9 @@
#
# Author:: Seth Chisamore <schisamo@opscode.com>
# Author:: Seth Chisamore <schisamo@getchef.com>
# Cookbook Name:: php
# Provider:: pear_package
#
# Copyright:: 2011, Opscode, Inc <legal@opscode.com>
# 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.
@@ -64,7 +64,6 @@ action :remove do
Chef::Log.info("Removing #{@new_resource}")
remove_package(@current_resource.package_name, @new_resource.version)
end
else
end
end
@@ -117,10 +116,9 @@ end
def current_installed_version
@current_installed_version ||= begin
v = nil
version_check_cmd = "#{@bin} -d "
version_check_cmd << " preferred_state=#{can_haz(@new_resource, "preferred_state")}"
version_check_cmd << " list#{expand_channel(can_haz(@new_resource, "channel"))}"
version_check_cmd << " preferred_state=#{can_haz(@new_resource, 'preferred_state')}"
version_check_cmd << " list#{expand_channel(can_haz(@new_resource, 'channel'))}"
p = shell_out(version_check_cmd)
response = nil
response = grep_for_version(p.stdout, @new_resource.package_name) if p.stdout =~ /\.?Installed packages/i
@@ -131,9 +129,9 @@ end
def candidate_version
@candidate_version ||= begin
candidate_version_cmd = "#{@bin} -d "
candidate_version_cmd << "preferred_state=#{can_haz(@new_resource, "preferred_state")}"
candidate_version_cmd << " search#{expand_channel(can_haz(@new_resource, "channel"))}"
candidate_version_cmd << "#{@new_resource.package_name}"
candidate_version_cmd << "preferred_state=#{can_haz(@new_resource, 'preferred_state')}"
candidate_version_cmd << " search#{expand_channel(can_haz(@new_resource, 'channel'))}"
candidate_version_cmd << " #{@new_resource.package_name}"
p = shell_out(candidate_version_cmd)
response = nil
response = grep_for_version(p.stdout, @new_resource.package_name) if p.stdout =~ /\.?Matched packages/i
@@ -142,32 +140,47 @@ def candidate_version
end
def install_package(name, version)
command = "echo \"\r\" | #{@bin} -d"
command << " preferred_state=#{can_haz(@new_resource, "preferred_state")}"
command = "printf \"\r\" | #{@bin} -d"
command << " preferred_state=#{can_haz(@new_resource, 'preferred_state')}"
command << " install -a#{expand_options(@new_resource.options)}"
command << " #{prefix_channel(can_haz(@new_resource, "channel"))}#{name}"
command << " #{prefix_channel(can_haz(@new_resource, 'channel'))}#{name}"
command << "-#{version}" if version && !version.empty?
pear_shell_out(command)
manage_pecl_ini(name, :create, can_haz(@new_resource, 'directives'), can_haz(@new_resource, 'zend_extensions')) if pecl?
enable_package(name)
end
def upgrade_package(name, version)
command = "echo \"\r\" | #{@bin} -d"
command << " preferred_state=#{can_haz(@new_resource, "preferred_state")}"
command = "printf \"\r\" | #{@bin} -d"
command << " preferred_state=#{can_haz(@new_resource, 'preferred_state')}"
command << " upgrade -a#{expand_options(@new_resource.options)}"
command << " #{prefix_channel(can_haz(@new_resource, "channel"))}#{name}"
command << " #{prefix_channel(can_haz(@new_resource, 'channel'))}#{name}"
command << "-#{version}" if version && !version.empty?
pear_shell_out(command)
manage_pecl_ini(name, :create, can_haz(@new_resource, 'directives'), can_haz(@new_resource, 'zend_extensions')) if pecl?
enable_package(name)
end
def remove_package(name, version)
command = "#{@bin} uninstall"
command << " #{expand_options(@new_resource.options)}"
command << " #{prefix_channel(can_haz(@new_resource, "channel"))}#{name}"
command << " #{prefix_channel(can_haz(@new_resource, 'channel'))}#{name}"
command << "-#{version}" if version && !version.empty?
pear_shell_out(command)
manage_pecl_ini(name, :delete) if pecl?
disable_package(name)
manage_pecl_ini(name, :delete, nil, nil) if pecl?
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') }
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') }
end
end
def pear_shell_out(command)
@@ -216,14 +229,21 @@ def manage_pecl_ini(name, action, directives, zend_extensions)
files = get_extension_files(name)
extensions = Hash[
files.map do |filepath|
rel_file = filepath.clone
rel_file.slice! ext_prefix if rel_file.start_with? ext_prefix
zend = zend_extensions.include?(rel_file)
[(zend ? filepath : rel_file) , zend]
end
files.map do |filepath|
rel_file = filepath.clone
rel_file.slice! ext_prefix if rel_file.start_with? ext_prefix
zend = zend_extensions.include?(rel_file)
[(zend ? filepath : rel_file), zend]
end
]
directory "#{node['php']['ext_conf_dir']}" do
owner 'root'
group 'root'
mode '0755'
recursive true
end
template "#{node['php']['ext_conf_dir']}/#{name}.ini" do
source 'extension.ini.erb'
cookbook 'php'
@@ -259,9 +279,9 @@ def pecl?
@pecl ||=
begin
# search as a pear first since most 3rd party channels will report pears as pecls!
search_args = String.new
search_args << " -d preferred_state=#{can_haz(@new_resource, "preferred_state")}"
search_args << " search#{expand_channel(can_haz(@new_resource, "channel"))} #{@new_resource.package_name}"
search_args = ''
search_args << " -d preferred_state=#{can_haz(@new_resource, 'preferred_state')}"
search_args << " search#{expand_channel(can_haz(@new_resource, 'channel'))} #{@new_resource.package_name}"
if grep_for_version(shell_out(node['php']['pear'] + search_args).stdout, @new_resource.package_name)
false

View File

@@ -1,9 +1,9 @@
#
# Author:: Seth Chisamore <schisamo@opscode.com>
# Author:: Seth Chisamore <schisamo@getchef.com>
# Cookbook Name:: php
# Provider:: pear_channel
#
# Copyright:: 2011, Opscode, Inc <legal@opscode.com>
# 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.
@@ -84,10 +84,8 @@ end
private
def exists?
begin
shell_out!("#{node['php']['pear']} channel-info #{@current_resource.channel_name}")
true
rescue Mixlib::ShellOut::ShellCommandFailed
false
end
shell_out!("#{node['php']['pear']} channel-info #{@current_resource.channel_name}")
true
rescue Mixlib::ShellOut::ShellCommandFailed
false
end