Skip to content
This repository has been archived by the owner on Nov 23, 2017. It is now read-only.

Commit

Permalink
wordpress cookbook use strings for keys
Browse files Browse the repository at this point in the history
  • Loading branch information
jtimberman committed May 25, 2011
1 parent 4c93d2d commit c8f6e6f
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 48 deletions.
28 changes: 17 additions & 11 deletions wordpress/README.rdoc → wordpress/README.md
@@ -1,14 +1,16 @@
= DESCRIPTION:
Description
====

Installs and configures Wordpress according to the instructions at http://codex.wordpress.org/Installing_WordPress. Does not set up a 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:
Requirements
====

== Platform:
## Platform

Tested on Ubuntu 9.04, 9.10.

== Cookbooks:
## Cookbooks

Opscode cookbooks, http://github.com/opscode/cookbooks/tree/master:

Expand All @@ -17,11 +19,12 @@ Opscode cookbooks, http://github.com/opscode/cookbooks/tree/master:
* apache2
* opensssl

== Libraries:
## Libraries

The openssl library is required from the openssl cookbook to generate secure passwords.

= ATTRIBUTES:
Attributes
====

* wordpress[:version] - Set the version to download.
* wordpress[:checksum] - sha256sum of the tarball, make sure this matches for the version!
Expand All @@ -39,7 +42,8 @@ Attributes will probably never need to change (these all default to randomly gen

The random generation is handled with the secure_password method in the openssl cookbook which is a cryptographically secure random generator and not predictable like the random method in the ruby standard library.

= USAGE:
Usage
====

If a different version than the default is desired, download that version and get the SHA256 checksum (sha256sum on Linux systems), and set the version and checksum attributes.

Expand All @@ -49,15 +53,17 @@ Chef will install and configure mysql, php, and apache2 according to the instruc

The mysql::server recipe needs to come first, and contain an execute resource to install mysql privileges from the grants.sql template in this cookbook.

== Note about MySQL:
## Note about MySQL

This cookbook will decouple the mysql::server and be smart about detecting whether to use a local database or find a database server in the environment in a later version.

= LICENSE and AUTHOR:
License and Author
====

Author:: Barry Steinglass (barry@opscode.com>)
Author:: Barry Steinglass (barry@opscode.com)
Author:: Joshua Timberman (joshua@opscode.com)

Copyright:: 2010, Opscode, Inc
Copyright:: 2010-2011, Opscode, Inc

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
10 changes: 5 additions & 5 deletions wordpress/attributes/default.rb
Expand Up @@ -19,8 +19,8 @@
#

# General settings
default[:wordpress][:version] = "3.1.2"
default[:wordpress][:checksum] = "1006a1bb97b42381ad82490d00d9b7fb9f7a1c9d83ee2ed36935a9eb99c81064"
default[:wordpress][:dir] = "/var/www/wordpress"
default[:wordpress][:db][:database] = "wordpressdb"
default[:wordpress][:db][:user] = "wordpressuser"
default['wordpress']['version'] = "3.1.2"
default['wordpress']['checksum'] = "1006a1bb97b42381ad82490d00d9b7fb9f7a1c9d83ee2ed36935a9eb99c81064"
default['wordpress']['dir'] = "/var/www/wordpress"
default['wordpress']['db']['database'] = "wordpressdb"
default['wordpress']['db']['user'] = "wordpressuser"
4 changes: 2 additions & 2 deletions wordpress/metadata.rb
Expand Up @@ -2,8 +2,8 @@
maintainer_email "cookbooks@opscode.com"
license "Apache 2.0"
description "Installs/Configures wordpress"
long_description IO.read(File.join(File.dirname(__FILE__), 'README.rdoc'))
version "0.8.0"
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version "0.8.1"

recipe "wordpress", "Installs and configures wordpress LAMP stack on a single system"

Expand Down
64 changes: 34 additions & 30 deletions wordpress/recipes/default.rb
Expand Up @@ -29,33 +29,33 @@
server_fqdn = node.fqdn
end

node.set[:wordpress][:db][:password] = secure_password
node.set[:wordpress][:keys][:auth] = secure_password
node.set[:wordpress][:keys][:secure_auth] = secure_password
node.set[:wordpress][:keys][:logged_in] = secure_password
node.set[:wordpress][:keys][:nonce] = secure_password
node.set['wordpress']['db']['password'] = secure_password
node.set['wordpress']['keys']['auth'] = secure_password
node.set['wordpress']['keys']['secure_auth'] = secure_password
node.set['wordpress']['keys']['logged_in'] = secure_password
node.set['wordpress']['keys']['nonce'] = secure_password

remote_file "#{Chef::Config[:file_cache_path]}/wordpress-#{node[:wordpress][:version]}.tar.gz" do
checksum node[:wordpress][:checksum]
source "http://wordpress.org/wordpress-#{node[:wordpress][:version]}.tar.gz"
remote_file "#{Chef::Config[:file_cache_path]}/wordpress-#{node['wordpress']['version']}.tar.gz" do
checksum node['wordpress']['checksum']
source "http://wordpress.org/wordpress-#{node['wordpress']['version']}.tar.gz"
mode "0644"
end

directory "#{node[:wordpress][:dir]}" do
directory "#{node['wordpress']['dir']}" do
owner "root"
group "root"
mode "0755"
action :create
end

execute "untar-wordpress" do
cwd node[:wordpress][:dir]
command "tar --strip-components 1 -xzf #{Chef::Config[:file_cache_path]}/wordpress-#{node[:wordpress][:version]}.tar.gz"
creates "#{node[:wordpress][:dir]}/wp-settings.php"
cwd node['wordpress']['dir']
command "tar --strip-components 1 -xzf #{Chef::Config[:file_cache_path]}/wordpress-#{node['wordpress']['version']}.tar.gz"
creates "#{node['wordpress']['dir']}/wp-settings.php"
end

execute "mysql-install-wp-privileges" do
command "/usr/bin/mysql -u root -p#{node[:mysql][:server_root_password]} < /etc/mysql/wp-grants.sql"
command "/usr/bin/mysql -u root -p#{node['mysql']['server_root_password']} < /etc/mysql/wp-grants.sql"
action :nothing
end

Expand All @@ -66,19 +66,19 @@
group "root"
mode "0600"
variables(
:user => node[:wordpress][:db][:user],
:password => node[:wordpress][:db][:password],
:database => node[:wordpress][:db][:database]
:user => node['wordpress']['db']['user'],
:password => node['wordpress']['db']['password'],
:database => node['wordpress']['db']['database']
)
notifies :run, resources(:execute => "mysql-install-wp-privileges"), :immediately
notifies :run, "execute[mysql-install-wp-privileges]", :immediately
end

execute "create #{node[:wordpress][:db][:database]} database" do
command "/usr/bin/mysqladmin -u root -p#{node[:mysql][:server_root_password]} create #{node[:wordpress][:db][:database]}"
execute "create #{node['wordpress']['db']['database']} database" do
command "/usr/bin/mysqladmin -u root -p#{node['mysql']['server_root_password']} create #{node['wordpress']['db']['database']}"
not_if do
require 'mysql'
m = Mysql.new("localhost", "root", node[:mysql][:server_root_password])
m.list_dbs.include?(node[:wordpress][:db][:database])
m = Mysql.new("localhost", "root", node['mysql']['server_root_password'])
m.list_dbs.include?(node['wordpress']['db']['database'])
end
notifies :create, "ruby_block[save node data]", :immediately
end
Expand All @@ -95,26 +95,30 @@
action :nothing
end

template "#{node[:wordpress][:dir]}/wp-config.php" do
template "#{node['wordpress']['dir']}/wp-config.php" do
source "wp-config.php.erb"
owner "root"
group "root"
mode "0644"
variables(
:database => node[:wordpress][:db][:database],
:user => node[:wordpress][:db][:user],
:password => node[:wordpress][:db][:password],
: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]
:database => node['wordpress']['db']['database'],
:user => node['wordpress']['db']['user'],
:password => node['wordpress']['db']['password'],
: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']
)
notifies :write, "log[Navigate to 'http://#{server_fqdn}/wp-admin/install.php' to complete wordpress installation]"
end

apache_site "000-default" do
enable false
end

web_app "wordpress" do
template "wordpress.conf.erb"
docroot "#{node[:wordpress][:dir]}"
docroot "#{node['wordpress']['dir']}"
server_name server_fqdn
server_aliases node.fqdn
end

0 comments on commit c8f6e6f

Please sign in to comment.