Skip to content

Commit cc5c2c7

Browse files
committed
refactor: migrate djbdns to service resources
1 parent 23279eb commit cc5c2c7

41 files changed

Lines changed: 1104 additions & 246 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.mise.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[env]
2+
_.path = "/opt/chef-workstation/bin"

Berksfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@ source 'https://supermarket.chef.io'
33
metadata
44

55
group :integration do
6-
cookbook 'test', path: './test/fixtures/cookbooks/test'
6+
cookbook 'test', path: './test/cookbooks/test'
77
end

LIMITATIONS.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Limitations
2+
3+
## Package Availability
4+
5+
### Upstream / Vendor
6+
7+
- Upstream publishes source tarballs and installation instructions, not an official package repository. The latest published upstream tarball is `djbdns-1.05.tar.gz`.
8+
- Upstream installation guidance requires a UNIX-like system plus `daemontools` 0.70 or later and `ucspi-tcp`, then a local compile and `make setup check`.
9+
10+
### APT (Debian / Ubuntu)
11+
12+
- Debian still ships `djbdns` as a maintained source package and builds split binaries including `axfrdns`, `djbdns-conf`, `djbdns-utils`, `dnscache`, `rbldns`, `tinydns`, and `walldns`.
13+
- Debian package pages for current and recent releases show distro-managed package availability for supported Debian architectures.
14+
- Ubuntu still carries `djbdns` in the `universe` source package set. The cookbook's current package-install path is therefore most defensible on Debian-family platforms.
15+
16+
### DNF / YUM (RHEL family)
17+
18+
- I did not find a primary-source upstream package repository for RHEL-family systems.
19+
- Inference: the cookbook's source-install path remains the only installation path directly backed by upstream documentation for RHEL-family platforms.
20+
21+
### Zypper (SUSE)
22+
23+
- I did not find a primary-source upstream package repository for SUSE/openSUSE.
24+
- Inference: source installation is also the only path clearly supported by upstream guidance on SUSE-family platforms.
25+
26+
## Architecture Limitations
27+
28+
- Upstream does not publish a tested architecture matrix; its guidance is source-build oriented rather than architecture-specific.
29+
- Debian and Ubuntu package availability is distribution-managed and architecture-dependent. The cookbook should treat package installs as Debian-family specific, not universally portable.
30+
31+
## Source / Compiled Installation
32+
33+
### Build Dependencies
34+
35+
| Platform Family | Packages / Requirements |
36+
|-----------------|-------------------------|
37+
| Debian | Compiler and build tools; upstream also requires `daemontools` and `ucspi-tcp` |
38+
| RHEL | Compiler and build tools; upstream also requires `daemontools` and `ucspi-tcp` |
39+
| SUSE | Compiler and build tools; upstream also requires `daemontools` and `ucspi-tcp` |
40+
41+
## Known Issues
42+
43+
- The cookbook's `install_method` heuristic is cookbook-local logic, not upstream vendor guidance.
44+
- The cookbook metadata currently advertises platforms that are broader and older than the upstream/package evidence gathered here. Platform modernization should be handled explicitly and separately from this resource migration.
45+
- `axfrdns` depends on `tcpserver` from `ucspi-tcp`, but the cookbook does not yet model that dependency as a first-class resource concern.

README.md

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ It may work with or without modification on other platforms, particularly using
2626

2727
## Chef
2828

29-
- Chef 14+
29+
- Chef 15.3+
3030

3131
## Cookbooks
3232

@@ -57,6 +57,25 @@ It may work with or without modification on other platforms, particularly using
5757

5858
## Resources
5959

60+
This cookbook is mid-migration from recipe/attribute-driven behavior toward higher-level resources. The current resource-first surface is:
61+
62+
- `djbdns_install` - installs djbdns and bootstraps shared users/directories.
63+
- `djbdns_server` - configures the public tinydns service.
64+
- `djbdns_internal_server` - configures the internal tinydns service with explicit records or legacy data-bag/template inputs.
65+
- `djbdns_cache` - configures the public dnscache service.
66+
- `djbdns_axfr` - configures the axfrdns service that fronts an existing public tinydns directory.
67+
- `djbdns_rr` - appends tinydns records inside an existing tinydns root.
68+
69+
The legacy recipes `default`, `server`, `cache`, `internal_server`, and `axfr` are now compatibility wrappers around those resources.
70+
71+
### Resource Model Roadmap
72+
73+
- `djbdns_install`: shared install/bootstrap layer
74+
- `djbdns_server`: public tinydns service
75+
- `djbdns_internal_server`: internal tinydns service with explicit data-bag/template inputs
76+
- `djbdns_cache`: public dnscache service
77+
- `djbdns_axfr`: axfr service bound to an existing public tinydns instance
78+
6079
## djbdns_rr
6180

6281
Adds a resource record for the specified FQDN.
@@ -89,7 +108,7 @@ end
89108

90109
## default
91110

92-
The default recipe installs djbdns software from package where available, otherwise installs from source. It also sets up the users that will run the djbdns services using the UID's specified by the attributes above. The service type to use is selected based on platform.
111+
Compatibility wrapper for `djbdns_install`.
93112

94113
The default recipe attempts to install djbdns on as many platforms as possible. It tries to determine the platform's installation method:
95114

@@ -104,15 +123,15 @@ Service specific users will be created as system users:
104123

105124
## axfr
106125

107-
Creates the axfrdns user and sets up the axfrdns service.
126+
Compatibility wrapper for `djbdns_axfr`.
108127

109128
## cache
110129

111-
Sets up a local DNS caching server.
130+
Compatibility wrapper for `djbdns_cache`.
112131

113132
## internal_server
114133

115-
Sets up a server to be an internal nameserver. To modify resource records in the environment, modify the tinydns-internal-data.erb template, or create entries in a data bag named `djbdns`, and an item named after the domain, with underscores instead of spaces. Example structure of the data bag:
134+
Compatibility wrapper for `djbdns_internal_server`. The resource supports explicit `records`, or the legacy fallback path of the `tinydns-internal-data.erb` template plus a `djbdns` data bag item named after the domain with underscores instead of spaces. Example structure of the legacy data bag:
116135

117136
```json
118137
{
@@ -134,7 +153,7 @@ Aliases and hosts should be an array of hashes, each entry containing the fqdn a
134153

135154
## server
136155

137-
Sets up a server to be a public nameserver. To modify resource records in the environment, modify the tinydns-data.erb template. The recipe does not yet use the data bag per `internal_server` above, but will in a future release.
156+
Compatibility wrapper for `djbdns_server`. To modify resource records in the environment, modify the tinydns-data.erb template. The recipe does not yet use the data bag per `internal_server` above, but will in a future release.
138157

139158
## Contributors
140159

documentation/djbdns_axfr.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# djbdns_axfr
2+
3+
Creates the axfrdns service directory, bootstraps the `axfrdns` user, and enables the runit-backed zone transfer service.
4+
5+
## Actions
6+
7+
| Action | Description |
8+
|--------|-------------|
9+
| `:create` | Configures and enables the axfrdns service (default) |
10+
11+
## Properties
12+
13+
| Property | Type | Default | Description |
14+
|----------|------|---------|-------------|
15+
| `service_name` | String | name property | Service name, typically `axfrdns` |
16+
| `manage_install` | Boolean | `true` | Also run `djbdns_install` before configuring the service |
17+
| `install_method` | String | platform-dependent | Install via `package` or `source` |
18+
| `package_name` | String | `'djbdns'` | Package name for package installs |
19+
| `source_url` | String | `'https://cr.yp.to/djbdns/djbdns-1.05.tar.gz'` | Upstream source tarball |
20+
| `bin_dir` | String | derived from `install_method` | Location of djbdns binaries used by runit |
21+
| `service_dir` | String | `'/etc/djbdns/axfrdns'` | Service root directory |
22+
| `sv_dir` | String | `'/etc/sv'` | runit service directory |
23+
| `service_link_dir` | String | `'/etc/service'` | runit enabled-service directory |
24+
| `listen_ip` | String | `'127.0.0.1'` | Address passed to `axfrdns-conf` |
25+
| `tinydns_dir` | String | `'/etc/djbdns/tinydns'` | Public tinydns directory used by axfrdns |
26+
| `axfrdns_uid` | Integer | `9996` | UID for the `axfrdns` account |
27+
| `dnscache_uid` | Integer | `9997` | UID for the `dnscache` account |
28+
| `dnslog_uid` | Integer | `9998` | UID for the `dnslog` account |
29+
| `tinydns_uid` | Integer | `9999` | UID for the `tinydns` account |
30+
31+
## Examples
32+
33+
```ruby
34+
djbdns_axfr 'axfrdns'
35+
```
36+
37+
```ruby
38+
djbdns_axfr 'axfrdns' do
39+
manage_install false
40+
service_dir '/srv/axfrdns'
41+
tinydns_dir '/srv/tinydns'
42+
listen_ip '192.0.2.53'
43+
end
44+
```

documentation/djbdns_cache.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# djbdns_cache
2+
3+
Creates the public dnscache service directory, manages allowed client networks, and enables the runit-backed cache service.
4+
5+
## Actions
6+
7+
| Action | Description |
8+
|--------|-------------|
9+
| `:create` | Configures and enables the public dnscache service (default) |
10+
11+
## Properties
12+
13+
| Property | Type | Default | Description |
14+
|----------|------|---------|-------------|
15+
| `service_name` | String | name property | Service name, typically `public-dnscache` |
16+
| `manage_install` | Boolean | `true` | Also run `djbdns_install` before configuring the service |
17+
| `install_method` | String | platform-dependent | Install via `package` or `source` |
18+
| `package_name` | String | `'djbdns'` | Package name for package installs |
19+
| `source_url` | String | `'https://cr.yp.to/djbdns/djbdns-1.05.tar.gz'` | Upstream source tarball |
20+
| `bin_dir` | String | derived from `install_method` | Location of djbdns binaries used by runit |
21+
| `service_dir` | String | `'/etc/djbdns/public-dnscache'` | Service root directory |
22+
| `listen_ip` | String | `node['ipaddress']` | Address passed to `dnscache-conf` |
23+
| `allowed_networks` | Array | first two IP octets | Networks allowed to query the cache |
24+
| `resolved_domain` | String | `node['domain'] || 'domain.local'` | Internal domain pinned to localhost |
25+
| `resolved_reverse_domains` | Array | RFC 6303-style defaults | Reverse zones pinned to localhost |
26+
| `cache_size` | String | `'1000000'` | dnscache `CACHESIZE` environment value |
27+
| `data_limit` | String | `'3000000'` | dnscache `DATALIMIT` environment value |
28+
| `dnscache_uid` | Integer | `9997` | UID for the `dnscache` account |
29+
| `dnslog_uid` | Integer | `9998` | UID for the `dnslog` account |
30+
| `tinydns_uid` | Integer | `9999` | UID for the `tinydns` account |
31+
32+
## Examples
33+
34+
```ruby
35+
djbdns_cache 'public-dnscache'
36+
```
37+
38+
```ruby
39+
djbdns_cache 'public-dnscache' do
40+
manage_install false
41+
listen_ip '192.0.2.53'
42+
allowed_networks %w(192.0 198.51)
43+
end
44+
```

documentation/djbdns_install.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# djbdns_install
2+
3+
Installs djbdns and creates the base service accounts and directories used by the higher-level service resources.
4+
5+
## Actions
6+
7+
| Action | Description |
8+
|--------|-------------|
9+
| `:create` | Installs djbdns and bootstraps shared users and directories (default) |
10+
11+
## Properties
12+
13+
| Property | Type | Default | Description |
14+
|----------|------|---------|-------------|
15+
| `instance_name` | String | name property | Resource identity |
16+
| `install_method` | String | platform-dependent | Install via `package` or `source` |
17+
| `package_name` | String | `'djbdns'` | Package name for package installs |
18+
| `source_url` | String | `'https://cr.yp.to/djbdns/djbdns-1.05.tar.gz'` | Upstream source tarball |
19+
| `bin_dir` | String | derived from `install_method` | Install location for djbdns binaries |
20+
| `dnscache_uid` | Integer | `9997` | UID for the `dnscache` account |
21+
| `dnslog_uid` | Integer | `9998` | UID for the `dnslog` account |
22+
| `tinydns_uid` | Integer | `9999` | UID for the `tinydns` account |
23+
24+
## Examples
25+
26+
```ruby
27+
djbdns_install 'default'
28+
```
29+
30+
```ruby
31+
djbdns_install 'source-bootstrap' do
32+
install_method 'source'
33+
bin_dir '/usr/local/bin'
34+
end
35+
```
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# djbdns_internal_server
2+
3+
Creates the internal tinydns service and supports either explicit record data or the legacy data-bag/template fallback path.
4+
5+
## Actions
6+
7+
| Action | Description |
8+
|--------|-------------|
9+
| `:create` | Configures and enables the internal tinydns service (default) |
10+
11+
## Properties
12+
13+
| Property | Type | Default | Description |
14+
|----------|------|---------|-------------|
15+
| `service_name` | String | name property | Service name, typically `tinydns-internal` |
16+
| `manage_install` | Boolean | `true` | Also run `djbdns_install` before configuring the service |
17+
| `install_method` | String | platform-dependent | Install via `package` or `source` |
18+
| `package_name` | String | `'djbdns'` | Package name for package installs |
19+
| `source_url` | String | `'https://cr.yp.to/djbdns/djbdns-1.05.tar.gz'` | Upstream source tarball |
20+
| `bin_dir` | String | derived from `install_method` | Location of djbdns binaries used by runit |
21+
| `service_dir` | String | `'/etc/djbdns/tinydns-internal'` | Service root directory |
22+
| `sv_dir` | String | `'/etc/sv'` | runit service directory |
23+
| `service_link_dir` | String | `'/etc/service'` | runit enabled-service directory |
24+
| `listen_ip` | String | `'127.0.0.1'` | Address passed to `tinydns-conf` |
25+
| `zone_domain` | String | `node['domain'] || 'domain.local'` | Domain rendered into the fallback template |
26+
| `zone_ip` | String | `'127.0.0.1'` | IP rendered into the fallback template |
27+
| `data_template_source` | String | `'tinydns-internal-data.erb'` | Template used when no explicit records resolve |
28+
| `use_data_bag` | Boolean | `true` | Attempt legacy data-bag loading when `records` is empty |
29+
| `data_bag_name` | String | `'djbdns'` | Data bag name for legacy record loading |
30+
| `data_bag_item_id` | String, nil | `zone_domain.tr('.', '_')` | Data bag item id for legacy record loading |
31+
| `records` | Hash | `{}` | Explicit record map keyed by djbdns record type |
32+
| `dnscache_uid` | Integer | `9997` | UID for the `dnscache` account |
33+
| `dnslog_uid` | Integer | `9998` | UID for the `dnslog` account |
34+
| `tinydns_uid` | Integer | `9999` | UID for the `tinydns` account |
35+
36+
## Examples
37+
38+
```ruby
39+
djbdns_internal_server 'tinydns-internal' do
40+
use_data_bag false
41+
zone_domain 'int.example.test'
42+
zone_ip '192.0.2.20'
43+
end
44+
```
45+
46+
```ruby
47+
djbdns_internal_server 'tinydns-internal' do
48+
manage_install false
49+
records(
50+
'host' => [
51+
{ 'web1.int.example.test' => '192.0.2.10' },
52+
]
53+
)
54+
end
55+
```

documentation/djbdns_rr.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# djbdns_rr
2+
3+
Adds tinydns records by running the generated `add-*` helper scripts in an existing tinydns root directory.
4+
5+
## Actions
6+
7+
| Action | Description |
8+
|--------|-------------|
9+
| `:add` | Adds a tinydns resource record when it does not already exist (default) |
10+
11+
## Properties
12+
13+
| Property | Type | Default | Description |
14+
|----------|------|---------|-------------|
15+
| `fqdn` | String | name property | Fully qualified domain name to manage |
16+
| `ip` | String | required | IP address for the record |
17+
| `type` | String | `'host'` | Record helper to run: `alias`, `alias6`, `childns`, `host`, `host6`, `mx`, or `ns` |
18+
| `cwd` | String | `node['djbdns']['tinydns_internal_dir']/root` | Tinydns root directory containing `data` and `add-*` helpers |
19+
20+
## Examples
21+
22+
```ruby
23+
djbdns_rr 'www.example.com' do
24+
ip '192.0.2.10'
25+
end
26+
```
27+
28+
```ruby
29+
djbdns_rr 'ns.example.com' do
30+
ip '192.0.2.53'
31+
type 'ns'
32+
cwd '/etc/djbdns/tinydns-internal/root'
33+
end
34+
```

documentation/djbdns_server.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# djbdns_server
2+
3+
Creates the public tinydns service directory, renders the authoritative data file, and enables the runit service.
4+
5+
## Actions
6+
7+
| Action | Description |
8+
|--------|-------------|
9+
| `:create` | Configures and enables the public tinydns service (default) |
10+
11+
## Properties
12+
13+
| Property | Type | Default | Description |
14+
|----------|------|---------|-------------|
15+
| `service_name` | String | name property | Service name, typically `tinydns` |
16+
| `manage_install` | Boolean | `true` | Also run `djbdns_install` before configuring the service |
17+
| `install_method` | String | platform-dependent | Install via `package` or `source` |
18+
| `package_name` | String | `'djbdns'` | Package name for package installs |
19+
| `source_url` | String | `'https://cr.yp.to/djbdns/djbdns-1.05.tar.gz'` | Upstream source tarball |
20+
| `bin_dir` | String | derived from `install_method` | Location of djbdns binaries used by runit |
21+
| `service_dir` | String | `'/etc/djbdns/tinydns'` | Service root directory |
22+
| `listen_ip` | String | `'127.0.0.1'` | Address passed to `tinydns-conf` |
23+
| `domain` | String, nil | `node['domain']` | Domain rendered into `root/data` |
24+
| `data_template_source` | String | `'tinydns-data.erb'` | Template for the `root/data` file |
25+
| `dnscache_uid` | Integer | `9997` | UID for the `dnscache` account |
26+
| `dnslog_uid` | Integer | `9998` | UID for the `dnslog` account |
27+
| `tinydns_uid` | Integer | `9999` | UID for the `tinydns` account |
28+
29+
## Examples
30+
31+
```ruby
32+
djbdns_server 'tinydns'
33+
```
34+
35+
```ruby
36+
djbdns_server 'tinydns' do
37+
manage_install false
38+
service_dir '/srv/tinydns'
39+
listen_ip '192.0.2.10'
40+
domain 'example.com'
41+
end
42+
```

0 commit comments

Comments
 (0)