Skip to content

Commit 106c341

Browse files
jaymzhfacebook-github-bot
authored andcommitted
new cookbook: fb_opendkim (facebook#265)
Summary: Note this isn't added to `test_services` cookbook because it would require keys and a real domain and such. Signed-off-by: Phil Dibowitz <phil@ipom.com> Pull Request resolved: facebook#265 Differential Revision: D69666424 fbshipit-source-id: 46d5953c7d8e1d4a84068bcb7ebe62138c2e9632
1 parent 1cf9390 commit 106c341

File tree

6 files changed

+156
-0
lines changed

6 files changed

+156
-0
lines changed

cookbooks/fb_opendkim/README.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
fb_opendkim Cookbook
2+
====================
3+
4+
Requirements
5+
------------
6+
7+
Attributes
8+
----------
9+
* node['fb_opendkim']['config']
10+
* node['fb_opendkim']['manage_packages']
11+
* node['fb_opendkim']['sysconfig']
12+
13+
Usage
14+
-----
15+
### Packages
16+
17+
This cookbook will install the necessary packages. If you prefer to install
18+
them yourself, set `node['fb_opendkim']['manage_packages']` to `false`.
19+
20+
### Configuration
21+
22+
The configuration file is generated by the single-level hash in
23+
`node['fb_opendkim']['config']`. A default configuration is provided in this
24+
cookbook, but you'll certainly need to add more.
25+
26+
### Keys
27+
28+
This cookbook does not manage the keys for you. You should drop them off in an
29+
appropriate place for your distribution. For example, in Debian, this is
30+
`/etc/dkimkeys/<domain>/<service>.{private,txt}`.
31+
32+
Once you've done that you can set either
33+
`node['fb_opendkim']['config']['KeyFile']`,
34+
`node['fb_opendkim']['config']['Selector']`, and
35+
`node['fb_opendkim']['config']['Domain']` for simple setups, or alternatively,
36+
setup signingtables.
37+
38+
### Service Environment Variables
39+
40+
You can customize some options that the Unit file will read in the
41+
`node['fb_opendkim']['sysconfig']` hash. Note that if you specify `socket`, it
42+
will override the socket in the config file, and for this reason we recommend
43+
not setting socket here.
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#
2+
# vim: syntax=ruby:expandtab:shiftwidth=2:softtabstop=2:tabstop=2
3+
#
4+
# Copyright (c) 2025-present, Meta Platforms, Inc.
5+
# Copyright (c) 2025-present, Phil Dibowitz
6+
# All rights reserved.
7+
#
8+
# Licensed under the Apache License, Version 2.0 (the "License");
9+
# you may not use this file except in compliance with the License.
10+
# You may obtain a copy of the License at
11+
#
12+
# http://www.apache.org/licenses/LICENSE-2.0
13+
#
14+
# Unless required by applicable law or agreed to in writing, software
15+
# distributed under the License is distributed on an "AS IS" BASIS,
16+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17+
# See the License for the specific language governing permissions and
18+
# limitations under the License.
19+
#
20+
21+
rundir = '/run/opendkim'
22+
23+
default['fb_opendkim'] = {
24+
'manage_packages' => true,
25+
'config' => {
26+
'Syslog' => 'yes',
27+
'SyslogSuccess' => 'yes',
28+
'Canonicalization' => 'relaxed/simple',
29+
'OversignHeaders' => 'From',
30+
'UserID' => 'opendkim',
31+
'UMask' => '007',
32+
'Socket' => "local:#{rundir}/opendkim.sock",
33+
'PidFile' => '/run/opendkim/opendkim.pid',
34+
'TrustAnchorFile' => '/usr/share/dns/root.key',
35+
},
36+
'sysconfig' => {
37+
'rundir' => '/run/opendkim',
38+
# if you specify a socket here, it'll override the config
39+
# since it's _required_ in the config, put it only there and
40+
# not here.
41+
'user' => 'opendkim',
42+
'group' => 'opendkim',
43+
'pidfile' => '$RUNDIR/$NAME.pid',
44+
},
45+
}

cookbooks/fb_opendkim/metadata.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
name 'fb_opendkim'
2+
maintainer 'Meta Platforms, Inc.'
3+
maintainer_email 'noreply@meta.com'
4+
license 'Apache-2.0'
5+
description 'Installs/Configures opendkim'
6+
version '0.1.0'
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#
2+
# Cookbook:: fb_opendkim
3+
# Recipe:: default
4+
#
5+
# Copyright:: 2025-present, Meta Platforms, Inc.
6+
# Copyright:: 2025-present, Phil Dibowitz
7+
#
8+
# Licensed under the Apache License, Version 2.0 (the "License");
9+
# you may not use this file except in compliance with the License.
10+
# You may obtain a copy of the License at
11+
#
12+
# http://www.apache.org/licenses/LICENSE-2.0
13+
#
14+
# Unless required by applicable law or agreed to in writing, software
15+
# distributed under the License is distributed on an "AS IS" BASIS,
16+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17+
# See the License for the specific language governing permissions and
18+
# limitations under the License.
19+
#
20+
21+
packages = %w{
22+
opendkim
23+
opendkim-tools
24+
}
25+
26+
package 'opendkim packages' do
27+
only_if { node['fb_opendkim']['manage_packages'] }
28+
package_name packages
29+
action :upgrade
30+
end
31+
32+
template '/etc/opendkim.conf' do
33+
owner node.root_user
34+
group node.root_group
35+
mode '0644'
36+
notifies :restart, 'service[opendkim]'
37+
end
38+
39+
sysconfig = value_for_platform_family(
40+
['rhel', 'fedora'] => '/etc/sysconfig/opendkim',
41+
['debian'] => '/etc/default/opendkim',
42+
)
43+
44+
template sysconfig do
45+
source 'sysconfig.erb'
46+
owner node.root_user
47+
group node.root_group
48+
mode '0644'
49+
notifies :restart, 'service[opendkim]'
50+
end
51+
52+
service 'opendkim' do
53+
action [:enable, :start]
54+
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 modify!
2+
<% node['fb_opendkim']['config'].each do |key, val| %>
3+
<%= key %> <%= val %>
4+
<% 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 modify!
2+
<% node['fb_opendkim']['sysconfig'].each do |key, val| %>
3+
<%= key.upcase %>="<%= val %>"
4+
<% end %>

0 commit comments

Comments
 (0)