5 # Copyright:: 2024, OpenStreetMap Foundation
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
11 # https://www.apache.org/licenses/LICENSE-2.0
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.
20 include_recipe "accounts"
21 include_recipe "apache"
23 include_recipe "postgresql"
24 include_recipe "tools"
26 passwords = data_bag_item("otrs", "passwords")
28 apache_module "perl" do
29 package "libapache2-mod-perl2"
32 apache_module "deflate"
33 apache_module "headers"
34 apache_module "rewrite"
36 database_cluster = node[:otrs][:database_cluster]
37 database_name = node[:otrs][:database_name]
38 database_user = node[:otrs][:database_user]
39 database_password = passwords[node[:otrs][:database_password]]
40 site = node[:otrs][:site]
41 site_aliases = node[:otrs][:site_aliases] || []
43 postgresql_user database_user do
44 cluster database_cluster
45 password database_password
48 postgresql_database database_name do
49 cluster database_cluster
53 package "dbconfig-common"
55 template "/etc/dbconfig-common/otrs2.conf" do
56 source "dbconfig.config.erb"
60 variables :database_name => database_name,
61 :database_user => database_user,
62 :database_password => database_password
65 apt_package "otrs2" do
66 options "-t #{node[:lsb][:codename]}-backports"
69 # Ensure debconf is repopulated on a dbconfig change
70 execute "dpkg-reconfigure-otrs2" do
72 command "dpkg-reconfigure -fnoninteractive otrs2"
73 subscribes :run, "template[/etc/dbconfig-common/otrs2.conf]"
76 # Disable deb otrs2 apache config
77 apache_conf "otrs2" do
81 # Disable deb otrs2 cron job
82 file "/etc/cron.d/otrs2" do
84 manage_symlink_source true
87 systemd_service "otrs" do
88 description "OTRS Daemon"
92 exec_start_pre "-/usr/share/otrs/bin/otrs.Daemon.pl stop" # Stop if race with deb cron
93 exec_start "/usr/share/otrs/bin/otrs.Daemon.pl start"
95 protect_system "strict"
97 read_write_paths ["/var/lib/otrs", "/var/log/exim4", "/var/spool/exim4"]
101 action [:enable, :start]
102 subscribes :restart, "apt_package[otrs2]"
103 subscribes :restart, "systemd_service[otrs]"
106 ssl_certificate site do
107 domains [site] + site_aliases
108 notifies :reload, "service[apache2]"
112 template "apache-debian.erb"
113 variables :aliases => site_aliases
116 template "/etc/cron.daily/otrs-backup" do
117 source "backup.cron.erb"