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,56 @@
#
# Cookbook Name:: wordpress
# Recipe:: apache
#
# Copyright 2009-2010, Opscode, 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"
# On Windows PHP comes with the MySQL Module and we use IIS on Windows
unless platform? "windows"
include_recipe "php::module_mysql"
include_recipe "apache2"
include_recipe "apache2::mod_php5"
end
include_recipe "wordpress::app"
if platform?('windows')
include_recipe 'iis::remove_default_site'
iis_pool 'WordpressPool' do
no_managed_code true
action :add
end
iis_site 'Wordpress' do
protocol :http
port 80
path node['wordpress']['dir']
application_pool 'WordpressPool'
action [:add,:start]
end
else
web_app "wordpress" do
template "wordpress.conf.erb"
docroot node['wordpress']['dir']
server_name node['wordpress']['server_name']
server_aliases node['wordpress']['server_aliases']
server_port node['wordpress']['server_port']
enable true
end
end

View File

@@ -0,0 +1,90 @@
#
# Cookbook Name:: wordpress
# Recipe:: app
#
# Copyright 2009-2010, Opscode, 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 "wordpress::database"
::Chef::Recipe.send(:include, Opscode::OpenSSL::Password)
node.set_unless['wordpress']['keys']['auth'] = secure_password
node.set_unless['wordpress']['keys']['secure_auth'] = secure_password
node.set_unless['wordpress']['keys']['logged_in'] = secure_password
node.set_unless['wordpress']['keys']['nonce'] = secure_password
node.set_unless['wordpress']['salt']['auth'] = secure_password
node.set_unless['wordpress']['salt']['secure_auth'] = secure_password
node.set_unless['wordpress']['salt']['logged_in'] = secure_password
node.set_unless['wordpress']['salt']['nonce'] = secure_password
node.save unless Chef::Config[:solo]
directory node['wordpress']['dir'] do
action :create
recursive true
if platform_family?('windows')
rights :read, 'Everyone'
else
owner node['wordpress']['install']['user']
group node['wordpress']['install']['group']
mode '00755'
end
end
archive = platform_family?('windows') ? 'wordpress.zip' : 'wordpress.tar.gz'
if platform_family?('windows')
windows_zipfile node['wordpress']['parent_dir'] do
source node['wordpress']['url']
action :unzip
not_if {::File.exists?("#{node['wordpress']['dir']}\\index.php")}
end
else
tar_extract node['wordpress']['url'] do
target_dir node['wordpress']['dir']
creates File.join(node['wordpress']['dir'], 'index.php')
user node['wordpress']['install']['user']
group node['wordpress']['install']['group']
tar_flags [ '--strip-components 1' ]
not_if { ::File.exists?("#{node['wordpress']['dir']}/index.php") }
end
end
template "#{node['wordpress']['dir']}/wp-config.php" do
source 'wp-config.php.erb'
mode node['wordpress']['config_perms']
variables(
:db_name => node['wordpress']['db']['name'],
:db_user => node['wordpress']['db']['user'],
:db_password => node['wordpress']['db']['pass'],
:db_host => node['wordpress']['db']['host'],
:db_prefix => node['wordpress']['db']['prefix'],
:db_charset => node['wordpress']['db']['charset'],
:db_collate => node['wordpress']['db']['collate'],
:auth_key => node['wordpress']['keys']['auth'],
:secure_auth_key => node['wordpress']['keys']['secure_auth'],
:logged_in_key => node['wordpress']['keys']['logged_in'],
:nonce_key => node['wordpress']['keys']['nonce'],
:auth_salt => node['wordpress']['salt']['auth'],
:secure_auth_salt => node['wordpress']['salt']['secure_auth'],
:logged_in_salt => node['wordpress']['salt']['logged_in'],
:nonce_salt => node['wordpress']['salt']['nonce'],
:lang => node['wordpress']['languages']['lang'],
:allow_multisite => node['wordpress']['allow_multisite'],
:wp_config_options => node['wordpress']['wp_config_options']
)
owner node['wordpress']['install']['user']
group node['wordpress']['install']['group']
action :create
end

View File

@@ -0,0 +1,94 @@
#
# Cookbook Name:: wordpress
# Recipe:: database
# Author:: Lucas Hansen (<lucash@opscode.com>)
# Author:: Julian C. Dunn (<jdunn@getchef.com>)
# Author:: Craig Tracey (<craigtracey@gmail.com>)
#
# Copyright (C) 2013, 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.
#
unless platform_family?('windows')
mysql_client 'default' do
action :create
end
end
mysql2_chef_gem 'default' do
action :install
end
::Chef::Recipe.send(:include, Opscode::OpenSSL::Password)
::Chef::Recipe.send(:include, Wordpress::Helpers)
node.set_unless['wordpress']['db']['pass'] = secure_password
node.save unless Chef::Config[:solo]
db = node['wordpress']['db']
if is_local_host? db['host']
# The following is required for the mysql community cookbook to work properly
include_recipe 'selinux::disabled' if node['platform_family'] == 'rhel'
mysql_service db['instance_name'] do
port db['port']
version db['mysql_version']
initial_root_password db['root_password']
action [:create, :start]
end
socket = "/var/run/mysql-#{db['instance_name']}/mysqld.sock"
if node['platform_family'] == 'debian'
link '/var/run/mysqld/mysqld.sock' do
to socket
not_if 'test -f /var/run/mysqld/mysqld.sock'
end
elsif node['platform_family'] == 'rhel'
link '/var/lib/mysql/mysql.sock' do
to socket
not_if 'test -f /var/lib/mysql/mysql.sock'
end
end
mysql_connection_info = {
:host => 'localhost',
:username => 'root',
:socket => socket,
:password => db['root_password']
}
mysql_database db['name'] do
connection mysql_connection_info
action :create
end
mysql_database_user db['user'] do
connection mysql_connection_info
password db['pass']
host db['host']
database_name db['name']
action :create
end
mysql_database_user db['user'] do
connection mysql_connection_info
database_name db['name']
privileges [:all]
action :grant
end
end

View File

@@ -0,0 +1,20 @@
#
# Cookbook Name:: wordpress
# Recipe:: default
#
# Copyright 2009-2010, Opscode, 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 "wordpress::apache"

View File

@@ -0,0 +1,64 @@
#
# Cookbook Name:: wordpress
# Recipe:: languages
# Author:: Koseki Kengo <koseki@gmail.com>
#
# Copyright 2013, Opscode, 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 "wordpress"
directory "#{node['wordpress']['dir']}/wp-content/languages" do
owner "root"
group "root"
mode "0755"
action :create
recursive true
end
unless node['wordpress']['languages']['lang'].to_s.empty? &&
node['wordpress']['languages']['version'].to_s.empty?
urls = node['wordpress']['languages']['urls']
node['wordpress']['languages']['projects'].to_a.each do |project|
next unless urls[project]
file = "#{node['wordpress']['dir']}/wp-content/languages/"
file += "#{project.tr('_', '-')}-" if project != 'main'
file += "#{node['wordpress']['languages']['lang']}.mo"
remote_file file do
source urls[project]
owner "root"
group "root"
mode "0644"
action :create_if_missing
end
end
node['wordpress']['languages']['themes'].to_a.each do |project|
next unless urls[project]
file = "#{node['wordpress']['dir']}/wp-content/themes/#{project}/languages/"
file += "#{node['wordpress']['languages']['lang']}.mo"
remote_file file do
source urls[project]
owner "root"
group "root"
mode "0644"
action :create_if_missing
end
end
end

View File

@@ -0,0 +1,63 @@
#
# Cookbook Name:: wordpress
# Recipe:: nginx
#
# Copyright 2009-2010, Opscode, 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.
#
node.set_unless['php-fpm']['pools'] = []
include_recipe "php-fpm"
php_fpm_pool "wordpress" do
listen "127.0.0.1:9001"
user node['wordpress']['install']['user']
group node['wordpress']['install']['group']
if node['platform'] == 'ubuntu' and node['platform_version'] == '10.04'
process_manager 'dynamic'
end
listen_owner node['wordpress']['install']['user']
listen_group node['wordpress']['install']['group']
php_options node['wordpress']['php_options']
start_servers 5
end
include_recipe "php::module_mysql"
node.set_unless['nginx']['default_site_enabled'] = false
include_recipe "nginx"
include_recipe "wordpress::app"
template "#{node['nginx']['dir']}/sites-enabled/wordpress.conf" do
source "nginx.conf.erb"
variables(
:docroot => node['wordpress']['dir'],
:server_name => node['wordpress']['server_name'],
:server_aliases => node['wordpress']['server_aliases'],
:server_port => node['wordpress']['server_port']
)
action :create
end
# The following block is specifically for OS's like CentOS that include a
# default site as a part of the install. This block will only be triggered if
# node['nginx']['default_site_enable'] is set to false.
if node['platform_family'] == 'rhel' && !node['nginx']['default_site_enabled']
file File.join(node['nginx']['dir'], 'conf.d', 'default.conf') do
action :delete
notifies :reload, 'service[nginx]'
end
end