Use attribute for root dir

This commit is contained in:
Râu Cao 2024-01-08 11:35:04 +03:00
parent 98acd429de
commit daadd9374f
Signed by: raucao
GPG Key ID: 37036C356E56CC51
2 changed files with 14 additions and 12 deletions

View File

@ -5,11 +5,23 @@
domain = node["email"]["domain"]
hostname = node["email"]["hostname"]
root_dir = node["email"]["root_directory"]
ip_addr = node["knife_zero"]["host"]
node.override["set_fqdn"] = hostname
include_recipe "hostname"
user "vmail" do
gid "mail"
system true
manage_home false
end
directory root_dir do
owner "vmail"
group "mail"
end
tls_cert_for hostname do
auth "gandi_dns"
action :create

View File

@ -15,6 +15,7 @@ end
domain = node["email"]["domain"]
hostname = node["email"]["hostname"]
root_dir = node["email"]["root_directory"]
ip_addr = node["knife_zero"]["host"]
ldap_search_base = node["email"]["ldap_search_base"]
@ -22,17 +23,6 @@ ldap_user_filter = "(&(objectClass=person)(mailRoutingAddress=%u))"
credentials = Chef::EncryptedDataBagItem.load('credentials', 'email')
user "vmail" do
gid "mail"
system true
manage_home false
end
directory "/var/vmail" do
owner "vmail"
group "mail"
end
template "/etc/dovecot/dovecot.conf" do
source "dovecot.conf.erb"
mode 0644
@ -70,7 +60,7 @@ template "/etc/dovecot/conf.d/10-mail.conf" do
variables mail_uid: "vmail",
mail_gid: "mail",
mail_location: "mbox:~/mail:INBOX=~/mail/INBOX",
mail_home: "/var/vmail/%d/%n"
mail_home: "#{root_dir}/%d/%n"
notifies :restart, "service[dovecot]", :delayed
end