puppetlabs-apache icon indicating copy to clipboard operation
puppetlabs-apache copied to clipboard

default and default-ssl vhosts are managed unconditionally

Open wywerne opened this issue 1 year ago • 5 comments

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,

wywerne avatar Feb 22 '24 14:02 wywerne

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

ThomasMinor avatar Apr 24 '24 06:04 ThomasMinor

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

ekohl avatar Apr 26 '24 08:04 ekohl

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

wywerne avatar Apr 26 '24 08:04 wywerne

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

ekohl avatar Apr 26 '24 08:04 ekohl

I think manage_ is a more common pattern than create_.

Ok for me, you are right

wywerne avatar Apr 26 '24 09:04 wywerne