I want to setup and configure Apache via Puppet and request a SSL certificate with acme_tiny.py. My Puppet classes and resources for the web server and for acme-tiny work in most case, except for the first start.
Unfortunately, acme_tiny needs a running web server, which is not starting until after the acme_tiny resource has successfully completed. I imagine that the flow should be something like this:
Install Apache -> Start Apache -> Configure a HTTP vhost -> Reload Apache -> Run acme_tiny -> Configure the HTTPS vhost -> Reload Apache
The problem is that the resource "apache2 reload" can only exist once in Puppet and I get a dependency cycle if I order the acme_tiny resource in between. Additionally, the resource is also managed by the puppetlabs/apache module, every time a new vhost is created, but only applied last. Currently, the flow is like this:
Install Apache -> Start Apache -> Configure a HTTP vhost -> Run acme_tiny (fails) -> Configure the HTTPS vhost (skipped due to failed dependencies) -> Configure everything else -> Reload Apache (skipped due to failed dependencies)
If I then manually start Apache2 after the first run, it all works fine: The certificate is retrieved, the HTTPS vhost is created and the web server is reloaded. Unfortunately it does not work without manual intervention.
My acme-tiny resource looks like this:
exec { "${url}.crt":
command => "acme_tiny.py --quiet --account-key ./${url}_account.key --csr ./${url}.csr --acme-dir /home/web/${url}/www > ${url}.crt",
path => [ '/usr/bin', '/usr/local/bin' ],
cwd => $profile::apache::params::ssl_dir,
require => File['acme_tiny.py'],
subscribe => File["${profile::apache::params::ssl_dir}/${url}.csr"],
notify => Service['apache2'],
}
Does anybody have an idea how to fix this? Ideally, it should all be completed in one Puppet run, second best option would be if a second Puppet run is needed without manual intervention needed. Essentially, if acme_tiny fails, only the configuration of the HTTPS vhost should fail, but not reloading Apache.