Skip to content

Commit 0029329

Browse files
authored
Merge pull request #15 from shoddyguard/update_documentation
Prepare module for v.0.2.0 release
2 parents c5c3a54 + 7485096 commit 0029329

File tree

6 files changed

+133
-19
lines changed

6 files changed

+133
-19
lines changed

.rufo

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
quote_style :single

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@ All notable changes to this project will be documented in this file.
44

55
## Release
66

7-
### [v0.1.1](https://github.com/shoddyguard/Puppet-Adguard/tree/v0.1.1) (2020-04-01)
7+
### [v0.2.0](https://github.com/shoddyguard/Puppet-Adguard/tree/v0.2.0) (2020-04-01)
88

99
**Features**
1010
- Moved several complex types into their own definitions rather than defining them in the parameters of the main class.
11+
- Added a new function for validating TLS options
1112
- Moved default parameter declarations from hiera into the manifests. This allows Puppet-Strings to extract default values into documentaion and makes things easier to locate.
1213
- Tidied up documentation and added some more examples
1314
- Expanded acceptance testing slightly

README.md

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,73 @@ class {'adguard':
136136
```
137137
For more information on this please see the [official AdGuard documentation](https://github.com/AdguardTeam/AdGuardHome/wiki/Clients#newclient)
138138

139+
## Configuring DHCP
140+
AdGuard Home supports acting as a DHCP server and as of v0.2.0 this module allows for configuration of those options.
141+
To enable DHCP you would need to set `enable_dhcp` to `true`, specify a `dhcp_interface` and then specify your `dhcp_v4_options`/`dhcp_v6_options`
142+
Example:
143+
```puppet
144+
class {'adguard':
145+
users => [{
146+
username => 'user',
147+
password => '$2y$10$c6lDDShTh5ezcvKhyWwOMet6C/0tLxlgYX53wf58jl9tBdUVbYSqe',
148+
}],
149+
enable_dhcp => true,
150+
dhcp_interface => 'eth0',
151+
dhcp_v4_options => {
152+
gateway_ip => '192.168.1.1',
153+
subnet_mask => '255.255.255.0',
154+
range_start => '192.168.1.2',
155+
range_end => '192.168.1.20',
156+
lease_duration => 86400, # in seconds
157+
}
158+
```
159+
If you'd like to enable special DHCP options this can be done via the `options` parameter, these should be given as `CODE hex HEX_VALUE` (eg `6 hex 0102030401020305`).
160+
```puppet
161+
class {'adguard':
162+
users => [{
163+
username => 'user',
164+
password => '$2y$10$c6lDDShTh5ezcvKhyWwOMet6C/0tLxlgYX53wf58jl9tBdUVbYSqe',
165+
}],
166+
enable_dhcp => true,
167+
dhcp_interface => 'eth0',
168+
dhcp_v4_options => {
169+
gateway_ip => '192.168.1.1',
170+
subnet_mask => '255.255.255.0',
171+
range_start => '192.168.1.2',
172+
range_end => '192.168.1.20',
173+
lease_duration => 86400, # in seconds
174+
options => [
175+
'6 hex 0102030401020305'
176+
],
177+
}
178+
```
179+
For more information see the official [AdGuard documentation](https://github.com/AdguardTeam/AdGuardHome/wiki/DHCP#config-4)
180+
181+
## TLS Configuration
182+
As of v0.2.0 this module now supports setting the TLS settings in Adguard. This remains largely untested so use with caution and please report any issues on the module repository.
183+
A basic configuration would look like:
184+
```puppet
185+
class {'adguard':
186+
users => [{
187+
username => 'user',
188+
password => '$2y$10$c6lDDShTh5ezcvKhyWwOMet6C/0tLxlgYX53wf58jl9tBdUVbYSqe',
189+
}],
190+
enable_tls => true,
191+
tls_options => {
192+
server_name => 'adguard-test.com',
193+
force_https => false,
194+
port_https => 443,
195+
port_dns_over_tls => 853,
196+
port_dns_over_quic => 784,
197+
port_dnscrypt => 0,
198+
allow_unencrypted_doh => false,
199+
strict_sni_check => false,
200+
certificate_path => '/root/cert.pem',
201+
private_key_path => '/root/key.pem',
202+
}
203+
```
204+
More information on these settings can be found in the [official AdGuard docs](https://github.com/AdguardTeam/AdGuardHome/wiki/Encryption)
205+
139206
# Know Limitations
140207
## Configuration overwriting itself/Disabling configuration file management
141208
Due to the fact this module manages configuration of AdGuard by manipulating the `AdGuardHome.yaml` file there may be instances where Puppet fights against AdGuard Home with both trying to change the contents of the file.

metadata.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "shoddyguard-adguard",
3-
"version": "0.1.1",
3+
"version": "0.2.0",
44
"author": "Steve Brown",
55
"summary": "Manages AdGuard Home",
66
"license": "Apache-2.0",

spec/acceptance/dhcp_spec.rb

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Tests applying adguard with basic DHCP options
2+
require 'spec_helper_acceptance'
3+
4+
describe 'adguard_dhcp' do
5+
it 'applies succesfully' do
6+
dhcp_pp = <<-MANIFEST
7+
class {'adguard':
8+
users => [
9+
{
10+
username => 'user',
11+
password => '$2y$10$c6lDDShTh5ezcvKhyWwOMet6C/0tLxlgYX53wf58jl9tBdUVbYSqe',
12+
}],
13+
enable_dhcp => true,
14+
dhcp_interface => 'eth0',
15+
dhcp_v4_options => {
16+
gateway_ip => '192.168.1.1',
17+
subnet_mask => '255.255.255.0',
18+
range_start => '192.168.1.2',
19+
range_end => '192.168.1.20',
20+
lease_duration => 86400,
21+
}
22+
}
23+
MANIFEST
24+
idempotent_apply(dhcp_pp)
25+
end
26+
27+
describe service('AdGuardHome') do
28+
it { is_expected.to be_enabled }
29+
it { is_expected.to be_running }
30+
end
31+
32+
describe file('/opt/AdGuardHome/AdGuardHome.yaml') do
33+
it { is_expected.to be_file }
34+
it { is_expected.to contain %r{interface_name: eth0} }
35+
it { is_expected.to contain %r{gateway_ip: 192.168.1.1} }
36+
it { is_expected.to contain %r{subnet_mask: 255.255.255.0} }
37+
it { is_expected.to contain %r{range_start: 192.168.1.2} }
38+
it { is_expected.to contain %r{range_end: 192.168.1.20} }
39+
it { is_expected.to contain %r{lease_duration: 86400} }
40+
end
41+
end

spec/acceptance/tls_spec.rb

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@
22
# Only basic configuration is checked as unsure how to test more extensively in a container.
33
require 'spec_helper_acceptance'
44

5-
# Copy over a dummy SSL cert + key (generated by OpenSSL) to use for testing SSL,
6-
# this expires on 2022/04/02, unsure if this will cause errors in the future.
7-
# This also only tests the "path" options for TLS and not specifying the certs directly, we should implement this later.
8-
pp_tls = <<-MANIFEST
5+
describe 'adguard_tls' do
6+
it 'applies succesfully' do
7+
# Copy over a dummy SSL cert + key (generated by OpenSSL) to use for testing SSL,
8+
# this expires on 2022/04/02, unsure if this will cause errors in the future.
9+
# This also only tests the "path" options for TLS and not specifying the certs directly, we should implement this later.
10+
pp_tls = <<-MANIFEST
911
$ca_cert = @("CA_CERT"/L)
1012
-----BEGIN CERTIFICATE-----
1113
MIIFcjCCA1oCCQDRZO9ndAf3hTANBgkqhkiG9w0BAQsFADB7MQswCQYDVQQGEwJH
@@ -126,22 +128,24 @@ class {'adguard':
126128
}
127129
MANIFEST
128130

129-
idempotent_apply(pp_tls)
130-
131-
describe 'adguard_tls' do
132-
context service('AdGuardHome') do
131+
idempotent_apply(pp_tls)
132+
end
133+
describe service('AdGuardHome') do
133134
it { is_expected.to be_enabled }
134135
it { is_expected.to be_running }
135136
end
136-
# Ensure our ports are listening
137-
context port(80) do
138-
it { is_expected.to be_listening }
139-
end
140-
context port(53) do
141-
it { is_expected.to be_listening }
142-
end
143-
context file('/opt/AdGuardHome/AdGuardHome.yaml') do
137+
138+
describe file('/opt/AdGuardHome/AdGuardHome.yaml') do
144139
it { is_expected.to be_file }
145-
its(:content) { is_expected.to match(%r{server_name: adguard-test.com}) }
140+
it { is_expected.to contain %r{server_name: adguard-test.com} }
141+
it { is_expected.to contain %r{force_https: false} }
142+
it { is_expected.to contain %r{port_https: 443} }
143+
it { is_expected.to contain %r{port_dns_over_tls: 853} }
144+
it { is_expected.to contain %r{port_dns_over_quic: 784} }
145+
it { is_expected.to contain %r{port_dnscrypt: 0} }
146+
it { is_expected.to contain %r{allow_unencrypted_doh: false} }
147+
it { is_expected.to contain %r{strict_sni_check: false} }
148+
it { is_expected.to contain %r{certificate_path: /root/cert.pem} }
149+
it { is_expected.to contain %r{private_key_path: /root/key.pem} }
146150
end
147151
end

0 commit comments

Comments
 (0)