From: Tom Hughes Date: Thu, 26 Jan 2017 18:29:11 +0000 (+0000) Subject: Merge remote-tracking branch 'github/pull/102' X-Git-Url: https://git.openstreetmap.org/chef.git/commitdiff_plain/67c2aceb91955ff583c41807759d203a4478e4b1?hp=de5ea0729bd1f982f7fda34729d149d9a40766b9 Merge remote-tracking branch 'github/pull/102' --- diff --git a/.kitchen.yml b/.kitchen.yml index b800b89a3..cd6ebeb1a 100644 --- a/.kitchen.yml +++ b/.kitchen.yml @@ -28,6 +28,10 @@ suites: - name: bind run_list: - recipe[bind::default] + - name: blogs + run_list: + - recipe[accounts::default] + - recipe[blogs::default] - name: forum run_list: - recipe[accounts::default] diff --git a/cookbooks/blogs/.foodcritic b/cookbooks/blogs/.foodcritic new file mode 100644 index 000000000..d8973b2fb --- /dev/null +++ b/cookbooks/blogs/.foodcritic @@ -0,0 +1,4 @@ +~FC001 +~FC003 +~FC064 +~FC065 diff --git a/cookbooks/blogs/README.md b/cookbooks/blogs/README.md new file mode 100644 index 000000000..a42843891 --- /dev/null +++ b/cookbooks/blogs/README.md @@ -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 index 000000000..d230b5915 --- /dev/null +++ b/cookbooks/blogs/attributes/default.rb @@ -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 index 000000000..2461ead90 --- /dev/null +++ b/cookbooks/blogs/metadata.rb @@ -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 index 000000000..f90c3ce5d --- /dev/null +++ b/cookbooks/blogs/recipes/default.rb @@ -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 index 000000000..1cb0fe44c --- /dev/null +++ b/cookbooks/blogs/templates/default/apache.erb @@ -0,0 +1,27 @@ +# DO NOT EDIT - This file is being maintained by Chef + + + 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 %>/ + + + + ServerName <%= @name %> + ServerAdmin webmaster@openstreetmap.org + + CustomLog /var/log/apache2/<%= @name %>-access.log combined + ErrorLog /var/log/apache2/<%= @name %>-error.log + + DocumentRoot <%= @directory %> + + SSLEngine on + + +> + Require all granted + diff --git a/cookbooks/blogs/templates/default/cron.erb b/cookbooks/blogs/templates/default/cron.erb new file mode 100644 index 000000000..3985f1ffb --- /dev/null +++ b/cookbooks/blogs/templates/default/cron.erb @@ -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 index 000000000..20059bfda --- /dev/null +++ b/test/data_bags/accounts/blogs.json @@ -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 index 000000000..9d5268271 --- /dev/null +++ b/test/integration/blogs/serverspec/apache_spec.rb @@ -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