Skip to content

Commit 00fbc2c

Browse files
authored
Merge pull request #322 from irregulator/feat/stub_first_option
stub: add support for stub-first stub zone option
2 parents e431b7a + b0b3ae6 commit 00fbc2c

File tree

4 files changed

+46
-0
lines changed

4 files changed

+46
-0
lines changed

REFERENCE.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2359,6 +2359,11 @@ Create an unbound stub zone for caching upstream name resolvers
23592359
lookups does not affect an (unsigned) internal domain. A DS record
23602360
externally can create validation failures for that internal domain.
23612361

2362+
[*stub_first*]
2363+
(optional) Defaults to false. Controls 'stub-first' stub zone option.
2364+
If true, a query that fails with the stub clause is attempted again
2365+
without the stub clause.
2366+
23622367
[*type*]
23632368
(optional) Defaults to 'transparent', can be 'deny', 'refuse', 'static',
23642369
'transparent', 'typetransparent', 'redirect' or 'nodefault'.
@@ -2374,6 +2379,7 @@ The following parameters are available in the `unbound::stub` defined type:
23742379
* [`nameservers`](#-unbound--stub--nameservers)
23752380
* [`insecure`](#-unbound--stub--insecure)
23762381
* [`no_cache`](#-unbound--stub--no_cache)
2382+
* [`stub_first`](#-unbound--stub--stub_first)
23772383
* [`type`](#-unbound--stub--type)
23782384
* [`config_file`](#-unbound--stub--config_file)
23792385

@@ -2405,6 +2411,14 @@ Data type: `Variant[Boolean, Enum['true', 'false']]`
24052411

24062412

24072413

2414+
Default value: `false`
2415+
2416+
##### <a name="-unbound--stub--stub_first"></a>`stub_first`
2417+
2418+
Data type: `Variant[Boolean, Enum['true', 'false']]`
2419+
2420+
2421+
24082422
Default value: `false`
24092423

24102424
##### <a name="-unbound--stub--type"></a>`type`

manifests/stub.pp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@
2424
# lookups does not affect an (unsigned) internal domain. A DS record
2525
# externally can create validation failures for that internal domain.
2626
#
27+
# [*stub_first*]
28+
# (optional) Defaults to false. Controls 'stub-first' stub zone option.
29+
# If true, a query that fails with the stub clause is attempted again
30+
# without the stub clause.
31+
#
2732
# [*type*]
2833
# (optional) Defaults to 'transparent', can be 'deny', 'refuse', 'static',
2934
# 'transparent', 'typetransparent', 'redirect' or 'nodefault'.
@@ -37,6 +42,7 @@
3742
# lint:ignore:quoted_booleans
3843
Variant[Boolean, Enum['true', 'false']] $insecure = false,
3944
Variant[Boolean, Enum['true', 'false']] $no_cache = false,
45+
Variant[Boolean, Enum['true', 'false']] $stub_first = false,
4046
# lint:endignore
4147
Unbound::Local_zone_type $type = 'transparent',
4248
Optional[Stdlib::Unixpath] $config_file = undef,

spec/defines/stub_spec.rb

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,29 @@
7777
}
7878
end
7979

80+
context 'with stub_first set' do
81+
let(:params) do
82+
{
83+
address: ['::1'],
84+
stub_first: true
85+
}
86+
end
87+
88+
it { is_expected.to compile.with_all_deps }
89+
it { is_expected.to contain_unbound__stub('lab.example.com') }
90+
91+
it {
92+
expect(subject).to contain_concat__fragment('unbound-stub-lab.example.com').with(
93+
content: <<~ZONE
94+
stub-zone:
95+
name: "lab.example.com"
96+
stub-addr: ::1
97+
stub-first: yes
98+
ZONE
99+
)
100+
}
101+
end
102+
80103
context 'with address set as string' do
81104
let(:params) do
82105
{

templates/stub.erb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ stub-zone:
66
<% @nameservers.each do |host| -%>
77
stub-host: <%= host %>
88
<% end -%>
9+
<% if @stub_first == 'true' or @stub_first == true -%>
10+
stub-first: yes
11+
<% end -%>
912
<% if @no_cache == 'true' or @no_cache == true -%>
1013
stub-no-cache: yes
1114
<% end -%>

0 commit comments

Comments
 (0)