@@ -16,6 +16,13 @@ secure point-to-point connections in routed or bridged configurations.
1616
1717* [ ` wireguard::interface ` ] ( #wireguardinterface ) : Defines wireguard tunnel interfaces
1818
19+ ** Functions**
20+
21+ * [ ` wireguard::genkey ` ] ( #wireguardgenkey ) : Returns an array containing the wireguard private and public (in this order) key for a certain interface.
22+ * [ ` wireguard::genprivatekey ` ] ( #wireguardgenprivatekey ) : Returns the private key. Will be generated and saved to disk if it doesn't already exist.
23+ * [ ` wireguard::genpsk ` ] ( #wireguardgenpsk ) : Returns string containing the wireguard psk for a certain interface.
24+ * [ ` wireguard::genpublickey ` ] ( #wireguardgenpublickey ) : Returns a public key derived from a private key. Will be generated and saved to disk if it doesn't already exist.
25+
1926## Classes
2027
2128### wireguard
@@ -95,6 +102,14 @@ Define wireguard interfaces
95102
96103Default value: {}
97104
105+ ##### ` config_dir_purge `
106+
107+ Data type: ` Boolean `
108+
109+
110+
111+ Default value: $wireguard::params::config_dir_purge
112+
98113### wireguard::config
99114
100115Class configures files and directories for wireguard
@@ -115,6 +130,12 @@ Data type: `String`
115130
116131The config_dir access mode bits
117132
133+ ##### ` config_dir_purge `
134+
135+ Data type: ` Boolean `
136+
137+
138+
118139### wireguard::install
119140
120141Class installs wireguard packages and sets yum repository
@@ -169,7 +190,7 @@ The following parameters are available in the `wireguard::interface` defined typ
169190
170191##### ` private_key `
171192
172- Data type: ` String `
193+ Data type: ` Any `
173194
174195Private key for data encryption
175196
@@ -193,6 +214,8 @@ Data type: `Optional[Variant[Array,String]]`
193214
194215List of IP (v4 or v6) addresses (optionally with CIDR masks) to
195216be assigned to the interface.
217+ Data type isn't 100% correct but needs to be 'Any' to allow 'Deferred'
218+ on Puppet 6 systems. epp will enforce Optional[ Variant[ Array,String]] .
196219
197220Default value: ` undef `
198221
@@ -282,3 +305,192 @@ Data type: `Optional[Variant[Array,String]]`
282305
283306
284307Default value: ` undef `
308+
309+ ## Functions
310+
311+ ### wireguard::genkey
312+
313+ Type: Ruby 4.x API
314+
315+ Returns an array containing the wireguard private and public (in this order) key for a certain interface.
316+
317+ #### Examples
318+
319+ ##### Creating private and public key for the interface wg0.
320+
321+ ``` puppet
322+ wireguard::genkey('wg0', '/etc/wireguard') => [
323+ '2N0YBID3tnptapO/V5x3GG78KloA8xkLz1QtX6OVRW8=',
324+ 'Pz4sRKhRMSet7IYVXXeZrAguBSs+q8oAVMfAAXHJ7S8=',
325+ ]
326+ ```
327+
328+ #### ` wireguard::genkey(String $name, Optional[String] $path) `
329+
330+ Returns an array containing the wireguard private and public (in this order) key for a certain interface.
331+
332+ Returns: ` Array ` Returns [ $private_key, $public_key] .
333+
334+ ##### Examples
335+
336+ ###### Creating private and public key for the interface wg0.
337+
338+ ``` puppet
339+ wireguard::genkey('wg0', '/etc/wireguard') => [
340+ '2N0YBID3tnptapO/V5x3GG78KloA8xkLz1QtX6OVRW8=',
341+ 'Pz4sRKhRMSet7IYVXXeZrAguBSs+q8oAVMfAAXHJ7S8=',
342+ ]
343+ ```
344+
345+ ##### ` name `
346+
347+ Data type: ` String `
348+
349+ The interface name.
350+
351+ ##### ` path `
352+
353+ Data type: ` Optional[String] `
354+
355+ Absolut path to the wireguard key files (default '/etc/wireguard').
356+
357+ ### wireguard::genprivatekey
358+
359+ Type: Ruby 4.x API
360+
361+ Returns the private key. Will be generated and saved to disk if it doesn't already exist.
362+
363+ #### Examples
364+
365+ ##### Creating private key for the interface wg0.
366+
367+ ``` puppet
368+ wireguard::genprivatekey('/etc/wireguard/wg0.key') => '2N0YBID3tnptapO/V5x3GG78KloA8xkLz1QtX6OVRW8='
369+ ```
370+
371+ ##### Using it as a Deferred function
372+
373+ ``` puppet
374+ include wireguard
375+ wireguard::interface { 'wg0':
376+ private_key => Deferred('wireguard::genprivatekey', ['/etc/wireguard/wg0.key']),
377+ listen_port => 53098,
378+ }
379+ ```
380+
381+ #### ` wireguard::genprivatekey(String $path) `
382+
383+ Returns the private key. Will be generated and saved to disk if it doesn't already exist.
384+
385+ Returns: ` String ` Returns the private key.
386+
387+ ##### Examples
388+
389+ ###### Creating private key for the interface wg0.
390+
391+ ``` puppet
392+ wireguard::genprivatekey('/etc/wireguard/wg0.key') => '2N0YBID3tnptapO/V5x3GG78KloA8xkLz1QtX6OVRW8='
393+ ```
394+
395+ ###### Using it as a Deferred function
396+
397+ ``` puppet
398+ include wireguard
399+ wireguard::interface { 'wg0':
400+ private_key => Deferred('wireguard::genprivatekey', ['/etc/wireguard/wg0.key']),
401+ listen_port => 53098,
402+ }
403+ ```
404+
405+ ##### ` path `
406+
407+ Data type: ` String `
408+
409+ Absolut path to the private key
410+
411+ ### wireguard::genpsk
412+
413+ Type: Ruby 4.x API
414+
415+ Returns string containing the wireguard psk for a certain interface.
416+
417+ #### Examples
418+
419+ ##### Creating psk for the interface wg0.
420+
421+ ``` puppet
422+ wireguard::genpsk('wg0') => 'FIVuvMyHvzujQweYa+oJdLDRvrpbHBithvMmNjN5rK4='
423+ ```
424+
425+ #### ` wireguard::genpsk(String $name, Optional[String] $path) `
426+
427+ Returns string containing the wireguard psk for a certain interface.
428+
429+ Returns: ` String ` Returns psk.
430+
431+ ##### Examples
432+
433+ ###### Creating psk for the interface wg0.
434+
435+ ``` puppet
436+ wireguard::genpsk('wg0') => 'FIVuvMyHvzujQweYa+oJdLDRvrpbHBithvMmNjN5rK4='
437+ ```
438+
439+ ##### ` name `
440+
441+ Data type: ` String `
442+
443+ The interface name.
444+
445+ ##### ` path `
446+
447+ Data type: ` Optional[String] `
448+
449+ Absolut path to the wireguard key files (default '/etc/wireguard').
450+
451+ ### wireguard::genpublickey
452+
453+ Type: Ruby 4.x API
454+
455+ Returns a public key derived from a private key.
456+ Will be generated and saved to disk if it doesn't already exist.
457+
458+ #### Examples
459+
460+ ##### Creating public key for the interface wg0.
461+
462+ ``` puppet
463+ wireguard::genpublickey('/etc/wireguard/wg0.key',
464+ '/etc/wireguard/wg0.pub'
465+ ) => 'gNaMjIpR7LKg019iktKJC74GX/MD3Y35Wo+WRNRQZxA='
466+ ```
467+
468+ #### ` wireguard::genpublickey(String $private_key_path, String $public_key_path) `
469+
470+ Returns a public key derived from a private key.
471+ Will be generated and saved to disk if it doesn't already exist.
472+
473+ Returns: ` String ` Returns the public key.
474+
475+ ##### Examples
476+
477+ ###### Creating public key for the interface wg0.
478+
479+ ``` puppet
480+ wireguard::genpublickey('/etc/wireguard/wg0.key',
481+ '/etc/wireguard/wg0.pub'
482+ ) => 'gNaMjIpR7LKg019iktKJC74GX/MD3Y35Wo+WRNRQZxA='
483+ ```
484+
485+ ##### ` private_key_path `
486+
487+ Data type: ` String `
488+
489+ Absolut path to the private key
490+
491+ ##### ` public_key_path `
492+
493+ Data type: ` String `
494+
495+ Absolut path to the public key
496+
0 commit comments