Skip to content

Feature/configure zone file with dsl #85

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 32 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
d66d18b
Couple fixes to achive compatibility described in metadata.json (Pupp…
konradkuczynski Nov 17, 2017
482fe70
Adding Travis CI configuration
konradkuczynski Nov 17, 2017
fdcb5e3
Switch to newer version of rspec-puppet
konradkuczynski Nov 17, 2017
74fee6e
Adding support for Puppet 5.x
konradkuczynski Nov 17, 2017
1c4c8b0
correction of Travis CI tests
konradkuczynski Nov 17, 2017
25dcef3
adding dsl's file manifests and unit tests
konradkuczynski Dec 7, 2017
774555d
adding beaker tests
konradkuczynski Dec 8, 2017
ff4dbe9
correction of travis.yaml
konradkuczynski Dec 8, 2017
e17f25b
correction repo puppet's modules
konradkuczynski Dec 8, 2017
d298aa0
correction repo puppet's modules - docker 7
konradkuczynski Dec 8, 2017
982ed64
acceptance tests for different versions of puppet
konradkuczynski Dec 8, 2017
a80e517
acceptance tests for centos7
konradkuczynski Dec 8, 2017
ef0f0eb
description of zone's definition parametres
konradkuczynski Dec 11, 2017
bf2fef6
adding assert comand to record plus unit tests
konradkuczynski Dec 12, 2017
26e9f78
adding assert to definition file
konradkuczynski Dec 12, 2017
68c7f4c
modification of README.md
konradkuczynski Dec 12, 2017
dda9bd7
Complete tests for dns zones
konradkuczynski Dec 13, 2017
63b6fba
Correction of unit tests
konradkuczynski Dec 13, 2017
89c3a77
Modification of README.md
konradkuczynski Dec 13, 2017
9c5002e
adding tests for centos 6
konradkuczynski Dec 13, 2017
aa0e9aa
Nodesets for Debian and Ubuntu
konradkuczynski Dec 14, 2017
a45daa8
Correction of README.md
konradkuczynski Dec 14, 2017
3667449
Adding puppet version config for beaker tests
konradkuczynski Dec 14, 2017
2bb736c
Adding debian 78 nodeset
konradkuczynski Dec 14, 2017
a4639a3
Modification of Travis tests
konradkuczynski Dec 14, 2017
8b0dd77
Beaker doesn't support tests puppet 3 for centos - skipped
konradkuczynski Dec 14, 2017
29bf751
Travis test for puppet 3 - correction
konradkuczynski Dec 14, 2017
474d67e
MOdification os Debian - tests of Travis
konradkuczynski Dec 15, 2017
7acc3bb
Some small changes in test suit
konradkuczynski Dec 15, 2017
2a6e5c1
BUmp of puppet-concat version
konradkuczynski Dec 15, 2017
30a3cde
bump puppet concat version
konradkuczynski Dec 18, 2017
f28d9be
rollback metadaja.json
konradkuczynski Dec 18, 2017
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
13 changes: 13 additions & 0 deletions .fixtures.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
fixtures:
repositories:
concat:
repo: "https://github.com/puppetlabs/puppetlabs-concat.git"
ref: "1.2.1"
stdlib:
repo: "https://github.com/puppetlabs/puppetlabs-stdlib.git"
ref: "4.12.0"
assert:
repo: "https://github.com/binford2k/puppet-assert.git"
ref: "v0.2.1"
symlinks:
bind: "#{source_dir}"
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.bundle
spec/fixtures/manifests
spec/fixtures/modules
.vagrant/
log/
2 changes: 2 additions & 0 deletions .rspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
--format documentation
--color
84 changes: 84 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
---
language: ruby
sudo: false
bundler_args: --jobs=3 --retry=3
cache: bundler
script:
- bundle exec rake test
notifications:
email: false
matrix:
fast_finish: true
include:
# On Puppet 5.x
- rvm: '2.1'
- rvm: '2.3'
sudo: required
services: docker
env: PUPPET_INSTALL_VERSION='5' PUPPET_AGENT_INSTALL_VERSION='5.3.3' PUPPET_COLLECTION=puppet5 RS_SET="centos-7-docker"
script: bundle exec rake beaker
- rvm: '2.3'
sudo: required
services: docker
env: PUPPET_INSTALL_VERSION='5' PUPPET_AGENT_INSTALL_VERSION='5.3.3' PUPPET_COLLECTION=puppet5 RS_SET="ubuntu-14.04-docker"
script: bundle exec rake beaker
- rvm: '2.3'
sudo: required
services: docker
env: PUPPET_INSTALL_VERSION='5' PUPPET_AGENT_INSTALL_VERSION='5.3.3' PUPPET_COLLECTION=puppet5 RS_SET="debian-82-docker"
script: bundle exec rake beaker
- rvm: '2.3'
- rvm: '2.4'
# On Puppet 4.x
- rvm: '1.9'
env: PUPPET_GEM_VERSION='~> 4.8.0'
- rvm: '2.0'
env: PUPPET_GEM_VERSION='~> 4.8.0'
- rvm: '2.3'
sudo: required
services: docker
env: PUPPET_INSTALL_VERSION='4' PUPPET_AGENT_INSTALL_VERSION='1.10.7' RS_SET="centos-7-docker"
script: bundle exec rake beaker
- rvm: '2.3'
sudo: required
services: docker
env: PUPPET_INSTALL_VERSION='4' PUPPET_AGENT_INSTALL_VERSION='1.10.7' RS_SET="ubuntu-14.04-docker"
script: bundle exec rake beaker
- rvm: '2.3'
sudo: required
services: docker
env: PUPPET_INSTALL_VERSION='4' PUPPET_AGENT_INSTALL_VERSION='1.10.7' RS_SET="debian-82-docker"
script: bundle exec rake beaker
- rvm: '2.1'
env: PUPPET_GEM_VERSION='~> 4'
- rvm: '2.3'
env: PUPPET_GEM_VERSION='~> 4'
- rvm: '2.4'
env: PUPPET_GEM_VERSION='~> 4'
# On Puppet 3.x
- rvm: '1.8'
env: PUPPET_GEM_VERSION='~> 3.2.0'
- rvm: '1.9'
env: PUPPET_GEM_VERSION='~> 3'
- rvm: '2.0'
env: PUPPET_GEM_VERSION='~> 3'
- rvm: '2.3'
sudo: required
services: docker
env: PUPPET_INSTALL_VERSION='3.8.7' RS_SET="ubuntu-14.04-docker"
script: bundle exec rake beaker
- rvm: '2.3'
sudo: required
services: docker
env: PUPPET_INSTALL_VERSION='3.8.7' RS_SET="debian-78-docker"
script: bundle exec rake beaker
- rvm: '2.3'
sudo: required
services: docker
env: PUPPET_INSTALL_VERSION='3.8.7' RS_SET="centos-7-docker"
script: bundle exec rake beaker
# On default Puppet 2.x
- rvm: '1.8'
env: PUPPET_GEM_VERSION='~> 2'
- rvm: '1.9'
env: PUPPET_GEM_VERSION='~> 2'
24 changes: 19 additions & 5 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,23 @@
# A sample Gemfile
source "https://rubygems.org"
source ENV['GEM_SOURCE'] || 'https://rubygems.org/'

# gem "rails"
puppet_ver = ENV['PUPPET_GEM_VERSION'] || '~> 5'

gem 'rspec', '~> 3.1.0'
gem 'rspec-puppet'
gem 'rake'
gem 'puppet'
gem 'puppet', puppet_ver
gem 'puppetlabs_spec_helper'
gem 'puppet-lint'
gem 'puppet-lint'
group :acceptance do
gem 'beaker-rspec', :require => false
gem 'beaker-pe', :require => false
gem 'beaker-module_install_helper', '~> 0.1.0', :require => false
gem 'puppet-examples-helpers', :require => false
gem 'vagrant-wrapper', :require => false
gem 'vagrant-wrapper', :require => false
end if RUBY_VERSION > '2.1'

group :development do
gem 'pry'
gem 'pry-byebug'
end if RUBY_VERSION > '2.1'
54 changes: 29 additions & 25 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,41 +1,45 @@
GEM
remote: https://rubygems.org/
specs:
diff-lcs (1.2.4)
diff-lcs (1.3)
facter (1.7.0)
hiera (1.2.0)
json_pure
json_pure (1.7.7)
metaclass (0.0.1)
mocha (0.13.3)
metaclass (0.0.4)
mocha (1.3.0)
metaclass (~> 0.0.1)
puppet (3.1.1)
facter (~> 1.6)
hiera (~> 1.0)
puppet-lint (0.3.2)
puppetlabs_spec_helper (0.4.1)
mocha (>= 0.10.5)
puppet (2.7.26)
facter (~> 1.5)
puppet-lint (1.1.0)
puppet-syntax (2.4.1)
rake
rspec (>= 2.9.0)
rspec-puppet (>= 0.1.1)
rake (10.0.4)
rspec (2.13.0)
rspec-core (~> 2.13.0)
rspec-expectations (~> 2.13.0)
rspec-mocks (~> 2.13.0)
rspec-core (2.13.1)
rspec-expectations (2.13.0)
diff-lcs (>= 1.1.3, < 2.0)
rspec-mocks (2.13.1)
rspec-puppet (0.1.6)
puppetlabs_spec_helper (1.1.1)
mocha
puppet-lint
puppet-syntax
rake
rspec-puppet
rake (10.5.0)
rspec (3.1.0)
rspec-core (~> 3.1.0)
rspec-expectations (~> 3.1.0)
rspec-mocks (~> 3.1.0)
rspec-core (3.1.7)
rspec-support (~> 3.1.0)
rspec-expectations (3.1.2)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.1.0)
rspec-mocks (3.1.3)
rspec-support (~> 3.1.0)
rspec-puppet (2.6.9)
rspec
rspec-support (3.1.2)

PLATFORMS
ruby

DEPENDENCIES
puppet
puppet (~> 2)
puppet-lint
puppetlabs_spec_helper
rake
rspec (~> 3.1.0)
rspec-puppet
52 changes: 49 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,61 @@ and manage its DNS zone files.

* `bind` : Main class to install and enable the server.
* `bind::server::conf` : Main definition to configure the server.
* `bind::zone::definition` : Definition to add zone to main server configuration file and create zone file.
* `bind::zone::record` : Definition to add records into zone file.
* `bind::server::file` : Definition to manage zone files.
* `bind::package` : Class to install the server package (included from `bind`)
* `bind::service` : Class to manage the server service (included from `bind`)


The split between `bind` and `bind::server::conf` allows to use a static file
or a different template-based file for the main `named.conf` file if needed,
while still using this module for the main package, service and managing zone
files. This is useful if you have a large and/or complex named.conf file.
Note that you may also use the `bind::package` and `bind::service` classes on
their own, though you won't need to if you use the main class, which includes
them both.
them both. In order to add zone definition to already existed named.conf file and add zone file you can use `bind::zone::definition`. If you want to just add record to existed file zone use `bind::zone::record`.

## Examples

Here is a typical LAN recursive caching DNS server configuration :
Here is a typical DNS server configuration :
```puppet
include bind
bind::server::conf { '/etc/named.conf':
listen_on_addr => [ 'any' ],
listen_on_v6_addr => [ 'any' ],
forwarders => [ '8.8.8.8', '8.8.4.4' ],
allow_query => [ 'localnets' ],
}
bind::zone::definition { 'dev.internal':
definition_file => '/etc/named.conf',
zone_file => '/var/named/dev.internal.zone',
zone_type => 'master',
allow_update => 'none',
soa_nameserver => 'dev.internal',
soa_contact => 'root.localhost',
ttl => '1800',
minimum_ttl => '3H',
refresh => '1D',
retry => '1H',
expire => '1W',
serial => '20171208', # for example current date
}

Bind::Zone::Record { target_file => '/var/named/dev.internal.zone' }

bind::zone::record {
'NS_server_node1.dev.internal': rname => '@', rtype => 'NS', rdata => 'node1.dev.internal', zone_name => 'dev.internal';
'node1.dev.internal': rname => 'node1', rtype => 'A', rdata => '192.168.33.10', zone_name => 'dev.internal';
}

```
Zone definition in /etc/named.conf and zone file (i.e /var/named/dev.internal.zone) can be add with directive `bind::zone::definition`.
If named.conf file oraz zone file is not correct, then resource `assert` raise error and reload of bind service won't be done. Zone record can be add with directive `bind::zone::record`.



Here is anther way to set a typical LAN recursive caching DNS server configuration :
```puppet
include bind
bind::server::conf { '/etc/named.conf':
Expand All @@ -49,6 +88,14 @@ The zone files for the above could then be managed like this :
bind::server::file { 'myzone.lan':
source => 'puppet:///modules/mymodule/dns/myzone.lan',
}
# Here you can add new records to myzone.lan file, without changing source file
Bind::Zone::Record { target_file => '/var/named/myzone.lan' }

bind::zone::record {
'NS_server_node1.myzone.lan': rname => '@', rtype => 'NS', rdata => 'node1.myzone.lan', zone_name => 'myzone.lan';
'node1.myzone.lan': rname => 'node1', rtype => 'A', rdata => '192.168.33.10', zone_name => 'myzone.lan';
'node2.myzone.lan': rname => 'node2', rdata => '192.168.33.12', zone_name => 'myzone.lan';
}
bind::server::file { '1.168.192.in-addr.arpa':
source => 'puppet:///modules/mymodule/dns/1.168.192.in-addr.arpa',
}
Expand Down Expand Up @@ -121,4 +168,3 @@ bind::server::conf {
},
}
```

5 changes: 4 additions & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,7 @@ rescue Bundler::BundlerError => e
$stderr.puts e.message
$stderr.puts "Run `bundle install` to install missing gems"
exit e.status_code
end
end

desc 'Run all tests'
task :test => [ :syntax, :lint, :spec ]
1 change: 1 addition & 0 deletions examples/init.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include bind
32 changes: 32 additions & 0 deletions examples/server/conf.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Taken from the "Sample Usage :"
include bind::server
bind::server::conf { '/etc/named.conf':
recursion => 'no',
acls => {
'rfc1918' => [ '10/8', '172.16/12', '192.168/16' ],
},
masters => {
'mymasters' => [ '192.0.2.1', '198.51.100.1' ],
},
zones => {
'example.com' => [
'type master',
'file "example.com"',
],
'example.org' => [
'type slave',
'file "slaves/example.org"',
'masters { mymasters; }',
],
},
}
bind::server::file { 'example.com':
source => 'puppet:///modules/bind/named.empty',
}
Bind::Zone::Record { target_file => '/var/named/example.com' }

bind::zone::record {
'NS_server_world1.example.com': rname => '@', rtype => 'NS', rdata => 'world1.example.com', zone_name => 'example.com';
'world1.example.com': rname => 'world1', rtype => 'A', rdata => '192.168.56.110', zone_name => 'example.com';
'world2.example.com': rname => 'world2', rdata => '192.168.56.112', zone_name => 'example.com';
}
45 changes: 45 additions & 0 deletions examples/zone/bad_definition.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Taken from the "Sample Usage :"
# Bug in bind::zone::record. Ther is no A for dns server. Changes don't take effect, because bind service won't be reload
include bind::server
bind::server::conf { '/etc/named.conf':
acls => {
'rfc1918' => [ '10/8', '172.16/12', '192.168/16' ],
},
masters => {
'mymasters' => [ '192.0.2.1', '198.51.100.1' ],
},
zones => {
'example.com' => [
'type master',
'file "example.com"',
],
'example.org' => [
'type slave',
'file "slaves/example.org"',
'masters { mymasters; }',
],
},
}

bind::zone::definition { 'baddev.internal':
definition_file => '/etc/named.conf',
zone_file => '/var/named/badtest_file.com',
zone_type => 'master',
allow_update => 'none',
soa_nameserver => 'world.baddev.internal',
soa_contact => 'badworld.com',
ttl => '1800',
minimum_ttl => '3H',
refresh => '1D',
retry => '1H',
expire => '1W',
serial => '20171208', # for example current date
}

Bind::Zone::Record { target_file => '/var/named/badtest_file.com' }

bind::zone::record {
'NS_server_node1.baddev.internal': rname => '@', rtype => 'NS', rdata => 'node1.baddev.internal', zone_name => 'baddev.internal';
'node3.baddev.internal': rname => 'node3', rtype => 'A', rdata => '192.168.32.10', zone_name => 'baddev.internal';
'node2.baddev.internal': rname => 'node2', rdata => '192.168.32.12', zone_name => 'dev.internal';
}
Loading