Skip to content

Commit

Permalink
started refactoring to meet modules guidelines
Browse files Browse the repository at this point in the history
  • Loading branch information
chris flöß committed Jul 8, 2010
1 parent 2e9b2bc commit f958dc7
Show file tree
Hide file tree
Showing 17 changed files with 317 additions and 10 deletions.
2 changes: 1 addition & 1 deletion manifests/modules.pp
Expand Up @@ -8,4 +8,4 @@
import "ree"
import "nginx"
import "puppet_client"
import "packages"
import "servercharlie"
5 changes: 3 additions & 2 deletions manifests/nodes.pp
Expand Up @@ -14,7 +14,7 @@
node 'servercharlie.bestgroup' inherits default {
# TODO: Refactor. Charlie needs postgres stuff, but it shouldn't be
# named in b2c_test
include b2c_test
include servercharlie
adva_users{"puppet-admin": username => "puppet-admin",}
}

Expand All @@ -24,12 +24,13 @@
# those packages commen to all of s-k
node 'ext-b2c-sk-test' inherits default {
include b2c_test
include b2c_base_configs
include sk_base
include gems_sk_all
include gems_b2c_base
include ree
include packages::redis
include nginx
include ext-b2c::nginx
include sphinx
adva_users{"application": username => "application",}
}
Expand Down
6 changes: 0 additions & 6 deletions manifests/site.pp
Expand Up @@ -3,12 +3,6 @@
import "modules"
import "nodes"

## We probably don't want this yet, since we don't know what
## it does.
#
## The filebucket option allows for file backups to the server
#filebucket { main: server => 'my.server.name' }
#
## Set global defaults - including backing up all files to the main filebucket and adds a global path
#File { backup => main }
#Exec { path => "/usr/bin:/usr/sbin/:/bin:/sbin" }
7 changes: 7 additions & 0 deletions modules/base_configs/manifests/init.pp
Expand Up @@ -31,8 +31,15 @@
group => "root",
mode => 644,
source => "puppet:///base_configs/ssh_config";
}
}

class b2c_base_configs {
file {
# Pin Postgres to 8.4
"/etc/apt/preferences":
source => "puppet:///base_configs/apt/preferences_b2c";
}

}

47 changes: 47 additions & 0 deletions modules/ext-b2c/files/b2c-test/b2c-test.nginx.conf
@@ -0,0 +1,47 @@
worker_processes 1;

#error_log logs/error.log;
#pid logs/nginx.pid;

events {
worker_connections 1024;
}

http {
server_tokens off;
passenger_root /opt/ruby-ee/lib/ruby/gems/1.8/gems/passenger-2.2.14;
passenger_ruby /opt/ruby-ee/bin/ruby;
passenger_max_pool_size 8;
#passenger_root /usr/lib/ruby/gems/1.8/gems/passenger-2.2.8;
#passenger_ruby /usr/bin/ruby1.8;

include mime.types;
default_type application/octet-stream;

log_format main '$remote_addr - $remote_user [$time_local] $request '
'"$status" $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';

#access_log logs/access.log;

server_names_hash_bucket_size 128;

sendfile on;
tcp_nopush on;
keepalive_timeout 65;
tcp_nodelay on;

gzip on;
gzip_http_version 1.1;
gzip_comp_level 3;
gzip_proxied any;
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;

# make sure gzip does not lose large gzipped js or css files
# see http://blog.leetsoft.com/2007/7/25/nginx-gzip-ssl
gzip_buffers 16 8k;
gzip_disable "MSIE [1-6].(?!.*SV1)";

include /opt/nginx/conf/sites-enabled/*;

}
66 changes: 66 additions & 0 deletions modules/ext-b2c/files/b2c-test/ext.b2c.sk.test
@@ -0,0 +1,66 @@
server {
listen 80;
server_name ext-b2c-sk-test;
access_log /home/application/projects/sk_b2c/testing/shared/log/nginx_access.log;
root /home/application/projects/sk_b2c/testing/current/public;
index index.html index.htm;

auth_basic "Staging";
auth_basic_user_file staging.sk.htpasswd;

# passenger stuff
passenger_enabled on;
rails_env test;
rails_spawn_method smart-lv2;
rails_framework_spawner_idle_time 1800;
rails_app_spawner_idle_time 600;

location ~* ^/(javascripts|stylesheets|images/layout|images/colorbox|digital_contents) {
expires max;
}
location /data/pricelists {
root /home/application/projects/s_k/staging/shared;
internal;
}

# For the app maintenance
if (-f $document_root/system/maintenance.html) {
rewrite ^(.*)$ /system/maintenance.html break;
return 503;
}
}

#server {
# listen 443;
# server_name ext-con-sk-test.siewert-kau.de;
# access_log /home/application/projects/s_k/staging/shared/log/nginx_access.log;
# root /home/application/projects/s_k/staging/current/public;
# index index.html index.htm;
#
# auth_basic "Staging";
# auth_basic_user_file staging.sk.htpasswd;
#
# # passenger stuff
# passenger_enabled on;
# rails_env staging;
# rails_spawn_method smart-lv2;
# rails_framework_spawner_idle_time 1800;
# rails_app_spawner_idle_time 600;
#
# ssl on;
# ssl_certificate /home/application/.ssh/siewert-kau.de.chained.crt;
# ssl_certificate_key /home/application/.ssh/siewert-kau.de.key;
#
# location ~* ^/(javascripts|stylesheets|images/layout|images/colorbox|digital_contents) {
# expires max;
# }
# location /data/pricelists {
# root /home/application/projects/s_k/staging/shared;
# internal;
# }
#
# # For the app maintenance
# if (-f $document_root/system/maintenance.html) {
# rewrite ^(.*)$ /system/maintenance.html break;
# }
#}
1 change: 1 addition & 0 deletions modules/ext-b2c/files/b2c-test/staging.sk.htpasswd
@@ -0,0 +1 @@
advademo:cZmlwfKQj4NTg
62 changes: 62 additions & 0 deletions modules/ext-b2c/files/init.d/nginx
@@ -0,0 +1,62 @@
#! /bin/sh

### BEGIN INIT INFO
# Provides: nginx
# Required-Start: $all
# Required-Stop: $all
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts the nginx web server
# Description: starts nginx using start-stop-daemon
### END INIT INFO

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/opt/nginx/sbin/nginx
NAME=nginx
DESC=nginx

test -x $DAEMON || exit 0

# Include nginx defaults if available
if [ -f /etc/default/nginx ] ; then
. /etc/default/nginx
fi

set -e

case "$1" in
start)
echo -n "Starting $DESC: "
start-stop-daemon --start --quiet --pidfile /opt/nginx/logs/$NAME.pid \
--exec $DAEMON -- $DAEMON_OPTS || true
echo "$NAME."
;;
stop)
echo -n "Stopping $DESC: "
start-stop-daemon --stop --quiet --pidfile /opt/nginx/logs/$NAME.pid \
--exec $DAEMON || true
echo "$NAME."
;;
restart|force-reload)
echo -n "Restarting $DESC: "
start-stop-daemon --stop --quiet --pidfile \
/opt/nginx/logs/$NAME.pid --exec $DAEMON || true
sleep 1
start-stop-daemon --start --quiet --pidfile \
/opt/nginx/logs/$NAME.pid --exec $DAEMON -- $DAEMON_OPTS || true
echo "$NAME."
;;
reload)
echo -n "Reloading $DESC configuration: "
start-stop-daemon --stop --signal HUP --quiet --pidfile /opt/nginx/logs/$NAME.pid \
--exec $DAEMON || true
echo "$NAME."
;;
*)
N=/etc/init.d/$NAME
echo "Usage: $N {start|stop|restart|reload|force-reload}" >&2
exit 1
;;
esac

exit 0
13 changes: 13 additions & 0 deletions modules/ext-b2c/files/logrotate.d/nginx
@@ -0,0 +1,13 @@
/opt/nginx/logs/*.log {
daily
missingok
rotate 52
compress
delaycompress
notifempty
create 640 root adm
sharedscripts
postrotate
[ ! -f /opt/nginx/logs/nginx.pid ] || kill -USR1 `cat /opt/nginx/logs/nginx.pid`
endscript
}
Empty file.
52 changes: 52 additions & 0 deletions modules/ext-b2c/manifests/nginx.pp
@@ -0,0 +1,52 @@
class ext-b2c::nginx {
file {
"/etc/init.d/nginx":
ensure => present,
owner => "root",
group => "root",
mode => 644,
source => "puppet:///b2c-test/init.d/nginx";
"/etc/logrotate.d/nginx":
ensure => present,
owner => "root",
group => "root",
mode => 644,
source => "puppet:///b2c-test/logrotate.d/nginx";
}

exec { "/opt/ruby-ee/bin/passenger-install-nginx-module --auto --prefix=/opt/nginx --auto-download --extra-configure-flags='--with-http_ssl_module'":
require => Exec["/opt/ree.bash"],
cwd => "/opt",
creates => "/opt/nginx",
logoutput => true,
onlyif => "test -e /opt/ruby-ee/bin/ruby",
timeout => "-1",
path => "/opt:/opt/ruby-ee/bin:/opt/ruby-ee/sbin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
}

service { "nginx":
require => Exec["/opt/ruby-ee/bin/passenger-install-nginx-module --auto --prefix=/opt/nginx --auto-download --extra-configure-flags='--with-http_ssl_module'"],
#ensure => running,
enable => true,
}

file {
# main nginx: /opt/nginx/nginx.conf
"/opt/nginx/conf/nginx.conf":
require => Exec["/opt/ruby-ee/bin/passenger-install-nginx-module --auto --prefix=/opt/nginx --auto-download --extra-configure-flags='--with-http_ssl_module'"],
source => "puppet:///ext-b2c/b2c-test/b2c-test.nginx.conf";

# htaccess
"/opt/nginx/conf/staging.sk.htpasswd":
source => "puppet:///ext-b2c/b2c-test/staging.sk.htpasswd";

# Sites available
"/opt/nginx/conf/sites-available/ext.b2c.sk.test":
source => "puppet:///ext-b2c/b2c-test/ext.b2c.sk.test";

# Sites enabled
"/opt/nginx/conf/sites-enabled/ext.b2c.sk.test":
ensure => "/opt/nginx/conf/sites-available/ext.b2c.sk.test",
require => File["/opt/nginx/conf/sites-available/ext.b2c.sk.test"];
}
}
Binary file added modules/packages/files/redis_1.02-1_amd64.deb
Binary file not shown.
1 change: 0 additions & 1 deletion modules/packages/manifests/init.pp
@@ -1 +0,0 @@
import "redis"
39 changes: 39 additions & 0 deletions modules/packages/manifests/redis.pp
@@ -0,0 +1,39 @@
class packages::redis {
if $hostname =~ /servercharlie.*/ {
#notify{"GOT IN"}
file {
"/home/adva/builds/redis_1.02-1_i386.deb":
ensure => present,
source => "puppet:///packages/redis_1.02-1_i386.deb";
}
} else {
file {
"/home/adva/builds/redis_1.02-1_amd64.deb":
ensure => present,
source => "puppet:///packages/redis_1.02-1_amd64.deb";
}
}

file {
"/etc/redis.conf":
ensure => present;
}

if $hostname =~ /servercharlie.*/ {
package {
"redis":
require => File["/home/adva/builds/redis_1.02-1_i386.deb"],
source => "/home/adva/builds/redis_1.02-1_i386.deb",
ensure => installed,
provider => dpkg;
}
} else {
package {
"redis":
require => File["/home/adva/builds/redis_1.02-1_amd64.deb"],
source => "/home/adva/builds/redis_1.02-1_amd64.deb",
ensure => installed,
provider => dpkg;
}
}
}
17 changes: 17 additions & 0 deletions modules/packages/manifests/sphinx.pp
@@ -0,0 +1,17 @@
# file /etc/puppet/modules/sphinx/manifests/init.pp

class sphinx {
file {
"/home/adva/builds/sphinx_0.9.9-1_amd64.deb":
ensure => present,
source => "puppet:///sphinx/sphinx_0.9.9-1_amd64.deb";
}

package {
"sphinx":
require => File["/home/adva/builds/sphinx_0.9.9-1_amd64.deb"],
source => "/home/adva/builds/sphinx_0.9.9-1_amd64.deb",
ensure => installed,
provider => dpkg;
}
}
1 change: 1 addition & 0 deletions modules/puppet_client/files/puppet/puppet.conf
Expand Up @@ -13,6 +13,7 @@
manifest = /home/puppet-admin/puppet_config/manifests/site.pp
manifestdir = /home/puppet-admin/puppet_config/manifests
modulepath = /home/puppet-admin/puppet_config/modules:/usr/share/puppet/modules
templatedir = /home/puppet-admin/puppet_config/templates

[puppetd]
# The server to which server puppetd should connect
Expand Down
8 changes: 8 additions & 0 deletions modules/servercharlie/manifests/init.pp
@@ -0,0 +1,8 @@
class servercharlie {
package {
"postgresql":
ensure => installed;
"postgresql-server-dev-8.3":
ensure => installed;
}
}

0 comments on commit f958dc7

Please sign in to comment.