Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
jay7x committed Nov 30, 2024
1 parent 5a4c4c6 commit 230d303
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
18 changes: 17 additions & 1 deletion manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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' }
Expand Down
18 changes: 18 additions & 0 deletions manifests/install.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 230d303

Please sign in to comment.