Skip to content

Start apache without all vhosts #2509

Open
@justafish

Description

@justafish

Use Case

When creating a new site that uses a letsencrypt certificate, the non-ssl version needs to be deployed and run before the SSL configuration can be added and deployed.
e.g.

    apache::vhost { "${servername}":
        servername => $servername,
        port       => 80,
        docroot    => $docroot,
        block      => 'scm',
        rewrites   => [
            {
                comment      => 'redirect non-SSL traffic to SSL site except letsencrypt',
                rewrite_cond => ['%{HTTPS} off', '%{REQUEST_URI} !^/.well-known/acme-challenge'],
                rewrite_rule => ['(.*) https://%{HTTP_HOST}%{REQUEST_URI}'],
            }
        ],
    }
    ->letsencrypt::certonly { "${servername}":
        plugin               => 'webroot',
        webroot_paths        => [$docroot],
        domains              => [$servername],
        manage_cron          => true,
        cron_hour            => [0,12],
        cron_minute          => '30',
        cron_success_command => '/bin/systemctl reload apache2.service',
    }

    # This can't be uncommented on the first run as apache will fail due the files not existing yet
    #apache::vhost { "${servername}-ssl":
    #    servername => $servername,
    #    port       => 443,
    #    docroot    => $docroot,
    #    block      => 'scm',
    #    ssl        => true,
    #    ssl_cert   => "${$facts['letsencrypt_directory'][$servername]}/fullchain.pem",
    #    ssl_key    => "${$facts['letsencrypt_directory'][$servername]}/privkey.pem",
    #}

Describe the Solution You Would Like

Allow a vhost to be added and processed after apache has started

Describe Alternatives You've Considered

I've tried using puppet stages but this doesn't work, and also looked at transition but that doesn't seem to be quite what I need

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions