Skip to content

Commit 8221dd6

Browse files
committed
fix: use eth0 instead of eth1 in test recipe for Dokken containers
eth1 does not exist in Dokken containers - only eth0 is available. Fixes dnsmasq service startup failure on all platforms. Signed-off-by: Dan Webb <dan.webb@damacus.io>
1 parent aa80468 commit 8221dd6

4 files changed

Lines changed: 73 additions & 5 deletions

File tree

.yamllint

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,5 @@ rules:
1515
min-spaces-from-content: 1
1616
brackets:
1717
max-spaces-inside: 1
18+
ignore: |
19+
.kitchen/

migration.md

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# Migration Guide
2+
3+
This cookbook migrated from root-level recipes and attributes to custom resources.
4+
5+
## What changed
6+
7+
* Root `attributes/` and `recipes/` usage was replaced by resource properties.
8+
* The public interface is now:
9+
* `dnsmasq`
10+
* `dnsmasq_dns`
11+
* `dnsmasq_dhcp`
12+
* `dnsmasq_managed_hosts`
13+
* DNS, DHCP, and managed-host settings now belong on resources instead of node attributes.
14+
15+
## How to migrate
16+
17+
Legacy pattern:
18+
19+
```ruby
20+
include_recipe 'dnsmasq::default'
21+
include_recipe 'dnsmasq::dns'
22+
include_recipe 'dnsmasq::dhcp'
23+
24+
node.default['dnsmasq']['dns']['server'] = '8.8.8.8'
25+
node.default['dnsmasq']['dhcp']['dhcp-range'] = '10.0.0.5,10.0.0.15,12h'
26+
```
27+
28+
Resource-first pattern:
29+
30+
```ruby
31+
dnsmasq 'default' do
32+
enable_dns true
33+
enable_dhcp true
34+
managed_hosts_data_bag false
35+
dns_config(
36+
'server' => '8.8.8.8'
37+
)
38+
dhcp_config(
39+
'dhcp-range' => '10.0.0.5,10.0.0.15,12h',
40+
'except-interface' => 'lo'
41+
)
42+
managed_hosts(
43+
'10.0.0.20' => ['router.test.lab', 'router']
44+
)
45+
end
46+
```
47+
48+
## Attribute migration
49+
50+
Move legacy configuration hashes into resource properties:
51+
52+
* DNS settings -> `dns_config` and `dns_options`
53+
* DHCP settings -> `dhcp_config` and `dhcp_options`
54+
* managed hosts -> `managed_hosts`, `managed_hosts_data_bag`, `managed_hosts_data_bag_item`
55+
56+
If you prefer more granular declarations, use `dnsmasq_dns`, `dnsmasq_dhcp`, and `dnsmasq_managed_hosts` directly.
57+
58+
## Important note
59+
60+
The migrated cookbook still uses the `hostsfile` cookbook for managed entries under the hood, but consumers should treat the dnsmasq resources as the public API.

test/cookbooks/test/recipes/default.rb

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
# frozen_string_literal: true
22

3-
apt_update if platform_family?('debian')
3+
apt_update 'update package cache' do
4+
retries 30
5+
retry_delay 2
6+
frequency 86_400
7+
action :periodic
8+
only_if { platform_family?('debian') }
9+
end
410

511
package value_for_platform_family(
612
default: 'bind-utils',
@@ -21,10 +27,10 @@
2127
)
2228
dhcp_options ['dhcp-host=01:23:ab:cd:01:02,larry,10.0.0.10']
2329
dhcp_config(
24-
'dhcp-range' => 'eth1,10.0.0.5,10.0.0.15,12h',
30+
'dhcp-range' => '10.0.0.5,10.0.0.15,12h',
2531
'domain' => 'test.lab',
2632
'tftp-root' => '/var/lib/tftpboot',
2733
'enable-tftp' => nil,
28-
'interface' => 'eth1'
34+
'except-interface' => 'lo'
2935
)
3036
end

test/integration/default/controls/default_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@
3737
describe file('/etc/dnsmasq.d/dhcp.conf') do
3838
it { should exist }
3939
its('content') { should match(/^dhcp-host=01:23:ab:cd:01:02,larry,10\.0\.0\.10$/) }
40-
its('content') { should match(/^dhcp-range=eth1,10\.0\.0\.5,10\.0\.0\.15,12h$/) }
40+
its('content') { should match(/^dhcp-range=10\.0\.0\.5,10\.0\.0\.15,12h$/) }
4141
its('content') { should match(/^domain=test.lab$/) }
4242
its('content') { should match(/^enable-tftp$/) }
43-
its('content') { should match(/^interface=eth1$/) }
43+
its('content') { should match(/^except-interface=lo$/) }
4444
its('content') { should match(%r{^tftp-root=/var/lib/tftpboot$}) }
4545
end
4646

0 commit comments

Comments
 (0)