Skip to content

Commit 4f39a0f

Browse files
authored
Merge pull request #36 from zehweh/refactor/epp-template-partials
Extract shared EPP template partials to reduce duplication
2 parents ce81be4 + 83d4c90 commit 4f39a0f

10 files changed

Lines changed: 697 additions & 1969 deletions

templates/_common_properties.epp

Lines changed: 290 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,290 @@
1+
<%- |
2+
Optional[Enum['networkd', 'NetworkManager']] $renderer = undef,
3+
#lint:ignore:quoted_booleans
4+
Optional[Variant[Enum['true', 'false', 'yes', 'no'], Boolean]] $dhcp4 = undef,
5+
Optional[Variant[Enum['true', 'false', 'yes', 'no'], Boolean]] $dhcp6 = undef,
6+
#lint:endignore
7+
Optional[Integer] $ipv6_mtu = undef,
8+
Optional[Boolean] $ipv6_privacy = undef,
9+
Optional[Tuple[Enum['ipv4', 'ipv6'], 0]] $link_local = undef,
10+
Optional[Boolean] $ignore_carrier = undef,
11+
Optional[Boolean] $critical = undef,
12+
Optional[Enum['mac']] $dhcp_identifier = undef,
13+
Optional[Struct[{
14+
Optional['use_dns'] => Boolean,
15+
Optional['use_ntp'] => Boolean,
16+
Optional['send_hostname'] => Boolean,
17+
Optional['use_hostname'] => Boolean,
18+
Optional['use_mtu'] => Boolean,
19+
Optional['hostname'] => Stdlib::Fqdn,
20+
Optional['use_routes'] => Boolean,
21+
Optional['route_metric'] => Integer,
22+
Optional['use_domains'] => Variant[Enum['route', 'true', 'false', 'yes', 'no'], Boolean],
23+
}]] $dhcp4_overrides = undef,
24+
Optional[Struct[{
25+
Optional['use_dns'] => Boolean,
26+
Optional['use_ntp'] => Boolean,
27+
Optional['send_hostname'] => Boolean,
28+
Optional['use_hostname'] => Boolean,
29+
Optional['use_mtu'] => Boolean,
30+
Optional['hostname'] => Stdlib::Fqdn,
31+
Optional['use_routes'] => Boolean,
32+
Optional['route_metric'] => Integer,
33+
Optional['use_domains'] => Variant[Enum['route', 'true', 'false', 'yes', 'no'], Boolean],
34+
}]] $dhcp6_overrides = undef,
35+
Optional[Boolean] $accept_ra = undef,
36+
Optional[Array[Variant[
37+
Stdlib::IP::Address,
38+
Hash[
39+
Stdlib::IP::Address,
40+
Struct[{
41+
Optional['lifetime'] => Variant[Enum['forever'], Integer[0,0]],
42+
Optional['label'] => String[1]
43+
}]
44+
]
45+
]]] $addresses = undef,
46+
Optional[Enum['eui64', 'stable-privacy']] $ipv6_address_generation = undef,
47+
Optional[String] $ipv6_address_token = undef,
48+
Optional[Stdlib::IP::Address::V4::Nosubnet] $gateway4 = undef,
49+
Optional[Stdlib::IP::Address::V6::Nosubnet] $gateway6 = undef,
50+
Optional[Struct[{
51+
Optional['search'] => Array[Stdlib::Fqdn],
52+
'addresses' => Array[Stdlib::IP::Address]
53+
}]] $nameservers = undef,
54+
Optional[Stdlib::MAC] $macaddress = undef,
55+
Optional[Integer] $mtu = undef,
56+
Optional[Boolean] $optional = undef,
57+
Optional[Array[String]] $optional_addresses = undef,
58+
Optional[Enum['manual', 'off']] $activation_mode = undef,
59+
Optional[Array[Struct[{
60+
Optional['from'] => Stdlib::IP::Address,
61+
'to' => Variant[Stdlib::IP::Address, Enum['default', '0.0.0.0/0', '::/0']],
62+
Optional['via'] => Stdlib::IP::Address::Nosubnet,
63+
Optional['on_link'] => Boolean,
64+
Optional['metric'] => Integer,
65+
Optional['type'] => Enum['unicast', 'unreachable', 'blackhole', 'prohibited'],
66+
Optional['scope'] => Enum['global', 'link', 'host'],
67+
Optional['table'] => Integer,
68+
Optional['mtu'] => Integer,
69+
Optional['congestion_window'] => Integer,
70+
Optional['advertised_receive_window'] => Integer,
71+
}]]] $routes = undef,
72+
Optional[Array[Struct[{
73+
'from' => Stdlib::IP::Address,
74+
'to' => Variant[Stdlib::IP::Address, Enum['default', '0.0.0.0/0', '::/0']],
75+
Optional['table'] => Integer,
76+
Optional['priority'] => Integer,
77+
Optional['mark'] => Integer,
78+
Optional['type_of_service'] => Integer,
79+
}]]] $routing_policy = undef,
80+
Optional[Boolean] $neigh_suppress = undef,
81+
82+
| -%>
83+
<%- if $renderer != undef { -%>
84+
renderer: <%= $renderer %>
85+
<%- } -%>
86+
<%- if $dhcp4 != undef { -%>
87+
dhcp4: <%= $dhcp4 %>
88+
<%- } -%>
89+
<%- if $dhcp6 != undef { -%>
90+
dhcp6: <%= $dhcp6 %>
91+
<%- } -%>
92+
<%- if $ipv6_mtu != undef { -%>
93+
ipv6-mtu: <%= $ipv6_mtu %>
94+
<%- } -%>
95+
<%- if $ipv6_privacy != undef { -%>
96+
ipv6-privacy: <%= $ipv6_privacy %>
97+
<%- } -%>
98+
<%- if $link_local != undef { -%>
99+
link-local: <%= $link_local %>
100+
<%- } -%>
101+
<%- if $ignore_carrier != undef { -%>
102+
ignore-carrier: <%= $ignore_carrier %>
103+
<%- } -%>
104+
<%- if $critical != undef { -%>
105+
critical: <%= $critical %>
106+
<%- } -%>
107+
<%- if $dhcp_identifier != undef { -%>
108+
dhcp-identifier: <%= $dhcp_identifier %>
109+
<%- } -%>
110+
<%- if $dhcp4_overrides != undef { -%>
111+
dhcp4-overrides:
112+
<%- if $dhcp4_overrides[use_dns] != undef { -%>
113+
use-dns: <%= $dhcp4_overrides[use_dns] %>
114+
<%- } -%>
115+
<%- if $dhcp4_overrides[use_ntp] != undef { -%>
116+
use-ntp: <%= $dhcp4_overrides[use_ntp] %>
117+
<%- } -%>
118+
<%- if $dhcp4_overrides[send_hostname] != undef { -%>
119+
send-hostname: <%= $dhcp4_overrides[send_hostname] %>
120+
<%- } -%>
121+
<%- if $dhcp4_overrides[use_hostname] != undef { -%>
122+
use-hostname: <%= $dhcp4_overrides[use_hostname] %>
123+
<%- } -%>
124+
<%- if $dhcp4_overrides[use_mtu] != undef { -%>
125+
use-mtu: <%= $dhcp4_overrides[use_mtu] %>
126+
<%- } -%>
127+
<%- if $dhcp4_overrides[hostname] != undef { -%>
128+
hostname: <%= $dhcp4_overrides[hostname] %>
129+
<%- } -%>
130+
<%- if $dhcp4_overrides[use_routes] != undef { -%>
131+
use-routes: <%= $dhcp4_overrides[use_routes] %>
132+
<%- } -%>
133+
<%- if $dhcp4_overrides[route_metric] != undef { -%>
134+
route-metric: <%= $dhcp4_overrides[route_metric] %>
135+
<%- } -%>
136+
<%- if $dhcp4_overrides[use_domains] != undef { -%>
137+
use-domains: <%= $dhcp4_overrides[use_domains] %>
138+
<%- } -%>
139+
<%- } -%>
140+
<%- if $dhcp6_overrides != undef { -%>
141+
dhcp6-overrides:
142+
<%- if $dhcp6_overrides[use_dns] != undef { -%>
143+
use-dns: <%= $dhcp6_overrides[use_dns] %>
144+
<%- } -%>
145+
<%- if $dhcp6_overrides[use_ntp] != undef { -%>
146+
use-ntp: <%= $dhcp6_overrides[use_ntp] %>
147+
<%- } -%>
148+
<%- if $dhcp6_overrides[send_hostname] != undef { -%>
149+
send-hostname: <%= $dhcp6_overrides[send_hostname] %>
150+
<%- } -%>
151+
<%- if $dhcp6_overrides[use_hostname] != undef { -%>
152+
use-hostname: <%= $dhcp6_overrides[use_hostname] %>
153+
<%- } -%>
154+
<%- if $dhcp6_overrides[use_mtu] != undef { -%>
155+
use-mtu: <%= $dhcp6_overrides[use_mtu] %>
156+
<%- } -%>
157+
<%- if $dhcp6_overrides[hostname] != undef { -%>
158+
hostname: <%= $dhcp6_overrides[hostname] %>
159+
<%- } -%>
160+
<%- if $dhcp6_overrides[use_routes] != undef { -%>
161+
use-routes: <%= $dhcp6_overrides[use_routes] %>
162+
<%- } -%>
163+
<%- if $dhcp6_overrides[route_metric] != undef { -%>
164+
route-metric: <%= $dhcp6_overrides[route_metric] %>
165+
<%- } -%>
166+
<%- if $dhcp6_overrides[use_domains] != undef { -%>
167+
use-domains: <%= $dhcp6_overrides[use_domains] %>
168+
<%- } -%>
169+
<%- } -%>
170+
<%- if $accept_ra != undef { -%>
171+
accept-ra: <%= $accept_ra %>
172+
<%- } -%>
173+
<%- if $addresses != undef { -%>
174+
addresses:
175+
<%- $addresses.each | $address | { -%>
176+
<%- if $address.is_a(Hash) { -%>
177+
<%- $address.each | $add, $option | { -%>
178+
- <%= $add %>:
179+
<%- if $option['lifetime'] != undef { -%>
180+
lifetime: <%= $option['lifetime'] %>
181+
<%- } -%>
182+
<%- if $option['label'] != undef { -%>
183+
label: <%= $option['label'] %>
184+
<%- } -%>
185+
<%- } -%>
186+
<%- } else { -%>
187+
- <%= $address %>
188+
<%- } -%>
189+
<%- } -%>
190+
<%- } -%>
191+
<%- if $ipv6_address_generation != undef { -%>
192+
ipv6-address-generation: <%= $ipv6_address_generation %>
193+
<%- } -%>
194+
<%- if $ipv6_address_token != undef { -%>
195+
ipv6-address-token: <%= $ipv6_address_token %>
196+
<%- } -%>
197+
<%- if $gateway4 != undef { -%>
198+
gateway4: <%= $gateway4 %>
199+
<%- } -%>
200+
<%- if $gateway6 != undef { -%>
201+
gateway6: <%= $gateway6 %>
202+
<%- } -%>
203+
<%- if $nameservers != undef { -%>
204+
nameservers:
205+
<%- if $nameservers[search] != undef { -%>
206+
search: <%= $nameservers[search] %>
207+
<%- } -%>
208+
<%- if $nameservers[addresses] != undef { -%>
209+
addresses:
210+
<%- $nameservers[addresses].each |$address| { -%>
211+
- <%= $address %>
212+
<%- } -%>
213+
<%- } -%>
214+
<%- } -%>
215+
<%- if $macaddress != undef { -%>
216+
macaddress: <%= $macaddress %>
217+
<%- } -%>
218+
<%- if $mtu != undef { -%>
219+
mtu: <%= $mtu %>
220+
<%- } -%>
221+
<%- if $optional != undef { -%>
222+
optional: <%= $optional %>
223+
<%- } -%>
224+
<%- if $optional_addresses != undef { -%>
225+
optional-addresses:
226+
<%- $optional_addresses.each |$optional_address| { -%>
227+
- <%= $optional_address %>
228+
<%- } -%>
229+
<%- } -%>
230+
<%- if $activation_mode != undef { -%>
231+
activation-mode: <%= $activation_mode %>
232+
<%- } -%>
233+
<%- if $routes != undef { -%>
234+
routes:
235+
<%- $routes.each |$route| { -%>
236+
- to: <%= $route[to] %>
237+
<%- if $route[via] != undef { -%>
238+
via: <%= $route[via] %>
239+
<%- } -%>
240+
<%- if $route[from] != undef { -%>
241+
from: <%= $route[from] %>
242+
<%- } -%>
243+
<%- if $route[on_link] != undef { -%>
244+
on-link: <%= $route[on_link] %>
245+
<%- } -%>
246+
<%- if $route[metric] != undef { -%>
247+
metric: <%= $route[metric] %>
248+
<%- } -%>
249+
<%- if $route['type'] != undef { -%>
250+
type: <%= $route['type'] %>
251+
<%- } -%>
252+
<%- if $route[scope] != undef { -%>
253+
scope: <%= $route[scope] %>
254+
<%- } -%>
255+
<%- if $route[table] != undef { -%>
256+
table: <%= $route[table] %>
257+
<%- } -%>
258+
<%- if $route[mtu] != undef { -%>
259+
mtu: <%= $route[mtu] %>
260+
<%- } -%>
261+
<%- if $route[congestion_window] != undef { -%>
262+
congestion-window: <%= $route[congestion_window] %>
263+
<%- } -%>
264+
<%- if $route[advertised_receive_window] != undef { -%>
265+
advertised-receive-window: <%= $route[advertised_receive_window] %>
266+
<%- } -%>
267+
<%- } -%>
268+
<%- } -%>
269+
<%- if $routing_policy != undef { -%>
270+
routing-policy:
271+
<%- $routing_policy.each |$policy| { -%>
272+
- to: <%= $policy[to] %>
273+
from: <%= $policy[from] %>
274+
<%- if $policy[table] != undef { -%>
275+
table: <%= $policy[table] %>
276+
<%- } -%>
277+
<%- if $policy[priority] != undef { -%>
278+
priority: <%= $policy[priority] %>
279+
<%- } -%>
280+
<%- if $policy[mark] != undef { -%>
281+
mark: <%= $policy[mark] %>
282+
<%- } -%>
283+
<%- if $policy[type_of_service] != undef { -%>
284+
type-of-service: <%= $policy[type_of_service] %>
285+
<%- } -%>
286+
<%- } -%>
287+
<%- } -%>
288+
<%- if $neigh_suppress != undef { -%>
289+
neigh-suppress: <%= $neigh_suppress %>
290+
<%- } -%>

0 commit comments

Comments
 (0)