Skip to content

Commit fb1f4b3

Browse files
authored
Merge pull request #339 from yakatz/feature/package-scripts
Add scripts with server
2 parents b8b8035 + d97033a commit fb1f4b3

File tree

4 files changed

+281
-78
lines changed

4 files changed

+281
-78
lines changed

REFERENCE.md

Lines changed: 120 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,14 @@ Determins if a tls key is generated
339339

340340
Default value: `false`
341341

342+
##### `tls_static_key`
343+
344+
Data type: `Boolean`
345+
346+
Determins if a tls key is generated
347+
348+
Default value: `false`
349+
342350
##### `crl_days`
343351

344352
Data type: `Integer`
@@ -375,7 +383,7 @@ Name of the corresponding openvpn endpoint
375383

376384
##### `compression`
377385

378-
Data type: `Enum['comp-lzo', '']`
386+
Data type: `String`
379387

380388
Which compression algorithim to use
381389

@@ -517,6 +525,14 @@ Activates tls-auth to Add an additional layer of HMAC authentication on top of t
517525

518526
Default value: `false`
519527

528+
##### `tls_crypt`
529+
530+
Data type: `Boolean`
531+
532+
Encrypt and authenticate all control channel packets with the key from keyfile. (See --tls-auth for more background.)
533+
534+
Default value: `false`
535+
520536
##### `x509_name`
521537

522538
Data type: `Optional[String]`
@@ -662,45 +678,53 @@ The following parameters are available in the `openvpn::client_specific_config`
662678

663679
##### `server`
664680

665-
Data type: `String`
681+
Data type: `String[1]`
666682

667683
Name of the corresponding openvpn endpoint
668684

669685
##### `iroute`
670686

671-
Data type: `Array[String]`
687+
Data type: `Array[String[1]]`
672688

673689
Array of iroute combinations.
674690

675691
Default value: []
676692

677693
##### `iroute_ipv6`
678694

679-
Data type: `Array[String]`
695+
Data type: `Array[String[1]]`
680696

681697
Array of IPv6 iroute combinations.
682698

683699
Default value: []
684700

685701
##### `route`
686702

687-
Data type: `Array[String]`
703+
Data type: `Array[String[1]]`
688704

689705
Array of route combinations pushed to client.
690706

691707
Default value: []
692708

693709
##### `ifconfig`
694710

695-
Data type: `Variant[Boolean, String]`
711+
Data type: `Optional[String[1]]`
696712

697713
IP configuration to push to the client.
698714

699-
Default value: `false`
715+
Default value: `undef`
716+
717+
##### `ifconfig_ipv6`
718+
719+
Data type: `Optional[String[1]]`
720+
721+
IPv6 configuration to push to the client.
722+
723+
Default value: `undef`
700724

701725
##### `dhcp_options`
702726

703-
Data type: `Array[String]`
727+
Data type: `Array[String[1]]`
704728

705729
DHCP options to push to the client.
706730

@@ -716,12 +740,20 @@ Default value: `false`
716740

717741
##### `ensure`
718742

719-
Data type: `Enum[present, absent]`
743+
Data type: `Enum['present', 'absent']`
720744

721745
Sets the client specific configuration file status (present or absent)
722746

723747
Default value: present
724748

749+
##### `manage_client_configs`
750+
751+
Data type: `Boolean`
752+
753+
Manage dependencies on Openvpn::Client ressources
754+
755+
Default value: `true`
756+
725757
### openvpn::deploy::client
726758

727759
Collect the exported configs for an Host and ensure a running Openvpn Service
@@ -982,6 +1014,30 @@ Logfile for this openvpn server
9821014

9831015
Default value: `false`
9841016

1017+
##### `manage_logfile_directory`
1018+
1019+
Data type: `Boolean`
1020+
1021+
Manage the directory that the logfile is located in
1022+
1023+
Default value: `false`
1024+
1025+
##### `logdirectory_user`
1026+
1027+
Data type: `String[1]`
1028+
1029+
The owner user of the logfile directory
1030+
1031+
Default value: 'nobody'
1032+
1033+
##### `logdirectory_group`
1034+
1035+
Data type: `String[1]`
1036+
1037+
The owner group of the logfile directory
1038+
1039+
Default value: 'nobody'
1040+
9851041
##### `port`
9861042

9871043
Data type: `String`
@@ -1000,7 +1056,7 @@ Default value: `undef`
10001056

10011057
##### `proto`
10021058

1003-
Data type: `Enum['tcp', 'udp']`
1059+
Data type: `Enum['tcp', 'tcp4', 'tcp6', 'udp', 'udp4', 'udp6']`
10041060

10051061
What IP protocol is being used.
10061062

@@ -1160,19 +1216,35 @@ Default value: 7505
11601216

11611217
##### `up`
11621218

1163-
Data type: `String`
1219+
Data type: `Optional[String[1]]`
11641220

1165-
Script which we want to run when openvpn server starts
1221+
Script which we want to run when openvpn server starts. If the path to the scirpt does not contain a slash, it will be assumed to be in `openvpn/${name}/scripts` directory.
11661222

1167-
Default value: ''
1223+
Default value: `undef`
11681224

11691225
##### `down`
11701226

1171-
Data type: `String`
1227+
Data type: `Optional[String[1]]`
11721228

1173-
Script which we want to run when openvpn server stops
1229+
Script which we want to run when openvpn server stops. If the path to the scirpt does not contain a slash, it will be assumed to be in `openvpn/${name}/scripts` directory.
11741230

1175-
Default value: ''
1231+
Default value: `undef`
1232+
1233+
##### `client_connect`
1234+
1235+
Data type: `Optional[String[1]]`
1236+
1237+
Script which we want to run when a client connects. If the path to the scirpt does not contain a slash, it will be assumed to be in `openvpn/${name}/scripts` directory.
1238+
1239+
Default value: `undef`
1240+
1241+
##### `client_disconnect`
1242+
1243+
Data type: `Optional[String[1]]`
1244+
1245+
Script which we want to run when a client disconnects. If the path to the scirpt does not contain a slash, it will be assumed to be in `openvpn/${name}/scripts` directory.
1246+
1247+
Default value: `undef`
11761248

11771249
##### `username_as_common_name`
11781250

@@ -1296,19 +1368,19 @@ Default value: ''
12961368

12971369
##### `ldap_tls_client_cert_file`
12981370

1299-
Data type: `String`
1371+
Data type: `Optional[Stdlib::Absolutepath]`
13001372

13011373
LDAP TLS authentication: path to the tls client certificate
13021374

1303-
Default value: ''
1375+
Default value: `undef`
13041376

13051377
##### `ldap_tls_client_key_file`
13061378

1307-
Data type: `String`
1379+
Data type: `Optional[Stdlib::Absolutepath]`
13081380

13091381
LDAP TLS authentication: path to the tls client key
13101382

1311-
Default value: ''
1383+
Default value: `undef`
13121384

13131385
##### `verb`
13141386

@@ -1398,6 +1470,14 @@ Activates tls-auth to Add an additional layer of HMAC authentication on top of t
13981470

13991471
Default value: `false`
14001472

1473+
##### `tls_crypt`
1474+
1475+
Data type: `Boolean`
1476+
1477+
Encrypt and authenticate all control channel packets with the key from keyfile. (See --tls-auth for more background.)
1478+
1479+
Default value: `false`
1480+
14011481
##### `tls_server`
14021482

14031483
Data type: `Boolean`
@@ -1582,6 +1662,26 @@ A pre-shared static key.
15821662

15831663
Default value: `undef`
15841664

1665+
##### `scripts`
1666+
1667+
Data type: `Hash[String, Hash]`
1668+
1669+
Hash of scripts to copy with this instance.
1670+
For example, to put a script in `/etc/openvpn/test-site/scripts/add-tap-to-bridge.sh` and use it as an `up` script
1671+
``` puppet
1672+
openvpn::server { 'test-site':
1673+
....
1674+
up => 'add-tap-to-bridge.sh',
1675+
scripts => {
1676+
"add-tap-to-bridge.sh" => {
1677+
source => 'puppet:///path/to/add-tap-to-bridge.sh',
1678+
},
1679+
},
1680+
}
1681+
```
1682+
1683+
Default value: {}
1684+
15851685
##### `custom_options`
15861686

15871687
Data type: `Hash`

manifests/server.pp

Lines changed: 40 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,10 @@
4141
# @param management Enable management interface
4242
# @param management_ip IP address where the management interface will listen
4343
# @param management_port Port where the management interface will listen
44-
# @param up Script which we want to run when openvpn server starts
45-
# @param down Script which we want to run when openvpn server stops
44+
# @param up Script which we want to run when openvpn server starts. If the path to the scirpt does not contain a slash, it will be assumed to be in `openvpn/${name}/scripts` directory.
45+
# @param down Script which we want to run when openvpn server stops. If the path to the scirpt does not contain a slash, it will be assumed to be in `openvpn/${name}/scripts` directory.
46+
# @param client_connect Script which we want to run when a client connects. If the path to the scirpt does not contain a slash, it will be assumed to be in `openvpn/${name}/scripts` directory.
47+
# @param client_disconnect Script which we want to run when a client disconnects. If the path to the scirpt does not contain a slash, it will be assumed to be in `openvpn/${name}/scripts` directory.
4648
# @param username_as_common_name If true then set username-as-common-name
4749
# @param client_cert_not_required If true then set client-cert-not-required
4850
# @param ldap_enabled If ldap is enabled, do stuff
@@ -95,6 +97,20 @@
9597
# @param remote_cert_tls Enable or disable use of remote-cert-tls for the session. Generally used with client configuration
9698
# @param nobind Whether or not to bind to a specific port number.#
9799
# @param secret A pre-shared static key.
100+
# @param scripts Hash of scripts to copy with this instance.
101+
# For example, to put a script in `/etc/openvpn/test-site/scripts/add-tap-to-bridge.sh` and use it as an `up` script
102+
# ``` puppet
103+
# openvpn::server { 'test-site':
104+
# ....
105+
# up => 'add-tap-to-bridge.sh',
106+
# scripts => {
107+
# "add-tap-to-bridge.sh" => {
108+
# source => 'puppet:///path/to/add-tap-to-bridge.sh',
109+
# },
110+
# },
111+
# }
112+
# ```
113+
#
98114
# @param custom_options Hash of additional options to append to the configuration file.
99115
#
100116
# @example install
@@ -106,6 +122,7 @@
106122
# email => '[email protected]',
107123
# server => '10.200.200.0 255.255.255.0',
108124
# }
125+
#
109126
# @example a server in client mode
110127
# file {
111128
# '/etc/openvpn/zurich/keys/ca.crt':
@@ -164,8 +181,10 @@
164181
Boolean $management = false,
165182
String $management_ip = 'localhost',
166183
Variant[Stdlib::Port::Unprivileged,Enum['unix']] $management_port = 7505,
167-
String $up = '',
168-
String $down = '',
184+
Optional[String[1]] $up = undef,
185+
Optional[String[1]] $down = undef,
186+
Optional[String[1]] $client_connect = undef,
187+
Optional[String[1]] $client_disconnect = undef,
169188
Boolean $username_as_common_name = false,
170189
Boolean $client_cert_not_required = false,
171190
Boolean $ldap_enabled = false,
@@ -218,6 +237,7 @@
218237
Boolean $remote_cert_tls = false,
219238
Boolean $nobind = false,
220239
Optional[String] $secret = undef,
240+
Hash[String, Hash] $scripts = {},
221241
Hash $custom_options = {},
222242
) {
223243

@@ -294,6 +314,12 @@
294314
mode => '0750',
295315
notify => $lnotify,
296316
}
317+
file {
318+
[ "${etc_directory}/openvpn/${name}/scripts", ]:
319+
ensure => directory,
320+
mode => '0750',
321+
recurse => true,
322+
}
297323
if $shared_ca {
298324
ensure_resource(file, "${etc_directory}/openvpn/${ca_name}", {
299325
ensure => directory,
@@ -411,6 +437,10 @@
411437

412438
# template use $_easyrsa_version
413439
$_easyrsa_version = $openvpn::easyrsa_version
440+
441+
# Template might need script directory
442+
$_script_dir = "${etc_directory}/openvpn/${name}/scripts"
443+
414444
file { "${etc_directory}/openvpn/${name}.conf":
415445
owner => root,
416446
group => 0,
@@ -432,6 +462,12 @@
432462
notify => $lnotify,
433463
}
434464

465+
$scripts.each |String $scriptname, Hash $properties| {
466+
file { "${_script_dir}/${scriptname}":
467+
* => $properties,
468+
}
469+
}
470+
435471
if $ldap_enabled == true {
436472
file {
437473
"${etc_directory}/openvpn/${name}/auth/ldap.conf":

0 commit comments

Comments
 (0)