Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

default and default-ssl vhosts are managed unconditionally #2528

Open
wywerne opened this issue Feb 22, 2024 · 5 comments
Open

default and default-ssl vhosts are managed unconditionally #2528

wywerne opened this issue Feb 22, 2024 · 5 comments

Comments

@wywerne
Copy link

wywerne commented Feb 22, 2024

Parameters default_vhost & default_ssl_vhost are set to false but I have "Duplicate declaration: Apache::Vhost[default] is already declared at (file: /data/puppet/code/modules/apache/manifests/init.pp, line: 853); cannot redeclare..." If I declare a default vhost with the apache::vhost function

In init.pp :
image

In hiera data :
image

Can you add in init.pp :

  Boolean $create_default_vhost   = true,
...
    if $create_default_vhost {
      ::apache::vhost { 'default':
...
      }
      $ssl_access_log_file = $::osfamily ? {
        'freebsd' => $access_log_file,
        default   => "ssl_${access_log_file}",
      }
      ::apache::vhost { 'default-ssl':
...
      }
    } 

Regards,

@ThomasMinor
Copy link
Contributor

So using another name for the default host is not an option for you?

@ekohl
Copy link
Collaborator

ekohl commented Apr 26, 2024

The apache class has a parameter default_vhost which you can set to false. Then it doesn't create a default one.

@ekohl ekohl closed this as completed Apr 26, 2024
@wywerne
Copy link
Author

wywerne commented Apr 26, 2024

This param default_vhost is used in :
$default_vhost_ensure = $default_vhost ? {
true => 'present',
false => 'absent'
}
and the result is that the resource "::apache::vhost { 'default':" is defined but absent and unusable

@ekohl
Copy link
Collaborator

ekohl commented Apr 26, 2024

Ah, now I get it. I'm going to rephrase the issue so I understand it.

In the following code the vhosts default and default-ssl are always defined:

$default_vhost_ensure = $default_vhost ? {
true => 'present',
false => 'absent'
}
$default_ssl_vhost_ensure = $default_ssl_vhost ? {
true => 'present',
false => 'absent'
}
::apache::vhost { 'default':
ensure => $default_vhost_ensure,
port => 80,
docroot => $docroot,
scriptalias => $scriptalias,
serveradmin => $serveradmin,
access_log_file => $access_log_file,
priority => 15,
ip => $ip,
logroot_mode => $logroot_mode,
manage_docroot => $default_vhost,
use_servername_for_filenames => true,
use_port_for_filenames => true,
}
$ssl_access_log_file = $facts['os']['family'] ? {
'FreeBSD' => $access_log_file,
default => "ssl_${access_log_file}",
}
::apache::vhost { 'default-ssl':
ensure => $default_ssl_vhost_ensure,
port => 443,
ssl => true,
docroot => $docroot,
scriptalias => $scriptalias,
serveradmin => $serveradmin,
access_log_file => $ssl_access_log_file,
priority => 15,
ip => $ip,
logroot_mode => $logroot_mode,
manage_docroot => $default_ssl_vhost,
use_servername_for_filenames => true,
use_port_for_filenames => true,
}

The request is a parameter to not manage them at all so the names are available.

I think manage_ is a more common pattern than create_.

@ekohl ekohl reopened this Apr 26, 2024
@ekohl ekohl changed the title Error 500 on SERVER if I want to manage the default vhosts default and default-ssl vhosts are managed unconditionally Apr 26, 2024
@ekohl ekohl added the feature label Apr 26, 2024
@wywerne
Copy link
Author

wywerne commented Apr 26, 2024

I think manage_ is a more common pattern than create_.

Ok for me, you are right

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants