From 649c05666604a5f56b220a12c24cb152d56e3e91 Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Mon, 18 May 2020 13:53:55 +0000 Subject: [PATCH] Add test for nominatim cookbook --- .github/workflows/test-kitchen.yml | 1 + .kitchen.yml | 3 +++ cookbooks/nginx/recipes/default.rb | 1 + cookbooks/nominatim/attributes/default.rb | 6 ++++++ cookbooks/nominatim/metadata.rb | 4 ++-- cookbooks/nominatim/recipes/default.rb | 3 ++- test/data_bags/accounts/lonvia.json | 6 ++++++ test/data_bags/accounts/nominatim.json | 6 ++++++ .../nominatim/serverspec/nginx_spec.rb | 17 +++++++++++++++++ 9 files changed, 44 insertions(+), 3 deletions(-) create mode 100644 test/data_bags/accounts/lonvia.json create mode 100644 test/data_bags/accounts/nominatim.json create mode 100644 test/integration/nominatim/serverspec/nginx_spec.rb diff --git a/.github/workflows/test-kitchen.yml b/.github/workflows/test-kitchen.yml index d6d3f83eb..f62bc5d93 100644 --- a/.github/workflows/test-kitchen.yml +++ b/.github/workflows/test-kitchen.yml @@ -56,6 +56,7 @@ jobs: - networking - nginx - nodejs + - nominatim - ntp - openssh - osmosis diff --git a/.kitchen.yml b/.kitchen.yml index 51f0fc43e..f664702b6 100644 --- a/.kitchen.yml +++ b/.kitchen.yml @@ -202,6 +202,9 @@ suites: - name: nodejs run_list: - recipe[nodejs::default] + - name: nominatim + run_list: + - recipe[nominatim::default] - name: ntp run_list: - recipe[ntp::default] diff --git a/cookbooks/nginx/recipes/default.rb b/cookbooks/nginx/recipes/default.rb index f17e3dc44..cfd79376d 100644 --- a/cookbooks/nginx/recipes/default.rb +++ b/cookbooks/nginx/recipes/default.rb @@ -19,6 +19,7 @@ include_recipe "apt" include_recipe "munin" +include_recipe "ssl" package "nginx" diff --git a/cookbooks/nominatim/attributes/default.rb b/cookbooks/nominatim/attributes/default.rb index d096f9394..fe1118822 100644 --- a/cookbooks/nominatim/attributes/default.rb +++ b/cookbooks/nominatim/attributes/default.rb @@ -1,7 +1,9 @@ default[:nominatim][:state] = "off" # or: standalone, master, slave default[:nominatim][:dbadmins] = [] +default[:nominatim][:dbcluster] = "12/main" default[:nominatim][:dbname] = "nominatim" default[:nominatim][:tablespaces] = [] +default[:nominatim][:postgis] = "2.5" default[:nominatim][:logdir] = "/var/log/nominatim" default[:nominatim][:repository] = "https://git.openstreetmap.org/public/nominatim.git" default[:nominatim][:revision] = "master" @@ -17,3 +19,7 @@ default[:nominatim][:fpm_pools] = { } default[:nominatim][:redirects] = {} + +default[:postgresql][:versions] |= [node[:nominatim][:dbcluster].split("/").first] + +default[:accounts][:users][:nominatim][:status] = :role diff --git a/cookbooks/nominatim/metadata.rb b/cookbooks/nominatim/metadata.rb index 57b19a03a..017bc0912 100644 --- a/cookbooks/nominatim/metadata.rb +++ b/cookbooks/nominatim/metadata.rb @@ -6,11 +6,11 @@ description "Installs and configures nominatim servers" version "1.0.0" supports "ubuntu" -depends "systemd" -depends "apache" +depends "accounts" depends "fail2ban" depends "git" depends "munin" depends "nginx" depends "postgresql" depends "python" +depends "systemd" diff --git a/cookbooks/nominatim/recipes/default.rb b/cookbooks/nominatim/recipes/default.rb index 929645f38..46a03fc91 100644 --- a/cookbooks/nominatim/recipes/default.rb +++ b/cookbooks/nominatim/recipes/default.rb @@ -17,6 +17,7 @@ # limitations under the License. # +include_recipe "accounts" include_recipe "munin" basedir = data_bag_item("accounts", "nominatim")["home"] @@ -312,7 +313,7 @@ directory "#{basedir}/etc" do mode 0o775 end -%w[user_agent referer email].each do |name| +%w[user_agent referrer email].each do |name| file "#{basedir}/etc/nginx_blocked_#{name}.conf" do action :create_if_missing owner "nominatim" diff --git a/test/data_bags/accounts/lonvia.json b/test/data_bags/accounts/lonvia.json new file mode 100644 index 000000000..168453963 --- /dev/null +++ b/test/data_bags/accounts/lonvia.json @@ -0,0 +1,6 @@ +{ + "id": "lonvia", + "uid": "1056", + "comment": "Sarah Hoffmann", + "email": "lonvia@example.com" +} diff --git a/test/data_bags/accounts/nominatim.json b/test/data_bags/accounts/nominatim.json new file mode 100644 index 000000000..675eb7776 --- /dev/null +++ b/test/data_bags/accounts/nominatim.json @@ -0,0 +1,6 @@ +{ + "id": "nominatim", + "uid": "518", + "comment": "nominatim.openstreetmap.org", + "home": "/srv/nominatim.openstreetmap.org" +} diff --git a/test/integration/nominatim/serverspec/nginx_spec.rb b/test/integration/nominatim/serverspec/nginx_spec.rb new file mode 100644 index 000000000..03901cc32 --- /dev/null +++ b/test/integration/nominatim/serverspec/nginx_spec.rb @@ -0,0 +1,17 @@ +require "serverspec" + +# Required by serverspec +set :backend, :exec + +describe package("nginx") do + it { should be_installed } +end + +describe service("nginx") do + it { should be_enabled } + it { should be_running } +end + +describe port(8050) do + it { should be_listening.with("tcp") } +end -- 2.39.5