Skip to content

Commit fb45cf9

Browse files
jaymzhfacebook-github-bot
authored andcommitted
New cookbook: fb_cyrus (facebook#249)
Summary: This cookbook manages Cyrus mail services (IMAP). Signed-off-by: Phil Dibowitz <phil@ipom.com> Pull Request resolved: facebook#249 Test Plan: This Imported from GitHub, without a `Test Plan:` line. Differential Revision: D69054376 fbshipit-source-id: 85951f377e0759188da670b3fa02d1d0baa8a069
1 parent ef315fb commit fb45cf9

File tree

8 files changed

+286
-0
lines changed

8 files changed

+286
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Delivery for Local Phases Execution
2+
#
3+
# This file allows you to execute test phases locally on a workstation or
4+
# in a CI pipeline. The delivery-cli will read this file and execute the
5+
# command(s) that are configured for each phase. You can customize them
6+
# by just modifying the phase key on this file.
7+
#
8+
# By default these phases are configured for Cookbook Workflow only
9+
#
10+
11+
[local_phases]
12+
unit = "echo skipping unit phase."
13+
lint = "chef exec cookstyle"
14+
# foodcritic has been deprecated in favor of cookstyle so we skip the syntax
15+
# phase now.
16+
syntax = "echo skipping syntax phase. Use lint phase instead."
17+
provision = "chef exec kitchen create"
18+
deploy = "chef exec kitchen converge"
19+
smoke = "chef exec kitchen verify"
20+
# The functional phase is optional, you can define it by uncommenting
21+
# the line below and running the command: `delivery local functional`
22+
# functional = ""
23+
cleanup = "chef exec kitchen destroy"
24+
25+
# Remote project.toml file
26+
#
27+
# Instead of the local phases above, you may specify a remote URI location for
28+
# the `project.toml` file. This is useful for teams that wish to centrally
29+
# manage the behavior of the `delivery local` command across many different
30+
# projects.
31+
#
32+
# remote_file = "https://url/project.toml"

cookbooks/fb_cyrus/.gitignore

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
.vagrant
2+
*~
3+
*#
4+
.#*
5+
\#*#
6+
.*.sw[a-z]
7+
*.un~
8+
9+
# Bundler
10+
Gemfile.lock
11+
gems.locked
12+
bin/*
13+
.bundle/*
14+
15+
# test kitchen
16+
.kitchen/
17+
kitchen.local.yml
18+
19+
# Chef Infra
20+
Berksfile.lock
21+
.zero-knife.rb
22+
Policyfile.lock.json
23+
24+
.idea/
25+

cookbooks/fb_cyrus/README.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
fb_cyrus Cookbook
2+
=================
3+
4+
Requirements
5+
------------
6+
7+
Attributes
8+
----------
9+
* node['fb_cyrus']['manage_packages']
10+
* node['fb_cyrus']['configs']['cyrus'][$SERVICE][$CONFIG]
11+
* node['fb_cyrus']['configs']['imapd'][$KEY]
12+
13+
Usage
14+
-----
15+
16+
### Packages
17+
18+
This cookbook will install the necessary packages and keep them up-to-date. If
19+
you don't want that, you can set `node['fb_cyrus']['manage_packages']` to
20+
`false`.
21+
22+
Note that this cookbook only sets up the `imapd` services and thus only
23+
installs the core, administrative, and imap packages - it does not install or
24+
setup pop3 or nntp at this time.
25+
26+
### Configuration
27+
28+
The default configuration for cyrus.conf is in
29+
`node['fb_cyrus']['configs']['cyrus']`, and you can easily add to it. For
30+
example, to enable pop3, you could do:
31+
32+
```ruby
33+
node.default['fb_cyrus']['configs']['cyrus']['SERVICES']['pops3'] = {
34+
...
35+
}
36+
```
37+
38+
The configuration for imapd.conf is in `node['fb_cyrus']['configs']['imapd']`,
39+
and you can easily add your certificates with:
40+
41+
```ruby
42+
node.default['fb_cyrus']['configs']['imapd']['tls_server_cert'] = '...'
43+
node.default['fb_cyrus']['configs']['imapd']['tls_server_key'] = '...'
44+
```
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
default['fb_cyrus'] = {
2+
'manage_packages' => true,
3+
'configs' => {
4+
'cyrus' => {
5+
'START' => {
6+
'recover' => {
7+
'cmd' => '/usr/sbin/cyrus ctl_cyrusdb -r',
8+
},
9+
'idled' => {
10+
'cmd' => 'idled',
11+
},
12+
'delprune' => {
13+
'cmd' => '/usr/sbin/cyrus expire -E 3',
14+
},
15+
'tlsprune' => {
16+
'cmd' => '/usr/sbin/cyrus tls_prune',
17+
},
18+
'deleteprune' => {
19+
'cmd' => '/usr/sbin/cyrus expire -E 4 -D 28',
20+
'at' => '0430',
21+
},
22+
'expungeprune' => {
23+
'cmd' => '/usr/sbin/cyrus expire -E 4 -X 28',
24+
'at' => '0445',
25+
},
26+
},
27+
'SERVICES' => {
28+
# required for admin services, but force to listen
29+
# on localhost
30+
'imap' => {
31+
'cmd' => 'imapd -U 30',
32+
'listen' => 'localhost:imap',
33+
'prefork' => 0,
34+
'maxchild' => 100,
35+
},
36+
'imaps' => {
37+
'cmd' => 'imapd -s -U 30',
38+
'listen' => 'imaps',
39+
'prefork' => 1,
40+
'maxchild' => 100,
41+
},
42+
'lmtpunix' => {
43+
'cmd' => 'lmtpd',
44+
'listen' => '/run/cyrus/socket/lmtp',
45+
'prefork' => 0,
46+
'maxchild' => 20,
47+
},
48+
'sieve' => {
49+
'cmd' => 'timsieved',
50+
'listen' => 'localhost:sieve',
51+
'prefork' => 0,
52+
'maxchild' => 100,
53+
},
54+
'notify' => {
55+
'cmd' => 'notifyd',
56+
'listen' => '/run/cyrus/socket/notify',
57+
'proto' => 'udp',
58+
'prefork' => 1,
59+
},
60+
},
61+
'EVENTS' => {
62+
'checkpoint' => {
63+
'cmd' => '/usr/sbin/cyrus ctl_cyrusdb -c',
64+
'period' => 30,
65+
},
66+
'delprune' => {
67+
'cmd' => '/usr/sbin/cyrus expire -E 3',
68+
'at' => '0401',
69+
},
70+
'tlsprune' => {
71+
'cmd' => '/usr/sbin/cyrus tls_prune',
72+
'at' => '0401',
73+
},
74+
'squatter1' => {
75+
'cmd' => '/usr/bin/ionice -c idle /usr/lib/cyrus/bin/squatter -i',
76+
'period' => 120,
77+
},
78+
'squattera' => {
79+
'cmd' => '/usr/lib/cyrus/bin/squatter',
80+
'at' => '0517',
81+
},
82+
},
83+
},
84+
'imapd' => {
85+
'configdirectory' => '/var/lib/cyrus',
86+
'proc_path' => '/run/cyrus/proc',
87+
'mboxname_lockpath' => '/run/cyrus/lock',
88+
'defaultpartition' => 'default',
89+
'partition-default' => '/var/spool/cyrus/mail',
90+
'partition-news' => '/var/spool/cyrus/news',
91+
'newsspool' => '/var/spool/news',
92+
'altnamespace' => 'yes',
93+
'unixhierarchysep' => 'no',
94+
'lmtp_downcase_rcpt' => 'yes',
95+
'admins' => 'cyrus',
96+
'allowanonymouslogin' => 'no',
97+
'popminpoll' => 0,
98+
'autocreate_quota' => 0,
99+
'umask' => '077',
100+
'sieveusehomedir' => 'false',
101+
'sievedir' => '/var/spool/sieve',
102+
'httpmodules' => 'caldav carddav',
103+
'hashimapspool' => 'true',
104+
'allowplaintext' => 'no',
105+
'sasl_pwcheck_method' => 'auxprop',
106+
'sasl_auxprop_plugin' => 'sasldb',
107+
'sasl_auto_transition' => 'no',
108+
'tls_client_ca_dir' => '/etc/ssl/certs',
109+
'tls_session_timeout' => 1440,
110+
'lmtpsocket' => '/run/cyrus/socket/lmtp',
111+
'idlesocket' => '/run/cyrus/socket/idle',
112+
'notifysocket' => '/run/cyrus/socket/notify',
113+
'syslog_prefix' => 'cyrus',
114+
'debug' => 'yes',
115+
},
116+
},
117+
}

cookbooks/fb_cyrus/metadata.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
name 'fb_cyrus'
2+
maintainer 'Meta Platforms, Inc.'
3+
maintainer_email 'noreply@facebook.com'
4+
license 'Apache-2.0'
5+
description 'Manages Cyrus Mail Services'
6+
version '0.1.0'
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#
2+
# Cookbook:: fb_cyrus
3+
# Recipe:: default
4+
#
5+
# Copyright (c) 2025-present, Facebook, Inc.
6+
# Copyright (c) 2025-present, Phil Dibowitz
7+
# All rights reserved.
8+
#
9+
# Licensed under the Apache License, Version 2.0 (the "License");
10+
# you may not use this file except in compliance with the License.
11+
# You may obtain a copy of the License at
12+
#
13+
# http://www.apache.org/licenses/LICENSE-2.0
14+
#
15+
# Unless required by applicable law or agreed to in writing, software
16+
# distributed under the License is distributed on an "AS IS" BASIS,
17+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18+
# See the License for the specific language governing permissions and
19+
# limitations under the License.
20+
#
21+
22+
packages = %w{
23+
cyrus-admin
24+
cyrus-clients
25+
cyrus-imapd
26+
}
27+
28+
package 'cyrus packages' do
29+
only_if { node['fb_cyrus']['manage_packages'] }
30+
package_name packages
31+
action :upgrade
32+
end
33+
34+
template '/etc/cyrus.conf' do
35+
owner node.root_user
36+
group node.root_group
37+
mode '0644'
38+
notifies :restart, 'service[cyrus-imapd]'
39+
end
40+
41+
template '/etc/imapd.conf' do
42+
owner node.root_user
43+
group node.root_group
44+
mode '0644'
45+
notifies :restart, 'service[cyrus-imapd]'
46+
end
47+
48+
service 'cyrus-imapd' do
49+
action [:enable, :start]
50+
end
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# This file managed by Chef - do not modify!
2+
<% node['fb_cyrus']['configs']['cyrus'].each do |section, config| %>
3+
<%= section.upcase %> {
4+
<% config.each do |entry, options| %>
5+
<%= entry %> <%= options.map { |x, y| "#{x}=#{y.is_a?(Integer) ? y : "\"#{y}\""}" }.join(' ') %>
6+
<% end %>
7+
}
8+
<% end %>
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# This file is controlled by Chef - do not edit!
2+
<% node['fb_cyrus']['configs']['imapd'].each do |key, val| %>
3+
<%= key %>: <%= val %>
4+
<% end %>

0 commit comments

Comments
 (0)