Skip to content

Commit

Permalink
basic lemp stack for drupal
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Pirog committed Oct 6, 2012
1 parent 58a2793 commit 6496a51
Show file tree
Hide file tree
Showing 82 changed files with 3,857 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*DS_Store*
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
kalabox
=======

Local development environment for drupal
Local development environment for drupal
31 changes: 31 additions & 0 deletions manifests/site.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
node "default" {
# set a static ip for our webserver
# NOT DOING THIS YET
#
# network::interface { box:
# style => webserver,
# }

# initialize core packages
include network
include puppet
include ssh
include git
include samba

# initialize LEMP stack
include phpfpm
phpfpm::nginx::kalabox { "default":
server_name => "kala",
root => "/var/www",
}
include mysql

# initialize bonus shit
include solr
include drush
include phpmyadmin

# build basic drupal site
# drupal::site { basic }
}
4 changes: 4 additions & 0 deletions modules/drush/manifests/init.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

class drush {
include drush::install
}
7 changes: 7 additions & 0 deletions modules/drush/manifests/install.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

class drush::install {

package { "drush":
ensure => latest,
}
}
9 changes: 9 additions & 0 deletions modules/git/manifests/init.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

class git {

include git::params

package { $git::params::packages:
ensure => present,
}
}
4 changes: 4 additions & 0 deletions modules/git/manifests/params.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

class git::params {
$packages = "git-core"
}
10 changes: 10 additions & 0 deletions modules/mysql/manifests/client.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

class mysql::client::install {
package { "mysql-client":
ensure => present,
}
}

class mysql::client {
include mysql::client::install
}
4 changes: 4 additions & 0 deletions modules/mysql/manifests/init.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

class mysql {
include mysql::server
}
43 changes: 43 additions & 0 deletions modules/mysql/manifests/my.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@

define mysql::my (
# basic settings
$path = "/etc/mysql/my.cnf",
$port = 3306,
$socket = "/var/run/mysqld/mysqld.sock",
$user = "mysql",
$default_storage_engine = "innodb",

# fine tuning
$key_buffer = "384M",
$max_allowed_packet = "32M",
$thread_stack = "400K",
$thread_cache_size = "8",
$read_rnd_buffer_size = "8M",
$myisam_sort_buffer_size = "64M",
$table_open_cache = "512",
$sort_buffer_size = "2M",
$read_buffer_size = "2M",

# query cache config
$query_cache_limit = "1M",
$query_cache_size = "64M",

# innodb
$innodb_flush_log_at_trx_commit = "0",

# mysqldump
$msd_max_allowed_packet = "32M",

#isamchk
$ikey_buffer_size = "256M",
$isort_buffer_size = "256M",
$iread_buffer = "2M",
$iwrite_buffer = "2M",
) {

file {
"${path}":
path => "${path}",
content => template("mysql/my.cnf.erb"),
}
}
4 changes: 4 additions & 0 deletions modules/mysql/manifests/server.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

class mysql::server {
include mysql::server::install, mysql::server::config, mysql::server::service
}
10 changes: 10 additions & 0 deletions modules/mysql/manifests/server/config.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

class mysql::server::config {

mysql::my { "my.cnf":
path => "/etc/mysql/my.cnf",
require => Class["mysql::server::install"],
notify => Class["mysql::server::service"],
}

}
9 changes: 9 additions & 0 deletions modules/mysql/manifests/server/db.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

define mysql::server::db($username, $password, $host = 'localhost') {
$root_password = $mysql::server::install::password
exec { "create-${name}-db":
unless => "/usr/bin/mysql -u${username} -p${password} ${name}",
command => "/usr/bin/mysql -uroot -p${root_password} -e \"create database ${name}; grant all on ${name}.* to ${username}@${host} identified by '$password';\"",
require => Class['mysql::server::service'],
}
}
20 changes: 20 additions & 0 deletions modules/mysql/manifests/server/install.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@

class mysql::server::install {
$password = "password"

package { "mysql-server":
ensure => present
}

phpfpm::extension { "php5-mysql": }

exec { "Set MySQL server root password":
subscribe => Package["mysql-server"],
refreshonly => true,
unless => "mysqladmin -uroot -p$password status",
path => "/bin:/usr/bin",
command => "mysqladmin -uroot password $password",
}


}
11 changes: 11 additions & 0 deletions modules/mysql/manifests/server/service.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

class mysql::server::service {
service { "mysql-server":
ensure => running,
name => "mysql",
hasstatus => true,
hasrestart => true,
enable => true,
require => Class["mysql::server::install"],
}
}
147 changes: 147 additions & 0 deletions modules/mysql/templates/my.cnf.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
#
# The MySQL database server configuration file.
#
# You can copy this to one of:
# - "/etc/mysql/my.cnf" to set global options,
# - "~/.my.cnf" to set user-specific options.
#
# One can use all long options that the program supports.
# Run program with --help to get a list of available options and with
# --print-defaults to see which it would actually understand and use.
#
# For explanations see
# http://dev.mysql.com/doc/mysql/en/server-system-variables.html

# This will be passed to all mysql clients
# It has been reported that passwords should be enclosed with ticks/quotes
# escpecially if they contain "#" chars...
# Remember to edit /etc/mysql/debian.cnf when changing the socket location.
[client]
port = <%= port %>
socket = <%= socket %>

# Here is entries for some specific programs
# The following values assume you have at least 32M ram

# This was formally known as [safe_mysqld]. Both versions are currently parsed.
[mysqld_safe]
socket = <%= socket %>
nice = 0

[mysqld]
#
# * Basic Settings
#
user = <%= user %>
pid-file = /var/run/mysqld/mysqld.pid
socket = <%= socket %>
port = <%= port %>
basedir = /usr
datadir = /var/lib/mysql
tmpdir = /tmp
lc-messages-dir = /usr/share/mysql
skip-external-locking
default-storage-engine = <%= default_storage_engine %>

#
# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
bind-address = 127.0.0.1
#
# * Fine Tuning
#
key_buffer = <%= key_buffer %>
max_allowed_packet = <%= max_allowed_packet %>
thread_stack = <%= thread_stack %>
thread_cache_size = <%= thread_cache_size %>
# This replaces the startup script and checks MyISAM tables if needed
# the first time they are touched
myisam-recover = BACKUP
#max_connections = 100
#table_cache = 64
#thread_concurrency = 10
read_rnd_buffer_size = <%= read_rnd_buffer_size %>
myisam_sort_buffer_size = <%= myisam_sort_buffer_size %>
table_open_cache = <%= table_open_cache %>
sort_buffer_size = <%= sort_buffer_size %>
read_buffer_size = <%= read_buffer_size %>
#
# * Query Cache Configuration
#
query_cache_limit = <%= query_cache_limit %>
query_cache_size = <%= query_cache_size %>
#
# * Logging and Replication
#
# Both location gets rotated by the cronjob.
# Be aware that this log type is a performance killer.
# As of 5.1 you can enable the log at runtime!
#general_log_file = /var/log/mysql/mysql.log
#general_log = 1
#
# Error logging goes to syslog due to /etc/mysql/conf.d/mysqld_safe_syslog.cnf.
#
# Here you can see queries with especially long duration
#log_slow_queries = /var/log/mysql/mysql-slow.log
#long_query_time = 2
#log-queries-not-using-indexes
#
# The following can be used as easy to replay backup logs or for replication.
# note: if you are setting up a replication slave, see README.Debian about
# other settings you may need to change.
#server-id = 1
#log_bin = /var/log/mysql/mysql-bin.log
expire_logs_days = 10
max_binlog_size = 100M
#binlog_do_db = include_database_name
#binlog_ignore_db = include_database_name
#
# * InnoDB
#
# InnoDB is enabled by default with a 10MB datafile in /var/lib/mysql/.
# Read the manual for more InnoDB related options. There are many!
#
# Uncomment the following if you are using InnoDB tables
#innodb_data_file_path = ibdata1:2000M;ibdata2:10M:autoextend
#innodb_log_group_home_dir = C:\mysql\data/
# You can set .._buffer_pool_size up to 50 - 80 %
# of RAM but beware of setting memory usage too high
#innodb_buffer_pool_size = 384M
#innodb_additional_mem_pool_size = 20M
# Set .._log_file_size to 25 % of buffer pool size
#innodb_log_file_size = 100M
#innodb_log_buffer_size = 8M
innodb_flush_log_at_trx_commit = <%= innodb_flush_log_at_trx_commit %>
#innodb_lock_wait_timeout = 50
#
# * Security Features
#
# Read the manual, too, if you want chroot!
# chroot = /var/lib/mysql/
#
# For generating SSL certificates I recommend the OpenSSL GUI "tinyca".
#
# ssl-ca=/etc/mysql/cacert.pem
# ssl-cert=/etc/mysql/server-cert.pem
# ssl-key=/etc/mysql/server-key.pem

[mysqldump]
quick
quote-names
max_allowed_packet = <%= msd_max_allowed_packet %>

[mysql]
#no-auto-rehash # faster start of mysql but no tab completition

[isamchk]
key_buffer = <%= key_buffer %>
key_buffer_size = <%= ikey_buffer_size %>
sort_buffer_size = <%= isort_buffer_size %>
read_buffer = <%= iread_buffer %>
write_buffer = <%= iwrite_buffer %>

#
# * IMPORTANT: Additional settings that can override those from this file!
# The files must end with '.cnf', otherwise they'll be ignored.
#
!includedir /etc/mysql/conf.d/
10 changes: 10 additions & 0 deletions modules/network/manifests/config.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

class network::config {

file { "/etc/hosts" :
ensure => present,
content => template("network/hosts.erb"),
owner => "root",
group => "root",
}
}
4 changes: 4 additions & 0 deletions modules/network/manifests/init.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

class network {
include network::config
}
12 changes: 12 additions & 0 deletions modules/network/manifests/interface.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
define network::interface (
$style,
$ip = $::ipaddress,
$gateway = $::netmask) {

file { "/etc/network/interfaces":
owner => root,
group => root,
mode => 644,
content => template("network/${style}")
}
}
9 changes: 9 additions & 0 deletions modules/network/templates/hosts.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
127.0.0.1 localhost kala
127.0.1.1 <%= scope.lookupvar('hostname') %>

# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
Loading

0 comments on commit 6496a51

Please sign in to comment.