diff --git a/REFERENCE.md b/REFERENCE.md
index ce9b2f7..b19d818 100644
--- a/REFERENCE.md
+++ b/REFERENCE.md
@@ -78,11 +78,11 @@ The following parameters are available in the `caddy` class:
##### `version`
-Data type: `String[1]`
+Data type: `Optional[String[1]]`
-Which version is used.
+Which version of caddy to install when install_method is github.
-Default value: `'2.0.0'`
+Default value: `undef`
##### `install_method`
diff --git a/manifests/init.pp b/manifests/init.pp
index 0089bb5..b7b46d2 100644
--- a/manifests/init.pp
+++ b/manifests/init.pp
@@ -16,7 +16,7 @@
# }
#
# @param version
-# Which version is used.
+# Which version of caddy to install when install_method is github.
#
# @param install_method
# Which source is used.
@@ -76,7 +76,7 @@
# Whether the process and all its children can gain new privileges through execve().
#
class caddy (
- String[1] $version = '2.0.0',
+ Optional[String[1]] $version = undef,
Optional[Enum['github']] $install_method = undef,
Stdlib::Absolutepath $install_path = '/opt/caddy',
String[1] $caddy_user = 'caddy',
diff --git a/manifests/install.pp b/manifests/install.pp
index cfa14ba..4819059 100644
--- a/manifests/install.pp
+++ b/manifests/install.pp
@@ -9,6 +9,10 @@
$bin_file = "${caddy::install_path}/caddy"
if $caddy::install_method == 'github' {
+ if !$caddy::version {
+ fail('caddy::version must be set when caddy::install_method is github')
+ }
+
$caddy_url = 'https://github.com/caddyserver/caddy/releases/download'
$caddy_dl_url = "${caddy_url}/v${caddy::version}/caddy_${caddy::version}_linux_${caddy::arch}.tar.gz"
$caddy_dl_dir = "/var/cache/caddy_${caddy::version}_linux_${$caddy::arch}.tar.gz"
@@ -37,6 +41,10 @@
$caddy_source = "/var/cache/caddy-${caddy::version}/caddy"
} else {
+ if $caddy::version {
+ fail('caddy::version can only be set when caddy::install_method is github')
+ }
+
$caddy_url = 'https://caddyserver.com/api/download'
$caddy_dl_url = "${caddy_url}?os=linux&arch=${caddy::arch}&plugins=${caddy::caddy_features}&license=${caddy::caddy_license}&telemetry=${caddy::caddy_telemetry}"