puppetlabs / puppetlabs-apache

Puppet module for the Apache httpd server, maintained by Puppet, Inc.
https://forge.puppet.com/modules/puppetlabs/apache
Apache License 2.0
366 stars 1.08k forks source link

default and default-ssl vhosts are managed unconditionally #2528

Open wywerne opened 6 months ago

wywerne commented 6 months ago

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 commented 4 months ago

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

ekohl commented 4 months ago

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

wywerne commented 4 months ago

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 commented 4 months ago

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: https://github.com/puppetlabs/puppetlabs-apache/blob/c26ca5d581b7f0d0331bb61a9fb300ae99909378/manifests/init.pp#L842-L883

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_.

wywerne commented 4 months ago

I think manage_ is a more common pattern than create_.

Ok for me, you are right