From: Tom Hughes Date: Sun, 9 Feb 2014 19:30:12 +0000 (+0000) Subject: Initial work on a taginfo cookbook X-Git-Url: https://git.openstreetmap.org/chef.git/commitdiff_plain/6ed30a3d11d87fbec3d4ecef4c14b0f8ed707216 Initial work on a taginfo cookbook --- diff --git a/cookbooks/taginfo/README.md b/cookbooks/taginfo/README.md new file mode 100644 index 000000000..205739199 --- /dev/null +++ b/cookbooks/taginfo/README.md @@ -0,0 +1,34 @@ +Cookbook +======== +TODO: Enter the cookbook description here. + +e.g. +This cookbook makes your favorite breakfast sandwich. + +Requirements +------------ +TODO: List your cookbook requirements. Be sure to include any requirements this cookbook has on platforms, libraries, other cookbooks, packages, operating systems, etc. + +Attributes +---------- +TODO: List you cookbook attributes here. + +Usage +----- +TODO: Write usage instructions for each cookbook. + +Contributing +------------ +TODO: (optional) If this is a public cookbook, detail the process for contributing. If this is a private cookbook, remove this section. + +e.g. +1. Fork the repository on Github +2. Create a named feature branch (like `add_component_x`) +3. Write your change +4. Write tests for your change (if applicable) +5. Run the tests, ensuring they all pass +6. Submit a Pull Request using Github + +License and Authors +------------------- +Authors: TODO: List authors diff --git a/cookbooks/taginfo/attributes/default.rb b/cookbooks/taginfo/attributes/default.rb new file mode 100644 index 000000000..487e6d378 --- /dev/null +++ b/cookbooks/taginfo/attributes/default.rb @@ -0,0 +1 @@ +default[:osqa][:sites] = [] diff --git a/cookbooks/taginfo/metadata.rb b/cookbooks/taginfo/metadata.rb new file mode 100644 index 000000000..795a69aa0 --- /dev/null +++ b/cookbooks/taginfo/metadata.rb @@ -0,0 +1,19 @@ +name "taginfo" +maintainer "OpenStreetMap Administrators" +maintainer_email "admins@openstreetmap.org" +license "Apache 2.0" +description "Installs and configures taginfo" +long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) +version "1.0.0" +depends "apache" +depends "git" + +attribute "taginfo", + :display_name => "TAGINFO", + :description => "Hash of TAGINFO attributes", + :type => "hash" + +attribute "taginfo/sites", + :display_name => "Sites", + :description => "Array of TAGINFO sites to setup", + :default => [] diff --git a/cookbooks/taginfo/recipes/default.rb b/cookbooks/taginfo/recipes/default.rb new file mode 100644 index 000000000..ea329a57b --- /dev/null +++ b/cookbooks/taginfo/recipes/default.rb @@ -0,0 +1,111 @@ +# +# Cookbook Name:: taginfo +# Recipe:: default +# +# Copyright 2014, 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 "libsqlite3-dev" +package "zlib1g-dev" +package "libosmpbf-dev" +package "libprotobuf-dev" +package "libboost-dev" +package "libexpat1-dev" +package "libsparsehash-dev" +package "libgd2-xpm-dev" +package "make" +package "g++" + +package "sqlite3" + +package "ruby" +package "rubygems" +gem_package "json" +gem_package "sqlite3" +gem_package "sinatra" +gem_package "sinatra-r18n" +gem_package "rack-contrib" + +apache_module "passenger" + +munin_plugin "passenger_memory" +munin_plugin "passenger_processes" +munin_plugin "passenger_queues" +munin_plugin "passenger_requests" + +node[:taginfo][:sites].each do |site| + name = site[:name] + directory = site[:directory] || "/srv/#{name}" + + directory directory do + owner "taginfo" + group "taginfo" + mode 0755 + end + + git "#{directory}/osmium" do + action :sync + repository "git://github.com/joto/osmium.git" + revision "master" + user "taginfo" + group "taginfo" + end + + git "#{directory}/taginfo" do + action :sync + repository "git://github.com/joto/taginfo.git" + revision "master" + user "taginfo" + group "taginfo" + end + + settings = edit_file "#{directory}/taginfo/taginfo-config-example.json" do |line| + line.gsub!(/^( *)"cxxflags": ".*",/, "\\1\"cxxflags\": \"-I../../osmium/include\",") + + line + end + + file "#{directory}/taginfo-config.json" do + owner "taginfo" + group "taginfo" + mode 0644 + content settings + end + + execute "#{directory}/taginfo/tagstats/Makefile" do + action :nothing + command "make" + cwd "#{directory}/taginfo/tagstats" + user "taginfo" + group "taginfo" + subscribes :run, "git[#{directory}/osmium]" + subscribes :run, "git[#{directory}/taginfo]" + notifies :restart, "service[apache2]" + end + + directory "#{directory}/data" do + owner "taginfo" + group "taginfo" + mode 0755 + end + + apache_site name do + template "apache.erb" + directory "#{directory}/taginfo/web/public" + end +end diff --git a/cookbooks/taginfo/templates/default/apache.erb b/cookbooks/taginfo/templates/default/apache.erb new file mode 100644 index 000000000..9ebca518e --- /dev/null +++ b/cookbooks/taginfo/templates/default/apache.erb @@ -0,0 +1,21 @@ +# DO NOT EDIT - This file is being maintained by Chef + +<% [80, 443].each do |port| -%> + +> + ServerName <%= @name %> + ServerAdmin webmaster@openstreetmap.org +<% if port == 443 -%> + + SSLEngine on +<% end -%> + + CustomLog /var/log/apache2/<%= @name %>-access.log combined + ErrorLog /var/log/apache2/<%= @name %>-error.log + + DocumentRoot <%= @directory %> + RackEnv production + PassengerMinInstances 10 + PassengerPreStart http://<%= @name %>/ + +<% end -%> diff --git a/roles/grindtooth.rb b/roles/grindtooth.rb index 7fc2daea9..00ffdcaf6 100644 --- a/roles/grindtooth.rb +++ b/roles/grindtooth.rb @@ -2,11 +2,6 @@ name "grindtooth" description "Master role applied to grindtooth" default_attributes( - :accounts => { - :users => { - :jochen => { :status => :administrator } - } - }, :networking => { :interfaces => { :internal_ipv4 => { @@ -20,5 +15,6 @@ default_attributes( ) run_list( - "role[ucl-internal]" + "role[ucl-internal]", + "role[taginfo]" ) diff --git a/roles/taginfo.rb b/roles/taginfo.rb new file mode 100644 index 000000000..2a273725f --- /dev/null +++ b/roles/taginfo.rb @@ -0,0 +1,28 @@ +name "taginfo" +description "Role applied to all taginfo servers" + +default_attributes( + :accounts => { + :users => { + :jochen => { + :status => :administrator + }, + :taginfo => { + :status => :role, + :members => [ :jochen, :tomh ] + } + } + }, + :apt => { + :sources => [ "brightbox-ruby-ng" ] + }, + :taginfo => { + :sites => [ + { :name => "taginfo.openstreetmap.org" } + ] + } +) + +run_list( + "recipe[taginfo]" +)