diff --git a/manifests/init.pp b/manifests/init.pp index a91c55f..4860975 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -96,9 +96,21 @@ # @param service_enable # Whether the service should be enabled or disabled # +# @param manage_repo +# Whether the APT/YUM repository should be installed. Only relevant when $install_method is 'repo'. +# +# @param distribution_channel +# Whether to use stable or testing distribution channel. Only relevant when $install_method is 'repo'. +# +# @param package_name +# Name of the caddy package to use. Only relevant when $install_method is 'repo' +# +# @param package_ensure +# Whether to install or remove the caddy package. Only relevant when $install_method is 'repo' +# class caddy ( String[1] $version = '2.0.0', - Optional[Enum['github']] $install_method = undef, + Optional[Enum['github','repo']] $install_method = undef, Stdlib::Absolutepath $install_path = '/opt/caddy', Boolean $manage_user = true, String[1] $caddy_user = 'caddy', @@ -124,6 +136,10 @@ String[1] $service_name = 'caddy', Stdlib::Ensure::Service $service_ensure = 'running', Boolean $service_enable = true, + Boolean $manage_repo = true, + Enum['stable','testing'] $distribution_channel = 'stable', + String[1] $package_name = 'caddy', + String[1] $package_ensure = 'installed', ) { case $caddy_architecture { 'x86_64', 'amd64': { $arch = 'amd64' } diff --git a/manifests/install.pp b/manifests/install.pp index 61bc2c3..7311c6c 100644 --- a/manifests/install.pp +++ b/manifests/install.pp @@ -9,6 +9,24 @@ $bin_file = "${caddy::install_path}/caddy" case $caddy::install_method { + 'repo': { + include apt + + if $caddy::manage_repo { + apt::source { 'caddy-stable': + location => 'https://dl.cloudsmith.io/public/caddy/stable/deb/debian', + release => 'any-version', + repos => 'main', + key => { + name => 'caddy-stable-archive-keyring.gpg', + source => 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key', + }, + } + } + package { $caddy::package_name: + ensure => $caddy::package_ensure, + } + } '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"