Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
.vagrant
Berksfile.lock
*~
*#
.#*
\#*#
.*.sw[a-z]
*.un~
pkg/

# Berkshelf
.vagrant
/cookbooks
Berksfile.lock

# Bundler
Gemfile.lock
bin/*
.bundle/*

.kitchen/
.kitchen.local.yml
115 changes: 115 additions & 0 deletions .kitchen.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
---
driver:
name: vagrant

provisioner:
name: chef_zero

platforms:
- name: ubuntu-12.04
- name: centos-6.4

suites:
- name: default
run_list:
- recipe[bind9-chroot::default]
attributes: {
'bind9': {
'zones': [
{
'domain':'example.com',
'type':'master',
'allow_transfer': [
'192.168.1.2',
'192.168.1.3'
],
'also_notify': [
'192.168.1.2',
'192.168.1.3'
],
'zone_info': {
'serial': '00000',
'soa': 'ns.example.com',
'contact': 'root.example.com',
'global_ttl': 300,
'nameserver': [
'ns1.example.com',
'ns2.example.com'
],
'mail_exchange': [
{
'host': 'ASPMX.L.GOOGLE.COM',
'priority': 10,
}
],
'records': [
{
'name': 'www',
'type': 'A',
'ip': '127.0.0.1'
}
]
}
},
{
'domain':'example.net',
'type':'slave',
'masters': [
'192.168.1.1'
]
}
]
}
}
- name: chroot
run_list:
- recipe[bind9-chroot::default]
attributes: {
'bind9': {
'chroot_dir': '/var/chroot/named',
'zones': [
{
'domain':'example.com',
'type':'master',
'allow_transfer': [
'192.168.1.2',
'192.168.1.3'
],
'also_notify': [
'192.168.1.2',
'192.168.1.3'
],
'zone_info': {
'serial': '00000',
'soa': 'ns.example.com',
'contact': 'root.example.com',
'global_ttl': 300,
'nameserver': [
'ns1.example.com',
'ns2.example.com'
],
'mail_exchange': [
{
'host': 'ASPMX.L.GOOGLE.COM',
'priority': 10,
}
],
'records': [
{
'name': 'www',
'type': 'A',
'ip': '127.0.0.1'
}
]
}
},
{
'domain':'example.net',
'type':'slave',
'masters': [
'192.168.1.1'
]
}
]
}
}
1 change: 1 addition & 0 deletions Berksfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
site :opscode
#source "http://api.berkshelf.com"

metadata
9 changes: 9 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
source 'https://rubygems.org'

gem 'berkshelf'
gem 'test-kitchen'
gem 'busser'
gem 'kitchen-vagrant'
gem 'foodcritic'
gem 'chefspec'
gem 'strainer'
gem 'guard'
gem 'guard-foodcritic'
gem 'guard-rspec'
16 changes: 16 additions & 0 deletions Guardfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# A sample Guardfile
# More info at https://github.com/guard/guard#readme

guard :rspec do
watch(%r{^spec/.+_spec\.rb$})
watch(%r{^spec/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
watch('spec/spec_helper.rb') { "spec" }
end


guard "foodcritic", cookbook_paths:"." do
watch(%r{attributes/.+\.rb$})
watch(%r{providers/.+\.rb$})
watch(%r{recipes/.+\.rb$})
watch(%r{resources/.+\.rb$})
end
195 changes: 105 additions & 90 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Description

This cookbook takes care of the installation and configuration of BIND9. You're able to define some global variables and manage your zonefiles via data bags (json example below).
This cookbook takes care of the installation and configuration of BIND9. You're able to define some global variables and manage your zonefiles via node attributes (example below). This allows zone creation to be controlled by a wrapper cookbook using any mechanism to fill the attributes such as data bags, searches, or other attributes.
It also supports automatic serial number generation and automatic resource records for chef nodes (see optional json in example below)
No DNSSEC, no configurable logging, no rndc shell operations or other safety checks (named-checkconf, etc.).

Expand Down Expand Up @@ -34,106 +34,121 @@ It's so much better if you take a look at the ```attributes/default.rb``` file f

#Usage

Add ```"recipe[bind9-chroot]"``` to your run list. If you want to use BIND9 for serving domains you need add the appropriate data via data bags (example below).
Please note that the data bag's structure is mandatory except:
Add ```"recipe[bind9-chroot]"``` to your run list. If you want to use BIND9 for serving domains you need to fill in the appropriate node attributes (example below).
Please note that the node attribute structure is mandatory except:

* TTL for DNS records (if you decide to leave it empty, the global TTL will take over).
* IP for DNS records (if not available, ```node['ipaddress']``` will be used).

In order to run a a chroot'ed Bind9 server, set the ```node[:bind9][:chroot_dir]``` to the desired chroot path and optionally the ```node[:bind9][:disclose]``` attributes.

To use this cookbook with Chef Solo, add ```"recipe[chef-solo-search]"``` to your run list, and create the data bags either manually or using the ```knife-solo_data_bag``` gem.

#Examples

To create and view the data bags:

$ knife data bag create zones
$ knife data bag create zones exampleDOTcom
$ ... do something ...
$ knife data bag from file zones exampleDOTcom.json

An example of a data bag with mail records and specific IPs.

{
"id": "exampleDOTcom",
"domain": "example.com",
"type": "master",
"allow_transfer": [ "8.8.4.4",
"8.8.8.8" ],
"zone_info": {
"global_ttl": 300,
"soa": "ns.example.com.",
"contact": "user.example.com.",
"nameserver": [ "ns.example.com.",
"ns.example.net." ],
"mail_exchange": [{
"host": "ASPMX.L.GOOGLE.COM.",
"priority": 10
},{
"host": "ALT1.ASPMX.L.GOOGLE.COM.",
"priority": 20
},{
"host": "ALT2.ASPMX.L.GOOGLE.COM.",
"priority": 20
},{
"host": "ASPMX2.GOOGLEMAIL.COM.",
"priority": 30
},{
"host": "ASPMX3.GOOGLEMAIL.COM.",
"priority": 30
},{
"host": "ASPMX4.GOOGLEMAIL.COM.",
"priority": 30
},{
"host": "ASPMX5.GOOGLEMAIL.COM.",
"priority": 30
}],
"records": [{
"name": "www",
"type": "A",
"ip": "127.0.0.1"
},{
"name": "img",
"ttl": 30,
"type": "A",
"ip": "127.0.0.1"
},{
"name": "mail",
"type": "CNAME",
"ip": "ghs.google.com."
}]
}
An example of node attributes with mail records and specific IPs.

node[:bind9][:zones] = [
{
"domain" => "example.com",
"type" => "master",
"allow_transfer" => [
"8.8.4.4",
"8.8.8.8"
],
"zone_info" => {
"global_ttl" => 300,
"soa" => "ns.example.com.",
"contact" => "user.example.com.",
"nameserver" => [
"ns.example.com.",
"ns.example.net."
],
"mail_exchange" => [
{
"host" => "ASPMX.L.GOOGLE.COM.",
"priority" => 10
},
{
"host" => "ALT1.ASPMX.L.GOOGLE.COM.",
"priority" => 20
},
{
"host" => "ALT2.ASPMX.L.GOOGLE.COM.",
"priority" => 20
},
{
"host" => "ASPMX2.GOOGLEMAIL.COM.",
"priority" => 30
},
{
"host" => "ASPMX3.GOOGLEMAIL.COM.",
"priority" => 30
},
{
"host" => "ASPMX4.GOOGLEMAIL.COM.",
"priority" => 30
},
{
"host" => "ASPMX5.GOOGLEMAIL.COM.",
"priority" => 30
}
],
"records" => [
{
"name" => "www",
"type" => "A",
"ip" => "127.0.0.1"
},
{
"name" => "img",
"ttl" => 30,
"type" => "A",
"ip" => "127.0.0.1"
},
{
"name" => "mail",
"type" => "CNAME",
"ip" => "ghs.google.com."
}
]
}
]
}

An example of a data bag with mail records and specific IPs.

{
"id": "exampleDOTcom",
"domain": "example.com",
"type": "master",
"allow_transfer": [],
"zone_info": {
"global_ttl": 300,
"soa": "ns.example.com.",
"contact": "user.example.com.",
"nameserver": [ "ns.example.com.",
"ns.example.net." ],
"mail_exchange": [],
"records": [{
"name": "www",
"type": "A"
},{
"name": "img",
"ttl": 30,
"type": "A"
},{
"name": "mail",
"type": "CNAME"
}]
An example of node attributes with mail records and specific IPs.

node[:bind9][:zones] = [
{
"domain" => "example.com",
"type" => "master",
"allow_transfer" => [],
"zone_info" => {
"global_ttl": 300,
"soa": "ns.example.com.",
"contact": "user.example.com.",
"nameserver": [
"ns.example.com.",
"ns.example.net."
],
"mail_exchange": [],
"records": [
{
"name": "www",
"type": "A"
},
{
"name": "img",
"ttl": 30,
"type": "A"
},
{
"name": "mail",
"type": "CNAME"
}
]
}
}
}
]

#Contributions

This cookbook is derived from [Mike Adolphs's](https://github.com/fooforge/chef-cookbook_bind9), and specific contributions can be tracked via git.
This cookbook is derived from [Mike Adolphs's](https://github.com/fooforge/chef-cookbook_bind9), and specific contributions can be tracked via git.
5 changes: 5 additions & 0 deletions Strainerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Strainerfile
knife test: bundle exec knife cookbook test $COOKBOOK
foodcritic: bundle exec foodcritic -f any $SANDBOX/$COOKBOOK
chefspec: bundle exec rspec --color
kitchen: bundle exec kitchen test -d always
Loading