Update cookbooks and add wordpress cookbook
This commit is contained in:
93
cookbooks/wordpress/CHANGELOG.md
Normal file
93
cookbooks/wordpress/CHANGELOG.md
Normal file
@@ -0,0 +1,93 @@
|
||||
CHANGELOG
|
||||
|
||||
v3.0.0 (2015-02-24)
|
||||
-------------------
|
||||
* Cookbook updated to support the MySQL 6.0 community cookbook
|
||||
* Added selinux as a dependency to resolve MySQL installation issues on CentOS
|
||||
* Adjustments made to Nginx/PHP-FPM configuration to work out of the box with CentOS
|
||||
* Added attribute to allow for additional WordPress configuration options
|
||||
* Updated bats tests to work when testing WordPress version 4+ and <4
|
||||
* Removed testing for Ubuntu 10.04 due to fast approaching EOL and bugs in several cookbooks WordPress depends on.
|
||||
|
||||
v2.1.5 (2014-06-28)
|
||||
-------------------
|
||||
* Recipe added to support installation with nginx
|
||||
|
||||
v2.1.2 (2014-04-03)
|
||||
-------------------
|
||||
* Fixes issue where `mysql::ruby` recipe was removed in v5 of community cookbook
|
||||
|
||||
v2.1.0 (2014-02-27)
|
||||
-------------------
|
||||
[COOK-4354] s/Wordpress/WordPress/g in docs
|
||||
[COOK-4356] Gets WordPress to be extracted to the proper directory
|
||||
[COOK-4191] WordPress table_prefix not configured when node['wordpress']['db']['prefix'] is set
|
||||
[COOK-4192] Add attribute to control WordPress multisite features
|
||||
[COOK-4366] apache2 port parameter
|
||||
|
||||
|
||||
v2.0.0 (2014-02-27)
|
||||
-------------------
|
||||
[COOK-4180] leverage the database cookbook
|
||||
|
||||
|
||||
v1.3.2 (2014-01-23)
|
||||
-------------------
|
||||
* [COOK-4248] - use "no_managed_code" when setting up WordPress Pool on Windows
|
||||
* [COOK-4170] - Wordpress tarball contains a wordpress subdirectory, causing "extract-wordpress" to execute every run and the WP URL to be http://hostname/wordpress/
|
||||
|
||||
|
||||
v1.3.0
|
||||
------
|
||||
### Bug
|
||||
- **[COOK-3478](https://tickets.opscode.com/browse/COOK-3478)** - Windows support for Wordpress
|
||||
|
||||
|
||||
v1.2.0
|
||||
------
|
||||
### New Feature
|
||||
- **[COOK-3321](https://tickets.opscode.com/browse/COOK-3321)** - Add languages recipe
|
||||
|
||||
### Improvement
|
||||
- **[COOK-3311](https://tickets.opscode.com/browse/COOK-3311)** - Remove legacy Test Kitchen, Add Travis CI
|
||||
|
||||
|
||||
v1.1.0
|
||||
------
|
||||
- Added Test Kitchen 1.0
|
||||
|
||||
Bug Fixes:
|
||||
- [COOK-1393]: wordpress recipe should use mysql::ruby to ensure ruby extension is installed
|
||||
- [COOK-2984]: wordpress cookbook has foodcritic failures
|
||||
|
||||
Improvements:
|
||||
- [COOK-2661]: Allow downloads from other repos for wordpress install
|
||||
|
||||
v1.0.0:
|
||||
-------
|
||||
- [COOK-1127] - update defaults to latest version
|
||||
- [COOK-1222] - support installing "latest" version
|
||||
- [COOK-1271] - Wordpress cookbook generates new password on every chef run
|
||||
|
||||
v0.8.8
|
||||
------
|
||||
- [COOK-826] - recipe doesn't quote password string
|
||||
|
||||
v0.8.6
|
||||
------
|
||||
- [COOK-534] - allow server_aliases to overridden by an attribute
|
||||
- [COOK-799] - fixed disables .htaccess breaking permalink feature
|
||||
- [COOK-820] - guard node.save with check for chef-solo in our cookbooks
|
||||
|
||||
v0.8.4
|
||||
------
|
||||
- [COOK-406] - wp-config.php.erb has wrong CRLF encoding
|
||||
- Dropping explicit support for Red Hat platforms due to issues in php and mysql cookbooks (COOK-603, COOK-672, COOK-816, COOK-679)
|
||||
|
||||
v0.8.2
|
||||
------
|
||||
- [COOK-435] Don't set the mysql root user password in wordpress cookbook
|
||||
- [COOK-535] - recursively create the directory
|
||||
- RHEL/CentOS/Fedora support (yeah!)
|
||||
- cleaned up node attribute keys
|
||||
- cleaned up README.md
|
||||
98
cookbooks/wordpress/README.md
Normal file
98
cookbooks/wordpress/README.md
Normal file
@@ -0,0 +1,98 @@
|
||||
[](https://travis-ci.org/brint/wordpress-cookbook)
|
||||
[](https://gemnasium.com/brint/wordpress-cookbook)
|
||||
|
||||
Description
|
||||
===========
|
||||
|
||||
The Chef WordPress cookbook installs and configures WordPress according to the instructions at http://codex.wordpress.org/Installing_WordPress.
|
||||
|
||||
Description
|
||||
===========
|
||||
|
||||
This cookbook does not set up the WordPress blog. You will need to do this manually by going to http://hostname/wp-admin/install.php (this URL may be different if you change the attribute values).
|
||||
|
||||
Requirements
|
||||
============
|
||||
|
||||
Platform
|
||||
--------
|
||||
|
||||
* Ubuntu 12.04, 14.04
|
||||
* RHEL/CentOS 5, 6
|
||||
* Windows
|
||||
|
||||
Cookbooks
|
||||
---------
|
||||
|
||||
* mysql
|
||||
* mysql_chef_gem
|
||||
* php
|
||||
* apache2
|
||||
* iis
|
||||
* windows
|
||||
* openssl (uses library to generate secure passwords)
|
||||
* selinux (used to disable selinux for MySQL on RHEL-based systems)
|
||||
|
||||
Attributes
|
||||
==========
|
||||
|
||||
### WordPress
|
||||
|
||||
* `node['wordpress']['version']` - Version of WordPress to download. Use 'latest' to download most recent version.
|
||||
* `node['wordpress']['parent_dir']` - Parent directory to where WordPress will be extracted. (Windows Only)
|
||||
* `node['wordpress']['dir']` - Location to place WordPress files.
|
||||
* `node['wordpress']['db']['root_password']` - Root password for MySQL (added for support with community cookbook version 6+)
|
||||
* `node['wordpress']['db']['instance_name']` - Name of the MySQL instance to use with MySQL (community cookbook version 6+)
|
||||
* `node['wordpress']['db']['name']` - Name of the WordPress MySQL database.
|
||||
* `node['wordpress']['db']['user']` - Name of the WordPress MySQL user.
|
||||
* `node['wordpress']['db']['pass']` - Password of the WordPress MySQL user. By default, generated using openssl cookbook.
|
||||
* `node['wordpress']['db']['prefix']` - Prefix of all MySQL tables created by WordPress.
|
||||
* `node['wordpress']['db']['host']` - Host of the WordPress MySQL database.
|
||||
* `node['wordpress']['db']['port']` - Port of the WordPress MySQL database.
|
||||
* `node['wordpress']['db']['charset']` - [Character set](http://dev.mysql.com/doc/refman/5.7/en/charset-charsets.html) of the WordPress MySQL database tables. Defaults to 'utf8'.
|
||||
* `node['wordpress']['db']['collate']` - [Collation](http://dev.mysql.com/doc/refman/5.7/en/charset-collation-effect.html) of the WordPress MySQL database tables.
|
||||
* `node['wordpress']['db']['mysql_version']` - Version of MySQL to install (for supporting community cookbook version 6+)
|
||||
|
||||
* `node['wordpress']['allow_multisite']` - Enable [multisite](http://codex.wordpress.org/Create_A_Network) features (default: false).
|
||||
* `node['wordpress']['wp_config_options']` - A hash of options to define in wp_config.php, output as key value pairs into a PHP constant e.g. `define( '<%= @key %>', <%= @value %> );`. Note: for values you will need to add single quotes around text but omit them for booleans and numbers. (default: {}).
|
||||
* `node['wordpress']['config_perms']` - Permissions to set for a site's wp-config.php.
|
||||
* `node['wordpress']['server_aliases']` - Aliases to use when setting up Virtual Host with Nginx or Apache
|
||||
* `node['wordpress']['server_port']` - Port to use when setting up the Virtual Host with Nginx or Apache
|
||||
|
||||
* `node['wordpress']['install']['user']` - Install user used for WordPress file permissions and the PHP-FPM user (if applicable)
|
||||
* `node['wordpress']['install']['group']` - Install group used for WordPress file permissions and the PHP-FPM group (if necessary)
|
||||
|
||||
* `node['wordpress']['parent_dir']` - Parent directory of where WordPress will be installed. This is used in the Windows installation to determine where the .zip will be downloaded to.
|
||||
* `node['wordpress']['dir']` - Path where WordPress should be installed
|
||||
* `node['wordpress']['url']` - URL to the zip or tarball installer of WordPress
|
||||
* `node['wordpress']['server_name']` - Hostname used for setting up the Virtual Host configuration for your WordPress site
|
||||
|
||||
* `node['wordpress']['php_options']` - Additional PHP settings for the installation.
|
||||
|
||||
Usage
|
||||
=====
|
||||
|
||||
Add the "wordpress" recipe to your node's run list or role, or include the recipe in another cookbook.
|
||||
|
||||
License and Author
|
||||
==================
|
||||
|
||||
* Author:: Barry Steinglass (barry@opscode.com)
|
||||
* Author:: Joshua Timberman (joshua@opscode.com)
|
||||
* Author:: Seth Chisamore (schisamo@opscode.com)
|
||||
* Author:: Lucas Hansen (lucash@opscode.com)
|
||||
* Author:: Julian C. Dunn (jdunn@getchef.com)
|
||||
|
||||
Copyright:: 2010-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.
|
||||
103
cookbooks/wordpress/attributes/default.rb
Normal file
103
cookbooks/wordpress/attributes/default.rb
Normal file
@@ -0,0 +1,103 @@
|
||||
#
|
||||
# Author:: Barry Steinglass (<barry@opscode.com>)
|
||||
# Author:: Koseki Kengo (<koseki@gmail.com>)
|
||||
# Author:: Lucas Hansen (<lucash@opscode.com>)
|
||||
# Author:: Julian C. Dunn (<jdunn@getchef.com>)
|
||||
#
|
||||
# Cookbook Name:: wordpress
|
||||
# Attributes:: wordpress
|
||||
#
|
||||
# Copyright 2009-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.
|
||||
#
|
||||
|
||||
# General settings
|
||||
default['wordpress']['version'] = 'latest'
|
||||
|
||||
default['wordpress']['db']['root_password'] = 'my_root_password'
|
||||
default['wordpress']['db']['instance_name'] = 'default'
|
||||
default['wordpress']['db']['name'] = "wordpressdb"
|
||||
default['wordpress']['db']['user'] = "wordpressuser"
|
||||
default['wordpress']['db']['pass'] = nil
|
||||
default['wordpress']['db']['prefix'] = 'wp_'
|
||||
default['wordpress']['db']['host'] = 'localhost'
|
||||
default['wordpress']['db']['port'] = '3306' # Must be a string
|
||||
default['wordpress']['db']['charset'] = 'utf8'
|
||||
default['wordpress']['db']['collate'] = ''
|
||||
case node['platform']
|
||||
when 'ubuntu'
|
||||
case node['platform_version']
|
||||
when '10.04'
|
||||
default['wordpress']['db']['mysql_version'] = '5.1'
|
||||
else
|
||||
default['wordpress']['db']['mysql_version'] = '5.5'
|
||||
end
|
||||
when 'centos', 'redhat'
|
||||
if node['platform_version'].to_i < 6
|
||||
default['wordpress']['db']['mysql_version'] = '5.0'
|
||||
elsif node['platform_version'].to_i < 7
|
||||
default['wordpress']['db']['mysql_version'] = '5.1'
|
||||
else
|
||||
default['wordpress']['db']['mysql_version'] = '5.5'
|
||||
end
|
||||
else
|
||||
default['wordpress']['db']['mysql_version'] = '5.5'
|
||||
end
|
||||
|
||||
default['wordpress']['allow_multisite'] = false
|
||||
|
||||
default['wordpress']['wp_config_options'] = {}
|
||||
|
||||
default['wordpress']['config_perms'] = 0644
|
||||
default['wordpress']['server_aliases'] = [node['fqdn']]
|
||||
default['wordpress']['server_port'] = '80'
|
||||
|
||||
default['wordpress']['install']['user'] = node['apache']['user']
|
||||
default['wordpress']['install']['group'] = node['apache']['group']
|
||||
|
||||
# Languages
|
||||
default['wordpress']['languages']['lang'] = ''
|
||||
default['wordpress']['languages']['version'] = ''
|
||||
default['wordpress']['languages']['repourl'] = 'http://translate.wordpress.org/projects/wp'
|
||||
default['wordpress']['languages']['projects'] = ['main', 'admin', 'admin_network', 'continents_cities']
|
||||
default['wordpress']['languages']['themes'] = []
|
||||
default['wordpress']['languages']['project_pathes'] = {
|
||||
'main' => '/',
|
||||
'admin' => '/admin/',
|
||||
'admin_network' => '/admin/network/',
|
||||
'continents_cities' => '/cc/'
|
||||
}
|
||||
%w{ten eleven twelve thirteen fourteen fifteen sixteen seventeen eighteen nineteen twenty}.each do |year|
|
||||
default['wordpress']['languages']['project_pathes']["twenty#{year}"] = "/twenty#{year}/"
|
||||
end
|
||||
node['wordpress']['languages']['project_pathes'].each do |project,project_path|
|
||||
# http://translate.wordpress.org/projects/wp/3.5.x/admin/network/ja/default/export-translations?format=mo
|
||||
default['wordpress']['languages']['urls'][project] =
|
||||
node['wordpress']['languages']['repourl'] + '/' +
|
||||
node['wordpress']['languages']['version'] + project_path +
|
||||
node['wordpress']['languages']['lang'] + '/default/export-translations?format=mo'
|
||||
end
|
||||
|
||||
if node['platform'] == 'windows'
|
||||
default['wordpress']['parent_dir'] = "#{ENV['SystemDrive']}\\inetpub"
|
||||
default['wordpress']['dir'] = "#{node['wordpress']['parent_dir']}\\wordpress"
|
||||
default['wordpress']['url'] = "https://wordpress.org/wordpress-#{node['wordpress']['version']}.zip"
|
||||
else
|
||||
default['wordpress']['server_name'] = node['fqdn']
|
||||
default['wordpress']['parent_dir'] = '/var/www'
|
||||
default['wordpress']['dir'] = "#{node['wordpress']['parent_dir']}/wordpress"
|
||||
default['wordpress']['url'] = "https://wordpress.org/wordpress-#{node['wordpress']['version']}.tar.gz"
|
||||
end
|
||||
|
||||
default['wordpress']['php_options'] = { 'php_admin_value[upload_max_filesize]' => '50M', 'php_admin_value[post_max_size]' => '55M' }
|
||||
38
cookbooks/wordpress/libraries/helpers.rb
Normal file
38
cookbooks/wordpress/libraries/helpers.rb
Normal file
@@ -0,0 +1,38 @@
|
||||
#
|
||||
# Cookbook Name:: wordpress
|
||||
# Library:: helpers
|
||||
# Author:: Yvo van Doorn <yvo@getchef.com>
|
||||
# Author:: Julian C. Dunn <jdunn@getchef.com>
|
||||
#
|
||||
# Copyright 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.
|
||||
#
|
||||
|
||||
module Wordpress
|
||||
module Helpers
|
||||
def is_local_host?(host)
|
||||
if host == 'localhost' || host == '127.0.0.1' || host == '::1'
|
||||
true
|
||||
else
|
||||
require 'socket'
|
||||
require 'resolv'
|
||||
Socket.ip_address_list.map { |a| a.ip_address }.include? Resolv.getaddress host
|
||||
end
|
||||
end
|
||||
|
||||
def self.make_db_query(user, pass, query)
|
||||
%< --user=#{user} --password="#{pass}" --execute="#{query}">
|
||||
end
|
||||
end
|
||||
end
|
||||
126
cookbooks/wordpress/metadata.json
Normal file
126
cookbooks/wordpress/metadata.json
Normal file
File diff suppressed because one or more lines are too long
56
cookbooks/wordpress/recipes/apache.rb
Normal file
56
cookbooks/wordpress/recipes/apache.rb
Normal 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
|
||||
90
cookbooks/wordpress/recipes/app.rb
Normal file
90
cookbooks/wordpress/recipes/app.rb
Normal 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
|
||||
94
cookbooks/wordpress/recipes/database.rb
Normal file
94
cookbooks/wordpress/recipes/database.rb
Normal 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
|
||||
20
cookbooks/wordpress/recipes/default.rb
Normal file
20
cookbooks/wordpress/recipes/default.rb
Normal 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"
|
||||
64
cookbooks/wordpress/recipes/languages.rb
Normal file
64
cookbooks/wordpress/recipes/languages.rb
Normal 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
|
||||
63
cookbooks/wordpress/recipes/nginx.rb
Normal file
63
cookbooks/wordpress/recipes/nginx.rb
Normal 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
|
||||
21
cookbooks/wordpress/templates/default/nginx.conf.erb
Normal file
21
cookbooks/wordpress/templates/default/nginx.conf.erb
Normal file
@@ -0,0 +1,21 @@
|
||||
server {
|
||||
listen <%= @server_port %>;
|
||||
server_name <%= @server_name %> <%= @server_aliases.join(" ") %>;
|
||||
|
||||
access_log /var/log/nginx/<%= @server_name %>.access.log;
|
||||
error_log /var/log/nginx/<%= @server_name %>.error.log;
|
||||
|
||||
root <%= @docroot %>;
|
||||
index index.php;
|
||||
|
||||
location / {
|
||||
try_files $uri $uri/ /index.php?$args;
|
||||
}
|
||||
|
||||
location ~ \.php$ {
|
||||
try_files $uri =404;
|
||||
include fastcgi_params;
|
||||
fastcgi_pass 127.0.0.1:9001;
|
||||
fastcgi_param SCRIPT_FILENAME <%= @docroot %>$fastcgi_script_name;
|
||||
}
|
||||
}
|
||||
31
cookbooks/wordpress/templates/default/wordpress.conf.erb
Normal file
31
cookbooks/wordpress/templates/default/wordpress.conf.erb
Normal file
@@ -0,0 +1,31 @@
|
||||
<VirtualHost *:<%= @params[:server_port] %>>
|
||||
ServerName <%= @params[:server_name] %>
|
||||
ServerAlias <% @params[:server_aliases].each do |a| %><%= a %> <% end %>
|
||||
DocumentRoot <%= @params[:docroot] %>
|
||||
|
||||
<Directory <%= @params[:docroot] %>>
|
||||
Options FollowSymLinks
|
||||
AllowOverride FileInfo Options
|
||||
<% if node['apache']['version'] == '2.4' %>
|
||||
Require all granted
|
||||
<% else %>
|
||||
Order allow,deny
|
||||
Allow from all
|
||||
<% end %>
|
||||
</Directory>
|
||||
|
||||
<Directory />
|
||||
Options FollowSymLinks
|
||||
AllowOverride None
|
||||
</Directory>
|
||||
|
||||
LogLevel info
|
||||
ErrorLog <%= node['apache']['log_dir'] %>/<%= @params[:name] %>-error.log
|
||||
CustomLog <%= node['apache']['log_dir'] %>/<%= @params[:name] %>-access.log combined
|
||||
|
||||
RewriteEngine On
|
||||
<% unless node['apache']['version'] == '2.4' %>
|
||||
RewriteLog <%= node['apache']['log_dir'] %>/<%= @application_name %>-rewrite.log
|
||||
RewriteLogLevel 0
|
||||
<% end %>
|
||||
</VirtualHost>
|
||||
99
cookbooks/wordpress/templates/default/wp-config.php.erb
Normal file
99
cookbooks/wordpress/templates/default/wp-config.php.erb
Normal file
@@ -0,0 +1,99 @@
|
||||
<?php
|
||||
/**
|
||||
* The base configurations of the WordPress.
|
||||
*
|
||||
* This file has the following configurations: MySQL settings, Table Prefix,
|
||||
* Secret Keys, WordPress Language, and ABSPATH. You can find more information
|
||||
* by visiting {@link http://codex.wordpress.org/Editing_wp-config.php Editing
|
||||
* wp-config.php} Codex page. You can get the MySQL settings from your web host.
|
||||
*
|
||||
* This file is used by the wp-config.php creation script during the
|
||||
* installation. You don't have to use the web site, you can just copy this file
|
||||
* to "wp-config.php" and fill in the values.
|
||||
*
|
||||
* @package WordPress
|
||||
*/
|
||||
|
||||
// ** MySQL settings - You can get this info from your web host ** //
|
||||
/** The name of the database for WordPress */
|
||||
define('DB_NAME', '<%= @db_name %>');
|
||||
|
||||
/** MySQL database username */
|
||||
define('DB_USER', '<%= @db_user %>');
|
||||
|
||||
/** MySQL database password */
|
||||
define('DB_PASSWORD', '<%= @db_password %>');
|
||||
|
||||
/** MySQL hostname */
|
||||
define('DB_HOST', '<%= @db_host %>');
|
||||
|
||||
/** Database Charset to use in creating database tables. */
|
||||
define('DB_CHARSET', '<%= @db_charset %>');
|
||||
|
||||
/** The Database Collate type. Don't change this if in doubt. */
|
||||
define('DB_COLLATE', '<%= @db_collate %>');
|
||||
|
||||
/**#@+
|
||||
* Authentication Unique Keys and Salts.
|
||||
*
|
||||
* Change these to different unique phrases!
|
||||
* You can generate these using the {@link https://api.wordpress.org/secret-key/1.1/salt/ WordPress.org secret-key service}
|
||||
* You can change these at any point in time to invalidate all existing cookies. This will force all users to have to log in again.
|
||||
*
|
||||
* @since 2.6.0
|
||||
*/
|
||||
define('AUTH_KEY', '<%= @auth_key %>');
|
||||
define('SECURE_AUTH_KEY', '<%= @secure_auth_key %>');
|
||||
define('LOGGED_IN_KEY', '<%= @logged_in_key %>');
|
||||
define('NONCE_KEY', '<%= @nonce_key %>');
|
||||
define('AUTH_SALT', '<%= @auth_salt %>');
|
||||
define('SECURE_AUTH_SALT', '<%= @secure_auth_salt %>');
|
||||
define('LOGGED_IN_SALT', '<%= @logged_in_salt %>');
|
||||
define('NONCE_SALT', '<%= @nonce_salt %>');
|
||||
|
||||
/**#@-*/
|
||||
|
||||
/**
|
||||
* WordPress Database Table prefix.
|
||||
*
|
||||
* You can have multiple installations in one database if you give each a unique
|
||||
* prefix. Only numbers, letters, and underscores please!
|
||||
*/
|
||||
$table_prefix = '<%= @db_prefix %>';
|
||||
|
||||
/**
|
||||
* WordPress Localized Language, defaults to English.
|
||||
*
|
||||
* Change this to localize WordPress. A corresponding MO file for the chosen
|
||||
* language must be installed to wp-content/languages. For example, install
|
||||
* de_DE.mo to wp-content/languages and set WPLANG to 'de_DE' to enable German
|
||||
* language support.
|
||||
*/
|
||||
define('WPLANG', '<%= @lang %>');
|
||||
|
||||
/**
|
||||
* For developers: WordPress debugging mode.
|
||||
*
|
||||
* Change this to true to enable the display of notices during development.
|
||||
* It is strongly recommended that plugin and theme developers use WP_DEBUG
|
||||
* in their development environments.
|
||||
*/
|
||||
define('WP_DEBUG', false);
|
||||
|
||||
<% if @allow_multisite %>
|
||||
/* Multisite */
|
||||
define( 'WP_ALLOW_MULTISITE', true );
|
||||
<% end %>
|
||||
|
||||
<% @wp_config_options.each do |key,value| %>
|
||||
define( '<%= key %>', <%= value %> );
|
||||
<% end %>
|
||||
|
||||
/* That's all, stop editing! Happy blogging. */
|
||||
|
||||
/** Absolute path to the WordPress directory. */
|
||||
if ( !defined('ABSPATH') )
|
||||
define('ABSPATH', dirname(__FILE__) . '/');
|
||||
|
||||
/** Sets up WordPress vars and included files. */
|
||||
require_once(ABSPATH . 'wp-settings.php');
|
||||
Reference in New Issue
Block a user