]> git.openstreetmap.org Git - chef.git/blob - cookbooks/db/recipes/base.rb
community: bump esr version of discourse
[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 "git"
21 include_recipe "postgresql"
22 include_recipe "python"
23 include_recipe "ruby"
24
25 aws_credentials = data_bag_item("db", "aws")
26
27 package %w[
28   cmake
29   g++
30   libboost-filesystem-dev
31   libboost-program-options-dev
32   libbz2-dev
33   libexpat1-dev
34   libosmium2-dev
35   libpqxx-dev
36   libprotozero-dev
37   libyaml-cpp-dev
38   make
39   zlib1g-dev
40 ]
41
42 git "/opt/osmdbt" do
43   action :sync
44   repository "https://github.com/openstreetmap/osmdbt.git"
45   revision "v0.9"
46   depth 1
47   user "root"
48   group "root"
49 end
50
51 node[:postgresql][:versions].each do |db_version|
52   directory "/opt/osmdbt/build-#{db_version}" do
53     owner "root"
54     group "root"
55     mode "755"
56   end
57
58   execute "/opt/osmdbt/build-#{db_version}" do
59     action :nothing
60     command "cmake -DPG_CONFIG=/usr/lib/postgresql/#{db_version}/bin/pg_config .."
61     cwd "/opt/osmdbt/build-#{db_version}"
62     user "root"
63     group "root"
64     subscribes :run, "directory[/opt/osmdbt/build-#{db_version}]"
65     subscribes :run, "git[/opt/osmdbt]"
66   end
67
68   execute "/opt/osmdbt/build-#{db_version}/postgresql-plugin/Makefile" do
69     action :nothing
70     command "make"
71     cwd "/opt/osmdbt/build-#{db_version}/postgresql-plugin"
72     user "root"
73     group "root"
74     subscribes :run, "execute[/opt/osmdbt/build-#{db_version}]"
75   end
76
77   link "/usr/lib/postgresql/#{db_version}/lib/osm-logical.so" do
78     to "/opt/osmdbt/build-#{db_version}/postgresql-plugin/osm-logical.so"
79     owner "root"
80     group "root"
81   end
82 end
83
84 package "lzop"
85
86 remote_file "/usr/local/bin/wal-g" do
87   action :create
88   source "https://github.com/wal-g/wal-g/releases/download/v2.0.1/wal-g-pg-ubuntu-20.04-amd64"
89   owner "root"
90   group "root"
91   mode "755"
92 end
93
94 template "/usr/local/bin/openstreetmap-wal-g" do
95   source "wal-g.erb"
96   owner "root"
97   group "postgres"
98   mode "750"
99   variables :aws_credentials => aws_credentials
100   sensitive true
101 end