{"id":21745165,"url":"https://github.com/zuazo/opendkim-cookbook","last_synced_at":"2025-10-05T20:36:12.181Z","repository":{"id":32436112,"uuid":"36014201","full_name":"zuazo/opendkim-cookbook","owner":"zuazo","description":"Chef cookbook to install and configure OpenDKIM.","archived":false,"fork":false,"pushed_at":"2020-01-29T09:18:40.000Z","size":93,"stargazers_count":2,"open_issues_count":2,"forks_count":7,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-26T22:05:18.722Z","etag":null,"topics":["antispam","authentication","chef","cookbook","devops","dkim","domainkeys","mta","opendkim"],"latest_commit_sha":null,"homepage":"https://supermarket.chef.io/cookbooks/opendkim","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zuazo.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-05-21T13:25:43.000Z","updated_at":"2020-04-28T07:28:00.000Z","dependencies_parsed_at":"2022-07-09T08:30:27.410Z","dependency_job_id":null,"html_url":"https://github.com/zuazo/opendkim-cookbook","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zuazo%2Fopendkim-cookbook","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zuazo%2Fopendkim-cookbook/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zuazo%2Fopendkim-cookbook/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zuazo%2Fopendkim-cookbook/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zuazo","download_url":"https://codeload.github.com/zuazo/opendkim-cookbook/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248665743,"owners_count":21142123,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["antispam","authentication","chef","cookbook","devops","dkim","domainkeys","mta","opendkim"],"created_at":"2024-11-26T07:13:48.281Z","updated_at":"2025-10-05T20:36:07.161Z","avatar_url":"https://github.com/zuazo.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"OpenDKIM Cookbook\n=================\n[![Documentation](http://img.shields.io/badge/docs-rdoc.info-blue.svg?style=flat)](http://www.rubydoc.info/github/zuazo/opendkim-cookbook)\n[![GitHub](http://img.shields.io/badge/github-zuazo/opendkim--cookbook-blue.svg?style=flat)](https://github.com/zuazo/opendkim-cookbook)\n[![License](https://img.shields.io/github/license/zuazo/opendkim-cookbook.svg?style=flat)](#license-and-author)\n\n[![Cookbook Version](https://img.shields.io/cookbook/v/opendkim.svg?style=flat)](https://supermarket.chef.io/cookbooks/opendkim)\n[![Dependency Status](http://img.shields.io/gemnasium/zuazo/opendkim-cookbook.svg?style=flat)](https://gemnasium.com/zuazo/opendkim-cookbook)\n[![Code Climate](http://img.shields.io/codeclimate/github/zuazo/opendkim-cookbook.svg?style=flat)](https://codeclimate.com/github/zuazo/opendkim-cookbook)\n[![Build Status](http://img.shields.io/travis/zuazo/opendkim-cookbook.svg?style=flat)](https://travis-ci.org/zuazo/opendkim-cookbook)\n[![Coverage Status](http://img.shields.io/coveralls/zuazo/opendkim-cookbook.svg?style=flat)](https://coveralls.io/r/zuazo/opendkim-cookbook?branch=master)\n[![Inline docs](http://inch-ci.org/github/zuazo/opendkim-cookbook.svg?branch=master\u0026style=flat)](http://inch-ci.org/github/zuazo/opendkim-cookbook)\n\nInstalls and configures [OpenDKIM](http://www.opendkim.org/): Open source implementation of the DKIM (Domain Keys Identified Mail) sender authentication system.\n\nRequirements\n============\n\n## Supported Platforms\n\nThis cookbook has been tested on the following platforms:\n\n* Amazon Linux\n* CentOS\n* Debian\n* Fedora\n* FreeBSD\n* Oracle Linux\n* RedHat\n* Scientific Linux\n* Ubuntu\n\nPlease, [let us know](https://github.com/zuazo/opendkim-cookbook/issues/new?title=I%20have%20used%20it%20successfully%20on%20...) if you use it successfully on any other platform.\n\n## Required Cookbooks\n\n* [yum-epel](https://supermarket.chef.io/cookbooks/yum-epel)\n\n## Required Applications\n\n* Chef `12` or higher.\n* Ruby `2.2` or higher.\n\nAttributes\n==========\n\n| Attribute                  | Default      | Description                  |\n|----------------------------|:------------:|------------------------------|\n| `node['opendkim']['conf']` | *calculated* | OpenDKIM configuration hash. |\n\n## Platform Support Related Attributes\n\nSome cookbook attributes are used internally to support the different platforms. Surely you want to change them if you want to support new platforms or want to improve the support of some platforms already supported.\n\n| Attribute                                 | Default               | Description                       |\n|-------------------------------------------|:---------------------:|-----------------------------------|\n| `node['opendkim']['conf_file']`           | *calculated*          | OpenDKIM Configuration file path.\n| `node['opendkim']['service']['name']`     | *calculated*          | OpenDKIM system service name.\n| `node['opendkim']['service']['supports']` | *calculated*          | OpenDKIM service supported actions.\n| `node['opendkim']['packages']['tools']`   | *calculated*          | OpenDKIM tools package name as array (currently unused).\n| `node['opendkim']['packages']['service']` | `%w(opendkim)`        | OpenDKIM daemon package name as array.\n| `node['opendkim']['run_dir']`             | `'/var/run/opendkim'` | OpenDKIM run directory used for the pidfile and as home for the system user.\n| `node['opendkim']['user']`                | `'opendkim'`          | OpenDKIM system user name.\n| `node['opendkim']['group']`               | `'opendkim'`          | OpenDKIM system group.\n\nRecipes\n=======\n\n## opendkim::default\n\nInstalls and configures OpenDKIM.\n\nUsage Examples\n==============\n\n## Including in a Cookbook Recipe\n\nYou can simply include it in a recipe:\n\n```ruby\ninclude_recipe 'opendkim'\n```\n\nDon't forget to include the `opendkim` cookbook as a dependency in the metadata.\n\n```ruby\n# metadata.rb\n# [...]\n\ndepends 'opendkim'\n```\n\n## Including in the Run List\n\nAnother alternative is to include the default recipe in your *Run List*:\n\n```json\n{\n  \"name\": \"mail.onddo.com\",\n  \"[...]\": \"[...]\",\n  \"run_list\": [\n    \"recipe[opendkim]\"\n  ]\n}\n```\n\n## Reading the Key from a Chef Vault Bag\n\nThis is a complete example that reads the DKIM key from a chef vault bag using the [`chef-vault`](https://supermarket.chef.io/cookbooks/chef-vault) cookbook. The *txt* field is completely optional.\n\nFor more information about this configuration options, see [opendkim.conf(5)](http://www.opendkim.org/opendkim.conf.5.html) and [opendkim(8)](http://www.opendkim.org/opendkim.8.html).\n\n```ruby\ndomain = 'example.com'\nselector = '20150522'\nkey_name = \"#{selector}._domainkey.#{domain} \"\\\n\ndirectory '/etc/opendkim' do\n  mode '00755'\nend\n\n# Configure and Create OpenDKIM Tables\n\n# Defines a table that will be queried to convert key names to sets of data of\n# the form (signing domain, signing selector, private key). The private key can\n# either contain a PEM-formatted private key, a base64-encoded DER format\n# private key, or a path to a file containing one of those.\nnode.default['opendkim']['conf']['KeyTable'] = 'refile:/etc/opendkim/KeyTable'\n\nfile '/etc/opendkim/KeyTable' do\n  mode '00644'\n  content(\n    \"#{key_name} \"\\\n    \"#{domain}:#{selector}:/etc/opendkim/keys/#{domain}/#{selector}.private\\n\"\n  )\nend\n\n# Defines a dataset that will be queried for the message sender's address\n# to determine which private key(s) (if any) should be used to sign the\n# message. The sender is determined from the value of the sender\n# header fields as described with SenderHeaders above. The key for this\n# lookup should be an address or address pattern that matches senders;\n# see the opendkim.conf(5) man page for more information. The value\n# of the lookup should return the name of a key found in the KeyTable\n# that should be used to sign the message. If MultipleSignatures\n# is set, all possible lookup keys will be attempted which may result\n# in multiple signatures being applied.\nnode.default['opendkim']['conf']['SigningTable'] =\n  'refile:/etc/opendkim/SigningTable'\n\nfile '/etc/opendkim/SigningTable' do\n  mode '00644'\n  content \"*@#{domain} #{key_name}\\n\"\nend\n\n# Install OpenDKIM\n\ninclude_recipe 'opendkim'\n\n# Read DKIM keys from chef-vault\n\n# node#save avoids chef-vault chicken \u0026 egg problem (a bit tricky)\nnode.save unless Chef::Config[:solo]\ninclude_recipe 'chef-vault'\nkey = chef_vault_item('dkim_keys', domain)\n\n# Create the credential files\n\ndirectory \"/etc/opendkim/keys/#{domain}\" do\n  owner node['opendkim']['user']\n  group node['opendkim']['group']\n  recursive true\nend\n\nfile \"/etc/opendkim/keys/#{domain}/#{selector}.private\" do\n  owner node['opendkim']['user']\n  group node['opendkim']['group']\n  mode '00640'\n  sensitive true if Chef::Resource.method_defined?(:sensitive)\n  content key['private']\nend\n\n# The txt is optional\nfile \"/etc/opendkim/keys/#{domain}/#{selector}.txt\" do\n  owner node['opendkim']['user']\n  group node['opendkim']['group']\n  mode '00644'\n  content key['txt']\n  only_if { key['txt'].is_a?(String) }\nend\n```\n\nThe vault bag content example:\n\n```json\n{\n  \"id\": \"example.com\",\n  \"private\": \"-----BEGIN RSA PRIVATE KEY-----\\n [...] \\n-----END RSA PRIVATE KEY-----\\n\",\n  \"txt\": \"v=DKIM1; k=rsa; p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKB [...]\"\n}\n```\n\nThe knife command to create the vault bag item:\n\n    $ knife vault create dkim_keys example.com [...]\n\nSee the [Chef-Vault documentation](https://github.com/Nordstrom/chef-vault/blob/master/README.md) to learn how to create chef-vault bags.\n\n## Integrate OpenDKIM with Postfix\n\nWe are using the [`postfix-full`](https://supermarket.chef.io/cookbooks/postfix-full) cookbook in this example:\n\n```ruby\nopendkim_port = 8891\n\n# Configure Postfix\nnode.default['postfix']['main']['milter_protocol'] = 2\nnode.default['postfix']['main']['milter_default_action'] = 'accept'\nnode.default['postfix']['main']['smtpd_milters'] =\n  \"inet:localhost:#{opendkim_port}\"\nnode.default['postfix']['main']['non_smtpd_milters'] =\n  \"inet:localhost:#{opendkim_port}\"\n\n# [...]\ninclude_recipe 'postfix-full'\n\n# Configure OpenDKIM\nnode.default['opendkim']['conf']['Mode'] = 'sv'\nnode.default['opendkim']['conf']['Socket'] = \"inet:#{opendkim_port}@localhost\"\n\n# [...]\ninclude_recipe 'opendkim'\n```\n\n## DNS Resource Record TXT Example\n\nThis a DNS TXT record example based on the examples above:\n\n```\n20150512._domainkey.example.com. 21599 IN TXT \"v=DKIM1; k=rsa; p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKB [...]\"\n```\n\nDeploy with Docker\n==================\n\nYou can use the *Dockerfile* included in the [cookbook source code](https://github.com/zuazo/opendkim-cookbook) to run the cookbook inside a container:\n\n    $ docker build -t chef-opendkim .\n    $ docker run -d -p 8891:8891 chef-opendkim\n\nThe sample *Dockerfile*:\n\n```Dockerfile\nFROM zuazo/chef-local:debian-7\n\nCOPY . /tmp/opendkim\nRUN berks vendor -b /tmp/opendkim/Berksfile $COOKBOOK_PATH\nRUN chef-client -r \"recipe[apt],recipe[opendkim]\"\n\nEXPOSE 8891\n\nCMD [\"/usr/sbin/opendkim\", \"-f\", \"-x\", \"/etc/opendkim.conf\", \"-u\", \"opendkim\", \"-P\", \"/var/run/opendkim/opendkim.pid\"]\n```\n\nSee the [chef-local container documentation](https://registry.hub.docker.com/u/zuazo/chef-local/) for more examples.\n\n## Testing Your Email DKIM Configuration\n\nYou can send an empty email to [check-auth@verifier.port25.com](mailto:check-auth@verifier.port25.com) to check that everything works correctly.\n\nTesting\n=======\n\nSee [TESTING.md](https://github.com/zuazo/opendkim-cookbook/blob/master/TESTING.md).\n\nContributing\n============\n\nPlease do not hesitate to [open an issue](https://github.com/zuazo/opendkim-cookbook/issues/new) with any questions or problems.\n\nSee [CONTRIBUTING.md](https://github.com/zuazo/opendkim-cookbook/blob/master/CONTRIBUTING.md).\n\nTODO\n====\n\nSee [TODO.md](https://github.com/zuazo/opendkim-cookbook/blob/master/TODO.md).\n\n\nLicense and Author\n=====================\n\n|                      |                                          |\n|:---------------------|:-----------------------------------------|\n| **Author:**          | [Raul Rodriguez](https://github.com/raulr) (\u003craul@onddo.com\u003e)\n| **Author:**          | [Xabier de Zuazo](https://github.com/zuazo) (\u003cxabier@zuazo.org\u003e)\n| **Contributor:**     | [Michael Burns](https://github.com/mburns)\n| **Copyright:**       | Copyright (c) 2015, Xabier de Zuazo\n| **Copyright:**       | Copyright (c) 2015, Onddo Labs, SL.\n| **License:**         | Apache License, Version 2.0\n\n    Licensed under the Apache License, Version 2.0 (the \"License\");\n    you may not use this file except in compliance with the License.\n    You may obtain a copy of the License at\n    \n        http://www.apache.org/licenses/LICENSE-2.0\n    \n    Unless required by applicable law or agreed to in writing, software\n    distributed under the License is distributed on an \"AS IS\" BASIS,\n    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n    See the License for the specific language governing permissions and\n    limitations under the License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzuazo%2Fopendkim-cookbook","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzuazo%2Fopendkim-cookbook","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzuazo%2Fopendkim-cookbook/lists"}