Initial commit
This commit is contained in:
40
manifests/vhost.pp
Normal file
40
manifests/vhost.pp
Normal file
@@ -0,0 +1,40 @@
|
||||
# modules/frankenphp/manifests/vhost.pp
|
||||
|
||||
define frankenphp::vhost (
|
||||
String $server_name,
|
||||
Stdlib::Absolutepath $root_dir = '/var/www/default',
|
||||
Optional[String] $proxy_target = undef,
|
||||
Optional[String] $fpm_socket = undef,
|
||||
Enum['php_server', 'proxy', 'fastcgi'] $mode = 'php_server',
|
||||
String $extra_config = '',
|
||||
Enum['present', 'absent'] $ensure = 'present',
|
||||
String $order = '10',
|
||||
) {
|
||||
|
||||
$caddyfile_path = $frankenphp::params::caddyfile_path
|
||||
|
||||
# Valider que les bons paramètres sont passés
|
||||
# if $mode == 'php_server' and $root_dir == '/var/www/default' {
|
||||
# }
|
||||
if $mode == 'proxy' and !$proxy_target {
|
||||
fail('Le mode proxy nécessite un $proxy_target (ex: "localhost:9001")')
|
||||
}
|
||||
if $mode == 'fastcgi' and !$fpm_socket {
|
||||
fail('Le mode fastcgi nécessite un $fpm_socket (ex: "unix//run/php/php.sock")')
|
||||
}
|
||||
|
||||
$vhost_content = epp('frankenphp/vhost.epp', {
|
||||
server_name => $server_name,
|
||||
root_dir => $root_dir,
|
||||
mode => $mode,
|
||||
proxy_target => $proxy_target,
|
||||
fpm_socket => $fpm_socket,
|
||||
extra_config => $extra_config,
|
||||
})
|
||||
|
||||
concat::fragment { "caddyfile-vhost-${server_name}":
|
||||
target => $caddyfile_path,
|
||||
order => $order,
|
||||
content => $vhost_content,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user