Version information
This version is compatible with:
- Puppet Enterprise 2019.8.x, 2019.7.x, 2019.5.x, 2019.4.x, 2019.3.x, 2019.2.x, 2019.1.x, 2019.0.x, 2018.1.x, 2017.3.x
- Puppet >= 5.0.0 < 7.0.0
- ,
Start using this module
Add this module to your Puppetfile:
mod 'adullact-wordpress', '3.1.0'
Learn more about managing modules with a PuppetfileDocumentation
wordpress
Table of Contents
- Description
- Setup - The basics of getting started with wordpress
- Usage - Configuration options and additional functionality
- Limitations - OS compatibility, etc.
- Development - Guide for contributing to the module
Description
This module downloads the WP-CLI tool and then uses it to download and configure WordPress instances.
This module does not manage a multisite installation but it can create one or several WordPress instances on same puppet node. Each instance, on the same node, has dedicated settings and can be managed separately.
Setup
What wordpress affects
As the name of module can explain, it affects WordPress installation and configuration.
This modules does not manage :
- system account, owner of WordPress files.
- nginx or apache vhost
- mariadb or mysql database and user
- php install
They have to be created before for instance by puppetlabs-mysql
, puppetlabs-apache
and puppetlabs-account
.
Setup Requirements
This wordpress
module depends on puppetlabs-stdlib
and puppet-archive
Beginning with wordpress
The following very basic step will install WP-CLI tool :
class { 'wordpress' :
}
Usage
Typical installation
The following code :
- downloads and installs WP-CLI.
- downloads and installs core WordPress in the last available version.
- creates tables in an already existing database
wp_mywpname
. - configures core WordPress
- sets the title of the instance.
- WP-CLI is ran as
wp
user. Files are owned by already existing userwp
.
class { 'wordpress' :
settings => {
'mywpname.mydomaine.com' => {
wproot => '/var/www/mywpname',
owner => 'wp',
dbhost => 'YY.YY.YY.YY',
dbname => 'wp_mywpname',
dbuser => 'mywp_dbusername',
dbpasswd => 'secretpass',
wpadminuser => 'mywp_adminuser',
wpadminpasswd => 'othersecret',
wpadminemail => 'foo@mydomain.com',
wptitle => 'the title is to deploy WordPress with puppet',
}
}
}
Typical installation + self update by WordPress
The following code :
- downloads and installs WP-CLI.
- downloads and installs core WordPress in the last available version.
- creates tables in an already existing database
wp_mywpname
. - configures core WordPress
- sets the title of the instance.
- WP-CLI is ran as
wp
user. Files are owned by already existing userwp
. - enables WordPress internal self update process (disabled by default).
class { 'wordpress' :
settings => {
'mywpname.mydomaine.com' => {
wproot => '/var/www/mywpname',
owner => 'wp',
dbhost => 'YY.YY.YY.YY',
dbname => 'wp_mywpname',
dbuser => 'mywp_dbusername',
dbpasswd => 'secretpass',
wpadminuser => 'mywp_adminuser',
wpadminpasswd => 'othersecret',
wpadminemail => 'foo@mydomain.com',
wptitle => 'the title is to deploy WordPress with puppet',
wpselfupdate => 'enabled',
}
}
}
Typical installation + update by Puppet
The following code :
- downloads and installs WP-CLI.
- downloads and installs core WordPress in the last available version.
- creates tables in an already existing database
wp_mywpname
. - configures core WordPress
- sets the title of the instance.
- WP-CLI is ran as
wp
user. Files are owned by already existing userwp
. - disables WordPress internal self update process.
- configures puppet to make WordPress core and language update to latest available version.
If an update occured (checked one time each day), you will
find in /var/wordpress_archives
:
- dump of database that was there before the update.
- archive of files that were there before the update.
class { 'wordpress' :
settings => {
'mywpname.mydomaine.com' => {
ensure => 'latest',
wproot => '/var/www/mywpname',
owner => 'wp',
dbhost => 'YY.YY.YY.YY',
dbname => 'wp_mywpname',
dbuser => 'mywp_dbusername',
dbpasswd => 'secretpass',
wpadminuser => 'mywp_adminuser',
wpadminpasswd => 'othersecret',
wpadminemail => 'foo@mydomain.com',
wptitle => 'the title is to deploy WordPress with puppet',
}
}
}
Typical installation + add themes + add plugins + locale
The following code :
- downloads and installs WP-CLI.
- downloads and installs core WordPress in the last available version and in french.
- creates tables in an already existing database
wp_mywpname
. - configures core WordPress
- sets the title of the instance.
- WP-CLI is ran as
wp
user. Files are owned by already existing userwp
. - manages more than defaults themes and plugins provided with core.
class { 'wordpress' :
settings => {
'mywpname.mydomaine.com' => {
wproot => '/var/www/mywpname',
owner => 'wp',
locale => 'fr_FR',
dbhost => 'YY.YY.YY.YY',
dbname => 'wp_mywpname',
dbuser => 'mywp_dbusername',
dbpasswd => 'secretpass',
wpadminuser => 'mywp_adminuser',
wpadminpasswd => 'othersecret',
wpadminemail => 'foo@mydomain.com',
wptitle => 'the title is to deploy WordPress with puppet',
wpresources => {
plugin => [
{ name => 'plugin1', 'ensure' => 'present' },
{ name => 'plugin2', 'ensure' => 'absent' },
],
theme => [
{ name => 'themenew', 'ensure' => 'latest' },
{ name => 'themeold', 'ensure' => 'absent' },
]
},
},
},
}
Several installations
The following code makes two installations on same Puppet node with dedicated settings :
- only WordPress in
wp2.foo.org
in updated by Puppet, the other is not updated at all. - the two WordPress instances use the same database server.
- the list of used plugins and themes configure are differents in each intance.
class { 'wordpress':
settings => {
'wp2.foo.org' => {
ensure => 'latest',
owner => 'wp2',
locale => 'fr_FR',
dbhost => 'XX.XX.XX.XX',
dbname => 'wordpress2',
dbuser => 'wp2userdb',
dbpasswd => 'secret_a',
wproot => '/var/www/wp2.foo.org',
wptitle => 'hola this wp2 instance is installed by puppet',
wpadminuser => 'wpadmin',
wpadminpasswd => 'secret_b',
wpadminemail => 'bar@foo.org',
wpresources => {
plugin => [
{ name => 'plugin_a', 'ensure' => 'latest' },
{ name => 'plugin_b', 'ensure' => 'absent' },
],
theme => [
{ name => 'themenew_a', },
{ name => 'themeold_a', 'ensure' => 'absent' },
]
},
},
'wp3.foo.org' => {
owner => 'wp3',
dbhost => 'XX.XX.XX.XX',
dbname => 'wordpress3',
dbuser => 'wp3userdb',
dbpasswd => 'secret_c',
wproot => '/var/www/wp3.foo.org',
wptitle => 'hola this wp3 instance is installed by puppet',
wpadminuser => 'wpadmin',
wpadminpasswd => 'secret_d',
wpadminemail => 'bar@foo.org',
wpresources => {
plugin => [
{ name => 'plugin_a', },
{ name => 'plugin_b', },
{ name => 'plugin_c', },
{ name => 'plugin_d', 'ensure' => 'absent' },
],
theme => [
{ name => 'themenew_b', },
{ name => 'themeold_a', 'ensure' => 'absent' },
]
},
},
},
}
Reference
Details in REFERENCE.md
.
Limitations
This module is tested with following OSes :
- Ubuntu 16.04
- Debian 8, 9
Known bugs are listed in CHANGELOG.md
file.
Even if module should work with Puppet4, Puppet 4 is end of life since 2019-01-01. So tests with Puppet 4 are removed. Acceptance tests are done with last available release of Puppet 5 and Puppet 6 (AIO).
PHP shiped with CentOS 7 is version 5.4. WordPress 5.2 requires at least 5.6.20. Default values for CentOS7 are not removed from the code. By this way we expect the module should works if php version requirement is respected. But, CentOS7 is removed from acceptance tests and from the list of compatible OSes.
Development
Home at URL https://gitlab.adullact.net/adullact/puppet-wordpress
Issues and MR are welcome.
Mirrored at URL https://github.com/adullact/puppet-wordpress
Release Notes/Contributors/License.
Details in CHANGELOG.md
.
Copyright (C) 2018 Association des Développeurs et Utilisateurs de Logiciels Libres
pour les Administrations et Colléctivités Territoriales.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/agpl.html>.
Reference
Table of Contents
Classes
Public Classes
wordpress
: Install WP-CLI tool, use it to download wordpress core, create tables in database, configure WordPress and manage plugins and themes.wordpress::params
: Sets defaults values for some variables and parameters.
Private Classes
wordpress::cli
: Install lastest WP-CLI tool.wordpress::core
: Use WP-CLI to download last version of WordPress core, create tables in database and configure WordPress.wordpress::external_fact
: Deploy files to forge an external fact named 'wordpress'wordpress::resource
: download and manage resources aka plugins and themes.wordpress::site
: Use WP-CLI to download last version of WordPress core, create tables in database and configure WordPress.
Defined types
Public Defined types
Private Defined types
wordpress::config::admin
: Configure settings (name password and email) of one user in the desired state.wordpress::config::option
: Configure an option in the desired statewordpress::core::config
: configure WordPress instance.wordpress::core::install
: Downloads and installs WordPress core and language.wordpress::core::update
: Backup and update WordPress core and language.wordpress::resource::activate
: Activates an already installed resource aka plugin or theme.wordpress::resource::install
: Downloads and installs a resource aka plugin or theme.wordpress::resource::uninstall
: Uninstall an already installed resource aka plugin or theme.wordpress::resource::update
: Updates an already installed resource aka plugin or theme.
Functions
wordpress::password_hash
: Hash a string
Classes
wordpress
Install WP-CLI tool, use it to download wordpress core, create tables in database, configure WordPress and manage plugins and themes.
Examples
Configure one WordPress instance for URL wordpress.foo.org by using already existing database server and database account and web server with vhost root '/var/www/wordpress.foo.org'.
class { 'wordpress':
settings => {
'wordpress.foo.org' => {
owner => 'wp',
dbhost => 'XX.XX.XX.XX',
dbname => 'wordpress',
dbuser => 'wpuserdb',
dbpasswd => 'kiki',
wproot => '/var/www/wordpress.foo.org',
wptitle => 'hola this wordpress instance is installed by puppet',
wpadminuser => 'wpadmin',
wpadminpasswd => 'lolo',
wpadminemail => 'bar@foo.org',
}
}
}
Bellow the datatype of `$settings`. Parameters without a default value are mandatory unless otherwise stated.
Hash[
String, # The URI of the WordPress instance (like : www.foo.org).
Hash[
Enum[
'ensure', # Possible values : present, absent, lastest (defaults present).
'wproot', # Path where is located root of WordPress instance.
'owner', # User that own files of WordPress instance.
'locale', # Language used by WordPress instance (defaults en_US).
'dbhost', # Address of the database server (must be MySQL or MariaDB).
'dbname', # Name of the database where tables of WordPress instance are stored.
'dbuser', # User of the database used by wordpress to connect to the database server.
'dbpasswd', # Password of the user of the database.
'dbprefix', # Set table prefix (defaults wp<random_number_with_4_digits>).
'wpselfupdate', # Possible values : disabled , enabled (defaults disabled).
'wptitle', # Init title of the WordPress instance.
'wpadminuser', # Name of admin account of the WordPress instance.
'wpadminpasswd', # Password of the admin account of the WordPress instance.
'wpadminemail', # email address of the admin account.
'wpresources', # Settings for plugins and themes (not mandatory).
],
Variant[
String,
Hash[
Enum[
'plugin',
'theme',
],
Array[
Hash[
Enum[
'name', # Name of the plugin or theme
'ensure', # Possible values : present, absent, latest (defaults present).
],
String
]
]
]
]
]
]
Parameters
The following parameters are available in the wordpress
class.
settings
Data type: Hash
Describes all availables settings in this module for all wordpress instances on this node. Defaults to empty hash.
Default value: {}
wparchives_path
Data type: Pattern['^/']
Gives the path where are stored archives done before update managed by puppet (not by WordPress itself with wpselfupdate
). Defaults to /var/wordpress_archives.
Default value: $wordpress::params::default_wparchives_path
wpcli_url
Data type: Pattern['^http']
Gives the address from which to download the WP-CLI tool. Defaults to 'https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar'.
Default value: $wordpress::params::default_wpcli_url
wpcli_bin
Data type: Pattern['^/']
Gives the path where the WP-CLI tools is deployed. Defaults to '/usr/local/bin/wp'.
Default value: $wordpress::params::default_wpcli_bin
hour_fact_update
Data type: Integer[1,23]
Gives the time (hour between 1 and 23) at which the update of external fact is done. Defaults to 7.
Default value: $wordpress::params::default_hour_fact_update
wordpress::params
Sets defaults values for some variables and parameters.
Defined types
Functions
wordpress::password_hash
Type: Ruby 4.x API
Hash a string
wordpress::password_hash(String $password)
The wordpress::password_hash function.
Returns: String
the password hash from the clear text password.
password
Data type: String
Plain text password.
Changelog
All notable changes to this project will be documented in this file.
Release 3.1.0
Features
- #82 allow puppetlabs/stdlib 6.x and puppet/archive 4.x
Release 3.0.0
Features
- #80 remove CentOS7 from compatible OSes
- #72 add Ubuntu1804 to compatible OSes
- #45 set a fixed version of installed WP-CLI
Bugfixes
- #78 space and double quote can be present in WP-CLI output
- #68 warning about String format is deprecated for #strftime
Known Issues
Release 2.0.0
Features
- #55 add debian9 support
- #57 use schedure resource instead of cron
- #63 README , details about basic usage
- #69 remove puppet4 acceptance tests
Bugfixes
- #64 update a resource can be not idempotent
- #65 remove :: usage
- #66 core update can be done in an idempotent way
- #67 declare private types as private
Known Issues
Release 1.3.5
Features
- #56 add puppet6 support
Bugfixes
Known Issues
Release 1.3.4
Features
Bugfixes
- #50 Build module with pdk 1.7.0.
- #51 Enable rubocop.
- #52 Enable beaker debug.
Known Issues
Release 1.3.3
Features
Bugfixes
- #48 move to beaker 4
Known Issues
Release 1.3.2
Features
Bugfixes
- #36 Modifying settings of administrator modifies nothing.
- #42 Modifying value of title in data modifies nothing.
- #44 An already installed plugin but not yet activated is never activated.
Known Issues
Release 1.3.1
Features
Bugfixes
- #25 Command wp core config is deprecated.
- #38 Update module compatiblility with pdk 1.6.1.
- #41 Exec with tar commande to make archive files before upgrade need path.
- #40 Add forgotten pdk new defined_type.
Known Issues
- #36 Modifying settings of administrator modifies nothing.
Release 1.3.0
Features
Bugfixes
- #33 Be able to use parameter to define archives path.
- #34 Use nokogiri provided by pdk for tests.
- #35 Update README description.
Known Issues
Release 1.2.0
Features
Bugfixes
- #1 Fix resources attribute ensure set to latest from scratch.
- #27 Fix typo in puppet strings.
- #28 Fix WordPress core attribute ensure set to latest from scratch.
- #29 Fix external fact variable extrapolation.
- #30 Fix missing assume yes answer in
spec_helper_acceptance.rb
. - #31 Add note about private aspect in puppet string.
- #32 Fix color in wp core check-update can mess up the data in the fact.
Known Issues
Release 1.1.3
Features
Bugfixes
- #20 Remove flag --allow-root when possible with WP-CLI.
- #23 Add details about settings parameter.
- #24 Modify default owner for CentOS.
Known Issues
- #1 Fix resources attribute ensure set to latest from scratch.
Release 1.1.2
Features
Bugfixes
- #22 Add multi instances example in README.
Known Issues
- #1 Fix resources attribute ensure set to latest from scratch.
Release 1.1.1
Features
Bugfixes
- #19 Fix README in usage with update by Puppet.
- #21 Update metadata for release 1.1.1.
Known Issues
- #1 Fix resources attribute ensure set to latest from scratch.
Release 1.1.0
Features
Bugfixes
- #5 Permit to modify hour of update for external_fact.
- #15 Fix plugins are installed but not activated.
- #16 Set
default_locale
toen_US
. - #17 In README add subtitles for different examples of usage.
Known Issues
- #1 Fix resources attribute ensure set to latest from scratch.
Release 1.0.3
Features
Bugfixes
- #9 Add acceptence tests about ressources.
- #10 Add acceptence tests about management of several instances.
- #13 Update README section Beginning with wordpress.
Known Issues
- #1 Fix attribute ensure set to latest from scratch with resources management.
- #5 Permit to modify hour of update for external_fact.
- #15 Fix plugins are installed but not activated.
- #16 Set
default_locale
toen_US
.
Release 1.0.2
Features
Bugfixes
- #11 Remove lint setting
no-only_variable_string-check
. - #12 Write WP-CLI instead of wpcli in project description.
Known Issues
- #1 Fix resources attribute ensure set to latest from scratch.
- #5 Permit to modify hour of update for external_fact.
Release 1.0.1
Features
Bugfixes
- #7 Add missing keywords in metadata.json.
- #8 Fix version in metadata.json.
Known Issues
- #1 Fix resources attribute ensure set to latest from scratch.
- #5 Permit to modify hour of update for external_fact.
Release 1.0.0
Features
Bugfixes
- #6 bump version to publish 1.0.0
Known Issues
- #1 Fix resources attribute ensure set to latest from scratch.
- #5 Permit to modify hour of update for external_fact.
Release 0.2.0
Features
Bugfixes
- #2 Fix license.
- #3 Add informations in chapter
Limitations
in README. - #4 Update CHANGELOG.
Known Issues
- #1 Fix resources attribute ensure set to latest from scratch.
- #5 Permit to modify hour of update for external_fact.
Dependencies
- puppetlabs-stdlib (>= 4.0.0 < 7.0.0)
- puppet-archive (>= 3.0.0 < 5.0.0)