]> git.openstreetmap.org Git - chef.git/blob - cookbooks/db/recipes/base.rb
Remove munin
[chef.git] / cookbooks / db / recipes / base.rb
1 #
2 # Cookbook:: db
3 # Recipe:: base
4 #
5 # Copyright:: 2011, OpenStreetMap Foundation
6 #
7 # Licensed under the Apache License, Version 2.0 (the "License");
8 # you may not use this file except in compliance with the License.
9 # You may obtain a copy of the License at
10 #
11 #     https://www.apache.org/licenses/LICENSE-2.0
12 #
13 # Unless required by applicable law or agreed to in writing, software
14 # distributed under the License is distributed on an "AS IS" BASIS,
15 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 # See the License for the specific language governing permissions and
17 # limitations under the License.
18 #
19
20 include_recipe "accounts"
21 include_recipe "git"
22 include_recipe "postgresql"
23 include_recipe "python"
24 include_recipe "ruby"
25
26 passwords = data_bag_item("db", "passwords")
27 wal_secrets = data_bag_item("db", "wal-secrets")
28
29 directory "/srv/www.openstreetmap.org" do
30   group "rails"
31   mode "2775"
32 end
33
34 rails_port "www.openstreetmap.org" do
35   directory "/srv/www.openstreetmap.org/rails"
36   user "rails"
37   group "rails"
38   repository "https://git.openstreetmap.org/public/rails.git"
39   revision "live"
40   build_assets false
41   database_host "localhost"
42   database_name "openstreetmap"
43   database_username "openstreetmap"
44   database_password passwords["openstreetmap"]
45 end
46
47 package %w[
48   cmake
49   libosmium2-dev
50   libprotozero-dev
51   libboost-filesystem-dev
52   libboost-program-options-dev
53   libbz2-dev
54   zlib1g-dev
55   libexpat1-dev
56   libyaml-cpp-dev
57   libpqxx-dev
58 ]
59
60 git "/opt/osmdbt" do
61   action :sync
62   repository "https://github.com/openstreetmap/osmdbt.git"
63   revision "v0.5"
64   depth 1
65   user "root"
66   group "root"
67 end
68
69 node[:postgresql][:versions].each do |db_version|
70   directory "/opt/osmdbt/build-#{db_version}" do
71     owner "root"
72     group "root"
73     mode "755"
74   end
75
76   execute "/opt/osmdbt/build-#{db_version}" do
77     action :nothing
78     command "cmake -DPG_CONFIG=/usr/lib/postgresql/#{db_version}/bin/pg_config .."
79     cwd "/opt/osmdbt/build-#{db_version}"
80     user "root"
81     group "root"
82     subscribes :run, "directory[/opt/osmdbt/build-#{db_version}]"
83     subscribes :run, "git[/opt/osmdbt]"
84   end
85
86   execute "/opt/osmdbt/build-#{db_version}/postgresql-plugin/Makefile" do
87     action :nothing
88     command "make"
89     cwd "/opt/osmdbt/build-#{db_version}/postgresql-plugin"
90     user "root"
91     group "root"
92     subscribes :run, "execute[/opt/osmdbt/build-#{db_version}]"
93   end
94
95   link "/usr/lib/postgresql/#{db_version}/lib/osm-logical.so" do
96     to "/opt/osmdbt/build-#{db_version}/postgresql-plugin/osm-logical.so"
97     owner "root"
98     group "root"
99   end
100 end
101
102 package "lzop"
103
104 remote_file "/usr/local/bin/wal-g" do
105   action :create
106   source "https://github.com/wal-g/wal-g/releases/download/v2.0.1/wal-g-pg-ubuntu-20.04-amd64"
107   owner "root"
108   group "root"
109   mode "755"
110 end
111
112 template "/usr/local/bin/openstreetmap-wal-g" do
113   source "wal-g.erb"
114   owner "root"
115   group "postgres"
116   mode "750"
117   variables :s3_key => wal_secrets["s3_key"]
118 end