]> git.openstreetmap.org Git - chef.git/commitdiff
Add cookbook for blogs.openstreetmap.org
authorTom Hughes <tom@compton.nu>
Fri, 25 Nov 2016 22:28:46 +0000 (22:28 +0000)
committerTom Hughes <tom@compton.nu>
Mon, 28 Nov 2016 22:18:09 +0000 (22:18 +0000)
.kitchen.yml
cookbooks/blogs/.foodcritic [new file with mode: 0644]
cookbooks/blogs/README.md [new file with mode: 0644]
cookbooks/blogs/attributes/default.rb [new file with mode: 0644]
cookbooks/blogs/metadata.rb [new file with mode: 0644]
cookbooks/blogs/recipes/default.rb [new file with mode: 0644]
cookbooks/blogs/templates/default/apache.erb [new file with mode: 0644]
cookbooks/blogs/templates/default/cron.erb [new file with mode: 0644]
test/data_bags/accounts/blogs.json [new file with mode: 0644]
test/integration/blogs/serverspec/apache_spec.rb [new file with mode: 0644]

index b800b89a368a32401b8c1e660c26d3b18aa92c63..cd6ebeb1a36188eedd749dac02032c9ed0948e28 100644 (file)
@@ -28,6 +28,10 @@ suites:
   - name: bind
     run_list:
       - recipe[bind::default]
   - name: bind
     run_list:
       - recipe[bind::default]
+  - name: blogs
+    run_list:
+      - recipe[accounts::default]
+      - recipe[blogs::default]
   - name: forum
     run_list:
       - recipe[accounts::default]
   - name: forum
     run_list:
       - recipe[accounts::default]
diff --git a/cookbooks/blogs/.foodcritic b/cookbooks/blogs/.foodcritic
new file mode 100644 (file)
index 0000000..d8973b2
--- /dev/null
@@ -0,0 +1,4 @@
+~FC001
+~FC003
+~FC064
+~FC065
diff --git a/cookbooks/blogs/README.md b/cookbooks/blogs/README.md
new file mode 100644 (file)
index 0000000..a428438
--- /dev/null
@@ -0,0 +1,5 @@
+# Blogs cookbook
+
+This cookbook configures the blog aggregator website found at
+[blogs.openstreetmap.org](https://blogs.openstreetmap.org). The code for
+the website itself is available at [github.com/gravitystorm/blogs.osm.org](https://github.com/gravitystorm/blogs.osm.org).
diff --git a/cookbooks/blogs/attributes/default.rb b/cookbooks/blogs/attributes/default.rb
new file mode 100644 (file)
index 0000000..d230b59
--- /dev/null
@@ -0,0 +1 @@
+default[:accounts][:users][:blogs][:status] = :role
diff --git a/cookbooks/blogs/metadata.rb b/cookbooks/blogs/metadata.rb
new file mode 100644 (file)
index 0000000..2461ead
--- /dev/null
@@ -0,0 +1,9 @@
+name              "blogs"
+maintainer        "OpenStreetMap Administrators"
+maintainer_email  "admins@openstreetmap.org"
+license           "Apache 2.0"
+description       "Configures server-info web site"
+long_description  IO.read(File.join(File.dirname(__FILE__), "README.md"))
+version           "1.0.0"
+depends           "apache"
+depends           "git"
diff --git a/cookbooks/blogs/recipes/default.rb b/cookbooks/blogs/recipes/default.rb
new file mode 100644 (file)
index 0000000..f90c3ce
--- /dev/null
@@ -0,0 +1,72 @@
+#
+# Cookbook Name:: blogs
+# Recipe:: default
+#
+# Copyright 2016, OpenStreetMap Foundation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+include_recipe "apache::ssl"
+include_recipe "git"
+
+package "ruby"
+package "ruby-dev"
+package "make"
+package "gcc"
+package "libsqlite3-dev"
+
+gem_package "bundler"
+
+directory "/srv/blogs.openstreetmap.org" do
+  owner "blogs"
+  group "blogs"
+  mode 0o755
+end
+
+git "/srv/blogs.openstreetmap.org" do
+  action :sync
+  repository "git://github.com/gravitystorm/blogs.osm.org.git"
+  user "blogs"
+  group "blogs"
+  notifies :run, "execute[/srv/blogs.openstreetmap.org/Gemfile]", :immediate
+end
+
+execute "/srv/blogs.openstreetmap.org/Gemfile" do
+  action :nothing
+  command "bundle install"
+  cwd "/srv/blogs.openstreetmap.org"
+  user "root"
+  group "root"
+  notifies :run, "execute[/srv/blogs.openstreetmap.org]", :immediate
+end
+
+execute "/srv/blogs.openstreetmap.org" do
+  action :nothing
+  command "/usr/local/bin/pluto build -t osm -o build"
+  cwd "/srv/blogs.openstreetmap.org"
+  user "blogs"
+  group "blogs"
+end
+
+apache_site "blogs.openstreetmap.org" do
+  template "apache.erb"
+  directory "/srv/blogs.openstreetmap.org/build"
+end
+
+template "/etc/cron.d/blogs" do
+  source "cron.erb"
+  owner "root"
+  group "root"
+  mode "0644"
+end
diff --git a/cookbooks/blogs/templates/default/apache.erb b/cookbooks/blogs/templates/default/apache.erb
new file mode 100644 (file)
index 0000000..3995ad5
--- /dev/null
@@ -0,0 +1,28 @@
+# DO NOT EDIT - This file is being maintained by Chef
+
+<VirtualHost *:80>
+   ServerName <%= @name %>
+   ServerAdmin webmaster@openstreetmap.org
+
+   CustomLog /var/log/apache2/<%= @name %>-access.log combined
+   ErrorLog /var/log/apache2/<%= @name %>-error.log
+
+   Redirect permanent / https://<%= @name %>/
+</VirtualHost>
+
+<VirtualHost *:443>
+   ServerName <%= @name %>
+   ServerAdmin webmaster@openstreetmap.org
+
+   CustomLog /var/log/apache2/<%= @name %>-access.log combined
+   ErrorLog /var/log/apache2/<%= @name %>-error.log
+
+   DocumentRoot <%= @directory %>
+   DirectoryIndex planet.html
+
+   SSLEngine on
+</VirtualHost>
+
+<Directory <%= @directory %>>
+   Require all granted
+</Directory>
diff --git a/cookbooks/blogs/templates/default/cron.erb b/cookbooks/blogs/templates/default/cron.erb
new file mode 100644 (file)
index 0000000..3985f1f
--- /dev/null
@@ -0,0 +1 @@
+*/30 * * * * blogs /usr/local/bin/pluto update
diff --git a/test/data_bags/accounts/blogs.json b/test/data_bags/accounts/blogs.json
new file mode 100644 (file)
index 0000000..20059bf
--- /dev/null
@@ -0,0 +1,6 @@
+{
+  "id": "blogs",
+  "uid": "525",
+  "comment": "Blog Aggregator",
+  "manage_home": false
+}
diff --git a/test/integration/blogs/serverspec/apache_spec.rb b/test/integration/blogs/serverspec/apache_spec.rb
new file mode 100644 (file)
index 0000000..9d52682
--- /dev/null
@@ -0,0 +1,21 @@
+require "serverspec"
+
+# Required by serverspec
+set :backend, :exec
+
+describe package("apache2") do
+  it { should be_installed }
+end
+
+describe service("apache2") do
+  it { should be_enabled }
+  it { should be_running }
+end
+
+describe port(80) do
+  it { should be_listening }
+end
+
+describe port(443) do
+  it { should be_listening }
+end