forked from jonhadfield/puppet-wordpress
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Essentially a rewrite of the whole module
- Loading branch information
Showing
10 changed files
with
305 additions
and
243 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,14 @@ | ||
name 'puppet-wordpress' | ||
version '0.0.4' | ||
source 'https://github.com/jonhadfield/puppet-wordpress' | ||
author 'Jon Hadfield' | ||
version '0.1.0' | ||
source 'https://github.com/hunner/puppet-wordpress' | ||
author 'Hunter Haugen' | ||
license 'Apache2' | ||
summary 'Puppet module to set up an instance of wordpress' | ||
description 'Installs wordpress and dependencies.' | ||
project_page 'https://github.com/jonhadfield/puppet-wordpress' | ||
description 'Installs wordpress and required mysql user. Configuration of apache and the MySQL server is required.' | ||
project_page 'https://github.com/hunner/puppet-wordpress' | ||
|
||
## Add dependencies, if any: | ||
dependency 'ripienaar/concat', '>= 0.2.0' | ||
dependency 'puppetlabs/mysql', '>= 0.5.0' | ||
dependency 'puppetlabs/apache', '>= 0.4.0' | ||
dependency 'puppetlabs/stdlib', '>= 2.3.1' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
# WordPress Module | ||
|
||
## Overview | ||
|
||
This will set up an installation of Wordpress 3.5 on Debian and Redhat style distributions. | ||
|
||
## Capabilities | ||
|
||
Installation includes: | ||
|
||
- Configuration of WordPress DB connection parameters | ||
- Generate secure keys and salts for `wp-config.php`. | ||
- Optional creation of MySQL database/user/permissions. | ||
|
||
## Parameters | ||
|
||
* `install_dir`<br /> | ||
Specifies the directory into which wordpress should be installed. Default: `/opt/wordpress` | ||
|
||
* `version`<br /> | ||
Specifies the version of wordpress to install. Default: `3.5` | ||
|
||
* `create_db`<br /> | ||
Specifies whether to create the db or not. Default: `true` | ||
|
||
* `create_db_user`<br /> | ||
Specifies whether to create the db user or not. Default: `true` | ||
|
||
* `db_name`<br /> | ||
Specifies the database name which the wordpress module should be configured to use. Default: `wordpress` | ||
|
||
* `db_host`<br /> | ||
Specifies the database host to connect to. Default: `localhost` | ||
|
||
* `db_user`<br /> | ||
Specifies the database user. Default: `wordpress` | ||
|
||
* `db_password`<br /> | ||
Specifies the database user's password in plaintext. Default: `password` | ||
|
||
* `wp_owner`<br /> | ||
Specifies the owner of the wordpress files. Default: `root` | ||
|
||
* `wp_group`<br /> | ||
Specifies the group of the wordpress files. Default: `0` (\*BSD/Darwin compatible GID) | ||
|
||
## Example Usage | ||
|
||
Default deployment (insecure; default passwords and installed as root): | ||
|
||
```puppet | ||
class { 'wordpress': } | ||
``` | ||
|
||
Basic deployment (secure database password, installed as `wordpress` user/group): | ||
|
||
```puppet | ||
class { 'wordpress': | ||
wp_owner => 'wordpress', | ||
wp_group => 'wordpress', | ||
db_user => 'wordpress', | ||
db_password => 'hvyH(S%t(\"0\"16', | ||
} | ||
``` | ||
|
||
Externally hosted MySQL DB: | ||
|
||
```puppet | ||
class { 'wordpress': | ||
db_user => 'wordpress', | ||
db_password => 'hvyH(S%t(\"0\"16', | ||
db_host => 'db.example.com', | ||
} | ||
``` | ||
|
||
Disable module's database/user creation (the database and db user must still exist with correct permissions): | ||
|
||
```puppet | ||
class { 'wordpress': | ||
db_user => 'wordpress', | ||
db_password => 'hvyH(S%t(\"0\"16', | ||
create_db => false, | ||
create_db_user => false, | ||
} | ||
``` | ||
|
||
Install specific version of WordPress: | ||
|
||
```puppet | ||
class { 'wordpress': | ||
version => '3.4', | ||
} | ||
``` | ||
|
||
Install WordPress to a specific directory: | ||
|
||
```puppet | ||
class { 'wordpress': | ||
install_dir => '/var/www/wordpress', | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,130 +1,69 @@ | ||
class wordpress::app { | ||
|
||
$wordpress_archive = 'wordpress-3.4.1.zip' | ||
|
||
$apache = $::operatingsystem ? { | ||
Ubuntu => apache2, | ||
CentOS => httpd, | ||
Debian => apache2, | ||
default => httpd | ||
class wordpress::app ( | ||
$install_dir, | ||
$version, | ||
$db_name, | ||
$db_host, | ||
$db_user, | ||
$db_password, | ||
$wp_owner, | ||
$wp_group, | ||
) { | ||
## Resource defaults | ||
File { | ||
owner => $wp_owner, | ||
group => $wp_group, | ||
mode => '0644', | ||
} | ||
|
||
$phpmysql = $::operatingsystem ? { | ||
Ubuntu => php5-mysql, | ||
CentOS => php-mysql, | ||
Debian => php5-mysql, | ||
default => php-mysql | ||
Exec { | ||
path => ['/bin','/sbin','/usr/bin','/usr/sbin'], | ||
cwd => $install_dir, | ||
logoutput => 'on_failure', | ||
user => $wp_owner, | ||
group => $wp_group, | ||
} | ||
|
||
$php = $::operatingsystem ? { | ||
Ubuntu => libapache2-mod-php5, | ||
CentOS => php, | ||
Debian => libapache2-mod-php5, | ||
default => php | ||
## Installation directory | ||
file { $install_dir: | ||
ensure => directory, | ||
recurse => true, | ||
} | ||
|
||
package { ['unzip',$apache,$php,$phpmysql]: | ||
ensure => latest | ||
## Download and extract | ||
exec { 'Download wordpress': | ||
command => "wget http://wordpress.org/wordpress-${version}.tar.gz", | ||
creates => "${install_dir}/wordpress-${version}.tar.gz", | ||
require => File[$install_dir], | ||
} | ||
|
||
$vhost_path = $apache ? { | ||
httpd => '/etc/httpd/conf.d/wordpress.conf', | ||
apache2 => '/etc/apache2/sites-enabled/000-default', | ||
default => '/etc/httpd/conf.d/wordpress.conf', | ||
-> exec { 'Extract wordpress': | ||
command => "tar zxvf ./wordpress-${version}.tar.gz --strip-components=1", | ||
creates => "${install_dir}/index.php", | ||
} | ||
|
||
service { $apache: | ||
ensure => running, | ||
enable => true, | ||
hasrestart => true, | ||
hasstatus => true, | ||
require => Package[$apache, $php, $phpmysql], | ||
subscribe => File['wordpress_vhost']; | ||
## Configure wordpress | ||
# | ||
# Template uses no variables | ||
file { "${install_dir}/wp-keysalts.php": | ||
ensure => present, | ||
content => template('wordpress/wp-keysalts.php.erb'), | ||
replace => false, | ||
require => Exec['Extract wordpress'], | ||
} | ||
|
||
file { | ||
'wordpress_application_dir': | ||
ensure => directory, | ||
path => '/opt/wordpress', | ||
before => File['wordpress_setup_files_dir']; | ||
'wordpress_setup_files_dir': | ||
ensure => directory, | ||
path => '/opt/wordpress/setup_files', | ||
before => File[ | ||
'wordpress_php_configuration', | ||
'wordpress_themes', | ||
'wordpress_plugins', | ||
'wordpress_installer', | ||
'wordpress_htaccess_configuration' | ||
]; | ||
'wordpress_installer': | ||
ensure => file, | ||
path => "/opt/wordpress/setup_files/${wordpress_archive}", | ||
notify => Exec['wordpress_extract_installer'], | ||
source => "puppet:///modules/wordpress/${wordpress_archive}"; | ||
'wordpress_php_configuration': | ||
ensure => file, | ||
path => '/opt/wordpress/wp-config.php', | ||
content => template('wordpress/wp-config.erb'), | ||
subscribe => Exec['wordpress_extract_installer']; | ||
'wordpress_htaccess_configuration': | ||
ensure => file, | ||
path => '/opt/wordpress/.htaccess', | ||
source => 'puppet:///modules/wordpress/.htaccess', | ||
subscribe => Exec['wordpress_extract_installer']; | ||
'wordpress_themes': | ||
ensure => directory, | ||
path => '/opt/wordpress/setup_files/themes', | ||
source => 'puppet:///modules/wordpress/themes/', | ||
recurse => true, | ||
purge => true, | ||
ignore => '.svn', | ||
notify => Exec['wordpress_extract_themes'], | ||
subscribe => Exec['wordpress_extract_installer']; | ||
'wordpress_plugins': | ||
ensure => directory, | ||
path => '/opt/wordpress/setup_files/plugins', | ||
source => 'puppet:///modules/wordpress/plugins/', | ||
recurse => true, | ||
purge => true, | ||
ignore => '.svn', | ||
notify => Exec['wordpress_extract_plugins'], | ||
subscribe => Exec['wordpress_extract_installer']; | ||
'wordpress_vhost': | ||
ensure => file, | ||
path => $vhost_path, | ||
source => 'puppet:///modules/wordpress/wordpress.conf', | ||
replace => true, | ||
require => Package[$apache]; | ||
} | ||
|
||
exec { | ||
'wordpress_extract_installer': | ||
command => "unzip -o\ | ||
/opt/wordpress/setup_files/${wordpress_archive}\ | ||
-d /opt/", | ||
refreshonly => true, | ||
require => Package['unzip'], | ||
path => ['/bin','/usr/bin','/usr/sbin','/usr/local/bin']; | ||
'wordpress_extract_themes': | ||
command => '/bin/sh -c \'for themeindex in `ls \ | ||
/opt/wordpress/setup_files/themes/*.zip`; \ | ||
do unzip -o \ | ||
$themeindex -d \ | ||
/opt/wordpress/wp-content/themes/; done\'', | ||
path => ['/bin','/usr/bin','/usr/sbin','/usr/local/bin'], | ||
refreshonly => true, | ||
require => Package['unzip'], | ||
subscribe => File['wordpress_themes']; | ||
'wordpress_extract_plugins': | ||
command => '/bin/sh -c \'for pluginindex in `ls \ | ||
/opt/wordpress/setup_files/plugins/*.zip`; \ | ||
do unzip -o \ | ||
$pluginindex -d \ | ||
/opt/wordpress/wp-content/plugins/; done\'', | ||
path => ['/bin','/usr/bin','/usr/sbin','/usr/local/bin'], | ||
refreshonly => true, | ||
require => Package['unzip'], | ||
subscribe => File['wordpress_plugins']; | ||
concat { "${install_dir}/wp-config.php": | ||
owner => $wp_owner, | ||
group => $wp_group, | ||
mode => '0755', | ||
require => Exec['Extract wordpress'], | ||
} | ||
concat::fragment { 'wp-config.php keysalts': | ||
target => "${install_dir}/wp-config.php", | ||
source => "${install_dir}/wp-keysalts.php", | ||
order => '10', | ||
require => File["${install_dir}/wp-keysalts.php"], | ||
} | ||
# Template uses: $db_name, $db_user, $db_password, $db_host | ||
concat::fragment { 'wp-config.php body': | ||
target => "${install_dir}/wp-config.php", | ||
content => template('wordpress/wp-config.php.erb'), | ||
order => '20', | ||
} | ||
} |
Oops, something went wrong.