Skip to content

Commit

Permalink
Adding wordpress state and adding formula dependencies in README
Browse files Browse the repository at this point in the history
  • Loading branch information
nmadhok committed Jan 8, 2015
1 parent 3796be1 commit c78c22d
Show file tree
Hide file tree
Showing 3 changed files with 162 additions and 1 deletion.
14 changes: 13 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Available states
Install and configure wordpress

Pillar customizations:
==========================
======================

.. code-block:: yaml
Expand All @@ -23,3 +23,15 @@ Pillar customizations:
wp-passwords:
wordpress: wordpressPassword
root: wordpressDatabasePassword
Formula Dependencies
====================

* `apache-formula <https://github.com/saltstack-formulas/apache-formula>`_
* `mysql-formula <https://github.com/saltstack-formulas/mysql-formula>`_
* `php-formula <https://github.com/saltstack-formulas/php-formula>`_

Author
======

Nitin Madhok nmadhok@g.clemson.edu
84 changes: 84 additions & 0 deletions wordpress/files/wp-config.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
<?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', '{{ database }}');

/** MySQL database username */
define('DB_USER', '{{ username }}');

/** MySQL database password */
define('DB_PASSWORD', '{{ password }}');

/** MySQL hostname */
define('DB_HOST', 'localhost');

/** Database Charset to use in creating database tables. */
define('DB_CHARSET', 'utf8');

/** The Database Collate type. Don't change this if in doubt. */
define('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
*/

require_once(ABSPATH . 'wp-keys.php');

/**#@-*/

/**
* 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 = 'wp_';

/**
* 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', '');

/**
* 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);

/* 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');
65 changes: 65 additions & 0 deletions wordpress/init.sls
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
{% if grains['os_family'] == 'RedHat' %}

wordpress-packages:
pkg.latest:
- pkgs:
- php-mysql
- MySQL-python
- require:
- pkg: mysql-packages

wordpress-database:
mysql_database.present:
- name: {{ pillar['wordpress']['wp-database'] }}
- require:
- service: mysqld
- pkg: wordpress-packages
mysql_user.present:
- name: {{ pillar['wordpress']['wp-username'] }}
- host: localhost
- password: {{ pillar['wordpress']['wp-passwords']['wordpress'] }}
- require:
- service: mysqld
- pkg: wordpress-packages
mysql_grants.present:
- database: {{ pillar['wordpress']['wp-database'] }}.*
- grant: all privileges
- user: {{ pillar['wordpress']['wp-username'] }}
- host: localhost
- require:
- mysql_database: {{ pillar['wordpress']['wp-database'] }}
- mysql_user: {{ pillar['wordpress']['wp-username'] }}

get-wordpress:
cmd.run:
- name: 'curl -O http://wordpress.org/latest.tar.gz && tar xvzf latest.tar.gz && /bin/rm latest.tar.gz'
- cwd: /var/www/html/
- unless: test -d /var/www/html/wordpress
- require:
- pkg: httpd-packages
- require_in:
- file: /var/www/html/wordpress/wp-config.php

wordpress-keys-file:
cmd.run:
- name: /usr/bin/curl -s -o /var/www/html/wordpress/wp-keys.php https://api.wordpress.org/secret-key/1.1/salt/ && /bin/sed -i "1i\\<?php" /var/www/html/wordpress/wp-keys.php && chown -R apache:apache /var/www/html/wordpress
- unless: test -e /var/www/html/wordpress/wp-keys.php
- require_in:
- file: /var/www/html/wordpress/wp-config.php

wordpress-config:
file.managed:
- name: /var/www/html/wordpress/wp-config.php
- source: salt://mysql/files/wp-config.php
- mode: 0644
- user: apache
- group: apache
- template: jinja
- context:
username: {{ pillar['wordpress']['wp-username'] }}
database: {{ pillar['wordpress']['wp-database'] }}
password: {{ pillar['wordpress']['wp-passwords']['wordpress'] }}
- require:
- cmd: get-wordpress

{% endif %}

0 comments on commit c78c22d

Please sign in to comment.