]> git.openstreetmap.org Git - chef.git/commitdiff
Add basic forum/fluxbb cookbook
authorGrant Slater <git@firefishy.com>
Mon, 10 Feb 2014 21:34:36 +0000 (21:34 +0000)
committerGrant Slater <git@firefishy.com>
Mon, 10 Feb 2014 21:34:47 +0000 (21:34 +0000)
cookbooks/forum/recipes/default.rb
cookbooks/forum/templates/default/apache.erb [new file with mode: 0644]
cookbooks/forum/templates/default/backup.cron.erb [new file with mode: 0644]
roles/forum.rb

index 58daae4221ea0d222deb4649924cf4a7c1684474..be229e75b00d68d37c418c7cdde2b5539ccc1f23 100644 (file)
 # See the License for the specific language governing permissions and
 # limitations under the License.
 #
-include_recipe "apache"
+include_recipe "apache:ssl"
+include_recipe "git"
+include_recipe "mysql"
+
+passwords = data_bag_item("forum", "passwords")
 
 package "php5"
 package "php5-cli"
@@ -24,3 +28,53 @@ package "php-apc"
 
 apache_module "php5"
 
+apache_site "default" do
+  action [ :disable ]
+end
+
+apache_site "forum.openstreetmap.org" do
+  template "apache.erb"
+end
+
+directory "/srv/forum.openstreetmap.org" do
+  owner "forum"
+  group "forum"
+  mode 0755
+end
+
+git "/srv/forum.openstreetmap.org/html/" do
+  action :sync
+  repository "http://github.com/fluxbb/fluxbb.git"
+  revision "refs/tags/fluxbb-1.5.6"
+  depth 1
+  user "forum"
+  group "forum"
+end
+
+directory "/srv/forum.openstreetmap.org/html/cache/" do
+  owner "www-data"
+  group "www-data"
+  mode 0755
+end
+
+directory "/srv/forum.openstreetmap.org/html/img/avatars/" do
+  owner "www-data"
+  group "www-data"
+  mode 0755
+end
+
+mysql_user "forum@localhost" do
+  password passwords["database"]
+end
+
+mysql_database "forum" do
+  permissions "forum@localhost" => :all
+end
+
+template "/etc/cron.daily/forum-backup" do
+  source "backup.cron.erb"
+  owner "root"
+  group "root"
+  mode 0750
+  variables :passwords => passwords
+end
diff --git a/cookbooks/forum/templates/default/apache.erb b/cookbooks/forum/templates/default/apache.erb
new file mode 100644 (file)
index 0000000..0eea9db
--- /dev/null
@@ -0,0 +1,28 @@
+# DO NOT EDIT - This file is being maintained by Chef
+
+<VirtualHost *:80>
+       ServerName forum.openstreetmap.org
+       ServerAlias forum.osm.org
+       ServerAdmin webmaster@openstreetmap.org
+
+       CustomLog /var/log/apache2/forum.openstreetmap.org-access.log combined
+       ErrorLog /var/log/apache2/forum.openstreetmap.org-error.log
+
+       DocumentRoot /srv/forum.openstreetmap.org/html/
+</VirtualHost>
+
+<VirtualHost *:443>
+       ServerName forum.openstreetmap.org
+       ServerAdmin webmaster@openstreetmap.org
+
+       SSLEngine on
+       SSLProtocol all -SSLv2
+       SSLCipherSuite ALL:!ADH:!EXPORT:!SSLv2:RC4+RSA:+HIGH:+MEDIUM:+LOW
+       SSLCertificateFile /etc/ssl/certs/openstreetmap.pem
+       SSLCertificateKeyFile /etc/ssl/private/openstreetmap.key
+
+       CustomLog /var/log/apache2/forum.openstreetmap.org-access.log combined
+       ErrorLog /var/log/apache2/forum.openstreetmap.org-error.log
+
+       DocumentRoot /srv/forum.openstreetmap.org
+</VirtualHost>
diff --git a/cookbooks/forum/templates/default/backup.cron.erb b/cookbooks/forum/templates/default/backup.cron.erb
new file mode 100644 (file)
index 0000000..31fd205
--- /dev/null
@@ -0,0 +1,20 @@
+#!/bin/sh
+exit 0
+
+# DO NOT EDIT - This file is being maintained by Chef
+
+T=$(mktemp -d -t -p /var/tmp forum.XXXXXXXXXX)
+D=$(date +%Y-%m-%d)
+B=forum-$D.tar.gz
+
+mkdir $T/forum-$D
+mysqldump --user=forum --password=<%= @passwords["database"] %> --opt forum > $T/forum-$D/forum.sql
+ln -s /srv/forum.openstreetmap.org $T/forum-$D/www
+
+export GZIP="--rsyncable -9"
+export RSYNC_RSH="ssh -ax -c arcfour"
+
+nice tar --create --gzip --dereference --directory=$T --file=$T/$B forum-$D
+nice rsync $T/$B backup::backup
+
+rm -rf $T
index 83abe0d88e5535181a93c84403dc34bd7e264c1e..701c993ba475f56f5f3623a6f76f24be9ebd91f2 100644 (file)
@@ -4,7 +4,13 @@ description "Role applied to all forum servers"
 default_attributes(
   :accounts => {
     :users => {
-      :lambertus => { :status => :administrator }
+      :lambertus => {
+        :status => :administrator 
+      },
+      :forum => {
+        :status => :role,
+        :members => [ :lambertus, :grant ]
+      }
     }
   },
   :apache => {